add fallback combinator

This commit is contained in:
Joey Hess 2014-11-19 18:57:58 -04:00
parent 5c34a575c8
commit 08242e29f6
1 changed files with 9 additions and 0 deletions

View File

@ -89,6 +89,15 @@ check c p = adjustProperty p $ \satisfy -> ifM (liftIO c)
, return NoChange , 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 -- | Marks a Property as trivial. It can only return FailedChange or
-- NoChange. -- NoChange.
-- --