[Haskell-cafe] Adding a DB Connection Pool to a Web Application
Steven Leiva
leiva.steven at gmail.com
Fri Oct 27 13:16:03 UTC 2017
Hi will - I wanted to thank you for your reply.
It seems like with runStderrLoggingT, I'd have to start learning about monad
transformers. I know that this is something that I have to learn eventually; I'm
100% convinced of that, but for now I am going with an orphaned instance of
MonadLogger IO. As soon as I wire up the database, I'll start on monad
transformers. I've been told that Stephen Diehl is a good resource for it.
Thank you very much.
On Thu, Oct 26, 2017 9:33 AM, Will Yager will.yager at gmail.com wrote:
You want e.g.
https://hackage.haskell.org/package/monad-logger-0.3.25.1/docs/Control-Monad-Logger.html#v:runStderrLoggingT
You can mentally replace “m” with “IO”.
It takes some monadic action that requires logging (like setting up a database
pool) and provides a concrete implementation of how logging should be done (like
printing messages to stdout), thus discharging the MonadLogger constraint. See
“MTL style”.
I think MonadLogger is as good an introduction to monad transformers as any,
since it’s fairly straightforward. Most of the instances are like the reader
monad, where they just pass around some function that takes the log details and
does something with them.
On Oct 26, 2017, at 8:43 AM, Steven Leiva <leiva.steven at gmail.com> wrote:
I thought implementing an instance of MonadLogger for IO that would simply
typecheck (and not log), but that would lead to an orphaned instance, correct?
What's the easiest next step to make forward progress here?
P.S. I am aware that there are a lot of advanced (for me anyway) Haskell that
can be done via monad transformers, natural transformations, etc., in order to
wire up a DB with Servant, but I am happy with the "next simplest step" until I
learn some of those concepts better. (Then Haskell makes refactoring a breeze!).
Steven Leiva
305.528.6038
leiva.steven at gmail.com
http://www.linkedin.com/in/stevenleiva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20171027/0959f620/attachment.html>
More information about the Haskell-Cafe
mailing list