leftToMaybe/rightToMaybe
Henning Thielemann
schlepptop at henning-thielemann.de
Fri Aug 9 18:00:08 CEST 2013
Am 09.08.2013 17:31, schrieb Dan Doel:
> Here's another smart-ass remark, then: use lens and bifunctors. They
> have great abstractions for these.
>
> mapEither and mapPair are just two specializations of bimap. It also
> has first and second which generalize mapFst, etc. And by the way,
> everyone here (I think) has missed that you can also traverse these
> things, but bifunctors also has that covered, with bitraverse.
>
> The individual parts are applications of lenses, too. over _1 and over
> _2 are mapFst and mapSnd. _1 and _2 function as traverseFst and
> traverseSnd.
These generalizations seem to be more natural to me than Control.Arrow.
(However, identifiers with leading underscore are a bad idea, since they
suppress "unused identifier" warnings in GHC. But I think I complained
about that before.)
More information about the Libraries
mailing list