Existentials

Simon Peyton-Jones simonpj@microsoft.com
Thu, 17 Apr 2003 11:42:46 +0100


|     data T =3D Foo (forall a. Enum a =3D> (a->a))
|=20
| could indeed be local universal quantification.  You can construct a
| Foo with any function of type (Enum=3D>a->a), e.g.  (Foo succ) is ok,
| (Foo id) is not.  When you pattern-match on the constructor, you get
| back the original universal type, e.g. the following is valid:
|=20
|     f :: T -> (Int,Bool,Char)
|     f (Foo g) =3D (g 0, g False, g 'a')
|=20
| It appears that ghc, Hugs, and nhc98 do not support local universals,
| although hbc does.

GHC and Hugs both do.  In fact, GHC supports arbitrary-rank universal
quantification.

Simon