<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">Well that was exacly what I needed, thanks a lot !<br />
I still have to understand exactly why ;-)</div>
<div name="messageSignatureSection"><br />
bruno</div>
<div name="messageReplySection"><br />
On 15 Jun 2016 08:35 +0200, Michael Snoyman <michael@snoyman.com>, wrote:<br />
<blockquote type="cite">
<div dir="ltr">If I understand the question correctly, what you're saying is:
<div><br /></div>
<div>* My upstream (testC) is both returning a result _and_ yielding a stream of values downstream</div>
<div>* My downstream (CL.consume) is collecting those values and returning a result based on them</div>
<div>* How can I capture both the upstream and downstream results?</div>
<div><br /></div>
<div>If so, this is the section of the docs with the relevant functions[1]. It provides a few different fusion functions to combine an upstream and downstream without throwing away the upstream result (which is the default behavior of conduit, for various design and usability reasons). In your case, this may look something like:</div>
<div><br /></div>
<div>runConduit (fuseBoth testC CL.consume)</div>
<div><br /></div>
<div>Michael</div>
<div><br /></div>
<div>[1] <a href="https://s3.amazonaws.com/haddock.stackage.org/lts-6.3/conduit-1.2.6.6/Data-Conduit.html#g:4">https://s3.amazonaws.com/haddock.stackage.org/lts-6.3/conduit-1.2.6.6/Data-Conduit.html#g:4</a></div>
</div>
<div class="gmail_extra"><br />
<div class="gmail_quote">On Wed, Jun 15, 2016 at 8:53 AM, <span dir="ltr"><<a href="mailto:bruno@ruomad.net" target="_blank">bruno@ruomad.net</a>></span> wrote:<br />
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div name="messageBodySection">Hello,<br />
I'm trying to use Data.Conduit, but I get stuck with mapAccum as how to get and retrieve the result.<br />
If I use it, I get a simple conduit like :<br />
<br />
testC :: ConduitM () Int IO Int<br />
testC = Src =$= cdt where<br />
src = CL.sourceList [1..10]<br />
cdt = CL.mapAccum (\x s -> (x+s, x) 0<br />
<br />
I can get the output with<br />
testC $$ CL.consume<br />
but how do I retrieve the accumulated sum ?<br />
<br />
Bruno</div>
<div name="messageSignatureSection"><br /></div>
</div>
<br />
_______________________________________________<br />
Haskell-Cafe mailing list<br />
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br />
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br />
<br /></blockquote>
</div>
<br /></div>
</blockquote>
</div>
</body>
</html>