管道奇怪的行为
Conduit weird behavior
我是 Haskell 管道的新手,正在学习如何使用它。我遇到了一个奇怪的行为。
在这里,我们有:
#!/usr/bin/env stack
-- stack --resolver lts-10.9 script
import Conduit
main :: IO ()
main = runConduit
$ yieldMany [1..10::Int]
.| do
mapC id .| (await >>= maybe (return ()) leftover)
printC
.| do
leftover "Hello There!"
printC
结果是:
$ ./Example21.hs
"Hello There!"
2
3
4
5
6
7
8
9
10
我不明白为什么 1
没有打印出来。
这是剩饭剩菜的行为。剩菜不能从 .|
融合算子之外传播。正如 the Haddocks 所说:
Leftover data returned from the right Conduit will be discarded.
如果您需要回收剩菜,可以使用fusion with leftovers功能。
我是 Haskell 管道的新手,正在学习如何使用它。我遇到了一个奇怪的行为。
在这里,我们有:
#!/usr/bin/env stack
-- stack --resolver lts-10.9 script
import Conduit
main :: IO ()
main = runConduit
$ yieldMany [1..10::Int]
.| do
mapC id .| (await >>= maybe (return ()) leftover)
printC
.| do
leftover "Hello There!"
printC
结果是:
$ ./Example21.hs
"Hello There!"
2
3
4
5
6
7
8
9
10
我不明白为什么 1
没有打印出来。
这是剩饭剩菜的行为。剩菜不能从 .|
融合算子之外传播。正如 the Haddocks 所说:
Leftover data returned from the right Conduit will be discarded.
如果您需要回收剩菜,可以使用fusion with leftovers功能。