We can get folds and unfolds over algebraic datatypes for free. (But who in their right mind would want to jump through all the hoops? (Co-)recursion schemes should really be in the language out of the box.) See also: Philip Wadler, Recursive types for free! Erik Meijer, Maarten Fokkinga, Ross Patterson, Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire Conor McBride, Clowns to the Left of me, Jokers to the Right: Dissecting Data Structures Richard Bird, Oege de Moor, The Algebra of Programming Fritz Ruehr, The Evolution of a Haskell Programmer The ideas are scattered all over the place, but this implementation is based on the code from McBride's Clowns and Jokers, where it's but a stepping stone towards building something else entirely.