help needed for adding isWHNF primop to 5.00.2

Simon Marlow simonmar@microsoft.com
Tue, 31 Jul 2001 13:41:38 +0100


> Tue, 31 Jul 2001 12:38:03 +0100, Simon Marlow=20
> <simonmar@microsoft.com> pisze:
>=20
> > That's the way I'd go.  You have to declare the primitive like this,
> > BTW:
> >=20
> > 	isWHNF# :: a -> (# State# RealWorld, Int# #)
> >=20
> > because the compiler doesn't know about the IO type and you=20
> can't return
> > a Bool directly.
>=20
> It can return a Bool, e.g. =3D=3D# returns a Bool.

But =3D=3D# doesn't also return an unboxed tuple, and the code generator =
has
special hacks to deal with primops that return enumerated types.  The
=3D=3D# primop actually returns an Int# which the code generator =
arranges to
convert into a real Bool using the closure table.

I guess you could return a Bool by actually indexing into the closure
table, or by just returning {False,True}_static_closure.

Cheers,
	Simon