Commit 9b38b38b authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Derive some additional Generic instances (cabal-install)

This is preparatory work for implementing #3169
it's kept in a different commit in order to facilitate
comparing code-generation.
parent dd5fe69a
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
......@@ -140,6 +141,7 @@ import Data.Function
( on )
import Data.List
( nubBy )
import GHC.Generics ( Generic )
--
-- * Configuration saved in the config file
......@@ -155,7 +157,7 @@ data SavedConfig = SavedConfig {
savedUploadFlags :: UploadFlags,
savedReportFlags :: ReportFlags,
savedHaddockFlags :: HaddockFlags
}
} deriving Generic
instance Monoid SavedConfig where
mempty = SavedConfig {
......
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
......@@ -44,6 +45,7 @@ import qualified Data.Map as Map
import Data.Monoid
( Monoid(..) )
#endif
import GHC.Generics ( Generic )
import qualified Hackage.Security.Client as Sec
import qualified Hackage.Security.Util.Path as Sec
......@@ -73,7 +75,7 @@ data GlobalFlags = GlobalFlags {
globalIgnoreSandbox :: Flag Bool,
globalIgnoreExpiry :: Flag Bool, -- ^ Ignore security expiry dates
globalHttpTransport :: Flag String
}
} deriving Generic
defaultGlobalFlags :: GlobalFlags
defaultGlobalFlags = GlobalFlags {
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Init.Types
......@@ -32,6 +34,7 @@ import Distribution.Text
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (Monoid(..))
#endif
import GHC.Generics (Generic)
-- | InitFlags is really just a simple type to represent certain
-- portions of a .cabal file. Rather than have a flag for EVERY
......@@ -72,7 +75,7 @@ data InitFlags =
, initVerbosity :: Flag Verbosity
, overwrite :: Flag Bool
}
deriving (Show)
deriving (Show, Generic)
-- the Monoid instance for Flag has later values override earlier
-- ones, which is why we want Maybe [foo] for collecting foo values,
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Sandbox.PackageEnvironment
......@@ -76,6 +78,7 @@ import qualified Text.PrettyPrint as Disp
import qualified Distribution.Compat.ReadP as Parse
import qualified Distribution.ParseUtils as ParseUtils ( Field(..) )
import qualified Distribution.Text as Text
import GHC.Generics ( Generic )
--
......@@ -89,7 +92,7 @@ data PackageEnvironment = PackageEnvironment {
-- for constructing nested sandboxes (see discussion in #1196).
pkgEnvInherit :: Flag FilePath,
pkgEnvSavedConfig :: SavedConfig
}
} deriving Generic
instance Monoid PackageEnvironment where
mempty = PackageEnvironment {
......
......@@ -503,7 +503,7 @@ data SkipAddSourceDepsCheck =
data BuildExFlags = BuildExFlags {
buildOnly :: Flag SkipAddSourceDepsCheck
}
} deriving Generic
buildExOptions :: ShowOrParseArgs -> [OptionField BuildExFlags]
buildExOptions _showOrParseArgs =
......@@ -894,7 +894,7 @@ data ReportFlags = ReportFlags {
reportUsername :: Flag Username,
reportPassword :: Flag Password,
reportVerbosity :: Flag Verbosity
}
} deriving Generic
defaultReportFlags :: ReportFlags
defaultReportFlags = ReportFlags {
......@@ -954,7 +954,7 @@ data GetFlags = GetFlags {
getPristine :: Flag Bool,
getSourceRepository :: Flag (Maybe RepoKind),
getVerbosity :: Flag Verbosity
}
} deriving Generic
defaultGetFlags :: GetFlags
defaultGetFlags = GetFlags {
......@@ -1039,7 +1039,7 @@ data ListFlags = ListFlags {
listSimpleOutput :: Flag Bool,
listVerbosity :: Flag Verbosity,
listPackageDBs :: [Maybe PackageDB]
}
} deriving Generic
defaultListFlags :: ListFlags
defaultListFlags = ListFlags {
......@@ -1119,7 +1119,7 @@ instance Semigroup ListFlags where
data InfoFlags = InfoFlags {
infoVerbosity :: Flag Verbosity,
infoPackageDBs :: [Maybe PackageDB]
}
} deriving Generic
defaultInfoFlags :: InfoFlags
defaultInfoFlags = InfoFlags {
......@@ -1520,7 +1520,7 @@ data UploadFlags = UploadFlags {
uploadPassword :: Flag Password,
uploadPasswordCmd :: Flag [String],
uploadVerbosity :: Flag Verbosity
}
} deriving Generic
defaultUploadFlags :: UploadFlags
defaultUploadFlags = UploadFlags {
......@@ -1792,7 +1792,7 @@ initCommand = CommandUI {
data SDistExFlags = SDistExFlags {
sDistFormat :: Flag ArchiveFormat
}
deriving Show
deriving (Show, Generic)
data ArchiveFormat = TargzFormat | ZipFormat -- | ...
deriving (Show, Eq)
......@@ -1843,7 +1843,7 @@ instance Semigroup SDistExFlags where
data Win32SelfUpgradeFlags = Win32SelfUpgradeFlags {
win32SelfUpgradeVerbosity :: Flag Verbosity
}
} deriving Generic
defaultWin32SelfUpgradeFlags :: Win32SelfUpgradeFlags
defaultWin32SelfUpgradeFlags = Win32SelfUpgradeFlags {
......@@ -1883,7 +1883,7 @@ instance Semigroup Win32SelfUpgradeFlags where
data ActAsSetupFlags = ActAsSetupFlags {
actAsSetupBuildType :: Flag BuildType
}
} deriving Generic
defaultActAsSetupFlags :: ActAsSetupFlags
defaultActAsSetupFlags = ActAsSetupFlags {
......@@ -1930,7 +1930,7 @@ data SandboxFlags = SandboxFlags {
sandboxSnapshot :: Flag Bool, -- FIXME: this should be an 'add-source'-only
-- flag.
sandboxLocation :: Flag FilePath
}
} deriving Generic
defaultSandboxLocation :: FilePath
defaultSandboxLocation = ".cabal-sandbox"
......@@ -2058,7 +2058,7 @@ instance Semigroup SandboxFlags where
data ExecFlags = ExecFlags {
execVerbosity :: Flag Verbosity
}
} deriving Generic
defaultExecFlags :: ExecFlags
defaultExecFlags = ExecFlags {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment