0
我寫了一個簡單的WAI的應用程序,它採用了ReaderT允許訪問像這樣的要求:WAI應用程序工作ghci的,但不與runhaskell
import qualified Network.Wai as W
handle :: (Resource a) => a -> ReaderT W.Request IO W.Response
其中handle
是完成大部分的功能處理。然後我把它在我的應用程序:
app :: W.Application
app = runReaderT (handle a) -- simplified; i don't think the value of a matters
main :: IO()
main = run 3000 app
但runhaskell main.hs
給了我下面的:
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)'
這讓我困惑的原因有兩個:
- 我沒有任何想法,爲什麼它預計該類型
- 調用
resp <- runReaderT (handle a) defaultRequest
在GHCI中工作!
這是怎麼發生的?
我在看一箇舊版本的Network.Wai文檔 - 德哦!非常感謝。 – hdgarrood