[Haskell-cafe] Re: The Worker/Wrapper Transformation

Brent Yorgey byorgey at gmail.com
Thu Jan 3 06:54:04 EST 2008


On Jan 3, 2008 6:08 AM, Achim Schneider <barsoap at web.de> wrote:

> Achim Schneider <barsoap at web.de> wrote:
>
> > [...]
>
> I'm trying to grok that
>
> [] = id
> ++ = .
>
> in the context of Hughes lists.
>
> I guess it would stop to slip away if I knew what : corresponds to.
>

Well, (:) has type a -> [a] -> [a], so a function corresponding to (:) for
Hughes lists should have type

foo :: a -> H a -> H a

that is,

foo :: a -> ([a] -> [a]) -> [a] -> [a]

so it can be written

foo x h = (x:) . h

which lambdabot informs me can also be written as (.) . (:).  But in the end
I'm not sure how helpful that is for understanding Hughes lists! I think the
key sentence from the paper is this: "by representing a list xs as the
function (xs ++) that appends this list to another list that has still to be
supplied."  If you understand that sentence, then you can understand why []
is id and (++) is (.).

-Brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080103/b48a6e3f/attachment.htm


More information about the Haskell-Cafe mailing list