State of DData

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Fri Mar 26 12:26:54 EST 2004


> > > Does the bias matter at all if Eq means equality?
> >
> > It should be documented, so "advanced users" can rely on the 
 behaviour.
> 
> In my opinion, even "advanced users" should adhere to The Haskell 
 Report which
> says that (==) means equality.
Content-Transfer-Encoding: quoted-printable

Contrived example:

  data Foo =3D Foo Int Int

  instance Eq Foo where
    (Foo x _) =3D=3D (Foo y _) =3D x =3D=3D y

  mkFoo x =3D Foo x (expensive_calculation x)
  fooX (Foo x _) =3D x
  fooY (Foo _ y) =3D y

  a =3D mkFoo 10
  b =3D mkFoo 10
    =

  m =3D if fooY a > 10 then add a empty else empty
  m' =3D add b m

Now it would be nice to know that a is in the collection, not b, because =
a's Y component has been forced, but b's hasn't.  Replacing a with b woul=
d waste work.

Thus knowing the bias may be important for time/space analysis.

--KW 8-)
-- =

Keith Wansbrough <kw217 at cl.cam.ac.uk>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.



More information about the Libraries mailing list