|The stupid question is the question not asked|
Re^5: Derangements iterator (callbacks)by Anonymous Monk
|on Jan 01, 2006 at 18:21 UTC||Need Help??|
From enumerators to cursors: turning the left fold inside out...
The mechanical inversion procedure presented in * had a catch: it relies on shift/reset (or call/cc plus a mutable cell, which is the same thing). How can we do such an inversion in Haskell? We can introduce a right fold enumerator, which is more amenable to such transformations. Or we can use a continuation monad and emulate shift/reset. The present article demonstrates the third approach: a non-recursive left-fold. We argue that such a left fold is the best interface for a collection. Indeed, given the non-recursive left-fold we can: