purescript / registry-dev

Development work related to the PureScript Registry
https://github.com/purescript/registry
97 stars 80 forks source link

Add base Log and Notify effects #564

Closed thomashoneyman closed 1 year ago

thomashoneyman commented 1 year ago

This takes the first step of #563 by abstracting two effects: MonadLog for logging information and MonadNotify for notifying subscribers of events. I took a little inspiration from Spago with the logging so that they're similar. I separated out notify from the logging because they're really separate behaviors. The first helps us diagnose issues and should be informative for registry developers; the second should be helpful and well-written to help registry users understand what has happened in the process. I hope the separation can help us be more conscientious when showing messages to users.

Both effects are fairly bare-bones right now but they demonstrate how to write more of these effects, how to interpret one effect in terms of another, how to write concrete monads that use the various interpreters, and so on. Eventually I am envisioning that we have a ServerM for the HTTP API with webhooks for notifying users; a GitHubM for events handled from a GitHub event with comments for notifying users; a LocalM for running these tools locally when working on registry resources, in which there is no need for notify; and a TestM for running tests, in which we might make sure particular functions notify what we'd expect.

In each case the monad can be built by mixing & matching the handlers.