monad-logger question

37 views
Skip to first unread message

Luke Evans

unread,
Jun 4, 2013, 2:25:01 PM6/4/13
to yeso...@googlegroups.com
I was trying to convert the function:

runDB connStr = runResourceT . runStderrLoggingT . withSqliteConn connStr . runSqlConn


...to take a Bool argument that would then switch between runStderrLoggingT and runNoLoggingT.  

Unfortunately, these involve different concrete types for the logger.  

I suspect this is life telling me that I need to strengthen my Haskell type-wrangling muscles, but anyway...
Can someone point me in the right direction?

Thanks!

-- Luke

Michael Snoyman

unread,
Jun 4, 2013, 11:38:33 PM6/4/13
to yeso...@googlegroups.com
If you look at LoggingT, you'll see that it has a function for how to log a message. If you provide a function which does nothing, it would be functionally identical to NoLoggingT. So you could write a function like:

runFakeLoggingT (LoggingT f) = f $ \_ _ _ _ -> return ()

Then you could choose between runStderrLoggingT and runFakeLoggingT based on your Bool parameter.



-- Luke

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Luke Evans

unread,
Jun 5, 2013, 3:15:55 AM6/5/13
to yeso...@googlegroups.com, mic...@snoyman.com
Thanks again Michael.  I was slowly coming to that conclusion, but sometimes faced with what looks like official and ready-made items, you just keep trying the round block in the square hole ;-)
Reply all
Reply to author
Forward
0 new messages