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/Parted/Types.hs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/Propellor/Property/Parted/Types.hs') diff --git a/src/Propellor/Property/Parted/Types.hs b/src/Propellor/Property/Parted/Types.hs index cfd8760d..5891cc16 100644 --- a/src/Propellor/Property/Parted/Types.hs +++ b/src/Propellor/Property/Parted/Types.hs @@ -4,6 +4,9 @@ import qualified Propellor.Property.Partition as Partition import Utility.DataUnits import Data.Char +import qualified Data.Semigroup as Sem +import Data.Monoid +import Prelude class PartedVal a where pval :: a -> String @@ -19,14 +22,17 @@ instance PartedVal TableType where data PartTable = PartTable TableType Alignment [Partition] deriving (Show) -instance Monoid PartTable where - -- | default TableType is MSDOS, with a `safeAlignment`. - mempty = PartTable MSDOS safeAlignment [] +instance Sem.Semigroup PartTable where -- | uses the TableType of the second parameter -- and the larger alignment, - mappend (PartTable _l1 a1 ps1) (PartTable l2 a2 ps2) = + PartTable _l1 a1 ps1 <> PartTable l2 a2 ps2 = PartTable l2 (max a1 a2) (ps1 ++ ps2) +instance Monoid PartTable where + -- | default TableType is MSDOS, with a `safeAlignment`. + mempty = PartTable MSDOS safeAlignment [] + mappend = (<>) + -- | A partition on the disk. data Partition = Partition { partType :: PartType @@ -80,11 +86,14 @@ fromPartSize :: PartSize -> ByteSize fromPartSize (MegaBytes b) = b * 1000000 fromPartSize (Bytes n) = n +instance Sem.Semigroup PartSize where + MegaBytes a <> MegaBytes b = MegaBytes (a + b) + Bytes a <> b = Bytes (a + fromPartSize b) + a <> Bytes b = Bytes (b + fromPartSize a) + instance Monoid PartSize where mempty = MegaBytes 0 - mappend (MegaBytes a) (MegaBytes b) = MegaBytes (a + b) - mappend (Bytes a) b = Bytes (a + fromPartSize b) - mappend a (Bytes b) = Bytes (b + fromPartSize a) + mappend = (<>) reducePartSize :: PartSize -> PartSize -> PartSize reducePartSize (MegaBytes a) (MegaBytes b) = MegaBytes (a - b) -- cgit v1.2.3