Combining LoggingT with another library's monad

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!

On Wed, Sep 24, 2014 at 10:50:05AM -0400, Joe Fiorini wrote:
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).
Don't you want `lift` instead of `return` in `handleHome`?

On Wed, Sep 24, 2014 at 04:08:08PM +0100, Tom Ellis wrote:
On Wed, Sep 24, 2014 at 10:50:05AM -0400, Joe Fiorini wrote:
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).
Don't you want `lift` instead of `return` in `handleHome`?
`lift` is in `Control.Monad.Trans.Class`, by the way.

Thanks, good to know I was on the right track. This gets me a new error I can work on now :) On Wednesday, September 24, 2014 11:14:44 AM UTC-4, Tom Ellis wrote:
On Wed, Sep 24, 2014 at 04:08:08PM +0100, Tom Ellis wrote:
On Wed, Sep 24, 2014 at 10:50:05AM -0400, Joe Fiorini wrote:
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).
Don't you want `lift` instead of `return` in `handleHome`?
`lift` is in `Control.Monad.Trans.Class`, by the way. _______________________________________________ Haskell-Cafe mailing list Haskel...@haskell.org javascript: http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Joe Fiorini
-
Tom Ellis