我使用network-conduit
下面的代碼有問題,裏面的新來源:如何添加管道哈斯克爾
import Data.Conduit.List as CL
import Data.Conduit.Text as CT
import qualified Data.ByteString.Char8 as S8
import qualified Data.Text as TT
mySource :: ResourceT m => Integer -> Source m Int
mySource i = {- function -} undefined
myApp :: Application
myApp src snk =
src $= CT.decode CT.ascii
$= CL.map decimal
$= CL.map {-problem here-}
$$ src
在問題的地方,我想寫類似
\t -> case t of
Left err = S8.pack $ "Error:" ++ e
Right (i,xs) = (>>>=) mySource
{- or better:
do
(>>>=) mySource
(<<<=) T.pack xs
-}
其中(>>>=)
功能推mySource
輸出到下一級 (<<<=)
正在發送功能回到上一級
'conduit'是否支持向上遊發送數據?我知道'管道'呢。也許你需要使用'pipes'作爲你的用例。 – Cactus 2016-03-30 06:54:10
'Conduit'可以用'leftover'將數據重新輸入到它自己的輸入中,但是在這裏,'Conduit'想要將輸入推回到它的上游'Conduit'的輸入中,這是不可能的。在這種情況下應該使用解析器'Conduit'。 – pat 2017-11-27 21:20:02