polymorphic type in state of state monad

Simon Peyton-Jones simonpj@microsoft.com
Tue, 11 Mar 2003 08:20:58 -0000


|  | > type State =3D Term a =3D> [a]
|  | > data M a =3D M (State -> IO(State,a))
|  |
|  | GHC yields a error message "Illegal polymorphic type".
|  | How to resolve this?

I can tell you what it happening.  If you have -fglasgow-exts on, the
type
for State is short for

	type State =3D forall a. Term a =3D> [a]

And then you can't use that polymorphic type in the argument of a tuple,
as you are doing in the next line. =20

Without -fglasgow-exts (i.e. in Haskell 98) the first line is plain
illegal: 'a' is not in scope.  But GHC may not produce as perspicuous a
message as it should for that.

Simon