[Haskell] Type of y f = f . f
Pedro Vasconcelos
pv at dcs.st-and.ac.uk
Mon Feb 28 04:19:03 EST 2005
On Mon, 28 Feb 2005 03:50:14 -0500
Jim Apple <japple at freeshell.org> wrote:
> Is there a type we can give to
>
> y f = f . f
>
> y id
> y head
> y fst
>
> are all typeable?
>
Using ghci:
Prelude> let y f = f.f
Prelude> :t y
y :: forall c. (c -> c) -> c -> c
So it admits principal type (a->a) -> a->a. From this you can see that
(y head) and (y fst) cannot be typed, whereas (y id) can. BTW, this
function is usually named 'twice'.
Best regards,
Pedro
--
Pedro Vasconcelos, School of Computer Science, University of St Andrews
-----------------------------------------------------------------------
"The difference between Theory and Practice
is greater in Practice than in Theory."
More information about the Haskell
mailing list