diff options
Diffstat (limited to 'Propellor/Types.hs')
| -rw-r--r-- | Propellor/Types.hs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Propellor/Types.hs b/Propellor/Types.hs index 3be10d3f..b1632923 100644 --- a/Propellor/Types.hs +++ b/Propellor/Types.hs @@ -1,20 +1,53 @@ +{-# LANGUAGE PackageImports #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} + module Propellor.Types where import Data.Monoid +import Control.Applicative import System.Console.ANSI +import "mtl" Control.Monad.Reader +import "MonadCatchIO-transformers" Control.Monad.CatchIO type HostName = String type GroupName = String type UserName = String +-- | The core data type of Propellor, this reprecents a property +-- that the system should have, and an action to ensure it has the +-- property. data Property = Property { propertyDesc :: Desc -- | must be idempotent; may run repeatedly - , propertySatisfy :: IO Result + , propertySatisfy :: Propellor Result } +-- | A property that can be reverted. data RevertableProperty = RevertableProperty Property Property +-- | Propellor's monad provides read-only access to attributes of the +-- system. +newtype Propellor a = Propellor { runWithHostAttr :: ReaderT HostAttr IO a } + deriving + ( Monad + , Functor + , Applicative + , MonadReader HostAttr + , MonadIO + , MonadCatchIO + ) + +-- | The attributes of a system. For example, its hostname. +newtype HostAttr = HostAttr + { _hostname :: HostName + } + +mkHostAttr :: HostName -> HostAttr +mkHostAttr = HostAttr + +getHostName :: Propellor HostName +getHostName = asks _hostname + class IsProp p where -- | Sets description. describe :: p -> Desc -> p |
