From 2f1848cb872419628bdf3180d337661de8a6d98e Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Thu, 30 Aug 2012 20:59:33 +0200 Subject: Added assertMaybe --- Spear.lkshw | 2 +- Spear/Setup.hs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Spear.lkshw b/Spear.lkshw index 2dd5288..f062526 100644 --- a/Spear.lkshw +++ b/Spear.lkshw @@ -1,7 +1,7 @@ Version of workspace file format: 1 Time of storage: - "Thu Aug 30 20:54:09 CEST 2012" + "Thu Aug 30 20:57:58 CEST 2012" Name of the workspace: "Spear" File paths of contained packages: diff --git a/Spear/Setup.hs b/Spear/Setup.hs index cfe379c..e7917cf 100644 --- a/Spear/Setup.hs +++ b/Spear/Setup.hs @@ -8,6 +8,7 @@ module Spear.Setup , runSetup_ , setupError , setupIO +, assertMaybe ) where @@ -50,3 +51,9 @@ setupError = MT.lift . throwError -- | Lift the given IO action into the 'Setup' monad. setupIO :: IO a -> Setup a setupIO = MT.lift . MT.lift + + +-- | Throw the given error string if given 'Nothing'. +assertMaybe :: Maybe a -> String -> Setup () +assertMaybe Nothing err = setupError err +assertMaybe _ _ = return () -- cgit v1.2.3