diff options
| author | Joey Hess <joeyh@joeyh.name> | 2018-04-23 13:20:13 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2018-04-23 13:20:13 -0400 |
| commit | 9228bda32f0a3f6d52e7cc5eb444376e7b024d8c (patch) | |
| tree | e3ada017b0f625db8b39a2212ab82c8e32a62b7c /src/Propellor/Property/Ssh.hs | |
| parent | 5ecbec11127449fefe4812fd6b374801ce8499c1 (diff) | |
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.
Diffstat (limited to 'src/Propellor/Property/Ssh.hs')
| -rw-r--r-- | src/Propellor/Property/Ssh.hs | 17 |
1 files changed, 12 insertions, 5 deletions
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. |
