I understand how forall
enables us to write polymorphic function.
According to this chapter, the normal function which we generally write are Rank 1 types. And this function is of Rank 2 type:
foo :: (forall a. a -> a) -> (Char,Bool)
foo f = (f 'c', f True)
It explains like this:
In general, a rank-n type is a function that has at least one rank-(n-1) argument but no arguments of even higher rank.
What does it actually mean by rank argument ?
Can somebody give an example of Rank 3 type which is similar to the above foo
function.
fix :: (a -> a) -> a
sure is rank-1, not rank-2. – Cassilda