[commit: base] master: Add isLeft/isRight (58d03b8)
Ian Lynagh
igloo at earth.li
Fri Apr 26 03:10:54 CEST 2013
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
https://github.com/ghc/packages-base/commit/58d03b8ed4342b80bd0ed8afa52c2b5c7f975534
>---------------------------------------------------------------
commit 58d03b8ed4342b80bd0ed8afa52c2b5c7f975534
Author: Simon Hengel <sol at typeful.net>
Date: Tue Dec 25 16:07:27 2012 +0100
Add isLeft/isRight
>---------------------------------------------------------------
Data/Either.hs | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Data/Either.hs b/Data/Either.hs
index 0fd862e..166c4f2 100644
--- a/Data/Either.hs
+++ b/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
More information about the ghc-commits
mailing list