[Haskell-cafe] Accumulating and threading output of functions

martin martin.drautzburg at web.de
Sat Jun 4 15:18:45 UTC 2016

Hello all,

I have a number of functions, whose type is something like this:

f:: a -> b -> (b, c)

i.e. it returns a modified b and an additional c.

Now I want to write a combinator, which assembles a list of such functions into a single one. This combinator will have
to thread the bs from one function to the next and accumulate the cs into a single c.

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
always a bad sign).

Are you aware of any idioms, how to do such things on the beaten track?

More information about the Haskell-Cafe mailing list