leftToMaybe/rightToMaybe
John Wiegley
johnw at fpcomplete.com
Wed Aug 7 07:04:09 CEST 2013
>>>>> Erik de Castro Lopo <mle+hs at mega-nerd.com> writes:
> And while we're at it:
> isLeft :: Either a b -> Bool
> isLeft (Left _) = True
> isLeft (Right _) = False
> isRight :: Either a b -> Bool
> isRight (Left _) = False
> isRight (Right _) = True
And what about:
fromLeft :: a -> Either a b -> a
fromLeft _ (Left x) = x
fromLeft x _ = x
fromRight :: b -> Either a b -> b
fromRight _ (Right x) = x
fromRight x _ = x
--
John Wiegley
FP Complete Haskell tools, training and consulting
http://fpcomplete.com johnw on #haskell/irc.freenode.net
More information about the Libraries
mailing list