Not lazy/smart enough

Simon Marlow simonmar@microsoft.com
Fri, 2 Nov 2001 10:10:14 -0000


> >>>>> "Sohrab" =3D=3D Sohrab Saran <sohrabsaran@hotmail.com> writes:
>=20
> > If at the Hugs interpreter prompt I type:
> > 3/4 =3D=3D 3/4
> > ...I get "True"
> > If I now type:
> > 3/0 =3D=3D 3/0
> > ...I should get "True" but I get a divide-by-zero error
> > instead. Anyone ready to fix this, or should I fix this myself?
>=20
> I don't believe this is a bug.
>=20
> Suppose we adopt your proposal, I think we'd also want to add the=20
> following equalities too:
>  =20
>   1.  f 3 =3D=3D f 3  =3D True
>  =20
>   2.  f 3 =3D=3D g 3  =3D True  where g x =3D f x
>  =20
>   3.  f 3 =3D=3D g 3  =3D True  where g x =3D x / 0; f x =3D x / 0
>  =20
>   4.  f 3 =3D=3D g 3  =3D True  where g is semantically equivalent to =
f
>  =20
> The problem with this is that it's hard to say why we'd accept 1-3 but
> not accept 4 and accepting 4 requires us to solve the halting problem.

I think you're missing the point - the original poster wants 3/0 to have
a non-bottom value, namely Infinity, which would make the equality hold.
This works in GHCi, because we choose to represent floating point
exceptions with the special values Infinity and NaN, but a Haskell
implementation isn't required to do this (see section 6.4 in the
report). =20

Personally I think GHC's behaviour is preferrable because it more
closely matches the IEEE standard and other languages.

Cheers,
	Simon