summaryrefslogtreecommitdiff
path: root/src/Propellor/Types
diff options
context:
space:
mode:
authorJoey Hess2016-03-24 22:01:30 -0400
committerJoey Hess2016-03-24 22:01:30 -0400
commit2a3530695c90f889df91f6a3a38a8989091f65a3 (patch)
tree6b14f864cb240d4aebe1d66f98cb4ec0418a50dc /src/Propellor/Types
parent027864bd1a18f2240f56cd3fb499c4d5d8caa45a (diff)
fix combineWith to only accept properties that have common targets
Diffstat (limited to 'src/Propellor/Types')
-rw-r--r--src/Propellor/Types/MetaTypes.hs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Propellor/Types/MetaTypes.hs b/src/Propellor/Types/MetaTypes.hs
index 60af33ef..6edea291 100644
--- a/src/Propellor/Types/MetaTypes.hs
+++ b/src/Propellor/Types/MetaTypes.hs
@@ -13,14 +13,12 @@ module Propellor.Types.MetaTypes (
Sing,
sing,
SingI,
- Union,
- Intersect,
- Concat,
IncludesInfo,
Targets,
NonTargets,
NotSuperset,
CheckCombineTargets(..),
+ Combine,
CannotCombineTargets,
type (&&),
Not,
@@ -89,6 +87,15 @@ type family Concat (list1 :: [a]) (list2 :: [a]) :: [a]
type instance Concat '[] bs = bs
type instance Concat (a ': as) bs = a ': (Concat as bs)
+-- | Combine two MetaTypes lists, yielding a list
+-- that has targets present in both, and nontargets present in either.
+type family Combine (list1 :: [a]) (list2 :: [a]) :: [a]
+type instance Combine (list1 :: [a]) (list2 :: [a]) =
+ (Concat
+ (NonTargets list1 `Union` NonTargets list2)
+ (Targets list1 `Intersect` Targets list2)
+ )
+
type family IncludesInfo t :: Bool
type instance IncludesInfo (Sing l) = Elem 'WithInfo l
@@ -97,8 +104,6 @@ type family CannotUseEnsurePropertyWithInfo (l :: [a]) :: Bool
type instance CannotUseEnsurePropertyWithInfo '[] = 'True
type instance CannotUseEnsurePropertyWithInfo (t ': ts) = Not (t `EqT` 'WithInfo) && CannotUseEnsurePropertyWithInfo ts
-data CheckCombineTargets = CannotCombineTargets | CanCombineTargets
-
-- | Detect intersection of two lists that don't have any common targets.
--
-- The name of this was chosen to make type errors a more understandable.
@@ -106,6 +111,8 @@ type family CannotCombineTargets (list1 :: [a]) (list2 :: [a]) (listr :: [a]) ::
type instance CannotCombineTargets l1 l2 '[] = 'CannotCombineTargets
type instance CannotCombineTargets l1 l2 (a ': rest) = 'CanCombineTargets
+data CheckCombineTargets = CannotCombineTargets | CanCombineTargets
+
-- | Every item in the subset must be in the superset.
--
-- The name of this was chosen to make type errors more understandable.