From 14fe4c4d6b5a29be94ecfc0572e0f9a9a081e795 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Apr 2018 09:03:46 -0400 Subject: fix broken SemigroupMonoid transition <> Turns out that with ghc 8.2.2, the instructions given on the page don't work. And the cppless variant that I had compiles, but into effectively mappend = mappend so it loops. The only way I can see to make it work without cpp is to use mappend = (Sem.<>) which is ugly and a land mine waiting to explode if someone changes it to a nicer mappend = (<>) with a newer version of ghc which will compile it and work ok, while breaking it with 8.2.2. Sigh. I posted to haskell-cafe about this. --- src/Propellor/Property/Ccache.hs | 2 +- src/Propellor/Property/Debootstrap.hs | 2 +- src/Propellor/Property/DiskImage/PartSpec.hs | 2 +- src/Propellor/Property/Firewall.hs | 2 +- src/Propellor/Property/Installer/Target.hs | 2 +- src/Propellor/Property/Parted.hs | 2 +- src/Propellor/Property/Parted/Types.hs | 4 ++-- src/Propellor/Property/Ssh.hs | 4 ++-- src/Propellor/Types.hs | 12 +++++++----- src/Propellor/Types/Chroot.hs | 4 ++-- src/Propellor/Types/Core.hs | 2 +- src/Propellor/Types/Dns.hs | 2 +- src/Propellor/Types/Docker.hs | 2 +- src/Propellor/Types/Info.hs | 2 +- src/Propellor/Types/Result.hs | 2 +- 15 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Propellor/Property/Ccache.hs b/src/Propellor/Property/Ccache.hs index ebc21b88..ea729b7c 100644 --- a/src/Propellor/Property/Ccache.hs +++ b/src/Propellor/Property/Ccache.hs @@ -31,7 +31,7 @@ instance Sem.Semigroup Limit where instance Monoid Limit where mempty = NoLimit - mappend = (<>) + mappend = (Sem.<>) -- | A string that will be parsed to get a data size. -- diff --git a/src/Propellor/Property/Debootstrap.hs b/src/Propellor/Property/Debootstrap.hs index c6e5c373..923229be 100644 --- a/src/Propellor/Property/Debootstrap.hs +++ b/src/Propellor/Property/Debootstrap.hs @@ -41,7 +41,7 @@ instance Sem.Semigroup DebootstrapConfig where instance Monoid DebootstrapConfig where mempty = DefaultConfig - mappend = (<>) + mappend = (Sem.<>) toParams :: DebootstrapConfig -> [CommandParam] toParams DefaultConfig = [] diff --git a/src/Propellor/Property/DiskImage/PartSpec.hs b/src/Propellor/Property/DiskImage/PartSpec.hs index 0698d806..652b53c8 100644 --- a/src/Propellor/Property/DiskImage/PartSpec.hs +++ b/src/Propellor/Property/DiskImage/PartSpec.hs @@ -189,7 +189,7 @@ instance Sem.Semigroup PartLocation where instance Monoid PartLocation where mempty = Middle - mappend = (<>) + mappend = (Sem.<>) partLocation :: PartSpec PartLocation -> PartLocation -> PartSpec PartLocation partLocation (mp, o, p, _) l = (mp, o, p, l) diff --git a/src/Propellor/Property/Firewall.hs b/src/Propellor/Property/Firewall.hs index ff7ffebf..7b62558d 100644 --- a/src/Propellor/Property/Firewall.hs +++ b/src/Propellor/Property/Firewall.hs @@ -205,4 +205,4 @@ instance Sem.Semigroup Rules where instance Monoid Rules where mempty = Everything - mappend = (<>) + mappend = (Sem.<>) diff --git a/src/Propellor/Property/Installer/Target.hs b/src/Propellor/Property/Installer/Target.hs index 54e9075e..8c865143 100644 --- a/src/Propellor/Property/Installer/Target.hs +++ b/src/Propellor/Property/Installer/Target.hs @@ -444,7 +444,7 @@ instance Sem.Semigroup TargetFilled where instance Monoid TargetFilled where mempty = TargetFilled (0 % 1) - mappend = (<>) + mappend = (Sem.<>) newtype TargetFilledHandle = TargetFilledHandle Integer diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs index 39ee1723..e11acf57 100644 --- a/src/Propellor/Property/Parted.hs +++ b/src/Propellor/Property/Parted.hs @@ -193,7 +193,7 @@ instance Sem.Semigroup DiskPart where instance Monoid DiskPart where mempty = FixedDiskPart - mappend = (<>) + mappend = (Sem.<>) -- | Make a partition use some percentage of the size of the disk -- (less all fixed size partitions), or the remaining space in the disk. diff --git a/src/Propellor/Property/Parted/Types.hs b/src/Propellor/Property/Parted/Types.hs index 5891cc16..11e0947c 100644 --- a/src/Propellor/Property/Parted/Types.hs +++ b/src/Propellor/Property/Parted/Types.hs @@ -31,7 +31,7 @@ instance Sem.Semigroup PartTable where instance Monoid PartTable where -- | default TableType is MSDOS, with a `safeAlignment`. mempty = PartTable MSDOS safeAlignment [] - mappend = (<>) + mappend = (Sem.<>) -- | A partition on the disk. data Partition = Partition @@ -93,7 +93,7 @@ instance Sem.Semigroup PartSize where instance Monoid PartSize where mempty = MegaBytes 0 - mappend = (<>) + mappend = (Sem.<>) reducePartSize :: PartSize -> PartSize -> PartSize reducePartSize (MegaBytes a) (MegaBytes b) = MegaBytes (a - b) diff --git a/src/Propellor/Property/Ssh.hs b/src/Propellor/Property/Ssh.hs index 05098983..c23a121b 100644 --- a/src/Propellor/Property/Ssh.hs +++ b/src/Propellor/Property/Ssh.hs @@ -238,7 +238,7 @@ instance Sem.Semigroup HostKeyInfo where instance Monoid HostKeyInfo where mempty = HostKeyInfo M.empty - mappend = (<>) + mappend = (Sem.<>) userPubKeys :: User -> [(SshKeyType, PubKeyText)] -> Property (HasInfo + UnixLike) userPubKeys u@(User n) l = pureInfoProperty ("ssh pubkey for " ++ n) $ @@ -260,7 +260,7 @@ instance Sem.Semigroup UserKeyInfo where instance Monoid UserKeyInfo where mempty = UserKeyInfo M.empty - mappend = (<>) + mappend = (Sem.<>) -- | Sets up a user with the specified public keys, and the corresponding -- private keys from the privdata. diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index 4b4378a9..7cbe9f13 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -235,7 +235,7 @@ instance SingI metatypes => Monoid (Property (MetaTypes metatypes)) where -- | A property that does nothing. mempty = Property sing "noop property" Nothing mempty mempty - mappend = (<>) + mappend = (Sem.<>) -- | Any type of RevertableProperty is a Semigroup. When revertable -- properties x and y are appended together, the resulting revertable @@ -253,10 +253,12 @@ instance RevertableProperty (s1 <> s2) (u2 <> u1) instance - ( Monoid (Property setupmetatypes) - , Monoid (Property undometatypes) + ( Monoid (Property (MetaTypes setupmetatypes)) + , Monoid (Property (MetaTypes undometatypes)) + , SingI setupmetatypes + , SingI undometatypes ) - => Monoid (RevertableProperty setupmetatypes undometatypes) + => Monoid (RevertableProperty (MetaTypes setupmetatypes) (MetaTypes undometatypes)) where mempty = RevertableProperty mempty mempty - mappend = (<>) + mappend = (Sem.<>) diff --git a/src/Propellor/Types/Chroot.hs b/src/Propellor/Types/Chroot.hs index b3751a9a..33742c86 100644 --- a/src/Propellor/Types/Chroot.hs +++ b/src/Propellor/Types/Chroot.hs @@ -28,7 +28,7 @@ instance Sem.Semigroup ChrootInfo where instance Monoid ChrootInfo where mempty = ChrootInfo mempty mempty - mappend = (<>) + mappend = (Sem.<>) instance Empty ChrootInfo where isEmpty i = and @@ -49,7 +49,7 @@ instance Sem.Semigroup ChrootCfg where instance Monoid ChrootCfg where mempty = NoChrootCfg - mappend = (<>) + mappend = (Sem.<>) instance Empty ChrootCfg where isEmpty c= c == NoChrootCfg diff --git a/src/Propellor/Types/Core.hs b/src/Propellor/Types/Core.hs index cd3e09c5..88c749b3 100644 --- a/src/Propellor/Types/Core.hs +++ b/src/Propellor/Types/Core.hs @@ -62,7 +62,7 @@ instance Sem.Semigroup (Propellor Result) where instance Monoid (Propellor Result) where mempty = return NoChange - mappend = (<>) + mappend = (Sem.<>) -- | An action that Propellor runs at the end, after trying to satisfy all -- properties. It's passed the combined Result of the entire Propellor run. diff --git a/src/Propellor/Types/Dns.hs b/src/Propellor/Types/Dns.hs index 21a4860c..30302a7d 100644 --- a/src/Propellor/Types/Dns.hs +++ b/src/Propellor/Types/Dns.hs @@ -194,7 +194,7 @@ instance Sem.Semigroup NamedConfMap where instance Monoid NamedConfMap where mempty = NamedConfMap M.empty - mappend = (<>) + mappend = (Sem.<>) instance Empty NamedConfMap where isEmpty (NamedConfMap m) = isEmpty m diff --git a/src/Propellor/Types/Docker.hs b/src/Propellor/Types/Docker.hs index 72703b82..2cd72af2 100644 --- a/src/Propellor/Types/Docker.hs +++ b/src/Propellor/Types/Docker.hs @@ -28,7 +28,7 @@ instance Sem.Semigroup DockerInfo where instance Monoid DockerInfo where mempty = DockerInfo mempty mempty - mappend = (<>) + mappend = (Sem.<>) instance Empty DockerInfo where isEmpty i = and diff --git a/src/Propellor/Types/Info.hs b/src/Propellor/Types/Info.hs index 2ab6da7b..b941cc8f 100644 --- a/src/Propellor/Types/Info.hs +++ b/src/Propellor/Types/Info.hs @@ -87,7 +87,7 @@ instance Sem.Semigroup (InfoVal v) where instance Monoid (InfoVal v) where mempty = NoInfoVal - mappend = (<>) + mappend = (Sem.<>) instance (Typeable v, Show v) => IsInfo (InfoVal v) where propagateInfo _ = PropagateInfo False diff --git a/src/Propellor/Types/Result.hs b/src/Propellor/Types/Result.hs index f552b29b..cc03edd8 100644 --- a/src/Propellor/Types/Result.hs +++ b/src/Propellor/Types/Result.hs @@ -18,7 +18,7 @@ instance Sem.Semigroup Result where instance Monoid Result where mempty = NoChange - mappend = (<>) + mappend = (Sem.<>) class ToResult t where toResult :: t -> Result -- cgit v1.2.3