[Haskell-cafe] How to deal with last item with concatMapAccumC in Conduit.

jun zhang zhangjun.julian at gmail.com
Mon Jul 17 02:48:05 UTC 2017

Dear cafes

I use Conduit to parse a huge file. And I need merge lines by condition.

I find the concatMapAccumC can do that and I write a demo as blow(with conduit-combinators-1.0.6,lts-6.18). 
The problem is if the last item didn’t make condition true, the data only keep in the accum but missing in stream.

Any one can give me some advises?


import Conduit

test' a s = case (a+s) > 5 of
    True -> (0,[a+s]) 
    False -> (a+s,[])

testlog::IO [Int]
testlog = runConduit $ (yieldMany [1,2,3,4,5,6,3]) $=  (concatMapAccumC test' 0 ) $$ sinkList


More information about the Haskell-Cafe mailing list