
26 May
2008
26 May
'08
5:35 p.m.
Thomas Davie wrote:
This is perhaps best explained with an example of something that can be typed with rank-2 types, but can't be typed otherwise:
main = f id 4
f g n = (g g) n
We note that the same instance of id must be made to have both the type (Int -> Int) and ((Int -> Int) -> (Int -> Int)) at the same time. Rank 2 types allows us to do this.
What a perplexing example! :-} Well anyway, I was under the impression that id :: x -> x, so I'm not really sure why this wouldn't work without Rank-2 types...