isLeft/isRight (Was: leftToMaybe/rightToMaybe)

Michael Snoyman michael at snoyman.com
Wed Aug 7 10:21:12 CEST 2013


On Wednesday, August 7, 2013, Erik de Castro Lopo wrote:

> Henning Thielemann wrote:
>
> > http://www.haskell.org/pipermail/libraries/2012-November/018709.html
> > http://www.haskell.org/pipermail/libraries/2012-December/018716.html
>
> Henning,
>
> In the second link above you wrote:
>
> > It would be a good opportunity to check how these packages use isLeft and
> > isRight. E.g. if they use them in connection with fromLeft and fromRight
> > then this would be an argument for me to exclude isLeft and isRight as
> > well.
>
> My main usage of isLeft/isRight is in HSpec tests where I write:
>
>
>      value1 `shouldSatisfy' isLeft
>      value2 `shouldSatisfy' isRight
>
> I would also be opposed to a fromLeft defined anything like fromJust:
>
>      Data.Maybe.fromJust :: Maybe a -> a
>
> but would not be opposed to a fromLeft defined as John Wiegley suggested:
>
>     fromLeft :: a -> Either a b -> a
>     fromLeft _ (Left x) = x
>     fromLeft x _ = x
>
>
+1. Let's avoid adding any new partial functions.


> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org <javascript:;>
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130807/6e0efbf3/attachment.htm>


More information about the Libraries mailing list