diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-01-19 14:15:49 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-01-19 14:15:49 -0400 |
| commit | 1ae21965aaba0303088052e873fea39708e331ed (patch) | |
| tree | 918a8e0575e6369e3d94598d675b089c54579cf2 /src/Propellor/Host.hs | |
| parent | db93c41f90e9ad68854b6b219fc9fe6d12085600 (diff) | |
rename HostLike to PropAccum
This is more general; it doesn't need to contain a Host.
It would, for example, be possible to make Property itself be an instance
of PropAccum.
Diffstat (limited to 'src/Propellor/Host.hs')
| -rw-r--r-- | src/Propellor/Host.hs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/Propellor/Host.hs b/src/Propellor/Host.hs deleted file mode 100644 index cfe90949..00000000 --- a/src/Propellor/Host.hs +++ /dev/null @@ -1,74 +0,0 @@ -{-# LANGUAGE PackageImports #-} - -module Propellor.Host where - -import Data.Monoid - -import Propellor.Types -import Propellor.Property - --- | Starts accumulating the properties of a Host. --- --- > host "example.com" --- > & someproperty --- > ! oldproperty --- > & otherproperty -host :: HostName -> Host -host hn = Host hn [] mempty - --- | Something that can accumulate properties. -class Hostlike h where - -- | Adds a property. - -- - -- Can add Properties and RevertableProperties - (&) :: IsProp p => h -> p -> h - - -- | Like (&), but adds the property as the - -- first property of the host. Normally, property - -- order should not matter, but this is useful - -- when it does. - (&^) :: IsProp p => h -> p -> h - - getHost :: h -> Host - -instance Hostlike Host where - (Host hn ps is) & p = Host hn (ps ++ [toProp p]) - (is <> getInfoRecursive p) - (Host hn ps is) &^ p = Host hn ([toProp p] ++ ps) - (getInfoRecursive p <> is) - getHost h = h - --- | Adds a property in reverted form. -(!) :: Hostlike 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 Hostlike. - --- The Info of the propertyChildren is adjusted to only include --- info that should be propigated out to the Property. --- --- DNS Info is propigated, so that eg, aliases of a Hostlike --- are reflected in the dns for the host where it runs. --- --- PrivData Info is propigated, so that properties used inside a --- Hostlike will have the necessary PrivData available. -propigateHostLike :: Hostlike hl => hl -> Property -> Property -propigateHostLike hl prop = prop - { propertyChildren = propertyChildren prop ++ hostprops - } - where - hostprops = map go $ hostProperties $ getHost hl - go p = - let i = propertyInfo p - in p - { propertyInfo = mempty - { _dns = _dns i - , _privData = _privData i - } - , propertyChildren = map go (propertyChildren p) - } |
