type specs not making it in to functions

Simon Peyton-Jones simonpj@microsoft.com
Mon, 28 Jan 2002 01:05:09 -0800


| > I can then say:
| >=20
| > > bar :: C a =3D> a -> Int
| > > bar (x :: a) =3D foo (undefined :: a)
| >=20
| > But not:
| >=20
| > > bar :: C a =3D> a -> Int
| > > bar x =3D foo (undefined :: a)
| >=20
| > because it tries to use a new scope for the type variable a and=20
| > doesn't unify it with the one in the type spec.  Why not?
|=20
| I don't know why it isn't the case in Haskell.
| In Mercury we do allow type variables in function type=20
| declarations to scope over explicit type qualifications in=20
| clause bodies.

It's a deliberate design choice, but certainly only one of taste.
It seems a bit odd for a type signature (perhaps separated by a long
way from the definition) should bind a type variable that scopes over
the function body. =20

Mark Shields and I are writing a paper about the scoped-type-variable
design in GHC; we'll discuss this point.

Simon