From 39f3acd6e473ee25e6c37fd5c8a5b4237d34127c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 18:41:30 -0400 Subject: propellor spin --- Propellor/Property.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Propellor/Property.hs') diff --git a/Propellor/Property.hs b/Propellor/Property.hs index e7ec704d..c2a8972e 100644 --- a/Propellor/Property.hs +++ b/Propellor/Property.hs @@ -33,6 +33,16 @@ combineProperties desc ps = Property desc $ go ps NoChange FailedChange -> return FailedChange _ -> go ls (r <> rs) +-- | Combines together two properties, resulting in one property +-- that ensures the first, and if the first succeeds, ensures the second. +-- The property uses the description of the first property. +before :: Property -> Property -> Property +p1 `before` p2 = Property (propertyDesc p1) $ do + r <- ensureProperty p1 + case r of + FailedChange -> return FailedChange + _ -> ensureProperty p2 + -- | Makes a perhaps non-idempotent Property be idempotent by using a flag -- file to indicate whether it has run before. -- Use with caution. -- cgit v1.3-2-g0d8e