Lambda Dusk
2012-04-01 08:58:11 UTC
Hi,
I am new to Happstack. Not so new to Haskell, but I have always had a big
trouble designing monadic data types. It always seems simple, but I have
some kind of mind block there.
I have some server settings (for now, a database connection pool), and I
want to put them into a ReaderT monad, that is then wrapped in the
ServerPartT. Specifically, I have these two functions:
withMongo :: (MongoPool -> IO a) -> IO ()
withMongo f = do
pool <- dbPool
f pool
killAll pool
runDB :: (MonadIO m) => MongoPool -> Action IO a -> m (Either Failure a)
runDB pool f = liftIO $ do
pipe <- runIOE $ aResource pool
access pipe master dbName f
I would love to change "withMongo" in a way that I can drop it in before my
"simpleHTTP" call. The type of runDB could be something like "Action IO a
-> ServerPartT m (Either Failure a)" so it can be used in any handler
without having to carry the pool with me all the time.
I know this is not exactly a Happstack question, but I'd thought the
chances are high someone on here has already done this specifically.
Thanks.
I am new to Happstack. Not so new to Haskell, but I have always had a big
trouble designing monadic data types. It always seems simple, but I have
some kind of mind block there.
I have some server settings (for now, a database connection pool), and I
want to put them into a ReaderT monad, that is then wrapped in the
ServerPartT. Specifically, I have these two functions:
withMongo :: (MongoPool -> IO a) -> IO ()
withMongo f = do
pool <- dbPool
f pool
killAll pool
runDB :: (MonadIO m) => MongoPool -> Action IO a -> m (Either Failure a)
runDB pool f = liftIO $ do
pipe <- runIOE $ aResource pool
access pipe master dbName f
I would love to change "withMongo" in a way that I can drop it in before my
"simpleHTTP" call. The type of runDB could be something like "Action IO a
-> ServerPartT m (Either Failure a)" so it can be used in any handler
without having to carry the pool with me all the time.
I know this is not exactly a Happstack question, but I'd thought the
chances are high someone on here has already done this specifically.
Thanks.
--
You received this message because you are subscribed to the Google Groups "HAppS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/happs/-/cAJ2wiO-VgEJ.
To post to this group, send email to happs-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to happs+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/happs?hl=en.
You received this message because you are subscribed to the Google Groups "HAppS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/happs/-/cAJ2wiO-VgEJ.
To post to this group, send email to happs-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to happs+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/happs?hl=en.