diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-10 15:17:15 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-10 15:17:15 -0400 |
| commit | 480a25aaa804208d76cd362c9a6bd222ec66dee6 (patch) | |
| tree | 7fae0a11735caab29e5c1106a243d7527b25e3d8 /src/Propellor/Property/List.hs | |
| parent | 1799f634d89f588eeaef6ff2f6226adf5add3389 (diff) | |
| parent | 63d653ee19b0f1bf2f4115d9f4ae9a93b00bae90 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/List.hs')
| -rw-r--r-- | src/Propellor/Property/List.hs | 24 |
1 files changed, 18 insertions, 6 deletions
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 |
