I'm trying to get my MongoDB working in Haskell. I was using this tutorial as a starting point. When I do these commands in prelude, I get a list of collections:
pipe <- runIOE $ connect $ Host "XXXXX.mongolab.com" $ PortNumber 33317
access pipe master <databaseName> $ auth <username> <password>
access pipe master <databaseName> allCollections
However, when I try to put that in Yesod Handler, it's not compiling. I have
getActivityR :: Handler Import.Value
getActivityR = do
pipe <- runIOE $ connect $ Host "XXXXX.mongolab.com" $ PortNumber 33317
access pipe master <databaseName> $ auth <username> <password>
access pipe master <databaseName> allCollections
returnJson $ object ["activity" .= ("abc" :: Text)]
The returnJson is really just there to let me know I completed the method. Eventually it will return the list of activities.
The error I'm getting is:
Couldn't match type `IO' with `HandlerT App IO'
Expected type: HandlerT App IO Pipe
Actual type: IO Pipe
In a stmt of a 'do' block:
pipe <- runIOE
$ connect $ Host "XXXXXX.mongolab.com" $ PortNumber 33317
So what is the difference between Prelude/GHCi and my Yesod code being built by Cabal?