darcs patch: Adding isLeft, isRight, fromLeft, fromRight, splitEithers

Ross Paterson ross at soi.city.ac.uk
Tue Oct 31 03:59:56 EST 2006

splitEithers (the Either counterpart of catMaybes) is a great idea.
(Except maybe for the name; all these split's are getting confusing.)
See also mapEither (the counterpart of mapMaybe) in Data.Map.

I'm not so keen on isLeft, isRight, fromLeft and fromRight.  Pattern
matching is clearer and safer: at the point you make the decision, the
type system has the extra information about the branch you've chosen.
It also pushes the programmer to put the decision and the use of the data
together, another good thing.  The isJust/fromJust combination is already
a rich source of bugs; we don't need more.  (Same goes for null/head/tail,
of course.)

More information about the Libraries mailing list