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

Michael Snoyman michael at snoyman.com
Wed Jul 19 11:50:10 UTC 2017


I'm afraid I doon't follow what it meant by the stream here. Could you
provide a complete, runnable example and indicate what the expected and
actual output are?

On Mon, Jul 17, 2017 at 5:48 AM, jun zhang <zhangjun.julian at gmail.com>
wrote:

> 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?
>
> Thanks
>
>
> ----------------------------
> import Conduit
>
> test'::Int->Int->(Int,[Int])
> 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
>
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170719/89b1588a/attachment.html>


More information about the Haskell-Cafe mailing list