diff options
author | Simon Hengel <sol@typeful.net> | 2012-12-25 16:07:27 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-04-25 22:18:35 +0100 |
commit | fd6fb7c8435e618532fabd648adc8829696384f9 (patch) | |
tree | 64834333e1c111771a52fcbda6fe8806ec25ea06 /libraries/base/Data/Either.hs | |
parent | 4eb3193467824e77b6d6bb55ae722c7cb04390e1 (diff) | |
download | haskell-fd6fb7c8435e618532fabd648adc8829696384f9.tar.gz |
Add isLeft/isRight
Diffstat (limited to 'libraries/base/Data/Either.hs')
-rw-r--r-- | libraries/base/Data/Either.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libraries/base/Data/Either.hs b/libraries/base/Data/Either.hs index 0fd862e025..166c4f2741 100644 --- a/libraries/base/Data/Either.hs +++ b/libraries/base/Data/Either.hs @@ -23,6 +23,8 @@ module Data.Either ( either, lefts, rights, + isLeft, + isRight, partitionEithers, ) where @@ -97,6 +99,16 @@ partitionEithers = foldr (either left right) ([],[]) left a ~(l, r) = (a:l, r) right a ~(l, r) = (l, a:r) +-- | Return `True` if the given value is a `Left`-value, `False` otherwise. +isLeft :: Either a b -> Bool +isLeft (Left _) = True +isLeft (Right _) = False + +-- | Return `True` if the given value is a `Right`-value, `False` otherwise. +isRight :: Either a b -> Bool +isRight (Left _) = False +isRight (Right _) = True + {- {-------------------------------------------------------------------- Testing |