1

pipes包中,教程Control.Pipes.Tutorial[1] 展示了如何使用 monad>>运算符“垂直堆叠”管道组件。

我将如何使用 Control.Frame 来做到这一点?

例如,使用 Control.Frame 教程中的定义:

source1 = fromList [1..10]
source2 = fromList [30..40]

-- combine two sources:

runFrame $ printer <-< (source1 ??? source2)

-- combine two transformers:

runFrame $ printer <-< (take' 3 ??? take' 2) <-< fromList [1..]

在此处使用>>for???不会进行类型检查。

[1] http://hackage.haskell.org/packages/archive/pipes/latest/doc/html/Control-Pipe-Tutorial.html#g:4

更新:这是我一直在尝试的粘贴:http: //hpaste.org/77986

看起来close是问题所在 - 请参阅bar8上面粘贴中的函数。>>如果我没有明确说明,这些框架是可组合的close。当然,我最终需要关闭它们。嗯……

4

1 回答 1

1

A Frame isn't a monad, it's an indexed monad. This means that the normal monad operators won't work, and you have to import the indexed versions of them. According to the tutorial, this means adding the following to the top of your file:

{-# LANGUAGE RebindableSyntax #-}

import Control.Frame
import Control.IMonad.Do
import Control.IMonad.Trans
import Prelude hiding (Monad(..))
于 2012-11-19T10:16:01.213 回答