module Propellor.PropAccum
( host
, Props(..)
, props
, (&)
, (&^)
, (!)
) where
import Propellor.Types
import Propellor.Types.MetaTypes
import Propellor.Types.Core
import Propellor.Property
import Data.Monoid
import Prelude
host :: HostName -> Props metatypes -> Host
host hn (Props ps) = Host hn ps (mconcat (map getInfoRecursive ps))
props :: Props UnixLike
props = Props []
infixl 1 &
infixl 1 &^
infixl 1 !
type family GetMetaTypes x
type instance GetMetaTypes (Property (MetaTypes t)) = MetaTypes t
type instance GetMetaTypes (RevertableProperty (MetaTypes t) undo) = MetaTypes t
(&)
::
( IsProp p
, MetaTypes y ~ GetMetaTypes p
, CheckCombinable x y ~ 'CanCombine
)
=> Props (MetaTypes x)
-> p
-> Props (MetaTypes (Combine x y))
Props c & p = Props (c ++ [toChildProperty p])
(&^)
::
( IsProp p
, MetaTypes y ~ GetMetaTypes p
, CheckCombinable x y ~ 'CanCombine
)
=> Props (MetaTypes x)
-> p
-> Props (MetaTypes (Combine x y))
Props c &^ p = Props (toChildProperty p : c)
(!)
:: (CheckCombinable x z ~ 'CanCombine)
=> Props (MetaTypes x)
-> RevertableProperty (MetaTypes y) (MetaTypes z)
-> Props (MetaTypes (Combine x z))
Props c ! p = Props (c ++ [toChildProperty (revert p)])