Skip to content

Commit c2c8517

Browse files
gwilsjaspervdj
authored andcommitted
Support GHC 8.4.1 by adding instance Semigroup ImportPortion
1 parent d24532c commit c2c8517

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/Language/Haskell/Stylish/Step/Imports.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import Data.Char (toLower)
2222
import Data.List (intercalate, sortBy)
2323
import qualified Data.Map as M
2424
import Data.Maybe (isJust, maybeToList)
25-
import Data.Monoid ((<>))
2625
import Data.Ord (comparing)
2726
import qualified Data.Set as S
27+
import Data.Semigroup (Semigroup ((<>)))
2828
import qualified Language.Haskell.Exts as H
2929

3030

@@ -168,10 +168,13 @@ data ImportPortion l
168168
= ImportSome [H.CName l] -- ^ @A(x, y, z)@
169169
| ImportAll -- ^ @A(..)@
170170

171+
instance Ord l => Semigroup (ImportPortion l) where
172+
ImportSome a <> ImportSome b = ImportSome (setUnion a b)
173+
_ <> _ = ImportAll
174+
171175
instance Ord l => Monoid (ImportPortion l) where
172176
mempty = ImportSome []
173-
mappend (ImportSome a) (ImportSome b) = ImportSome (setUnion a b)
174-
mappend _ _ = ImportAll
177+
mappend = (<>)
175178

176179
-- | O(n log n) union.
177180
setUnion :: Ord a => [a] -> [a] -> [a]

stylish-haskell.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Library
5757
file-embed >= 0.0.10 && < 0.1,
5858
haskell-src-exts >= 1.18 && < 1.21,
5959
mtl >= 2.0 && < 2.3,
60+
semigroups >= 0.18 && < 0.19,
6061
syb >= 0.3 && < 0.8,
6162
yaml >= 0.7 && < 0.9
6263

0 commit comments

Comments
 (0)