rfc: include bimap into Data.Either

Tobias Florek haskell at ibotty.net
Fri Apr 18 20:54:18 UTC 2014


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


More information about the Libraries mailing list