[Polysemy] Generalise and Move the Logger Effect to polysemy-wire-zoo#2306
[Polysemy] Generalise and Move the Logger Effect to polysemy-wire-zoo#2306mdimjasevic merged 17 commits intodevelopfrom
Conversation
- The logging level in the log action is not SAML-specific anymore
|
There is already a logger effect in polysemy-wire-zoo, which we use in galley and federator. Would it make sense to merge the two? |
It crossed my mind and I was lazy to look at that. But you're right, this is a good opportunity to do that so I'll do it. |
isovector
left a comment
There was a problem hiding this comment.
Looks good, but I'd suggest dropping discardTinyLogs
| discardLogs :: Sem (Logger msg ': r) a -> Sem r a | ||
| discardLogs = interpret $ \(Log _ _) -> pure () | ||
|
|
||
| discardTinyLogs :: Sem (Logger (Log.Msg -> Log.Msg) ': r) a -> Sem r a |
There was a problem hiding this comment.
Why do you need this function?
There was a problem hiding this comment.
This is to help GHC with type inference. If I don't use it, then GHC reports overlapping instances. An alternative is to use discardLogs @(Log.Msg -> Log.Msg) instead of discardTinyLogs.
There was a problem hiding this comment.
That's surprising to me. Does the polysemy plugin help?
There was a problem hiding this comment.
That's surprising to me. Does the polysemy plugin help?
It doesn't seem to. I tried this: 1) put the plugin as a GHC option in the cabal file and make its package a dependency, 2) use discardLogs instead of discardTinyLogs where I'm hoping the plugin would help, 3) observe I get the aforementioned error on overlapping instances, e.g.:
src/Federator/MockServer.hs:93:15: error:
* Overlapping instances for Member
(Wire.Sem.Logger.Logger
(System.Logger.Message.Msg -> System.Logger.Message.Msg))
'[Wire.Sem.Logger.Logger msg0, Embed IO]
arising from a use of `runWaiErrors'
Matching instances:
two instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
(The choice depends on the instantiation of `msg0'
To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
* In the second argument of `(.)', namely
`runWaiErrors @'[ValidationError, ServerError, MockException]'
In the second argument of `(.)', namely
`discardLogs
. runWaiErrors @'[ValidationError, ServerError, MockException]'
In the expression:
runM
. discardLogs
. runWaiErrors @'[ValidationError, ServerError, MockException]
|
93 | . runWaiErrors
| ^^^^^^^^^^^^...
cabal: Failed to build federator-1.0.0 (which is required by brig-2.0).
- The interpretation is not specific to TinyLog so it has been moved to the module where the Logger effect is defined
Done! I made the one that has been in Galley and Federator just a special case of the one I generalised from Spar. |
The PR generalises and moves the Logger effect from Spar into polysemy-wire-zoo.
Checklist
changelog.d.