diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-02 12:13:39 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-02 13:18:08 -0400 |
| commit | 526bcbf093af665f316a0ba4d1a836786ab66dcf (patch) | |
| tree | d4ceb9ec125587cfac37cb50c178fcc4624dcedf /Propellor/Property.hs | |
| parent | 7705f65ae22f38989f404c77de4d661b652e692e (diff) | |
type-safe reversions
Diffstat (limited to 'Propellor/Property.hs')
| -rw-r--r-- | Propellor/Property.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Propellor/Property.hs b/Propellor/Property.hs index 2764d614..10a51530 100644 --- a/Propellor/Property.hs +++ b/Propellor/Property.hs @@ -58,14 +58,6 @@ property `onChange` hook = Property (propertyDesc property) $ do return $ r <> r' _ -> return r --- | Indicates that the first property can only be satisfied once --- the second is. -requires :: Property -> Property -> Property -x `requires` y = combineProperties (propertyDesc x) [y, x] - -describe :: Property -> Desc -> Property -describe p d = p { propertyDesc = d } - (==>) :: Desc -> Property -> Property (==>) = flip describe infixl 1 ==> @@ -76,3 +68,17 @@ check c property = Property (propertyDesc property) $ ifM c ( ensureProperty property , return NoChange ) + +-- | Undoes the effect of a property. +revert :: RevertableProperty -> RevertableProperty +revert (RevertableProperty p1 p2) = RevertableProperty p2 p1 + +-- | Starts a list of Properties +props :: [Property] +props = [] + +-- | Adds a property to the list. +-- Can add both Properties and RevertableProperties. +(&) :: IsProp p => [Property] -> p -> [Property] +ps & p = toProp p : ps +infixl 1 & |
