Skip to content

Commit 30ae160

Browse files
committed
Remove redundant constraints
add -Wredundant-constraints ghc flag fix compiler warnings
1 parent e7aaad8 commit 30ae160

26 files changed

Lines changed: 41 additions & 53 deletions

File tree

Cabal-syntax/Cabal-syntax.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ library
5454
-Wno-unticked-promoted-constructors
5555
-Wcompat
5656
-Wnoncanonical-monad-instances
57+
-Wredundant-constraints
5758

5859
if impl(ghc >= 8.0) && impl(ghc < 8.8)
5960
ghc-options: -Wnoncanonical-monadfail-instances

Cabal-syntax/src/Distribution/Compat/Semigroup.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ gmempty = to gmempty'
4747
class GSemigroup f => GMonoid f where
4848
gmempty' :: f p
4949

50-
instance (Semigroup a, Monoid a) => GMonoid (K1 i a) where
50+
instance Monoid a => GMonoid (K1 i a) where
5151
gmempty' = K1 mempty
5252

5353
instance GMonoid f => GMonoid (M1 i c f) where

Cabal-syntax/src/Distribution/Compiler.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ instance Semigroup a => Semigroup (PerCompilerFlavor a) where
162162
(a <> a')
163163
(b <> b')
164164

165-
instance (Semigroup a, Monoid a) => Monoid (PerCompilerFlavor a) where
165+
instance Monoid a => Monoid (PerCompilerFlavor a) where
166166
mempty = PerCompilerFlavor mempty mempty
167167
mappend = (<>)
168168

Cabal-syntax/src/Distribution/FieldGrammar/Class.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ optionalField fn l = optionalFieldAla fn Identity l
209209

210210
-- | Optional field with default value.
211211
optionalFieldDef
212-
:: (FieldGrammar c g, Functor (g s), c (Identity a), Eq a)
212+
:: (FieldGrammar c g, c (Identity a), Eq a)
213213
=> FieldName
214214
-- ^ field name
215215
-> ALens' s a

Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,8 @@ libraryFieldGrammar
177177
, c (List CommaVCat (Identity ModuleReexport) ModuleReexport)
178178
, c (List FSep (MQuoted Extension) Extension)
179179
, c (List FSep (MQuoted Language) Language)
180-
, c (List FSep Token String)
181180
, c (List NoCommaFSep Token' String)
182181
, c (List VCat (MQuoted ModuleName) ModuleName)
183-
, c (List VCat (RelativePathNT Pkg File) (RelativePath Pkg File))
184182
, c (List FSep (SymbolicPathNT Pkg (Dir Framework)) (SymbolicPath Pkg (Dir Framework)))
185183
, c (List FSep (SymbolicPathNT Pkg (Dir Lib)) (SymbolicPath Pkg (Dir Lib)))
186184
, c (List FSep (SymbolicPathNT Pkg (Dir Source)) (SymbolicPath Pkg (Dir Source)))
@@ -233,7 +231,6 @@ foreignLibFieldGrammar
233231
, c (List FSep (Identity ForeignLibOption) ForeignLibOption)
234232
, c (List FSep (MQuoted Extension) Extension)
235233
, c (List FSep (MQuoted Language) Language)
236-
, c (List FSep Token String)
237234
, c (List FSep (SymbolicPathNT Pkg (Dir Framework)) (SymbolicPath Pkg (Dir Framework)))
238235
, c (List FSep (SymbolicPathNT Pkg (Dir Lib)) (SymbolicPath Pkg (Dir Lib)))
239236
, c (List FSep (SymbolicPathNT Pkg (Dir Source)) (SymbolicPath Pkg (Dir Source)))
@@ -277,7 +274,6 @@ executableFieldGrammar
277274
, c (List CommaVCat (Identity Mixin) Mixin)
278275
, c (List FSep (MQuoted Extension) Extension)
279276
, c (List FSep (MQuoted Language) Language)
280-
, c (List FSep Token String)
281277
, c (List FSep (SymbolicPathNT Pkg (Dir Framework)) (SymbolicPath Pkg (Dir Framework)))
282278
, c (List FSep (SymbolicPathNT Pkg (Dir Lib)) (SymbolicPath Pkg (Dir Lib)))
283279
, c (List FSep (SymbolicPathNT Pkg (Dir Source)) (SymbolicPath Pkg (Dir Source)))
@@ -355,7 +351,6 @@ testSuiteFieldGrammar
355351
, c (List CommaVCat (Identity Mixin) Mixin)
356352
, c (List FSep (MQuoted Extension) Extension)
357353
, c (List FSep (MQuoted Language) Language)
358-
, c (List FSep Token String)
359354
, c (List NoCommaFSep Token' String)
360355
, c (List VCat (MQuoted ModuleName) ModuleName)
361356
, c (List FSep (SymbolicPathNT Pkg (Dir Framework)) (SymbolicPath Pkg (Dir Framework)))
@@ -504,7 +499,6 @@ benchmarkFieldGrammar
504499
, c (List CommaVCat (Identity Mixin) Mixin)
505500
, c (List FSep (MQuoted Extension) Extension)
506501
, c (List FSep (MQuoted Language) Language)
507-
, c (List FSep Token String)
508502
, c (List NoCommaFSep Token' String)
509503
, c (List VCat (MQuoted ModuleName) ModuleName)
510504
, c (List FSep (SymbolicPathNT Pkg (Dir Framework)) (SymbolicPath Pkg (Dir Framework)))
@@ -611,7 +605,6 @@ buildInfoFieldGrammar
611605
, c (List CommaVCat (Identity Mixin) Mixin)
612606
, c (List FSep (MQuoted Extension) Extension)
613607
, c (List FSep (MQuoted Language) Language)
614-
, c (List FSep Token String)
615608
, c (List NoCommaFSep Token' String)
616609
, c (List VCat (MQuoted ModuleName) ModuleName)
617610
, c (List FSep (SymbolicPathNT Pkg (Dir Framework)) (SymbolicPath Pkg (Dir Framework)))
@@ -812,7 +805,7 @@ flagFieldGrammar name =
812805
-------------------------------------------------------------------------------
813806

814807
sourceRepoFieldGrammar
815-
:: (FieldGrammar c g, Applicative (g SourceRepo), c (Identity RepoType), c Token, c FilePathNT)
808+
:: (FieldGrammar c g, Applicative (g SourceRepo), c (Identity RepoType))
816809
=> RepoKind
817810
-> g SourceRepo SourceRepo
818811
sourceRepoFieldGrammar kind =

Cabal-syntax/src/Distribution/Types/CondTree.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ instance (NFData v, NFData a) => NFData (CondTree v a) where rnf = genericRnf
6666
instance Semigroup a => Semigroup (CondTree v a) where
6767
(CondNode a bs) <> (CondNode a' bs') = CondNode (a <> a') (bs <> bs')
6868

69-
instance (Semigroup a, Monoid a) => Monoid (CondTree v a) where
69+
instance Monoid a => Monoid (CondTree v a) where
7070
mappend = (<>)
7171
mempty = CondNode mempty mempty
7272

Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ versionRangeParser digitParser csv = expr
503503
, prettyShow (foldr1 unionVersionRanges (fmap op vs))
504504
]
505505

506-
verSet :: CabalParsing m => m (NonEmpty Version)
506+
verSet :: m (NonEmpty Version)
507507
verSet = do
508508
_ <- P.char '{'
509509
P.spaces
@@ -512,22 +512,22 @@ versionRangeParser digitParser csv = expr
512512
pure vs
513513

514514
-- a plain version without tags or wildcards
515-
verPlain :: CabalParsing m => m Version
515+
verPlain :: m Version
516516
verPlain = mkVersion . toList <$> P.sepByNonEmpty digitParser (P.char '.')
517517

518518
-- either wildcard or normal version
519-
verOrWild :: CabalParsing m => m (Bool, Version)
519+
verOrWild :: m (Bool, Version)
520520
verOrWild = do
521521
x <- digitParser
522522
verLoop (DList.singleton x)
523523

524524
-- trailing: wildcard (.y.*) or normal version (optional tags) (.y.z-tag)
525-
verLoop :: CabalParsing m => DList.DList Int -> m (Bool, Version)
525+
verLoop :: DList.DList Int -> m (Bool, Version)
526526
verLoop acc =
527527
verLoop' acc
528528
<|> (tags *> pure (False, mkVersion (DList.toList acc)))
529529

530-
verLoop' :: CabalParsing m => DList.DList Int -> m (Bool, Version)
530+
verLoop' :: DList.DList Int -> m (Bool, Version)
531531
verLoop' acc = do
532532
_ <- P.char '.'
533533
let digit = digitParser >>= verLoop . DList.snoc acc
@@ -542,7 +542,7 @@ versionRangeParser digitParser csv = expr
542542
P.spaces
543543
return a
544544

545-
tags :: CabalParsing m => m ()
545+
tags :: m ()
546546
tags = do
547547
ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum)
548548
case ts of

Cabal-syntax/src/Distribution/Utils/Structured.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ structureBuilder s0 = State.evalState (go s0) Map.empty
227227
-- @since 3.2.0.0
228228
class Typeable a => Structured a where
229229
structure :: Proxy a -> Structure
230-
default structure :: (Generic a, GStructured (Rep a)) => Proxy a -> Structure
230+
default structure :: GStructured (Rep a) => Proxy a -> Structure
231231
structure = genericStructure
232232

233233
-- This member is hidden. It's there to precalc
@@ -332,7 +332,7 @@ containerStructure _ =
332332
-------------------------------------------------------------------------------
333333

334334
-- | Derive 'structure' generically.
335-
genericStructure :: forall a. (Typeable a, Generic a, GStructured (Rep a)) => Proxy a -> Structure
335+
genericStructure :: forall a. (Typeable a, GStructured (Rep a)) => Proxy a -> Structure
336336
genericStructure _ = gstructured (typeRep (Proxy :: Proxy a)) (Proxy :: Proxy (Rep a)) 0
337337

338338
-- | Used to implement 'genericStructure'.

Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import qualified Distribution.Compat.NonEmptySet as NES
4040
-- instances
4141
-------------------------------------------------------------------------------
4242

43-
instance (Eq a, Show a) => ToExpr (Condition a) where toExpr = defaultExprViaShow
43+
instance (Show a) => ToExpr (Condition a) where toExpr = defaultExprViaShow
4444
instance (Show a, ToExpr c, Show c, Eq a, Eq c) => ToExpr (CondTree a c)
4545
instance (Show a, ToExpr c, Show c, Eq a, Eq c) => ToExpr (CondBranch a c)
4646
instance (ToExpr a) => ToExpr (NubList a)

Cabal/Cabal.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ library
7070
-Wincomplete-uni-patterns
7171
-Wincomplete-record-updates
7272
-Wno-unticked-promoted-constructors
73+
-Wredundant-constraints
7374

7475
if impl(ghc >= 8.0)
7576
ghc-options: -Wcompat -Wnoncanonical-monad-instances

0 commit comments

Comments
 (0)