[Haskell] How to zip folds: A library of fold transformers

Dylan Thurston dthurston at barnard.edu
Wed Oct 12 18:40:50 EDT 2005


On Tue, Oct 11, 2005 at 05:25:24PM -0700, oleg at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell/attachments/20051012/0c57645e/attachment.bin


More information about the Haskell mailing list