Report Issues

Simon Peyton-Jones simonpj@microsoft.com
Fri, 4 Jan 2002 06:11:07 -0800


Yes, that's a good point.  I think nub should be defined
as nubBy (=3D=3D), not as nubBy (not . (/=3D)).  I'll make it =
consistently so.

Simon

| -----Original Message-----
| From: Janis Voigtlaender [mailto:voigt@orchid.inf.tu-dresden.de]=20
| Sent: 04 January 2002 11:07
| To: haskell@haskell.org
| Subject: Report Issues
|=20
|=20
| Simon Peyton-Jones wrote:
| >=20
| > Folks,
| >=20
| > You have all been eating too much Xmas pudding.   Only one
| > Haskell98 Report issue has arisen since my release of 21 Dec.
|=20
| OK, here comes a rather trivial issue regarding the libraries:
|=20
| Section 7.6 of the Library Report gives the following example=20
| definition of nub:
|=20
| nub                     :: (Eq a) =3D> [a] -> [a]
| nub []                  =3D  []
| nub (x:xs)              =3D  x : nub (filter (\y -> x /=3D y) xs)
|=20
| But then, in Section 7.9, the following actual implementation=20
| is given:
|=20
| nub                     :: Eq a =3D> [a] -> [a]
| nub                     =3D  nubBy (=3D=3D)
|=20
| nubBy                   :: (a -> a -> Bool) -> [a] -> [a]
| nubBy eq []             =3D  []
| nubBy eq (x:xs)         =3D  x : nubBy eq (filter (\y -> not=20
| (eq x y)) xs)
|=20
| The two definitions are only equivalent, if for all x and y=20
| holds that=20
|      (x /=3D y)
| and
|      (not (x =3D=3D y))
| are equivalent.
| While this is true for all basic types, and is also true for=20
| user defined instances of Eq, if the programmer specifies=20
| only one of the two functions (=3D=3D) or (/=3D) and leaves the=20
| other one at the default method, nobody can prevent me from=20
| writing an instance declaration where I define (=3D=3D) and (/=3D)=20
| without adhering to the duality. This might be stupid to do,=20
| but still it contradicts the report, right?
|=20
| Janis.
|=20
|=20
| --
| Janis Voigtlaender
| http://wwwtcs.inf.tu-dresden.de/~voigt/
| mailto:voigt@tcs.inf.tu-dresden.de
|=20
| _______________________________________________
| Haskell mailing list
| Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
|=20