isLeft/isRight (Was: leftToMaybe/rightToMaybe)
Erik de Castro Lopo
mle+hs at mega-nerd.com
Wed Aug 7 10:12:11 CEST 2013
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
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the Libraries
mailing list