[Haskell-cafe] Re: Function Type Calculation (Take 2)
PR Stanley
prstanley at ntlworld.com
Fri May 2 03:43:34 EDT 2008
Just in case anyone missed this:
[1]
funk f x = f (funk f) x
f :: a
x :: b
funk f x :: c
therefore funk :: a -> b -> c
RHS
f (funk f) x :: c
f (funk f) :: d -> c
x :: d
f :: e -> d -> c
funk :: h -> e
f :: h
unification
f :: a = h = (e -> d -> c)
x b = d
No. x :: b = d (a typo?)
Paul: What's wrong with x being of type b and of type d? Could you
perhaps explain the error please?
Don't forget also that
funk :: a -> b -> c = h -> e,
which means that e = b -> c
Paul: is that something to do with partial application? (funk f) is
a partially applied function, correct? Again an explanation would be
appreciated.
therefore funk :: ((h -> e) -> b -> c) -> b -> c
No. I don't understand where you've got this expression from. It's
funk :: a -> b -> c = (e -> d -> c) -> b -> c = ((b -> c) -> b -> c) - > b -> c
According to GHCi:
Prelude> let funk f x = f (funk f) x
Prelude> :t funk
funk :: ((t1 -> t) -> t1 -> t) -> t1 -> t
which is about the same.
Thanks
Paul
More information about the Haskell-Cafe
mailing list