No subject


Thu Jul 5 12:38:43 CEST 2012


add nodes, and be able to step back. However, with this pattern of
interleaving a and b values, I could not help but duplicating in a way
every data or function declaration, to apply from an A or a B, and
often code is very similar (like for upA and downB).

Also, I want to go through the tree and modify it keeping the same
structure, applying different functions to A and B nodes, like a "map"
involving a pair of functions that will be applied alternatively. I
also want a kind of "fold". This leads very often to pairs or Either:

> (a -> a, b -> b)
> (ANode a b -> ANode a b, BNode a b -> BNode a b)
> Either (ANode a b) (BNode a b)

Out of curiosity, is all this (duplicating functions for alternating type
variables, using pairs) a known pattern ? Does it have a name ? Are
there well known (and less tedious) alternatives, or higher-level
workarounds ?

Thanks for any hint,
Eric



More information about the Haskell-Cafe mailing list