3

I have this conduit expression which works:

main1 = runResourceT
       $ CB.sourceHandle stdin
      $$ CB.lines
      =$ Cl.concatMap matches
      =$ Cl.mapMaybe readDouble
      =$ Cl.map fst
      =$ Cl.map bucket
      =$ Cl.map (BS.pack . show)
      =$ Cl.map (\x -> x <> BS.pack "\n")
      =$ CB.sinkHandle stdout

I'm having trouble splitting it up into two pieces, i.e. something like:

source = CB.sourceHandle stdin
  $$ CB.lines
  =$ Cl.concatMap matches
  =$ Cl.mapMaybe readDouble
  =$ Cl.map fst
  =$ Cl.map bucket

sink = Cl.map (BS.pack . show)
  =$ Cl.map (\x -> x <> BS.pack "\n")
  =$ CB.sinkHandle stdout

so that I can use:

runResourceT $ source =$ sink

or whatever... The error message I get from the type-checker is somewhat inscrutable.

4

1 に答える 1

2

側ではsource、すべての演算子を に置き換えます$=。これは、「ソースをコンジットと融合する」演算子、別名左融合です。

于 2013-02-21T03:54:22.953 に答える