I have written a simple WAI application, which uses a ReaderT to allow access to the request like so:
import qualified Network.Wai as W
handle :: (Resource a) => a -> ReaderT W.Request IO W.Response
where handle
is the function that does the bulk of the processing. I then call it in my application:
app :: W.Application
app = runReaderT (handle a) -- simplified; i don't think the value of a matters
main :: IO ()
main = run 3000 app
but runhaskell main.hs
gives me the following:
Couldn't match expected type `Control.Monad.Trans.Resource.ResourceT
IO'
with actual type `IO'
Expected type: ReaderT
W.Request (Control.Monad.Trans.Resource.ResourceT IO) W.Response
Actual type: ServerMonad W.Response
In the return type of a call of `handle'
In the first argument of `runReaderT', namely
`(handle a)'
which confuses me for two reasons:
- I don't have any idea why it's expecting that type
- Calling
resp <- runReaderT (handle a) defaultRequest
works in GHCI!
Why is this happening?