From 9228bda32f0a3f6d52e7cc5eb444376e7b024d8c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 23 Apr 2018 13:20:13 -0400 Subject: semigroup monoid change fallout; drop ghc 7 support Fix build with ghc 8.4, which broke due to the Semigroup Monoid change. See https://prime.haskell.org/wiki/Libraries/Proposals/SemigroupMonoid Dropped support for building propellor with ghc 7 (as in debian oldstable), to avoid needing to depend on the semigroups transitional package, but also because it's just too old to be worth supporting. If we indeed drop ghc 7 support entirely, some code to support "jessie" can be removed; concurrent-output can be de-embedded, and the Singletons code can be simplified. This commit was sponsored by Jack Hill on Patreon. --- src/Propellor/Property/Ssh.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/Propellor/Property/Ssh.hs') diff --git a/src/Propellor/Property/Ssh.hs b/src/Propellor/Property/Ssh.hs index fd89f97a..05098983 100644 --- a/src/Propellor/Property/Ssh.hs +++ b/src/Propellor/Property/Ssh.hs @@ -45,6 +45,7 @@ import Utility.FileMode import System.PosixCompat import qualified Data.Map as M import qualified Data.Set as S +import qualified Data.Semigroup as Sem import Data.List installed :: Property UnixLike @@ -229,13 +230,16 @@ newtype HostKeyInfo = HostKeyInfo instance IsInfo HostKeyInfo where propagateInfo _ = PropagateInfo False -instance Monoid HostKeyInfo where - mempty = HostKeyInfo M.empty - mappend (HostKeyInfo old) (HostKeyInfo new) = +instance Sem.Semigroup HostKeyInfo where + HostKeyInfo old <> HostKeyInfo new = -- new first because union prefers values from the first -- parameter when there is a duplicate key HostKeyInfo (new `M.union` old) +instance Monoid HostKeyInfo where + mempty = HostKeyInfo M.empty + mappend = (<>) + userPubKeys :: User -> [(SshKeyType, PubKeyText)] -> Property (HasInfo + UnixLike) userPubKeys u@(User n) l = pureInfoProperty ("ssh pubkey for " ++ n) $ UserKeyInfo (M.singleton u (S.fromList l)) @@ -250,10 +254,13 @@ newtype UserKeyInfo = UserKeyInfo instance IsInfo UserKeyInfo where propagateInfo _ = PropagateInfo False +instance Sem.Semigroup UserKeyInfo where + UserKeyInfo old <> UserKeyInfo new = + UserKeyInfo (M.unionWith S.union old new) + instance Monoid UserKeyInfo where mempty = UserKeyInfo M.empty - mappend (UserKeyInfo old) (UserKeyInfo new) = - UserKeyInfo (M.unionWith S.union old new) + mappend = (<>) -- | Sets up a user with the specified public keys, and the corresponding -- private keys from the privdata. -- cgit v1.3-2-g0d8e