我正在尝试理解来自http://www.yesodweb.com/book/conduits的代码。经过一些修复(例如替换Resource
为MonadResource
)后,它仍然无法编译:
sumSink :: MonadResource m => Sink Int m Int
sumSink = CL.fold (+) 0
sum' :: [Int] -> Int
sum' input = runST $ runResourceT $ CL.sourceList input $$ sumSink
给我以下错误:
Couldn't match type `GHC.ST.ST s' with `IO'
When using functional dependencies to combine
Control.Monad.Trans.Control.MonadBaseControl
(GHC.ST.ST s) (GHC.ST.ST s),
arising from the dependency `m -> b'
in the instance declaration in `Control.Monad.Trans.Control'
Control.Monad.Trans.Control.MonadBaseControl IO (GHC.ST.ST s),
arising from a use of `runResourceT'
at D:\Works\stablename\test.hs:43:22-33
In the expression: runResourceT
In the second argument of `($)', namely
`runResourceT $ CL.sourceList input $$ sumSink'
我正在使用 GHC 7.4.1 和导管 0.4.2。
PS 是否有任何教程没有损坏/是用导管 0.4 编写的?