From f2bb9a3db7ccb5fc0e64920017d305715b34ba95 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 23 Apr 2018 15:20:25 -0400 Subject: more ghc 8.4 build fixes Tested build with ghc 8.4 now. --- src/Propellor/Property/List.hs | 1 + src/Propellor/Types.hs | 29 ++++++++++++++++++++++------- src/Propellor/Types/Chroot.hs | 3 ++- src/Propellor/Types/Docker.hs | 3 ++- src/Propellor/Types/ResultCheck.hs | 1 + 5 files changed, 28 insertions(+), 9 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/List.hs b/src/Propellor/Property/List.hs index 758e51ce..e53b5ccb 100644 --- a/src/Propellor/Property/List.hs +++ b/src/Propellor/Property/List.hs @@ -20,6 +20,7 @@ import Propellor.Engine import Propellor.Exception import Data.Monoid +import Prelude toProps :: [Property (MetaTypes metatypes)] -> Props (MetaTypes metatypes) toProps ps = Props (map toChildProperty ps) diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index b7c7c7f7..c3926229 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -43,6 +43,7 @@ module Propellor.Types ( , module Propellor.Types.ZFS ) where +import qualified Data.Semigroup as Sem import Data.Monoid import Control.Applicative import Prelude @@ -212,14 +213,13 @@ class TightenTargets p where instance TightenTargets Property where tightenTargets (Property _ d a i c) = Property sing d a i c --- | Any type of Property is a monoid. When properties x and y are +-- | Any type of Property is a Semigroup. When properties x and y are -- appended together, the resulting property has a description like -- "x and y". Note that when x fails to be ensured, it will not -- try to ensure y. -instance SingI metatypes => Monoid (Property (MetaTypes metatypes)) +instance SingI metatypes => Sem.Semigroup (Property (MetaTypes metatypes)) where - mempty = Property sing "noop property" Nothing mempty mempty - mappend (Property _ d1 a1 i1 c1) (Property _ d2 a2 i2 c2) = + Property _ d1 a1 i1 c1 <> Property _ d2 a2 i2 c2 = Property sing d (a1 <> a2) (i1 <> i2) (c1 <> c2) where -- Avoid including "noop property" in description @@ -230,10 +230,26 @@ instance SingI metatypes => Monoid (Property (MetaTypes metatypes)) (Nothing, Just _) -> d2 (Nothing, Nothing) -> d1 --- | Any type of RevertableProperty is a monoid. When revertable +-- | Any type of Property is a Monoid. +instance SingI metatypes => Monoid (Property (MetaTypes metatypes)) + where + -- | A property that does nothing. + mempty = Property sing "noop property" Nothing mempty mempty + mappend = (<>) + +-- | Any type of RevertableProperty is a Semigroup. When revertable -- properties x and y are appended together, the resulting revertable -- property has a description like "x and y". -- Note that when x fails to be ensured, it will not try to ensure y. +instance + ( Sem.Semigroup (Property setupmetatypes) + , Sem.Semigroup (Property undometatypes) + ) + => Sem.Semigroup (RevertableProperty setupmetatypes undometatypes) + where + RevertableProperty s1 u1 <> RevertableProperty s2 u2 = + RevertableProperty (s1 <> s2) (u2 <> u1) + instance ( Monoid (Property setupmetatypes) , Monoid (Property undometatypes) @@ -241,5 +257,4 @@ instance => Monoid (RevertableProperty setupmetatypes undometatypes) where mempty = RevertableProperty mempty mempty - mappend (RevertableProperty s1 u1) (RevertableProperty s2 u2) = - RevertableProperty (s1 <> s2) (u2 <> u1) + mappend = (<>) diff --git a/src/Propellor/Types/Chroot.hs b/src/Propellor/Types/Chroot.hs index b27203e5..b3751a9a 100644 --- a/src/Propellor/Types/Chroot.hs +++ b/src/Propellor/Types/Chroot.hs @@ -6,9 +6,10 @@ import Propellor.Types import Propellor.Types.Empty import Propellor.Types.Info -import Data.Monoid import qualified Data.Semigroup as Sem import qualified Data.Map as M +import Data.Monoid +import Prelude data ChrootInfo = ChrootInfo { _chroots :: M.Map FilePath Host diff --git a/src/Propellor/Types/Docker.hs b/src/Propellor/Types/Docker.hs index 79577591..72703b82 100644 --- a/src/Propellor/Types/Docker.hs +++ b/src/Propellor/Types/Docker.hs @@ -6,9 +6,10 @@ import Propellor.Types import Propellor.Types.Empty import Propellor.Types.Info -import Data.Monoid import qualified Data.Semigroup as Sem import qualified Data.Map as M +import Data.Monoid +import Prelude data DockerInfo = DockerInfo { _dockerRunParams :: [DockerRunParam] diff --git a/src/Propellor/Types/ResultCheck.hs b/src/Propellor/Types/ResultCheck.hs index f03c174f..8c161850 100644 --- a/src/Propellor/Types/ResultCheck.hs +++ b/src/Propellor/Types/ResultCheck.hs @@ -14,6 +14,7 @@ import Propellor.Exception import Utility.Monad import Data.Monoid +import Prelude -- | This is a `Property` but its `Result` is not accurate; in particular -- it may return `NoChange` despite having made a change. -- cgit v1.2.3