haskell at brecknell.org
Tue Mar 20 21:35:49 EDT 2007
> Haskell has a way of making one feel dumb. This is by far the most
> challenging programming language I've ever used.
It (or perhaps the community around it) does have a way of making you
realise that the rabbit-hole really is very deep. But that's no reason
to feel dumb.
> I won't try to understand fix just yet, but I'm still confused by the
> type of fix:
> fix :: (a -> a) -> a
> It appears to me that it takes a function as an argument, and that
> function takes a single argument. So how are you passing fix an
> anonymous function taking 2 arguments? Sorry if I have beaten this
> horse to death, but my pea-sized brain is working overtime here.
As others have pointed out, fix is polymorphic, so "a" can stand for any
type, including "(b -> c)". Removing redundant parentheses, this means
fix can directly specialise to:
> fix :: ((b -> c) -> b -> c) -> b -> c
It may also help to think some more about the concepts of "currying" and
"partial application". Between the Haskell wiki and Wikipedia, you
should find some resources for that.
See also my "id" example in a previous post in this thread. That does
the same thing, but without fix there to confuse the issue.
More information about the Haskell-Cafe