From 349e675a499187379ddb14c5f6ce8203de10183e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 10 Oct 2015 11:40:12 -0400 Subject: Improved documentation, particularly of the Propellor module. This involved some code changes, including some renaming of instance methods. (ABI change) --- src/Propellor/PropAccum.hs | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'src/Propellor/PropAccum.hs') 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. -- -- cgit v1.2.3