[Haskell-cafe] Combining LoggingT with another library's monad

Joe Fiorini joe at joefiorini.com
Wed Sep 24 14:50:05 UTC 2014


As I've been learning Haskell, I've found I constantly get tripped up on
combining monads with transformers to form stacks. This seems to be very
common in web development, which is my primary use case for Haskell. I'm
using the Wheb framework as it's been the simplest to understand of all
the frameworks I've seen. To get a better understanding of monad
transformers, I'm trying to implement logging in a small app I wrote.
I'm attempting to use Control.Monad.Logger to add LoggingT to my monad
stack, that way I can use runStdoutLoggingT to log straight to stdout
(without having to deal with implementing my own monadLoggerLog method).
I added LoggingT to the top of my monad stack, but ran into lots of
problems and moved the LoggingT type to one of my route handlers (you
can see my latest attempt & the compiler error here
https://gist.github.com/joefiorini/9e89bdf86e28e6b98bf0).

I'm at a point now where I believe my problem is either a) I'm just not
understanding something about how monad transformers work, in which case
I just need to do some more reading or b) the LoggingT transformer is
simply not "compatible" with the WhebT transformer, in which case I need
to completely change my approach.

I'm not looking for someone to solve my problem for me; I'm just trying
to get a little guidance. Am I heading in the right direction here or
should I change up my approach? If the latter, can anyone give me a
little direction as to where to look?

Thanks!


More information about the Haskell-Cafe mailing list