summaryrefslogtreecommitdiff
path: root/src/Propellor/PropAccum.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/PropAccum.hs')
-rw-r--r--src/Propellor/PropAccum.hs44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/Propellor/PropAccum.hs b/src/Propellor/PropAccum.hs
index dec204a2..350f4ab4 100644
--- a/src/Propellor/PropAccum.hs
+++ b/src/Propellor/PropAccum.hs
@@ -4,6 +4,8 @@ module Propellor.PropAccum
( host
, props
, PropAccum(..)
+ , (&)
+ , (&^)
, (!)
, PropList
, propigateContainer
@@ -37,37 +39,45 @@ props = PropList []
-- | Something that can accumulate properties.
class PropAccum h where
-- | Adds a property.
- --
- -- Can add Properties and RevertableProperties
- (&) :: IsProp p => h -> p -> h
+ addProp :: IsProp p => h -> p -> h
- -- | Like (&), but adds the property at the front of the list.
- (&^) :: IsProp p => h -> p -> h
+ -- | Like addProp, but adds the property at the front of the list.
+ addPropFront :: IsProp p => h -> p -> h
getProperties :: h -> [Property HasInfo]
+-- | Adds a property to a `Host` or other `PropAccum`
+--
+-- Can add Properties and RevertableProperties
+(&) :: (PropAccum h, IsProp p) => h -> p -> h
+(&) = addProp
+
+-- | Adds a property before any other properties.
+(&^) :: (PropAccum h, IsProp p) => h -> p -> h
+(&^) = addPropFront
+
+-- | Adds a property in reverted form.
+(!) :: PropAccum h => h -> RevertableProperty -> h
+h ! p = h & revert p
+
+infixl 1 &
+infixl 1 &^
+infixl 1 !
+
instance PropAccum Host where
- (Host hn ps is) & p = Host hn (ps ++ [toProp p])
+ (Host hn ps is) `addProp` p = Host hn (ps ++ [toProp p])
(is <> getInfoRecursive p)
- (Host hn ps is) &^ p = Host hn (toProp p : ps)
+ (Host hn ps is) `addPropFront` p = Host hn (toProp p : ps)
(getInfoRecursive p <> is)
getProperties = hostProperties
data PropList = PropList [Property HasInfo]
instance PropAccum PropList where
- PropList l & p = PropList (toProp p : l)
- PropList l &^ p = PropList (l ++ [toProp p])
+ PropList l `addProp` p = PropList (toProp p : l)
+ PropList l `addPropFront` p = PropList (l ++ [toProp p])
getProperties (PropList l) = reverse l
--- | Adds a property in reverted form.
-(!) :: PropAccum h => h -> RevertableProperty -> h
-h ! p = h & revert p
-
-infixl 1 &^
-infixl 1 &
-infixl 1 !
-
-- | Adjust the provided Property, adding to its
-- propertyChidren the properties of the provided container.
--