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
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.