diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor.hs | 4 | ||||
| -rw-r--r-- | src/Propellor/PropAccum.hs | 18 | ||||
| -rw-r--r-- | src/Propellor/Property.hs | 4 | ||||
| -rw-r--r-- | src/Propellor/Property/List.hs | 24 | ||||
| -rw-r--r-- | src/Propellor/Types.hs | 12 |
5 files changed, 31 insertions, 31 deletions
diff --git a/src/Propellor.hs b/src/Propellor.hs index 46f56abe..4f777f11 100644 --- a/src/Propellor.hs +++ b/src/Propellor.hs @@ -37,6 +37,7 @@ module Propellor ( , host , (&) , (!) + , describe -- * Combining properties -- | Properties are often combined together in your propellor -- configuration. For example: @@ -47,6 +48,8 @@ module Propellor ( , before , onChange -- * Included modules + -- | These are only the core modules you'll need. There are many + -- more in propellor that you can import. , module Propellor.Types -- | Additional data types used by propellor , module Propellor.Property @@ -60,7 +63,6 @@ module Propellor ( -- | Combining a list of properties into a single property , module Propellor.Types.PrivData -- | Private data access for properties - , module Propellor.PropAccum , module X ) where diff --git a/src/Propellor/PropAccum.hs b/src/Propellor/PropAccum.hs index 350f4ab4..61cf3dc8 100644 --- a/src/Propellor/PropAccum.hs +++ b/src/Propellor/PropAccum.hs @@ -2,12 +2,10 @@ module Propellor.PropAccum ( host - , props , PropAccum(..) , (&) , (&^) , (!) - , PropList , propigateContainer ) where @@ -27,15 +25,6 @@ import Propellor.PrivData host :: HostName -> Host host hn = Host hn [] mempty --- | Starts accumulating a list of properties. --- --- > propertyList "foo" $ props --- > & someproperty --- > ! oldproperty --- > & otherproperty -props :: PropList -props = PropList [] - -- | Something that can accumulate properties. class PropAccum h where -- | Adds a property. @@ -71,13 +60,6 @@ instance PropAccum Host where (getInfoRecursive p <> is) getProperties = hostProperties -data PropList = PropList [Property HasInfo] - -instance PropAccum PropList where - PropList l `addProp` p = PropList (toProp p : l) - PropList l `addPropFront` p = PropList (l ++ [toProp p]) - getProperties (PropList l) = reverse l - -- | Adjust the provided Property, adding to its -- propertyChidren the properties of the provided container. -- diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 3ab66ca3..c7fc555f 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -100,6 +100,10 @@ onChangeFlagOnFail flagfile = combineWith go writeFile flagfile "" removeFlagFile = whenM (doesFileExist flagfile) $ removeFile flagfile +-- | Changes the description of a property. +describe :: IsProp p => p -> Desc -> p +describe = setDesc + -- | Alias for @flip describe@ (==>) :: IsProp (Property i) => Desc -> Property i -> Property i (==>) = flip describe diff --git a/src/Propellor/Property/List.hs b/src/Propellor/Property/List.hs index 283c5ec7..a88d44d7 100644 --- a/src/Propellor/Property/List.hs +++ b/src/Propellor/Property/List.hs @@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleInstances #-} module Propellor.Property.List ( + props, PropertyList(..), PropertyListType, ) where @@ -12,6 +13,22 @@ import Propellor.PropAccum import Data.Monoid +-- | Starts accumulating a list of properties. +-- +-- > propertyList "foo" $ props +-- > & someproperty +-- > ! oldproperty +-- > & otherproperty +props :: PropList +props = PropList [] + +data PropList = PropList [Property HasInfo] + +instance PropAccum PropList where + PropList l `addProp` p = PropList (toProp p : l) + PropList l `addPropFront` p = PropList (l ++ [toProp p]) + getProperties (PropList l) = reverse l + class PropertyList l where -- | Combines a list of properties, resulting in a single property -- that when run will run each property in the list in turn, @@ -21,12 +38,7 @@ class PropertyList l where -- Note that Property HasInfo and Property NoInfo are not the same -- type, and so cannot be mixed in a list. To make a list of -- mixed types, which can also include RevertableProperty, - -- use `props`: - -- - -- > propertyList "foo" $ props - -- > & someproperty - -- > ! oldproperty - -- > & otherproperty + -- use `props` propertyList :: Desc -> l -> Property (PropertyListType l) -- | Combines a list of properties, resulting in one property that diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index 0dfafbe8..fc700df0 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -177,9 +177,9 @@ data RevertableProperty = RevertableProperty (Property HasInfo) (Property HasInf (<!>) :: Property i1 -> Property i2 -> RevertableProperty p1 <!> p2 = RevertableProperty (toIProperty p1) (toIProperty p2) +-- | Class of types that can be used as properties of a host. class IsProp p where - -- | Sets description. - describe :: p -> Desc -> p + setDesc :: p -> Desc -> p toProp :: p -> Property HasInfo getDesc :: p -> Desc -- | Gets the info of the property, combined with all info @@ -187,21 +187,21 @@ class IsProp p where getInfoRecursive :: p -> Info instance IsProp (Property HasInfo) where - describe (IProperty _ a i cs) d = IProperty d a i cs + setDesc (IProperty _ a i cs) d = IProperty d a i cs toProp = id getDesc = propertyDesc getInfoRecursive (IProperty _ _ i cs) = i <> mconcat (map getInfoRecursive cs) instance IsProp (Property NoInfo) where - describe (SProperty _ a cs) d = SProperty d a cs + setDesc (SProperty _ a cs) d = SProperty d a cs toProp = toIProperty getDesc = propertyDesc getInfoRecursive _ = mempty instance IsProp RevertableProperty where -- | Sets the description of both sides. - describe (RevertableProperty p1 p2) d = - RevertableProperty (describe p1 d) (describe p2 ("not " ++ d)) + setDesc (RevertableProperty p1 p2) d = + RevertableProperty (setDesc p1 d) (setDesc p2 ("not " ++ d)) getDesc (RevertableProperty p1 _) = getDesc p1 toProp (RevertableProperty p1 _) = p1 -- | Return the Info of the currently active side. |
