This repository was archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
This repository was archived by the owner on Oct 19, 2024. It is now read-only.
Colog example in docs will not compile #331
Copy link
Copy link
Open
Description
I am wanting to add colog to my mu-haskell project. The example in the docs results in a compilation error. I have something like this:
main :: IO ()
main = runGRpcAppTrans msgProtoBuf 8080 logger server
where logger = usingLoggerT (LogAction $ liftIO putStrLn)
which results in the error:
[2 of 2] Compiling Main
/.../logging-test/src/Main.hs:21:51: error:
• Couldn't match expected type ‘IO (m ())’
with actual type ‘String -> IO ()’
• Probable cause: ‘putStrLn’ is applied to too few arguments
In the first argument of ‘liftIO’, namely ‘putStrLn’
In the second argument of ‘($)’, namely ‘liftIO putStrLn’
In the first argument of ‘usingLoggerT’, namely
‘(LogAction $ liftIO putStrLn)’
• Relevant bindings include
logger :: LoggerT msg m a -> m a (bound at src/Main.hs:21:9)
|
21 | where logger = usingLoggerT (LogAction $ liftIO putStrLn)
|
That error is easy enough to fix:
main :: IO ()
main = runGRpcAppTrans msgProtoBuf 8080 logger server
where logger = usingLoggerT (LogAction $ liftIO . putStrLn)
but then results in the following error:
/.../logging-test/src/Main.hs:20:48: error:
• No instance for (mtl-2.2.2:Control.Monad.Error.Class.MonadError
ServerError
(LoggerT
String
(transformers-0.5.6.2:Control.Monad.Trans.Except.ExceptT
ServerError IO)))
arising from a use of ‘server’
• In the fourth argument of ‘runGRpcAppTrans’, namely ‘server’
In the expression: runGRpcAppTrans msgProtoBuf 8080 logger server
In an equation for ‘main’:
main
= runGRpcAppTrans msgProtoBuf 8080 logger server
where
logger = usingLoggerT (LogAction $ liftIO . putStrLn)
|
20 | main = runGRpcAppTrans msgProtoBuf 8080 logger server
| ^^^^^^
I am not sure why I need to define an instance of MonadError
to get logging working. I'd like to update the docs with a working Colog example, but cannot figure out how to make the types line up. I created a minimal project if anyone wants to take a look:
Metadata
Metadata
Assignees
Labels
No labels