stupid strictness question

Simon Marlow simonmar@microsoft.com
Thu, 5 Dec 2002 10:02:06 -0000


> Now, we define:
>=20
> > data SMaybe a =3D SNothing | SJust !a  deriving Show
>=20
> Now, we run:
>=20
> *Strict> Just (undefined::Int)
> Just *** Exception: Prelude.undefined
> *Strict> Just $! (undefined::Int)
> *** Exception: Prelude.undefined
> *Strict> SJust $! (undefined::Int)
> *** Exception: Prelude.undefined
> *Strict> SJust (undefined::Int)
> SJust *** Exception: Prelude.undefined
>
> I can't figure out why this last one is different from the=20
> one before it, or the one before that.

This one is a GHCi (not GHC) bug.  You may have seen this message while
loading the source containing the strict constructor definition:

WARNING: ignoring polymorphic case in interpreted mode.
   Possibly due to strict polymorphic/functional constructor args.
   Your program may leak space unexpectedly.

which means that GHCi essentially ignored the strictness flag on the
polymorphic field of the SJust constructor.  To work around the bug, you
can compile that module with GHC.

The good news is that this bug will be fixed in the next major release.

Cheers,
	Simon