summaryrefslogtreecommitdiff
path: root/src/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2015-10-10 14:56:22 -0400
committerJoey Hess2015-10-10 15:05:05 -0400
commitae380f085bc867f7405ef0a16c849864c6552e47 (patch)
tree22bd030a05f85bfeff90eaa48a87915edf9cdf27 /src/Propellor/Property
parent28fe270223ed56ef8e7fd867573b5ba6a5a221c7 (diff)
tighten focus of Propellor module, adding Propellor.Base for all the exports
Diffstat (limited to 'src/Propellor/Property')
-rw-r--r--src/Propellor/Property/List.hs24
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