summaryrefslogtreecommitdiff
path: root/src/Propellor/Types
diff options
context:
space:
mode:
authorJoey Hess2015-10-17 14:48:15 -0400
committerJoey Hess2015-10-17 14:48:15 -0400
commitf6e352767eaf236acb929a9793dee28eb4897baa (patch)
tree57189708f4142015de967938d4e098a2ea6e165e /src/Propellor/Types
parentfe052464493571ac26d825823c8c6e95ddb096e2 (diff)
parent57f4eca88a1c3762b452171ee0a9d1a4f1367402 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Types')
-rw-r--r--src/Propellor/Types/CmdLine.hs9
-rw-r--r--src/Propellor/Types/Info.hs10
2 files changed, 4 insertions, 15 deletions
diff --git a/src/Propellor/Types/CmdLine.hs b/src/Propellor/Types/CmdLine.hs
index ca73c902..558c6e8b 100644
--- a/src/Propellor/Types/CmdLine.hs
+++ b/src/Propellor/Types/CmdLine.hs
@@ -1,20 +1,15 @@
-{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
-
module Propellor.Types.CmdLine where
import Propellor.Types.OS
import Propellor.Types.PrivData
import System.Posix.Types
-import Data.Typeable
-import Data.Monoid
-- | All the command line actions that propellor can perform.
data CmdLine
= Run HostName
| Spin [HostName] (Maybe HostName)
| SimpleRun HostName
- | ControlledRun HostName ControllerChain
| Set PrivDataField Context
| Unset PrivDataField Context
| UnsetUnused
@@ -34,7 +29,3 @@ data CmdLine
| GitPush Fd Fd
| Check
deriving (Read, Show, Eq)
-
--- | List of hosts that acted as controllers to cause a host to be spinned.
-newtype ControllerChain = ControllerChain [HostName]
- deriving (Read, Show, Eq, Typeable, Monoid)
diff --git a/src/Propellor/Types/Info.hs b/src/Propellor/Types/Info.hs
index 347a03e7..3330a033 100644
--- a/src/Propellor/Types/Info.hs
+++ b/src/Propellor/Types/Info.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Propellor.Types.Info (
Info,
@@ -17,15 +17,12 @@ import Data.Monoid
import Data.Maybe
-- | Information about a Host, which can be provided by its properties.
-data Info = Info [(Dynamic, Bool)]
+newtype Info = Info [(Dynamic, Bool)]
+ deriving (Monoid)
instance Show Info where
show (Info l) = "Info " ++ show (map (dynTypeRep . fst) l)
-instance Monoid Info where
- mempty = Info []
- mappend (Info a) (Info b) = Info (a <> b)
-
-- | Values stored in Info must be members of this class.
--
-- This is used to avoid accidentially using other data types
@@ -40,6 +37,7 @@ class (Typeable v, Monoid v) => IsInfo v where
addInfo :: IsInfo v => Info -> v -> Info
addInfo (Info l) v = Info ((toDyn v, propigateInfo v):l)
+-- The list is reversed here because addInfo builds it up in reverse order.
getInfo :: IsInfo v => Info -> v
getInfo (Info l) = mconcat (mapMaybe (fromDynamic . fst) (reverse l))