
7 Aug
2013
7 Aug
'13
1:04 a.m.
Erik de Castro Lopo
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