diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-10 11:40:12 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-10 11:40:12 -0400 |
| commit | 349e675a499187379ddb14c5f6ce8203de10183e (patch) | |
| tree | 44f9eed959335dca27bb35947a952c3ca9f97efb /src/Propellor/PropAccum.hs | |
| parent | ea29beecfeebf304e544ab588da43fa66d83fd43 (diff) | |
Improved documentation, particularly of the Propellor module.
This involved some code changes, including some renaming of instance
methods. (ABI change)
Diffstat (limited to 'src/Propellor/PropAccum.hs')
| -rw-r--r-- | src/Propellor/PropAccum.hs | 44 |
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. -- |
