isLeft/isRight (Was: leftToMaybe/rightToMaybe)

Erik de Castro Lopo mle+hs at
Wed Aug 7 10:12:11 CEST 2013

Henning Thielemann wrote:



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

Erik de Castro Lopo

More information about the Libraries mailing list