summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config-simple.hs2
-rw-r--r--debian/changelog8
-rw-r--r--doc/haskell_newbie.mdwn1
-rw-r--r--src/Propellor.hs4
-rw-r--r--src/Propellor/PropAccum.hs18
-rw-r--r--src/Propellor/Property.hs4
-rw-r--r--src/Propellor/Property/List.hs24
-rw-r--r--src/Propellor/Types.hs12
8 files changed, 38 insertions, 35 deletions
diff --git a/config-simple.hs b/config-simple.hs
index 9b314ada..67c06120 100644
--- a/config-simple.hs
+++ b/config-simple.hs
@@ -2,12 +2,12 @@
-- the propellor program.
import Propellor
-import Propellor.Property.Scheduled
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.Network as Network
--import qualified Propellor.Property.Ssh as Ssh
import qualified Propellor.Property.Cron as Cron
+import Propellor.Property.Scheduled
--import qualified Propellor.Property.Sudo as Sudo
import qualified Propellor.Property.User as User
--import qualified Propellor.Property.Hostname as Hostname
diff --git a/debian/changelog b/debian/changelog
index 3d6832a7..55076ae8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,12 @@ propellor (2.9.0) UNRELEASED; urgency=medium
* Added basic Uwsgi module, maintained by FĂ©lix Sipma.
* Add Apt.hasForeignArch. Thanks, Per Olofsson.
* Improved documentation, particularly of the Propellor module.
- This involved some code changes, including some renaming of instance
- methods. (ABI change)
+ * The Propellor module no longer exports many of the things it used to,
+ being now focused on only what's needed to write config.hs.
+ Use Propellor.Base to get all the things exported by Propellor before.
+ (API change)
+ * Some renaming of instance methods, and moving of functions to more
+ appropriate modules. (API change)
-- Joey Hess <id@joeyh.name> Thu, 08 Oct 2015 11:09:01 -0400
diff --git a/doc/haskell_newbie.mdwn b/doc/haskell_newbie.mdwn
index 24839b12..e368569c 100644
--- a/doc/haskell_newbie.mdwn
+++ b/doc/haskell_newbie.mdwn
@@ -16,7 +16,6 @@ So, `-- ` starts a comment in this file.
[[!format haskell """
import Propellor
-import Propellor.CmdLine
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.User as User
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.