How about 'mapBoth', since we're not mapping either of the options, but both of them. :)
bimap is not a good name for this. There are too many things that can be bimapped, and they are abstracted over using the Bifunctor class in bifunctors, which has a method named bimap.
I also think people should just use Bifunctor, instead of one-off functions being added into several modules. But I could live with bimapEither existing, I suppose.
-- DanOn Fri, Apr 18, 2014 at 4:54 PM, Tobias Florek <haskell@ibotty.net> wrote:
hi,
i propose to include the following functions into Data.Either.
mapLeft :: (a->b) -> Either a c -> Either b c
mapLeft f = bimap f id
bimap :: (a -> b) -> (c -> d) -> Either a c -> Either b d
bimap f g = either (Left . f) (Right . g)
bimap and mapLeft already exists in edward kmett's either library (and in categories-extras and in gabriel gonzales' errors), but imo they are very useful by itself to warrant an inclusion in base. given bimap, mapLeft might not cross the fairbairn threshold though.
note: i don't propose exporting them from Prelude.
discussion period: 2 weeks
cheers,
tobias florek
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries