[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 15:07:49 UTC 2010
The following commit has been merged in the master branch:
commit 6cadace09f4d366abbd4141ab367bde281452609
Author: John Goerzen <jgoerzen at complete.org>
Date: Wed Apr 5 03:31:32 2006 +0100
New function forceEitherMsg
diff --git a/MissingH/Either.hs b/MissingH/Either.hs
index 468cb2f..bf50094 100644
--- a/MissingH/Either.hs
+++ b/MissingH/Either.hs
@@ -1,5 +1,5 @@
{- arch-tag: Euither utilities
-Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+Copyright (C) 2004-2006 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : MissingH.Either
- Copyright : Copyright (C) 2004 John Goerzen
+ Copyright : Copyright (C) 2004-2006 John Goerzen
License : GNU GPL, version 2 or above
Maintainer : John Goerzen <jgoerzen at complete.org>
@@ -33,6 +33,7 @@ module MissingH.Either
(
maybeToEither,
forceEither,
+ forceEitherMsg,
eitherToMonadError
) where
import Control.Monad.Error
@@ -60,6 +61,11 @@ forceEither :: Show e => Either e a -> a
forceEither (Left x) = error (show x)
forceEither (Right x) = x
+{- | Like 'forceEither', but can raise a specific message with the error. -}
+forceEitherMsg :: Show e => String -> Either e a -> a
+forceEitherMsg msg (Left x) = error $ msg ++ ": " ++ show x
+forceEitherMsg _ (Right x) = x
+
{- | Takes an either and transforms it into something of the more generic
MonadError class. -}
eitherToMonadError :: MonadError e m => Either e a -> m a
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list