Skip to content

Commit ee7d5da

Browse files
authored
Merge pull request #12007 from haskell/monr1
Remove Distribution.Compat.Semigroup, derive via Generically instead
2 parents eab682c + 0db9dc8 commit ee7d5da

33 files changed

Lines changed: 80 additions & 323 deletions

File tree

Cabal-syntax/Cabal-syntax.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ library
7575
Distribution.Compat.NonEmptySet
7676
Distribution.Compat.Parsing
7777
Distribution.Compat.Prelude
78-
Distribution.Compat.Semigroup
7978
Distribution.Compiler
8079
Distribution.FieldGrammar
8180
Distribution.FieldGrammar.Class

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ module Distribution.Compat.Prelude
1616

1717
-- * Common type-classes
1818
, Semigroup (..)
19-
, gmappend
20-
, gmempty
2119
, Typeable
2220
, TypeRep
2321
, typeRep
2422
, Data
2523
, Generic
24+
, Generically (..)
2625
, NFData (..)
2726
, Binary (..)
2827
, Structured
@@ -232,8 +231,7 @@ import Data.Typeable (TypeRep, Typeable, typeRep)
232231
import Data.Void (Void, absurd, vacuous)
233232
import Data.Word (Word, Word16, Word32, Word64, Word8)
234233
import Distribution.Compat.Binary (Binary (..))
235-
import Distribution.Compat.Semigroup (gmappend, gmempty)
236-
import GHC.Generics (Generic)
234+
import GHC.Generics (Generic, Generically (..))
237235
import System.Exit (ExitCode (..), exitFailure, exitSuccess, exitWith)
238236
import Text.Read (readMaybe)
239237

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

Lines changed: 0 additions & 57 deletions
This file was deleted.

Cabal/Cabal.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ library
204204
Distribution.Compat.NonEmptySet,
205205
Distribution.Compat.Parsing,
206206
Distribution.Compat.Prelude,
207-
Distribution.Compat.Semigroup,
208207
Distribution.Compiler,
209208
Distribution.FieldGrammar,
210209
Distribution.FieldGrammar.Class,

Cabal/src/Distribution/Simple/GHC.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
{-# LANGUAGE RankNTypes #-}
88
{-# LANGUAGE ScopedTypeVariables #-}
99

10-
-----------------------------------------------------------------------------
11-
1210
-- |
1311
-- Module : Distribution.Simple.GHC
1412
-- Copyright : Isaac Jones 2003-2007

Cabal/src/Distribution/Simple/Haddock.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE DerivingVia #-}
34
{-# LANGUAGE DuplicateRecordFields #-}
45
{-# LANGUAGE FlexibleContexts #-}
56
{-# LANGUAGE LambdaCase #-}
@@ -156,6 +157,7 @@ data HaddockArgs = HaddockArgs
156157
-- ^ haddock's `--use-unicode` flag
157158
}
158159
deriving (Generic)
160+
deriving (Semigroup, Monoid) via Generically HaddockArgs
159161

160162
-- | The FilePath of a directory, it's a monoid under '(</>)'.
161163
newtype Directory = Dir {unDir' :: FilePath} deriving (Read, Show, Eq, Ord)
@@ -1638,12 +1640,6 @@ haddockToHscolour flags =
16381640

16391641
-- ------------------------------------------------------------------------------
16401642
-- Boilerplate Monoid instance.
1641-
instance Monoid HaddockArgs where
1642-
mempty = gmempty
1643-
1644-
instance Semigroup HaddockArgs where
1645-
(<>) = gmappend
1646-
16471643
instance Monoid Directory where
16481644
mempty = Dir "."
16491645

Cabal/src/Distribution/Simple/InstallDirs.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE CPP #-}
33
{-# LANGUAGE DeriveFunctor #-}
44
{-# LANGUAGE DeriveGeneric #-}
5+
{-# LANGUAGE DerivingVia #-}
56
{-# LANGUAGE FlexibleContexts #-}
67
{-# LANGUAGE OverloadedStrings #-}
78
{-# LANGUAGE RankNTypes #-}
@@ -109,17 +110,12 @@ data InstallDirs dir = InstallDirs
109110
, sysconfdir :: dir
110111
}
111112
deriving (Eq, Read, Show, Functor, Generic)
113+
deriving (Semigroup, Monoid) via Generically (InstallDirs dir)
112114

113115
instance Binary dir => Binary (InstallDirs dir)
114116
instance NFData dir => NFData (InstallDirs dir)
115117
instance Structured dir => Structured (InstallDirs dir)
116118

117-
instance Monoid dir => Monoid (InstallDirs dir) where
118-
mempty = gmempty
119-
120-
instance Semigroup dir => Semigroup (InstallDirs dir) where
121-
(<>) = gmappend
122-
123119
combineInstallDirs
124120
:: (a -> b -> c)
125121
-> InstallDirs a

Cabal/src/Distribution/Simple/Program/GHC.hs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE DerivingVia #-}
34
{-# LANGUAGE FlexibleContexts #-}
45
{-# LANGUAGE LambdaCase #-}
56
{-# LANGUAGE MultiWayIf #-}
@@ -608,6 +609,7 @@ data GhcOptions = GhcOptions
608609
-- Modifies some of the GHC error messages.
609610
}
610611
deriving (Show, Generic)
612+
deriving (Semigroup, Monoid) via Generically GhcOptions
611613

612614
data GhcMode
613615
= -- | @ghc -c@
@@ -1049,12 +1051,3 @@ splitRTSArgs args =
10491051
then addRTSArg arg $ go isRTSArg rest
10501052
else addNonRTSArg arg $ go isRTSArg rest
10511053
in go False args
1052-
1053-
-- -----------------------------------------------------------------------------
1054-
-- Boilerplate Monoid instance for GhcOptions
1055-
1056-
instance Monoid GhcOptions where
1057-
mempty = gmempty
1058-
1059-
instance Semigroup GhcOptions where
1060-
(<>) = gmappend

Cabal/src/Distribution/Simple/Setup/Benchmark.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE DerivingVia #-}
34
{-# LANGUAGE FlexibleContexts #-}
45
{-# LANGUAGE PatternSynonyms #-}
56
{-# LANGUAGE RankNTypes #-}
@@ -53,6 +54,7 @@ data BenchmarkFlags = BenchmarkFlags
5354
, benchmarkOptions :: [PathTemplate]
5455
}
5556
deriving (Show, Generic)
57+
deriving (Semigroup, Monoid) via Generically BenchmarkFlags
5658

5759
pattern BenchmarkCommonFlags
5860
:: Flag VerbosityFlags
@@ -148,9 +150,3 @@ benchmarkOptions' showOrParseArgs =
148150

149151
emptyBenchmarkFlags :: BenchmarkFlags
150152
emptyBenchmarkFlags = mempty
151-
152-
instance Monoid BenchmarkFlags where
153-
mempty = gmempty
154-
155-
instance Semigroup BenchmarkFlags where
156-
(<>) = gmappend

Cabal/src/Distribution/Simple/Setup/Build.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE DerivingVia #-}
34
{-# LANGUAGE FlexibleContexts #-}
45
{-# LANGUAGE PatternSynonyms #-}
56
{-# LANGUAGE RankNTypes #-}
@@ -59,6 +60,7 @@ data BuildFlags = BuildFlags
5960
, buildUseSemaphore :: Flag String
6061
}
6162
deriving (Read, Show, Generic)
63+
deriving (Semigroup, Monoid) via Generically BuildFlags
6264

6365
pattern BuildCommonFlags
6466
:: Flag VerbosityFlags
@@ -175,9 +177,3 @@ buildOptions progDb showOrParseArgs =
175177

176178
emptyBuildFlags :: BuildFlags
177179
emptyBuildFlags = mempty
178-
179-
instance Monoid BuildFlags where
180-
mempty = gmempty
181-
182-
instance Semigroup BuildFlags where
183-
(<>) = gmappend

0 commit comments

Comments
 (0)