1
我试图从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。
P.S.是否有任何教程没有被破解/是否在考虑管道-0.4的情况下编写?
我从'runST $ runResourceT $ CL.sourceList输入$$ sumSink'中删除'runResourceT $'后就能编译它了。不过,我还是什么都不懂。 – Artyom
管道0.5有一个在Haddocks中的新教程。我希望下周能够发布它。 –