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/Parted.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/Parted.hs')
| -rw-r--r-- | src/Propellor/Property/Parted.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs index 81b84972..39ee1723 100644 --- a/src/Propellor/Property/Parted.hs +++ b/src/Propellor/Property/Parted.hs @@ -42,6 +42,7 @@ import Propellor.Types.PartSpec (PartSpec) import Utility.DataUnits import System.Posix.Files +import qualified Data.Semigroup as Sem import Data.List (genericLength) data Eep = YesReallyDeleteDiskContents @@ -178,16 +179,21 @@ data DiskPart = FixedDiskPart | DynamicDiskPart DiskSpaceUse data DiskSpaceUse = Percent Int | RemainingSpace +instance Sem.Semigroup DiskPart where + FixedDiskPart <> FixedDiskPart = FixedDiskPart + DynamicDiskPart (Percent a) <> DynamicDiskPart (Percent b) = + DynamicDiskPart (Percent (a + b)) + DynamicDiskPart RemainingSpace <> DynamicDiskPart RemainingSpace = + DynamicDiskPart RemainingSpace + DynamicDiskPart (Percent a) <> _ = DynamicDiskPart (Percent a) + _ <> DynamicDiskPart (Percent b) = DynamicDiskPart (Percent b) + DynamicDiskPart RemainingSpace <> _ = DynamicDiskPart RemainingSpace + _ <> DynamicDiskPart RemainingSpace = DynamicDiskPart RemainingSpace + instance Monoid DiskPart where mempty = FixedDiskPart - mappend FixedDiskPart FixedDiskPart = FixedDiskPart - mappend (DynamicDiskPart (Percent a)) (DynamicDiskPart (Percent b)) = DynamicDiskPart (Percent (a + b)) - mappend (DynamicDiskPart RemainingSpace) (DynamicDiskPart RemainingSpace) = DynamicDiskPart RemainingSpace - mappend (DynamicDiskPart (Percent a)) _ = DynamicDiskPart (Percent a) - mappend _ (DynamicDiskPart (Percent b)) = DynamicDiskPart (Percent b) - mappend (DynamicDiskPart RemainingSpace) _ = DynamicDiskPart RemainingSpace - mappend _ (DynamicDiskPart RemainingSpace) = DynamicDiskPart RemainingSpace + mappend = (<>) -- | Make a partition use some percentage of the size of the disk -- (less all fixed size partitions), or the remaining space in the disk. |
