From 13beb3a02e5c59eb8c2c481f79535fb4469392d3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 18 May 2018 10:31:18 -0400 Subject: modernized and simplified the MetaTypes implementation now that compatability with ghc 7 is no longer needed. Data.Type.Bool contains effectively the same stuff that was implemented here, so removed my code. Tried to use Data.Type.Equality instead of my EqT, but it seems to be some other type of (type level) equality, and didn't compile. Instead went with the simpler EqT implementation that newer ghc versions allow. The rest of the changes are simply better syntax for defining type families. And upon using that syntax, ghc noticed that `type family a + b` does not have kind "ab" like I wrote before, but is kind *. Tested on debian stable with ghc 8.0.1. This commit was sponsored by John Pellman on Patreon. --- src/Propellor/Types.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/Propellor/Types.hs') diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index 7cbe9f13..e10e0f5b 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -154,13 +154,19 @@ instance IsProp (RevertableProperty setupmetatypes undometatypes) where -- | Type level calculation of the type that results from combining two -- types of properties. -type family CombinedType x y -type instance CombinedType (Property (MetaTypes x)) (Property (MetaTypes y)) = Property (MetaTypes (Combine x y)) -type instance CombinedType (RevertableProperty (MetaTypes x) (MetaTypes x')) (RevertableProperty (MetaTypes y) (MetaTypes y')) = RevertableProperty (MetaTypes (Combine x y)) (MetaTypes (Combine x' y')) --- When only one of the properties is revertable, the combined property is --- not fully revertable, so is not a RevertableProperty. -type instance CombinedType (RevertableProperty (MetaTypes x) (MetaTypes x')) (Property (MetaTypes y)) = Property (MetaTypes (Combine x y)) -type instance CombinedType (Property (MetaTypes x)) (RevertableProperty (MetaTypes y) (MetaTypes y')) = Property (MetaTypes (Combine x y)) +type family CombinedType x y where + CombinedType (Property (MetaTypes x)) (Property (MetaTypes y)) = + Property (MetaTypes (Combine x y)) + CombinedType + (RevertableProperty (MetaTypes x) (MetaTypes x')) + (RevertableProperty (MetaTypes y) (MetaTypes y')) = + RevertableProperty (MetaTypes (Combine x y)) (MetaTypes (Combine x' y')) + -- When only one of the properties is revertable, the combined + -- property is not fully revertable, so is not a RevertableProperty. + CombinedType (RevertableProperty (MetaTypes x) (MetaTypes x')) (Property (MetaTypes y)) = + Property (MetaTypes (Combine x y)) + CombinedType (Property (MetaTypes x)) (RevertableProperty (MetaTypes y) (MetaTypes y')) = + Property (MetaTypes (Combine x y)) type ResultCombiner = Maybe (Propellor Result) -> Maybe (Propellor Result) -> Maybe (Propellor Result) -- cgit v1.2.3