diff --git a/Cabal/Distribution/PackageDescription.hs b/Cabal/Distribution/PackageDescription.hs index 3bd06b6bfbc..20cb29b1224 100644 --- a/Cabal/Distribution/PackageDescription.hs +++ b/Cabal/Distribution/PackageDescription.hs @@ -111,7 +111,7 @@ module Distribution.PackageDescription ( import Distribution.Compat.Binary import qualified Distribution.Compat.Semigroup as Semi ((<>)) -import Distribution.Compat.Semigroup as Semi (Monoid(..), Semigroup) +import Distribution.Compat.Semigroup as Semi (Monoid(..), Semigroup, gmempty, gmappend) import qualified Distribution.Compat.ReadP as Parse import Distribution.Compat.ReadP ((<++)) import Distribution.Package @@ -314,15 +314,12 @@ data SetupBuildInfo = SetupBuildInfo { instance Binary SetupBuildInfo -instance Monoid SetupBuildInfo where - mempty = SetupBuildInfo { - setupDepends = Semi.mempty - } +instance Semi.Monoid SetupBuildInfo where + mempty = gmempty mappend = (Semi.<>) instance Semigroup SetupBuildInfo where - a <> b = SetupBuildInfo { setupDepends = combine setupDepends } - where combine field = field a `mappend` field b + (<>) = gmappend -- --------------------------------------------------------------------------- -- Module renaming @@ -498,11 +495,7 @@ data Executable = Executable { instance Binary Executable instance Monoid Executable where - mempty = Executable { - exeName = mempty, - modulePath = mempty, - buildInfo = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup Executable where diff --git a/Cabal/Distribution/Simple/Haddock.hs b/Cabal/Distribution/Simple/Haddock.hs index e2398ec521b..ab06b052590 100644 --- a/Cabal/Distribution/Simple/Haddock.hs +++ b/Cabal/Distribution/Simple/Haddock.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE DeriveGeneric #-} + ----------------------------------------------------------------------------- -- | -- Module : Distribution.Simple.Haddock @@ -54,6 +56,7 @@ import Data.Char ( isSpace ) import Data.Either ( rights ) import Data.Foldable ( traverse_, foldl' ) import Data.Maybe ( fromMaybe, listToMaybe ) +import GHC.Generics ( Generic ) import System.Directory (doesFileExist) import System.FilePath ( (), (<.>) @@ -97,7 +100,7 @@ data HaddockArgs = HaddockArgs { -- ^ To find the correct GHC, required. argTargets :: [FilePath] -- ^ Modules to process. -} +} deriving Generic -- | The FilePath of a directory, it's a monoid under '()'. newtype Directory = Dir { unDir' :: FilePath } deriving (Read,Show,Eq,Ord) @@ -760,46 +763,11 @@ exeBuildDir lbi exe = buildDir lbi exeName exe exeName exe ++ "-tmp" -- ------------------------------------------------------------------------------ -- Boilerplate Monoid instance. instance Monoid HaddockArgs where - mempty = HaddockArgs { - argInterfaceFile = mempty, - argPackageName = mempty, - argHideModules = mempty, - argIgnoreExports = mempty, - argLinkSource = mempty, - argCssFile = mempty, - argContents = mempty, - argVerbose = mempty, - argOutput = mempty, - argInterfaces = mempty, - argOutputDir = mempty, - argTitle = mempty, - argPrologue = mempty, - argGhcOptions = mempty, - argGhcLibDir = mempty, - argTargets = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup HaddockArgs where - a <> b = HaddockArgs { - argInterfaceFile = mult argInterfaceFile, - argPackageName = mult argPackageName, - argHideModules = mult argHideModules, - argIgnoreExports = mult argIgnoreExports, - argLinkSource = mult argLinkSource, - argCssFile = mult argCssFile, - argContents = mult argContents, - argVerbose = mult argVerbose, - argOutput = mult argOutput, - argInterfaces = mult argInterfaces, - argOutputDir = mult argOutputDir, - argTitle = mult argTitle, - argPrologue = mult argPrologue, - argGhcOptions = mult argGhcOptions, - argGhcLibDir = mult argGhcLibDir, - argTargets = mult argTargets - } - where mult f = f a `mappend` f b + (<>) = gmappend instance Monoid Directory where mempty = Dir "." diff --git a/Cabal/Distribution/Simple/InstallDirs.hs b/Cabal/Distribution/Simple/InstallDirs.hs index c7cead3dcf9..76fb2e390da 100644 --- a/Cabal/Distribution/Simple/InstallDirs.hs +++ b/Cabal/Distribution/Simple/InstallDirs.hs @@ -113,22 +113,7 @@ instance Functor InstallDirs where } instance (Semigroup dir, Monoid dir) => Monoid (InstallDirs dir) where - mempty = InstallDirs { - prefix = mempty, - bindir = mempty, - libdir = mempty, - libsubdir = mempty, - dynlibdir = mempty, - libexecdir = mempty, - includedir = mempty, - datadir = mempty, - datasubdir = mempty, - docdir = mempty, - mandir = mempty, - htmldir = mempty, - haddockdir = mempty, - sysconfdir = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup dir => Semigroup (InstallDirs dir) where diff --git a/Cabal/Distribution/Simple/Program/GHC.hs b/Cabal/Distribution/Simple/Program/GHC.hs index a46c3c17e84..dcaac2688ef 100644 --- a/Cabal/Distribution/Simple/Program/GHC.hs +++ b/Cabal/Distribution/Simple/Program/GHC.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE DeriveGeneric #-} + module Distribution.Simple.Program.GHC ( GhcOptions(..), GhcMode(..), @@ -27,6 +29,7 @@ import Distribution.Verbosity import Distribution.Utils.NubList import Language.Haskell.Extension +import GHC.Generics (Generic) import qualified Data.Map as M -- | A structured set of GHC options/flags @@ -211,7 +214,7 @@ data GhcOptions = GhcOptions { -- Modifies some of the GHC error messages. ghcOptCabal :: Flag Bool -} deriving Show +} deriving (Show, Generic) data GhcMode = GhcModeCompile -- ^ @ghc -c@ @@ -496,116 +499,8 @@ packageDbArgs implInfo -- Boilerplate Monoid instance for GhcOptions instance Monoid GhcOptions where - mempty = GhcOptions { - ghcOptMode = mempty, - ghcOptExtra = mempty, - ghcOptExtraDefault = mempty, - ghcOptInputFiles = mempty, - ghcOptInputModules = mempty, - ghcOptOutputFile = mempty, - ghcOptOutputDynFile = mempty, - ghcOptSourcePathClear = mempty, - ghcOptSourcePath = mempty, - ghcOptThisUnitId = mempty, - ghcOptPackageDBs = mempty, - ghcOptPackages = mempty, - ghcOptHideAllPackages = mempty, - ghcOptNoAutoLinkPackages = mempty, - ghcOptLinkLibs = mempty, - ghcOptLinkLibPath = mempty, - ghcOptLinkOptions = mempty, - ghcOptLinkFrameworks = mempty, - ghcOptLinkFrameworkDirs = mempty, - ghcOptNoLink = mempty, - ghcOptLinkNoHsMain = mempty, - ghcOptCcOptions = mempty, - ghcOptCppOptions = mempty, - ghcOptCppIncludePath = mempty, - ghcOptCppIncludes = mempty, - ghcOptFfiIncludes = mempty, - ghcOptLanguage = mempty, - ghcOptExtensions = mempty, - ghcOptExtensionMap = mempty, - ghcOptOptimisation = mempty, - ghcOptDebugInfo = mempty, - ghcOptProfilingMode = mempty, - ghcOptProfilingAuto = mempty, - ghcOptSplitObjs = mempty, - ghcOptNumJobs = mempty, - ghcOptHPCDir = mempty, - ghcOptGHCiScripts = mempty, - ghcOptHiSuffix = mempty, - ghcOptObjSuffix = mempty, - ghcOptDynHiSuffix = mempty, - ghcOptDynObjSuffix = mempty, - ghcOptHiDir = mempty, - ghcOptObjDir = mempty, - ghcOptOutputDir = mempty, - ghcOptStubDir = mempty, - ghcOptDynLinkMode = mempty, - ghcOptShared = mempty, - ghcOptFPic = mempty, - ghcOptDylibName = mempty, - ghcOptRPaths = mempty, - ghcOptVerbosity = mempty, - ghcOptCabal = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup GhcOptions where - a <> b = GhcOptions { - ghcOptMode = combine ghcOptMode, - ghcOptExtra = combine ghcOptExtra, - ghcOptExtraDefault = combine ghcOptExtraDefault, - ghcOptInputFiles = combine ghcOptInputFiles, - ghcOptInputModules = combine ghcOptInputModules, - ghcOptOutputFile = combine ghcOptOutputFile, - ghcOptOutputDynFile = combine ghcOptOutputDynFile, - ghcOptSourcePathClear = combine ghcOptSourcePathClear, - ghcOptSourcePath = combine ghcOptSourcePath, - ghcOptThisUnitId = combine ghcOptThisUnitId, - ghcOptPackageDBs = combine ghcOptPackageDBs, - ghcOptPackages = combine ghcOptPackages, - ghcOptHideAllPackages = combine ghcOptHideAllPackages, - ghcOptNoAutoLinkPackages = combine ghcOptNoAutoLinkPackages, - ghcOptLinkLibs = combine ghcOptLinkLibs, - ghcOptLinkLibPath = combine ghcOptLinkLibPath, - ghcOptLinkOptions = combine ghcOptLinkOptions, - ghcOptLinkFrameworks = combine ghcOptLinkFrameworks, - ghcOptLinkFrameworkDirs = combine ghcOptLinkFrameworkDirs, - ghcOptNoLink = combine ghcOptNoLink, - ghcOptLinkNoHsMain = combine ghcOptLinkNoHsMain, - ghcOptCcOptions = combine ghcOptCcOptions, - ghcOptCppOptions = combine ghcOptCppOptions, - ghcOptCppIncludePath = combine ghcOptCppIncludePath, - ghcOptCppIncludes = combine ghcOptCppIncludes, - ghcOptFfiIncludes = combine ghcOptFfiIncludes, - ghcOptLanguage = combine ghcOptLanguage, - ghcOptExtensions = combine ghcOptExtensions, - ghcOptExtensionMap = combine ghcOptExtensionMap, - ghcOptOptimisation = combine ghcOptOptimisation, - ghcOptDebugInfo = combine ghcOptDebugInfo, - ghcOptProfilingMode = combine ghcOptProfilingMode, - ghcOptProfilingAuto = combine ghcOptProfilingAuto, - ghcOptSplitObjs = combine ghcOptSplitObjs, - ghcOptNumJobs = combine ghcOptNumJobs, - ghcOptHPCDir = combine ghcOptHPCDir, - ghcOptGHCiScripts = combine ghcOptGHCiScripts, - ghcOptHiSuffix = combine ghcOptHiSuffix, - ghcOptObjSuffix = combine ghcOptObjSuffix, - ghcOptDynHiSuffix = combine ghcOptDynHiSuffix, - ghcOptDynObjSuffix = combine ghcOptDynObjSuffix, - ghcOptHiDir = combine ghcOptHiDir, - ghcOptObjDir = combine ghcOptObjDir, - ghcOptOutputDir = combine ghcOptOutputDir, - ghcOptStubDir = combine ghcOptStubDir, - ghcOptDynLinkMode = combine ghcOptDynLinkMode, - ghcOptShared = combine ghcOptShared, - ghcOptFPic = combine ghcOptFPic, - ghcOptDylibName = combine ghcOptDylibName, - ghcOptRPaths = combine ghcOptRPaths, - ghcOptVerbosity = combine ghcOptVerbosity, - ghcOptCabal = combine ghcOptCabal - } - where - combine field = field a `mappend` field b + (<>) = gmappend diff --git a/Cabal/Distribution/Simple/Setup.hs b/Cabal/Distribution/Simple/Setup.hs index bfad488e1a4..0c9cfa96ee4 100644 --- a/Cabal/Distribution/Simple/Setup.hs +++ b/Cabal/Distribution/Simple/Setup.hs @@ -188,7 +188,7 @@ allFlags flags = if all (\f -> fromFlagOrDefault False f) flags data GlobalFlags = GlobalFlags { globalVersion :: Flag Bool, globalNumericVersion :: Flag Bool - } + } deriving (Generic) defaultGlobalFlags :: GlobalFlags defaultGlobalFlags = GlobalFlags { @@ -239,18 +239,11 @@ emptyGlobalFlags :: GlobalFlags emptyGlobalFlags = mempty instance Monoid GlobalFlags where - mempty = GlobalFlags { - globalVersion = mempty, - globalNumericVersion = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup GlobalFlags where - a <> b = GlobalFlags { - globalVersion = combine globalVersion, - globalNumericVersion = combine globalNumericVersion - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Config flags @@ -811,104 +804,11 @@ emptyConfigFlags :: ConfigFlags emptyConfigFlags = mempty instance Monoid ConfigFlags where - mempty = ConfigFlags { - configPrograms = mempty, - configProgramPaths = mempty, - configProgramArgs = mempty, - configProgramPathExtra = mempty, - configHcFlavor = mempty, - configHcPath = mempty, - configHcPkg = mempty, - configVanillaLib = mempty, - configProfLib = mempty, - configSharedLib = mempty, - configDynExe = mempty, - configProfExe = mempty, - configProf = mempty, - configProfDetail = mempty, - configProfLibDetail = mempty, - configConfigureArgs = mempty, - configOptimization = mempty, - configProgPrefix = mempty, - configProgSuffix = mempty, - configInstallDirs = mempty, - configScratchDir = mempty, - configDistPref = mempty, - configVerbosity = mempty, - configUserInstall = mempty, - configPackageDBs = mempty, - configGHCiLib = mempty, - configSplitObjs = mempty, - configStripExes = mempty, - configStripLibs = mempty, - configExtraLibDirs = mempty, - configExtraFrameworkDirs = mempty, - configConstraints = mempty, - configDependencies = mempty, - configExtraIncludeDirs = mempty, - configIPID = mempty, - configConfigurationsFlags = mempty, - configTests = mempty, - configCoverage = mempty, - configLibCoverage = mempty, - configExactConfiguration = mempty, - configBenchmarks = mempty, - configFlagError = mempty, - configRelocatable = mempty, - configDebugInfo = mempty, - configAllowNewer = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup ConfigFlags where - a <> b = ConfigFlags { - configPrograms = combine configPrograms, - configProgramPaths = combine configProgramPaths, - configProgramArgs = combine configProgramArgs, - configProgramPathExtra = combine configProgramPathExtra, - configHcFlavor = combine configHcFlavor, - configHcPath = combine configHcPath, - configHcPkg = combine configHcPkg, - configVanillaLib = combine configVanillaLib, - configProfLib = combine configProfLib, - configSharedLib = combine configSharedLib, - configDynExe = combine configDynExe, - configProfExe = combine configProfExe, - configProf = combine configProf, - configProfDetail = combine configProfDetail, - configProfLibDetail = combine configProfLibDetail, - configConfigureArgs = combine configConfigureArgs, - configOptimization = combine configOptimization, - configProgPrefix = combine configProgPrefix, - configProgSuffix = combine configProgSuffix, - configInstallDirs = combine configInstallDirs, - configScratchDir = combine configScratchDir, - configDistPref = combine configDistPref, - configVerbosity = combine configVerbosity, - configUserInstall = combine configUserInstall, - configPackageDBs = combine configPackageDBs, - configGHCiLib = combine configGHCiLib, - configSplitObjs = combine configSplitObjs, - configStripExes = combine configStripExes, - configStripLibs = combine configStripLibs, - configExtraLibDirs = combine configExtraLibDirs, - configExtraFrameworkDirs = combine configExtraFrameworkDirs, - configConstraints = combine configConstraints, - configDependencies = combine configDependencies, - configExtraIncludeDirs = combine configExtraIncludeDirs, - configIPID = combine configIPID, - configConfigurationsFlags = combine configConfigurationsFlags, - configTests = combine configTests, - configCoverage = combine configCoverage, - configLibCoverage = combine configLibCoverage, - configExactConfiguration = combine configExactConfiguration, - configBenchmarks = combine configBenchmarks, - configFlagError = combine configFlagError, - configRelocatable = combine configRelocatable, - configDebugInfo = combine configDebugInfo, - configAllowNewer = combine configAllowNewer - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Copy flags @@ -920,7 +820,7 @@ data CopyFlags = CopyFlags { copyDistPref :: Flag FilePath, copyVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultCopyFlags :: CopyFlags defaultCopyFlags = CopyFlags { @@ -959,20 +859,11 @@ emptyCopyFlags :: CopyFlags emptyCopyFlags = mempty instance Monoid CopyFlags where - mempty = CopyFlags { - copyDest = mempty, - copyDistPref = mempty, - copyVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup CopyFlags where - a <> b = CopyFlags { - copyDest = combine copyDest, - copyDistPref = combine copyDistPref, - copyVerbosity = combine copyVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Install flags @@ -986,7 +877,7 @@ data InstallFlags = InstallFlags { installInPlace :: Flag Bool, installVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultInstallFlags :: InstallFlags defaultInstallFlags = InstallFlags { @@ -1039,24 +930,11 @@ emptyInstallFlags :: InstallFlags emptyInstallFlags = mempty instance Monoid InstallFlags where - mempty = InstallFlags{ - installPackageDB = mempty, - installDistPref = mempty, - installUseWrapper = mempty, - installInPlace = mempty, - installVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup InstallFlags where - a <> b = InstallFlags{ - installPackageDB = combine installPackageDB, - installDistPref = combine installDistPref, - installUseWrapper = combine installUseWrapper, - installInPlace = combine installInPlace, - installVerbosity = combine installVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * SDist flags @@ -1070,7 +948,7 @@ data SDistFlags = SDistFlags { sDistListSources :: Flag FilePath, sDistVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultSDistFlags :: SDistFlags defaultSDistFlags = SDistFlags { @@ -1119,24 +997,11 @@ emptySDistFlags :: SDistFlags emptySDistFlags = mempty instance Monoid SDistFlags where - mempty = SDistFlags { - sDistSnapshot = mempty, - sDistDirectory = mempty, - sDistDistPref = mempty, - sDistListSources = mempty, - sDistVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup SDistFlags where - a <> b = SDistFlags { - sDistSnapshot = combine sDistSnapshot, - sDistDirectory = combine sDistDirectory, - sDistDistPref = combine sDistDistPref, - sDistListSources = combine sDistListSources, - sDistVerbosity = combine sDistVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Register flags @@ -1153,7 +1018,7 @@ data RegisterFlags = RegisterFlags { regPrintId :: Flag Bool, regVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultRegisterFlags :: RegisterFlags defaultRegisterFlags = RegisterFlags { @@ -1245,28 +1110,11 @@ emptyRegisterFlags :: RegisterFlags emptyRegisterFlags = mempty instance Monoid RegisterFlags where - mempty = RegisterFlags { - regPackageDB = mempty, - regGenScript = mempty, - regGenPkgConf = mempty, - regInPlace = mempty, - regPrintId = mempty, - regDistPref = mempty, - regVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup RegisterFlags where - a <> b = RegisterFlags { - regPackageDB = combine regPackageDB, - regGenScript = combine regGenScript, - regGenPkgConf = combine regGenPkgConf, - regInPlace = combine regInPlace, - regPrintId = combine regPrintId, - regDistPref = combine regDistPref, - regVerbosity = combine regVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * HsColour flags @@ -1280,7 +1128,7 @@ data HscolourFlags = HscolourFlags { hscolourDistPref :: Flag FilePath, hscolourVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) emptyHscolourFlags :: HscolourFlags emptyHscolourFlags = mempty @@ -1296,26 +1144,11 @@ defaultHscolourFlags = HscolourFlags { } instance Monoid HscolourFlags where - mempty = HscolourFlags { - hscolourCSS = mempty, - hscolourExecutables = mempty, - hscolourTestSuites = mempty, - hscolourBenchmarks = mempty, - hscolourDistPref = mempty, - hscolourVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup HscolourFlags where - a <> b = HscolourFlags { - hscolourCSS = combine hscolourCSS, - hscolourExecutables = combine hscolourExecutables, - hscolourTestSuites = combine hscolourTestSuites, - hscolourBenchmarks = combine hscolourBenchmarks, - hscolourDistPref = combine hscolourDistPref, - hscolourVerbosity = combine hscolourVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend hscolourCommand :: CommandUI HscolourFlags hscolourCommand = CommandUI @@ -1389,7 +1222,7 @@ data HaddockFlags = HaddockFlags { haddockKeepTempFiles:: Flag Bool, haddockVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultHaddockFlags :: HaddockFlags defaultHaddockFlags = HaddockFlags { @@ -1526,48 +1359,11 @@ emptyHaddockFlags :: HaddockFlags emptyHaddockFlags = mempty instance Monoid HaddockFlags where - mempty = HaddockFlags { - haddockProgramPaths = mempty, - haddockProgramArgs = mempty, - haddockHoogle = mempty, - haddockHtml = mempty, - haddockHtmlLocation = mempty, - haddockForHackage = mempty, - haddockExecutables = mempty, - haddockTestSuites = mempty, - haddockBenchmarks = mempty, - haddockInternal = mempty, - haddockCss = mempty, - haddockHscolour = mempty, - haddockHscolourCss = mempty, - haddockContents = mempty, - haddockDistPref = mempty, - haddockKeepTempFiles= mempty, - haddockVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup HaddockFlags where - a <> b = HaddockFlags { - haddockProgramPaths = combine haddockProgramPaths, - haddockProgramArgs = combine haddockProgramArgs, - haddockHoogle = combine haddockHoogle, - haddockHtml = combine haddockHtml, - haddockHtmlLocation = combine haddockHtmlLocation, - haddockForHackage = combine haddockForHackage, - haddockExecutables = combine haddockExecutables, - haddockTestSuites = combine haddockTestSuites, - haddockBenchmarks = combine haddockBenchmarks, - haddockInternal = combine haddockInternal, - haddockCss = combine haddockCss, - haddockHscolour = combine haddockHscolour, - haddockHscolourCss = combine haddockHscolourCss, - haddockContents = combine haddockContents, - haddockDistPref = combine haddockDistPref, - haddockKeepTempFiles= combine haddockKeepTempFiles, - haddockVerbosity = combine haddockVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Clean flags @@ -1578,7 +1374,7 @@ data CleanFlags = CleanFlags { cleanDistPref :: Flag FilePath, cleanVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultCleanFlags :: CleanFlags defaultCleanFlags = CleanFlags { @@ -1614,20 +1410,11 @@ emptyCleanFlags :: CleanFlags emptyCleanFlags = mempty instance Monoid CleanFlags where - mempty = CleanFlags { - cleanSaveConf = mempty, - cleanDistPref = mempty, - cleanVerbosity = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup CleanFlags where - a <> b = CleanFlags { - cleanSaveConf = combine cleanSaveConf, - cleanDistPref = combine cleanDistPref, - cleanVerbosity = combine cleanVerbosity - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Build flags @@ -1643,7 +1430,7 @@ data BuildFlags = BuildFlags { -- UserHooks stop us from passing extra info in other ways buildArgs :: [String] } - deriving Show + deriving (Show, Generic) {-# DEPRECATED buildVerbose "Use buildVerbosity instead" #-} buildVerbose :: BuildFlags -> Verbosity @@ -1718,26 +1505,11 @@ emptyBuildFlags :: BuildFlags emptyBuildFlags = mempty instance Monoid BuildFlags where - mempty = BuildFlags { - buildProgramPaths = mempty, - buildProgramArgs = mempty, - buildVerbosity = mempty, - buildDistPref = mempty, - buildNumJobs = mempty, - buildArgs = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup BuildFlags where - a <> b = BuildFlags { - buildProgramPaths = combine buildProgramPaths, - buildProgramArgs = combine buildProgramArgs, - buildVerbosity = combine buildVerbosity, - buildDistPref = combine buildDistPref, - buildNumJobs = combine buildNumJobs, - buildArgs = combine buildArgs - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * REPL Flags @@ -1750,7 +1522,7 @@ data ReplFlags = ReplFlags { replVerbosity :: Flag Verbosity, replReload :: Flag Bool } - deriving Show + deriving (Show, Generic) defaultReplFlags :: ReplFlags defaultReplFlags = ReplFlags { @@ -1762,24 +1534,11 @@ defaultReplFlags = ReplFlags { } instance Monoid ReplFlags where - mempty = ReplFlags { - replProgramPaths = mempty, - replProgramArgs = mempty, - replVerbosity = mempty, - replDistPref = mempty, - replReload = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup ReplFlags where - a <> b = ReplFlags { - replProgramPaths = combine replProgramPaths, - replProgramArgs = combine replProgramArgs, - replVerbosity = combine replVerbosity, - replDistPref = combine replDistPref, - replReload = combine replReload - } - where combine field = field a `mappend` field b + (<>) = gmappend replCommand :: ProgramConfiguration -> CommandUI ReplFlags replCommand progConf = CommandUI @@ -1887,7 +1646,7 @@ data TestFlags = TestFlags { testKeepTix :: Flag Bool, -- TODO: think about if/how options are passed to test exes testOptions :: [PathTemplate] - } + } deriving (Generic) defaultTestFlags :: TestFlags defaultTestFlags = TestFlags { @@ -1979,28 +1738,11 @@ emptyTestFlags :: TestFlags emptyTestFlags = mempty instance Monoid TestFlags where - mempty = TestFlags { - testDistPref = mempty, - testVerbosity = mempty, - testHumanLog = mempty, - testMachineLog = mempty, - testShowDetails = mempty, - testKeepTix = mempty, - testOptions = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup TestFlags where - a <> b = TestFlags { - testDistPref = combine testDistPref, - testVerbosity = combine testVerbosity, - testHumanLog = combine testHumanLog, - testMachineLog = combine testMachineLog, - testShowDetails = combine testShowDetails, - testKeepTix = combine testKeepTix, - testOptions = combine testOptions - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Benchmark flags @@ -2010,7 +1752,7 @@ data BenchmarkFlags = BenchmarkFlags { benchmarkDistPref :: Flag FilePath, benchmarkVerbosity :: Flag Verbosity, benchmarkOptions :: [PathTemplate] - } + } deriving (Generic) defaultBenchmarkFlags :: BenchmarkFlags defaultBenchmarkFlags = BenchmarkFlags { @@ -2069,20 +1811,11 @@ emptyBenchmarkFlags :: BenchmarkFlags emptyBenchmarkFlags = mempty instance Monoid BenchmarkFlags where - mempty = BenchmarkFlags { - benchmarkDistPref = mempty, - benchmarkVerbosity = mempty, - benchmarkOptions = mempty - } + mempty = gmempty mappend = (Semi.<>) instance Semigroup BenchmarkFlags where - a <> b = BenchmarkFlags { - benchmarkDistPref = combine benchmarkDistPref, - benchmarkVerbosity = combine benchmarkVerbosity, - benchmarkOptions = combine benchmarkOptions - } - where combine field = field a `mappend` field b + (<>) = gmappend -- ------------------------------------------------------------ -- * Shared options utils