将源的输出合并到流中

Combine source's output into stream

我想要一个将源作为参数并将后者的输出与其自身的输出相结合的管道。在类型中,例如

combine :: ConduitM () Int m ()
        -> ConduitM Int (Int, Int) m ()

我希望以下内容

runConduit $ yieldMany [(1::Int)..]
          .| combine (yieldMany [100..])
          .| takeC 5
          .| sinkList

给予

[(1,100), (2,102), (3,103), (4,104), (5, 105)]

这是我的用例的简化版本。但我不确定如何解决

combine source = mapC $ \i -> do
  -- stream output from source somehow
  (i, i)

这可能吗?

我认为您正在寻找 ZipSource,在您的情况下可能看起来像这样:

getZipSource $ (,)
    <$> ZipSource (yieldMany [1..])
    <*> ZipSource (yieldMany [100..])