Evidence Elimination

Glynn Clements glynn.clements@virgin.net
Fri, 25 Oct 2002 20:39:09 +0100


Alejandro Russo wrote:

> I try the follow line in hugs (mode 98 enable)
>=20
> Prelude> :t (let f =3D \x -> x =3D=3D x in ( f 'a', f 123 ) )
> ERROR: Illegal Haskell 98 class constraint in inferred type
> *** Expression : let {...} in (f 'a',f 123)
> *** Type       : Num Char =3D> (Bool,Bool)
>=20
> Prelude>
>=20
> This happend because Num Char can never be satisfied with a=20
> predicate evidence. However in hugs without 98 mode the result
> of the previos line is :=20
>=20
> Prelude> :t ( let f =3D \x -> x =3D=3D x in (f 'a' , f 123 ) )
> let {...} in (f 'a',f 123) :: Num Char =3D> (Bool,Bool)
>=20
> This (maybe) indicates how  hugs make evidence elimination in=20
> runtime while Haskell 98 don=B4t do that. I don=B4t have a clear
> idea about this, please someone can help me?. Thanks.

AFAICT, this is a consequence of the monomorphism restriction, which
is discussed in section 4.5.5 of the Haskell report:

=09http://haskell.org/onlinereport/decls.html#sect4.5.5

--=20
Glynn Clements <glynn.clements@virgin.net>