Standard Library report: List union

Jon Fairbairn
Sun, 17 Mar 2002 19:06:44 +0000

> There's a remark at the beginning of 7.2 that says:
> =

> delete, (\\), union and intersect preserve the invariant=3D20
> that lists don't contain duplicates, provided that=3D20
> their first argument contains no duplicates.
> =

> The same applies to unionBy etc.   This design is one
> you might reasonably disagree with.  I'd have thought
> it would be more sensible to have the invariant that
> *both* arguments to union and intersect are assumed
> to be sets (no dups). =

That's partly what I was alluding to, but either way I'd
have thought that there were clearer definitions, for

unionBy eq xs ys =3D xs ++ [y | y <- nubBy eq ys, not (any (eq y) xs)]


-- =

J=F3n Fairbairn                       
31 Chalmers Road                               
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)