From c2c85171c6598b6e8a57fb0c314096339848ebc9 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Sun, 1 Apr 2018 01:23:52 +1000 Subject: Support GHC 8.4.1 by adding instance Semigroup ImportPortion --- lib/Language/Haskell/Stylish/Step/Imports.hs | 9 ++++++--- stylish-haskell.cabal | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Language/Haskell/Stylish/Step/Imports.hs b/lib/Language/Haskell/Stylish/Step/Imports.hs index 927719c..fc035a2 100644 --- a/lib/Language/Haskell/Stylish/Step/Imports.hs +++ b/lib/Language/Haskell/Stylish/Step/Imports.hs @@ -22,9 +22,9 @@ import Data.Char (toLower) import Data.List (intercalate, sortBy) import qualified Data.Map as M import Data.Maybe (isJust, maybeToList) -import Data.Monoid ((<>)) import Data.Ord (comparing) import qualified Data.Set as S +import Data.Semigroup (Semigroup ((<>))) import qualified Language.Haskell.Exts as H @@ -168,10 +168,13 @@ data ImportPortion l = ImportSome [H.CName l] -- ^ @A(x, y, z)@ | ImportAll -- ^ @A(..)@ +instance Ord l => Semigroup (ImportPortion l) where + ImportSome a <> ImportSome b = ImportSome (setUnion a b) + _ <> _ = ImportAll + instance Ord l => Monoid (ImportPortion l) where mempty = ImportSome [] - mappend (ImportSome a) (ImportSome b) = ImportSome (setUnion a b) - mappend _ _ = ImportAll + mappend = (<>) -- | O(n log n) union. setUnion :: Ord a => [a] -> [a] -> [a] diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal index ce86c21..f839c36 100644 --- a/stylish-haskell.cabal +++ b/stylish-haskell.cabal @@ -57,6 +57,7 @@ Library file-embed >= 0.0.10 && < 0.1, haskell-src-exts >= 1.18 && < 1.21, mtl >= 2.0 && < 2.3, + semigroups >= 0.18 && < 0.19, syb >= 0.3 && < 0.8, yaml >= 0.7 && < 0.9 -- cgit v1.2.3