first-class polymorphism beats rank-2 polymorphism

Simon Peyton-Jones simonpj@microsoft.com
Tue, 12 Mar 2002 02:06:25 -0800


| Ok, that's what I meant: in RHSs of other type synonyms.
| BTW, it also works when passing parameters to parameterized=20
| datatypes. Here is a variation on defining Generic as a=20
| datatypes as opposed to the earlier type synonym. Id is still=20
| the same type synonym as before.
|=20
| data Generic' i o =3D G (forall x. i x -> o x)
| type TP =3D Generic Id Id
|=20
| Yes, I was surprised to see that it works to this extent.

This works because you said Generic not Generic' in the
RHS of TP.  If you use Generic' the program is rejected, and so
it should be.

| system would ask for. So I revise my question: Does the
| current support for partially applied type synonyms=20
| pose any challenges or is it basically just like macro=20
| expansion? That is, is the type system maybe not even=20
| affected by it? If it is easy, why is not in Haskell 98 and=20
| in hugs? It is terribly useful.

It's just macro expansion.  GHC expands saturated type synonyms
before looking for well-formedness in types.  This is indeed=20
rather useful, and it's easy too.  It's not in H98 because no one
thought
of it then.=20

Simon