I have an example of System F plymorphism that I don't really understand:
If I would remove the types it would remain: \f.\a.f (f a) which makes no sense.
Can you help me with this? Thank you!
The erased term does make sense: in Haskell it would be \f a -> f (f a)
, a fairly ordinary function that applies its first argument to its second, and then again to the result.
The difference between \f a -> <body>
and \f.\a. <body>
is only one of notation. If you prefer, write the Haskell term \f -> \a -> f (f a)
, which is equivalent but syntactically a bit closer to the erased System F.
(Note that double
is not self application, which would be \f -> f f
.)