[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:02:51 UTC 2010
The following commit has been merged in the master branch:
commit 531afad4be72325c91817235166a5c3a4a7d79a2
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Oct 1 08:30:19 2005 +0100
New function forceMaybeMsg
diff --git a/MissingH/Maybe.hs b/MissingH/Maybe.hs
index ea7115f..58dd737 100644
--- a/MissingH/Maybe.hs
+++ b/MissingH/Maybe.hs
@@ -31,11 +31,16 @@ Copyright (c) 2004 John Goerzen, jgoerzen\@complete.org
-}
module MissingH.Maybe
(
- forceMaybe
+ forceMaybe, forceMaybeMsg
) where
{- | Pulls a Just value out of a Maybe value. If the Maybe value is
Nothing, raises an exception with error. -}
forceMaybe :: Maybe a -> a
-forceMaybe Nothing = error "forceMaybe: Got Nothing"
-forceMaybe (Just x) = x
+forceMaybe = forceMaybeMsg "forceMaybe: Got Nothing"
+
+{- | Like 'forceMaybe', but lets you customize the error message raised if
+Nothing is supplied. -}
+forceMaybeMsg :: String -> Maybe a -> a
+forceMaybeMsg msg Nothing = error msg
+forceMaybeMsg _ (Just x) = x
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list