From dd5fe69a9aa6f0090f9b4ebc4a358065460f04ca Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel <hvr@gnu.org> Date: Sun, 28 Feb 2016 08:21:20 +0100 Subject: [PATCH] Derive some additional Generic instances This is preparatory work for implementing #3169 it's kept in a different commit in order to facilitate comparing code-generation. --- Cabal/Distribution/Simple/Haddock.hs | 5 ++++- Cabal/Distribution/Simple/Program/GHC.hs | 5 ++++- Cabal/Distribution/Simple/Setup.hs | 24 ++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Cabal/Distribution/Simple/Haddock.hs b/Cabal/Distribution/Simple/Haddock.hs index e2398ec521..a96f9fc2ba 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) diff --git a/Cabal/Distribution/Simple/Program/GHC.hs b/Cabal/Distribution/Simple/Program/GHC.hs index a46c3c17e8..91af27f7ae 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@ diff --git a/Cabal/Distribution/Simple/Setup.hs b/Cabal/Distribution/Simple/Setup.hs index bfad488e1a..59a6b0d17b 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 { @@ -920,7 +920,7 @@ data CopyFlags = CopyFlags { copyDistPref :: Flag FilePath, copyVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultCopyFlags :: CopyFlags defaultCopyFlags = CopyFlags { @@ -986,7 +986,7 @@ data InstallFlags = InstallFlags { installInPlace :: Flag Bool, installVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultInstallFlags :: InstallFlags defaultInstallFlags = InstallFlags { @@ -1070,7 +1070,7 @@ data SDistFlags = SDistFlags { sDistListSources :: Flag FilePath, sDistVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultSDistFlags :: SDistFlags defaultSDistFlags = SDistFlags { @@ -1153,7 +1153,7 @@ data RegisterFlags = RegisterFlags { regPrintId :: Flag Bool, regVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultRegisterFlags :: RegisterFlags defaultRegisterFlags = RegisterFlags { @@ -1280,7 +1280,7 @@ data HscolourFlags = HscolourFlags { hscolourDistPref :: Flag FilePath, hscolourVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) emptyHscolourFlags :: HscolourFlags emptyHscolourFlags = mempty @@ -1389,7 +1389,7 @@ data HaddockFlags = HaddockFlags { haddockKeepTempFiles:: Flag Bool, haddockVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultHaddockFlags :: HaddockFlags defaultHaddockFlags = HaddockFlags { @@ -1578,7 +1578,7 @@ data CleanFlags = CleanFlags { cleanDistPref :: Flag FilePath, cleanVerbosity :: Flag Verbosity } - deriving Show + deriving (Show, Generic) defaultCleanFlags :: CleanFlags defaultCleanFlags = CleanFlags { @@ -1643,7 +1643,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 @@ -1750,7 +1750,7 @@ data ReplFlags = ReplFlags { replVerbosity :: Flag Verbosity, replReload :: Flag Bool } - deriving Show + deriving (Show, Generic) defaultReplFlags :: ReplFlags defaultReplFlags = ReplFlags { @@ -1887,7 +1887,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 { @@ -2010,7 +2010,7 @@ data BenchmarkFlags = BenchmarkFlags { benchmarkDistPref :: Flag FilePath, benchmarkVerbosity :: Flag Verbosity, benchmarkOptions :: [PathTemplate] - } + } deriving (Generic) defaultBenchmarkFlags :: BenchmarkFlags defaultBenchmarkFlags = BenchmarkFlags { -- GitLab