Question

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.

Was it helpful?

Solution

On the source side, replace all the operators with $=, which is the "fuse a source with a conduit" operator, aka left-fusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top