Proposal: add fromRight and fromLeft to Data.Either

amindfv at gmail.com amindfv at gmail.com
Sat May 21 12:33:45 UTC 2016


There's also (\(Right x)->x), which is pretty short and will give you a warning about the missing case.

(I could go either way on adding fromLeft/Right though)

Tom


> El 20 may 2016, a las 19:22, Francesco Ariis <fa-ml at ariis.it> escribió:
> 
>> On Fri, May 20, 2016 at 10:08:40PM +0200, Anton Felix Lorenzen wrote:
>> When working with Either,
>> I am often missing two simple functions:
>> fromRight :: Either a b -> b
>> fromLeft  :: Either a b -> a
> 
> Sometimes my lazy inner-self is guilty of longing for `fromRight` when
> typing:
> 
>    λ> either undefined id xyz
> 
> but then again, importing Data.Either wouldn't make thing any shorter :P
> 
>    λ> :m +Da<tab>.Ei<tab>
>    λ> fromRight zyx
> 
> 
> I can see fromRight being useful in one-off script; anything bigger than
> a few lines is asking for trouble!
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list