rfc: include bimap into Data.Either

Johan Tibell johan.tibell at gmail.com
Fri Apr 18 21:59:56 UTC 2014


How about 'mapBoth', since we're not mapping either of the options, but
both of them. :)
On Apr 18, 2014 11:10 PM, "Dan Doel" <dan.doel at gmail.com> wrote:

> 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.
>
> -- Dan
>
>
> On Fri, Apr 18, 2014 at 4:54 PM, Tobias Florek <haskell at 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 at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140418/0ea08cb0/attachment-0001.html>


More information about the Libraries mailing list