summaryrefslogtreecommitdiff
path: root/src/Propellor/Property.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-19 18:57:58 -0400
committerJoey Hess2014-11-19 18:57:58 -0400
commit08242e29f6878cbf514bdf68a4a7276d514a6aba (patch)
tree81f18ad959f5cdeae842296e4ee9e06b35533141 /src/Propellor/Property.hs
parent5c34a575c835c061dc68025292e003786f60490e (diff)
add fallback combinator
Diffstat (limited to 'src/Propellor/Property.hs')
-rw-r--r--src/Propellor/Property.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs
index 4b957317..9545979c 100644
--- a/src/Propellor/Property.hs
+++ b/src/Propellor/Property.hs
@@ -89,6 +89,15 @@ check c p = adjustProperty p $ \satisfy -> ifM (liftIO c)
, return NoChange
)
+-- | Tries the first property, but if it fails to work, instead uses
+-- the second.
+fallback :: Property -> Property -> Property
+fallback p1 p2 = adjustProperty p1 $ \satisfy -> do
+ r <- satisfy
+ if r == FailedChange
+ then propertySatisfy p2
+ else return r
+
-- | Marks a Property as trivial. It can only return FailedChange or
-- NoChange.
--