Proposal: Add isLeft/isRight to Data.Either

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Dec 5 15:29:34 CET 2012


On Mittwoch, 5. Dezember 2012, 09:23:31, Simon Hengel wrote:
> Hi Herbert,
> 
> On Tue, Dec 04, 2012 at 11:02:07PM +0100, Herbert Valerio Riedel wrote:
> > btw, what I've been missing even more than isLeft/isRight is something
> > like
> > 
> > 	leftMaybe :: Either a b -> Maybe a
> > 	leftMaybe (Left x) = Just x
> > 	leftMaybe _        = Nothing
> > 	
> > 	rightMaybe :: Either a b -> Maybe b
> > 	rightMaybe (Right x) = Just x
> > 	rightMaybe _         = Nothing
> 
> There seems to be support for this.  I think it would be useful to have
> a separate proposal/patch.

I'm not against it, but I would like to ask whether these are really used so 
frequently that

Prelude> :t either Just (const Nothing)
either Just (const Nothing) :: Either a b -> Maybe a

is too cumbersome.



More information about the Libraries mailing list