[Haskell-cafe] A very nontrivial parser

Tillmann Rendel rendel at rbg.informatik.tu-darmstadt.de
Sun Jul 8 09:49:44 EDT 2007

Andrew Coppin wrote:
> Oh, I don't mind not knowing how rank-2 types are *implemented*. ;-) But 
> it would be nice to know what they *are*... :-S
> (Thus far, they just seem to be some incomprehensible syntax that makes 
> the compiler stop complaining. In particular, I have no idea what the 
> difference between rank-2, rank-N and existentially quantified is...)

Most Haskell extensions are more like restriction removals from a 
application programmer's point of view. If you are fully ignorant of the 
matter and never realized there was a restriction, you have no reason to 
fear the removal of the restriction, since it enables you to stay 
ignorant of the matter. All you have to do is to pass some flag to the 
compiler for historical reasons.

(Ok, there is the question of portability to other compilers...)

The idea about higher-ranked types is to allow explicit forall keywords 
in types wherever you like. The restriction about rank-1-types is to 
disallow forall keywords almost everywhere.

So higher-ranked types aren't a edge-case extension, they are a sensible 
lifting of some edge-case restriction.

(Of course, for compiler writers and the like, lifting this restrictions 
means extending the type system and underlying theory. But why should 
you care?)

So instead of learning about higher-ranked types, I would learn about 
the forall keyword, getting higher-ranked types for free, by using it in 
some former illegal positions out of ignorance of the former restriction.

Most programming language extensions seem to arise like this: Wouldn't 
it be nice if I could write this and it would mean that. Maybe if I 
steal something from category theory, it could be possible...


More information about the Haskell-Cafe mailing list