darcs patch: add Data.Set.notMember and Data.Map.notMember

Cale Gibbard cgibbard at gmail.com
Fri Mar 10 21:36:28 EST 2006

> I don't like notElem either
> > * quite useful for cleaning up guards:
> >
> > f x | not (x `Set.member` map) && foo = ...
> > is hard to read.
> You may swap quards (or the "then" and "else" branches of "if"), or
> avoid the infix notation (which is horrible in this case anyway).
Although I'd normally agree with negated versions of things being
somewhat redundant, the infix version here is rather important, since
one often wants the code to look the same way as the mathematics. The
symbols \in and \not\in are both usually written infix, and that's not
going to change soon. Putting the membership operation in between is
nice, because we read the guard here as "If x is a member of xs
then..." rather than "If member x xs then..." anyway. Perhaps if the
proposal to allow somewhat more general expressions as infix operators
goes through (which I'm actually ambivalent about), I'd feel different
about this case.

If you want to reduce redundancy, let's unify the 3 separate ways to
say 'map'. :)

 - Cale

More information about the Libraries mailing list