[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

Neil Mitchell NeilMitchell
Fri Apr 23 15:21:53 UTC 2010


The following commit has been merged in the master branch:
commit 40250d3b118f82b2f1b268238b67cc9e1838fd80
Author: Neil Mitchell <Neil Mitchell>
Date:   Fri Dec 8 20:37:21 2006 +0100

    Add fromLeft, fromRight and fromEither to Data.Either.Utils

diff --git a/src/Data/Either/Utils.hs b/src/Data/Either/Utils.hs
index 53adbc6..0bcb398 100644
--- a/src/Data/Either/Utils.hs
+++ b/src/Data/Either/Utils.hs
@@ -34,7 +34,8 @@ module Data.Either.Utils
      maybeToEither,
      forceEither,
      forceEitherMsg,
-     eitherToMonadError
+     eitherToMonadError,
+     fromLeft, fromRight, fromEither
 ) where
 import Control.Monad.Error
 
@@ -71,3 +72,20 @@ MonadError class. -}
 eitherToMonadError :: MonadError e m => Either e a -> m a
 eitherToMonadError (Left x) = throwError x
 eitherToMonadError (Right x) = return x
+
+
+-- | Take a Left to a value, crashes on a Right
+fromLeft :: Either a b -> a
+fromLeft (Left a) = a
+fromLeft _ = error "Data.Either.Utils.fromLeft: Right"
+
+-- | Take a Right to a value, crashes on a Left
+fromRight :: Either a b -> b
+fromRight (Right a) = a
+fromRight _ = error "Data.Either.Utils.fromRight: Left"
+
+-- | Take an Either, and return the value inside it
+fromEither :: Either a a -> a
+fromEither (Left a) = a
+fromEither (Right a) = a
+

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list