<p dir="ltr">If c is a Monoid, you can use the RWS a c b () type instead and combine them with sequence_.</p>
<div class="gmail_quote">On 4 Jun 2016 5:19 pm, "martin" <<a href="mailto:martin.drautzburg@web.de">martin.drautzburg@web.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
I have a number of functions, whose type is something like this:<br>
<br>
f:: a -> b -> (b, c)<br>
<br>
i.e. it returns a modified b and an additional c.<br>
<br>
Now I want to write a combinator, which assembles a list of such functions into a single one. This combinator will have<br>
to thread the bs from one function to the next and accumulate the cs into a single c.<br>
<br>
While I was able to write this using a fold, I am not happy with it (my first attempt had a bad error in it, which is<br>
always a bad sign).<br>
<br>
Are you aware of any idioms, how to do such things on the beaten track?<br>
<br>
<br>
<br>
<br>
<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>
</blockquote></div>