summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGeorge Wilson <george@wils.online>2018-04-01 01:23:52 +1000
committerJasper Van der Jeugt <jaspervdj@gmail.com>2018-04-26 19:34:35 +0200
commitc2c85171c6598b6e8a57fb0c314096339848ebc9 (patch)
tree02456293be36cbeaa0654e9c0013e4ed0d4c1849
parentd24532c82472c4d11947a0afe8941f930664b0ac (diff)
downloadstylish-haskell-c2c85171c6598b6e8a57fb0c314096339848ebc9.tar.gz
Support GHC 8.4.1 by adding instance Semigroup ImportPortion
-rw-r--r--lib/Language/Haskell/Stylish/Step/Imports.hs9
-rw-r--r--stylish-haskell.cabal1
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