summaryrefslogtreecommitdiff
path: root/src/Propellor/Types.hs
diff options
context:
space:
mode:
authorJoey Hess2016-03-25 15:28:31 -0400
committerJoey Hess2016-03-25 15:28:31 -0400
commit1edce2b72614e2e8eceefde97436db024799ff20 (patch)
treebee36dec11710fae9cb93fe6d6f7e32293f26e01 /src/Propellor/Types.hs
parent9768434f5fa2f2ed0bbb0212763a76471186a3cd (diff)
ported Property.Apt
Diffstat (limited to 'src/Propellor/Types.hs')
-rw-r--r--src/Propellor/Types.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs
index db05e100..7098c83f 100644
--- a/src/Propellor/Types.hs
+++ b/src/Propellor/Types.hs
@@ -42,6 +42,7 @@ module Propellor.Types
, module Propellor.Types.Dns
, module Propellor.Types.Result
, module Propellor.Types.ZFS
+ , TightenTargets(..)
) where
import Data.Monoid
@@ -285,3 +286,25 @@ instance (CheckCombinable x y ~ 'CanCombine, SingI (Combine x y)) => Combines (R
combineWith sf tf (RevertableProperty x _) y = combineWith sf tf x y
instance (CheckCombinable x y ~ 'CanCombine, SingI (Combine x y)) => Combines (Property (MetaTypes x)) (RevertableProperty (MetaTypes y) (MetaTypes y')) where
combineWith sf tf x (RevertableProperty y _) = combineWith sf tf x y
+
+class TightenTargets p where
+ -- | Tightens the MetaType list of a Property (or similar),
+ -- to contain fewer targets.
+ --
+ -- For example, to make a property that uses apt-get, which is only
+ -- available on DebianLike systems:
+ --
+ -- > upgraded :: Property DebianLike
+ -- > upgraded = tightenTargets $ cmdProperty "apt-get" ["upgrade"]
+ tightenTargets
+ ::
+ -- Note that this uses PolyKinds
+ ( (Targets untightened `NotSuperset` Targets tightened) ~ 'CanCombine
+ , (NonTargets tightened `NotSuperset` NonTargets untightened) ~ 'CanCombine
+ , SingI tightened
+ )
+ => p (MetaTypes untightened)
+ -> p (MetaTypes tightened)
+
+instance TightenTargets Property where
+ tightenTargets (Property _ d a i c) = Property sing d a i c