12 Oct
2005
12 Oct
'05
10:40 p.m.
On Tue, Oct 11, 2005 at 05:25:24PM -0700, oleg@pobox.com wrote:
First we define the representation of a list as a fold:
newtype FR a = FR (forall ans. (a -> ans -> ans) -> ans -> ans) unFR (FR x) = x
It has a rank-2 type. The defining equations are: if flst is a value of a type |FR a|, then unFR flst f z = z if flst represents an empty list unFR flst f z = f e (unFR flst' f z) if flst represents the list with the head 'e' and flst' represents the rest of that list
Presumably you noticed that this is isomorphic to the representation of a list in lambda calculus, right? Peace, Dylan