{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Distribution.Simple.Setup
-- Copyright   :  Isaac Jones 2003-2004
--                Duncan Coutts 2007
-- License     :  BSD3
--
-- Maintainer  :  cabal-devel@haskell.org
-- Portability :  portable
--
-- This is a big module, but not very complicated. The code is very regular
-- and repetitive. It defines the command line interface for all the Cabal
-- commands. For each command (like @configure@, @build@ etc) it defines a type
-- that holds all the flags, the default set of flags and a 'CommandUI' that
-- maps command line flags to and from the corresponding flags type.
--
-- All the flags types are instances of 'Monoid', see
-- <http://www.haskell.org/pipermail/cabal-devel/2007-December/001509.html>
-- for an explanation.
--
-- The types defined here get used in the front end and especially in
-- @cabal-install@ which has to do quite a bit of manipulating sets of command
-- line flags.
--
-- This is actually relatively nice, it works quite well. The main change it
-- needs is to unify it with the code for managing sets of fields that can be
-- read and written from files. This would allow us to save configure flags in
-- config files.

module Distribution.Simple.Setup (

  GlobalFlags(..),   emptyGlobalFlags,   defaultGlobalFlags,   globalCommand,
  ConfigFlags(..),   emptyConfigFlags,   defaultConfigFlags,   configureCommand,
  configPrograms,
  configAbsolutePaths, readPackageDb, readPackageDbList, showPackageDb, showPackageDbList,
  CopyFlags(..),     emptyCopyFlags,     defaultCopyFlags,     copyCommand,
  InstallFlags(..),  emptyInstallFlags,  defaultInstallFlags,  installCommand,
  HaddockTarget(..),
  HaddockFlags(..),  emptyHaddockFlags,  defaultHaddockFlags,  haddockCommand,
  HscolourFlags(..), emptyHscolourFlags, defaultHscolourFlags, hscolourCommand,
  BuildFlags(..),    emptyBuildFlags,    defaultBuildFlags,    buildCommand,
  DumpBuildInfo(..),
  ReplFlags(..),                         defaultReplFlags,     replCommand,
  ReplOptions(..),
  CleanFlags(..),    emptyCleanFlags,    defaultCleanFlags,    cleanCommand,
  RegisterFlags(..), emptyRegisterFlags, defaultRegisterFlags, registerCommand,
                                                               unregisterCommand,
  SDistFlags(..),    emptySDistFlags,    defaultSDistFlags,    sdistCommand,
  TestFlags(..),     emptyTestFlags,     defaultTestFlags,     testCommand,
  TestShowDetails(..),
  BenchmarkFlags(..), emptyBenchmarkFlags,
  defaultBenchmarkFlags, benchmarkCommand,
  CopyDest(..),
  configureArgs, configureOptions, configureCCompiler, configureLinker,
  buildOptions, haddockOptions, installDirsOptions,
  testOptions', benchmarkOptions',
  programDbOptions, programDbPaths',
  programFlagsDescription,
  replOptions,
  splitArgs,

  defaultDistPref, optionDistPref,

  Flag(..),
  toFlag,
  fromFlag,
  fromFlagOrDefault,
  flagToMaybe,
  flagToList,
  maybeToFlag,
  BooleanFlag(..),
  boolOpt, boolOpt', trueArg, falseArg,
  optionVerbosity, optionNumJobs) where

import Prelude ()
import Distribution.Compat.Prelude hiding (get)

import Distribution.Compiler
import Distribution.ReadE
import Distribution.Parsec
import Distribution.Pretty
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
import Distribution.ModuleName
import Distribution.PackageDescription
import Distribution.Simple.Command hiding (boolOpt, boolOpt')
import qualified Distribution.Simple.Command as Command
import Distribution.Simple.Compiler
import Distribution.Simple.Flag
import Distribution.Simple.Utils
import Distribution.Simple.Program
import Distribution.Simple.InstallDirs
import Distribution.Verbosity
import Distribution.Utils.NubList
import Distribution.Types.ComponentId
import Distribution.Types.DumpBuildInfo
import Distribution.Types.GivenComponent
import Distribution.Types.Module
import Distribution.Types.PackageVersionConstraint

import Distribution.Compat.Stack
import Distribution.Compat.Semigroup (Last' (..), Option' (..))

-- FIXME Not sure where this should live
defaultDistPref :: FilePath
defaultDistPref :: String
defaultDistPref = String
"dist"

-- ------------------------------------------------------------
-- * Global flags
-- ------------------------------------------------------------

-- In fact since individual flags types are monoids and these are just sets of
-- flags then they are also monoids pointwise. This turns out to be really
-- useful. The mempty is the set of empty flags and mappend allows us to
-- override specific flags. For example we can start with default flags and
-- override with the ones we get from a file or the command line, or both.

-- | Flags that apply at the top level, not to any sub-command.
data GlobalFlags = GlobalFlags {
    GlobalFlags -> Flag Bool
globalVersion        :: Flag Bool,
    GlobalFlags -> Flag Bool
globalNumericVersion :: Flag Bool
  } deriving ((forall x. GlobalFlags -> Rep GlobalFlags x)
-> (forall x. Rep GlobalFlags x -> GlobalFlags)
-> Generic GlobalFlags
forall x. Rep GlobalFlags x -> GlobalFlags
forall x. GlobalFlags -> Rep GlobalFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GlobalFlags -> Rep GlobalFlags x
from :: forall x. GlobalFlags -> Rep GlobalFlags x
$cto :: forall x. Rep GlobalFlags x -> GlobalFlags
to :: forall x. Rep GlobalFlags x -> GlobalFlags
Generic, Typeable)

defaultGlobalFlags :: GlobalFlags
defaultGlobalFlags :: GlobalFlags
defaultGlobalFlags  = GlobalFlags {
    globalVersion :: Flag Bool
globalVersion        = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    globalNumericVersion :: Flag Bool
globalNumericVersion = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False
  }

globalCommand :: [Command action] -> CommandUI GlobalFlags
globalCommand :: forall action. [Command action] -> CommandUI GlobalFlags
globalCommand [Command action]
commands = CommandUI
  { commandName :: String
commandName         = String
""
  , commandSynopsis :: String
commandSynopsis     = String
""
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
         String
"This Setup program uses the Haskell Cabal Infrastructure.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"See http://www.haskell.org/cabal/ for more information.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" [GLOBAL FLAGS] [COMMAND [FLAGS]]\n"
  , commandDescription :: Maybe (String -> String)
commandDescription = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
      let
        commands' :: [Command action]
commands' = [Command action]
commands [Command action] -> [Command action] -> [Command action]
forall a. [a] -> [a] -> [a]
++ [CommandUI () -> (() -> [String] -> action) -> Command action
forall flags action.
CommandUI flags -> (flags -> [String] -> action) -> Command action
commandAddAction CommandUI ()
helpCommandUI () -> [String] -> action
forall a. HasCallStack => a
undefined]
        cmdDescs :: [(String, String)]
cmdDescs = [Command action] -> [(String, String)]
forall action. [Command action] -> [(String, String)]
getNormalCommandDescriptions [Command action]
commands'
        maxlen :: Int
maxlen    = [Int] -> Int
forall a. Ord a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ [String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
name | (String
name, String
_) <- [(String, String)]
cmdDescs]
        align :: String -> String
align String
str = String
str String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
maxlen Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
str) Char
' '
      in
         String
"Commands:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
unlines [ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
align String
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
descr
                 | (String
name, String
descr) <- [(String, String)]
cmdDescs ]
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"For more information about a command use\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" COMMAND --help\n\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Typical steps for installing Cabal packages:\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
                | String
x <- [String
"configure", String
"build", String
"install"]]
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandDefaultFlags :: GlobalFlags
commandDefaultFlags = GlobalFlags
defaultGlobalFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField GlobalFlags]
commandOptions      = \ShowOrParseArgs
_ ->
      [String
-> [String]
-> String
-> (GlobalFlags -> Flag Bool)
-> (Flag Bool -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [Char
'V'] [String
"version"]
         String
"Print version information"
         GlobalFlags -> Flag Bool
globalVersion (\Flag Bool
v GlobalFlags
flags -> GlobalFlags
flags { globalVersion :: Flag Bool
globalVersion = Flag Bool
v })
         MkOptDescr
  (GlobalFlags -> Flag Bool)
  (Flag Bool -> GlobalFlags -> GlobalFlags)
  GlobalFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
      ,String
-> [String]
-> String
-> (GlobalFlags -> Flag Bool)
-> (Flag Bool -> GlobalFlags -> GlobalFlags)
-> MkOptDescr
     (GlobalFlags -> Flag Bool)
     (Flag Bool -> GlobalFlags -> GlobalFlags)
     GlobalFlags
-> OptionField GlobalFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"numeric-version"]
         String
"Print just the version number"
         GlobalFlags -> Flag Bool
globalNumericVersion (\Flag Bool
v GlobalFlags
flags -> GlobalFlags
flags { globalNumericVersion :: Flag Bool
globalNumericVersion = Flag Bool
v })
         MkOptDescr
  (GlobalFlags -> Flag Bool)
  (Flag Bool -> GlobalFlags -> GlobalFlags)
  GlobalFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
      ]
  }

emptyGlobalFlags :: GlobalFlags
emptyGlobalFlags :: GlobalFlags
emptyGlobalFlags = GlobalFlags
forall a. Monoid a => a
mempty

instance Monoid GlobalFlags where
  mempty :: GlobalFlags
mempty = GlobalFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: GlobalFlags -> GlobalFlags -> GlobalFlags
mappend = GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup GlobalFlags where
  <> :: GlobalFlags -> GlobalFlags -> GlobalFlags
(<>) = GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Config flags
-- ------------------------------------------------------------

-- | Flags to @configure@ command.
--
-- IMPORTANT: every time a new flag is added, 'D.C.Setup.filterConfigureFlags'
-- should be updated.
-- IMPORTANT: every time a new flag is added, it should be added to the Eq instance
data ConfigFlags = ConfigFlags {
    -- This is the same hack as in 'buildArgs' and 'copyArgs'.
    -- TODO: Stop using this eventually when 'UserHooks' gets changed
    ConfigFlags -> [String]
configArgs :: [String],

    --FIXME: the configPrograms is only here to pass info through to configure
    -- because the type of configure is constrained by the UserHooks.
    -- when we change UserHooks next we should pass the initial
    -- ProgramDb directly and not via ConfigFlags
    ConfigFlags -> Option' (Last' ProgramDb)
configPrograms_     :: Option' (Last' ProgramDb), -- ^All programs that
                                                      -- @cabal@ may run
    ConfigFlags -> [(String, String)]
configProgramPaths  :: [(String, FilePath)], -- ^user specified programs paths
    ConfigFlags -> [(String, [String])]
configProgramArgs   :: [(String, [String])], -- ^user specified programs args
    ConfigFlags -> NubList String
configProgramPathExtra :: NubList FilePath,  -- ^Extend the $PATH
    ConfigFlags -> Flag CompilerFlavor
configHcFlavor      :: Flag CompilerFlavor, -- ^The \"flavor\" of the
                                                -- compiler, e.g. GHC.
    ConfigFlags -> Flag String
configHcPath        :: Flag FilePath, -- ^given compiler location
    ConfigFlags -> Flag String
configHcPkg         :: Flag FilePath, -- ^given hc-pkg location
    ConfigFlags -> Flag Bool
configVanillaLib    :: Flag Bool,     -- ^Enable vanilla library
    ConfigFlags -> Flag Bool
configProfLib       :: Flag Bool,     -- ^Enable profiling in the library
    ConfigFlags -> Flag Bool
configSharedLib     :: Flag Bool,     -- ^Build shared library
    ConfigFlags -> Flag Bool
configStaticLib     :: Flag Bool,     -- ^Build static library
    ConfigFlags -> Flag Bool
configDynExe        :: Flag Bool,     -- ^Enable dynamic linking of the
                                          -- executables.
    ConfigFlags -> Flag Bool
configFullyStaticExe :: Flag Bool,     -- ^Enable fully static linking of the
                                          -- executables.
    ConfigFlags -> Flag Bool
configProfExe       :: Flag Bool,     -- ^Enable profiling in the
                                          -- executables.
    ConfigFlags -> Flag Bool
configProf          :: Flag Bool,     -- ^Enable profiling in the library
                                          -- and executables.
    ConfigFlags -> Flag ProfDetailLevel
configProfDetail    :: Flag ProfDetailLevel, -- ^Profiling detail level
                                          --  in the library and executables.
    ConfigFlags -> Flag ProfDetailLevel
configProfLibDetail :: Flag ProfDetailLevel, -- ^Profiling  detail level
                                                 -- in the library
    ConfigFlags -> [String]
configConfigureArgs :: [String],      -- ^Extra arguments to @configure@
    ConfigFlags -> Flag OptimisationLevel
configOptimization  :: Flag OptimisationLevel,  -- ^Enable optimization.
    ConfigFlags -> Flag PathTemplate
configProgPrefix    :: Flag PathTemplate, -- ^Installed executable prefix.
    ConfigFlags -> Flag PathTemplate
configProgSuffix    :: Flag PathTemplate, -- ^Installed executable suffix.
    ConfigFlags -> InstallDirs (Flag PathTemplate)
configInstallDirs   :: InstallDirs (Flag PathTemplate), -- ^Installation
                                                            -- paths
    ConfigFlags -> Flag String
configScratchDir    :: Flag FilePath,
    ConfigFlags -> [String]
configExtraLibDirs  :: [FilePath],   -- ^ path to search for extra libraries
    ConfigFlags -> [String]
configExtraLibDirsStatic :: [FilePath],   -- ^ path to search for extra
                                              --   libraries when linking
                                              --   fully static executables
    ConfigFlags -> [String]
configExtraFrameworkDirs :: [FilePath],   -- ^ path to search for extra
                                              -- frameworks (OS X only)
    ConfigFlags -> [String]
configExtraIncludeDirs :: [FilePath],   -- ^ path to search for header files
    ConfigFlags -> Flag String
configIPID          :: Flag String, -- ^ explicit IPID to be used
    ConfigFlags -> Flag ComponentId
configCID           :: Flag ComponentId, -- ^ explicit CID to be used
    ConfigFlags -> Flag Bool
configDeterministic :: Flag Bool, -- ^ be as deterministic as possible
                                      -- (e.g., invariant over GHC, database,
                                      -- etc).  Used by the test suite

    ConfigFlags -> Flag String
configDistPref :: Flag FilePath, -- ^"dist" prefix
    ConfigFlags -> Flag String
configCabalFilePath :: Flag FilePath, -- ^ Cabal file to use
    ConfigFlags -> Flag Verbosity
configVerbosity :: Flag Verbosity, -- ^verbosity level
    ConfigFlags -> Flag Bool
configUserInstall :: Flag Bool,    -- ^The --user\/--global flag
    ConfigFlags -> [Maybe PackageDB]
configPackageDBs :: [Maybe PackageDB], -- ^Which package DBs to use
    ConfigFlags -> Flag Bool
configGHCiLib   :: Flag Bool,      -- ^Enable compiling library for GHCi
    ConfigFlags -> Flag Bool
configSplitSections :: Flag Bool,      -- ^Enable -split-sections with GHC
    ConfigFlags -> Flag Bool
configSplitObjs :: Flag Bool,      -- ^Enable -split-objs with GHC
    ConfigFlags -> Flag Bool
configStripExes :: Flag Bool,      -- ^Enable executable stripping
    ConfigFlags -> Flag Bool
configStripLibs :: Flag Bool,      -- ^Enable library stripping
    ConfigFlags -> [PackageVersionConstraint]
configConstraints :: [PackageVersionConstraint], -- ^Additional constraints for
                                                     -- dependencies.
    ConfigFlags -> [GivenComponent]
configDependencies :: [GivenComponent],
      -- ^The packages depended on.
    ConfigFlags -> [(ModuleName, Module)]
configInstantiateWith :: [(ModuleName, Module)],
      -- ^ The requested Backpack instantiation.  If empty, either this
      -- package does not use Backpack, or we just want to typecheck
      -- the indefinite package.
    ConfigFlags -> FlagAssignment
configConfigurationsFlags :: FlagAssignment,
    ConfigFlags -> Flag Bool
configTests               :: Flag Bool, -- ^Enable test suite compilation
    ConfigFlags -> Flag Bool
configBenchmarks          :: Flag Bool, -- ^Enable benchmark compilation
    ConfigFlags -> Flag Bool
configCoverage :: Flag Bool, -- ^Enable program coverage
    ConfigFlags -> Flag Bool
configLibCoverage :: Flag Bool, -- ^Enable program coverage (deprecated)
    ConfigFlags -> Flag Bool
configExactConfiguration  :: Flag Bool,
      -- ^All direct dependencies and flags are provided on the command line by
      -- the user via the '--dependency' and '--flags' options.
    ConfigFlags -> Flag String
configFlagError :: Flag String,
      -- ^Halt and show an error message indicating an error in flag assignment
    ConfigFlags -> Flag Bool
configRelocatable :: Flag Bool, -- ^ Enable relocatable package built
    ConfigFlags -> Flag DebugInfoLevel
configDebugInfo :: Flag DebugInfoLevel,  -- ^ Emit debug info.
    ConfigFlags -> Flag DumpBuildInfo
configDumpBuildInfo :: Flag DumpBuildInfo,
      -- ^ Should we dump available build information on build?
      -- Dump build information to disk before attempting to build,
      -- tooling can parse these files and use them to compile the
      -- source files themselves.
    ConfigFlags -> Flag Bool
configUseResponseFiles :: Flag Bool,
      -- ^ Whether to use response files at all. They're used for such tools
      -- as haddock, or ld.
    ConfigFlags -> Flag Bool
configAllowDependingOnPrivateLibs :: Flag Bool
      -- ^ Allow depending on private sublibraries. This is used by external
      -- tools (like cabal-install) so they can add multiple-public-libraries
      -- compatibility to older ghcs by checking visibility externally.
  }
  deriving ((forall x. ConfigFlags -> Rep ConfigFlags x)
-> (forall x. Rep ConfigFlags x -> ConfigFlags)
-> Generic ConfigFlags
forall x. Rep ConfigFlags x -> ConfigFlags
forall x. ConfigFlags -> Rep ConfigFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConfigFlags -> Rep ConfigFlags x
from :: forall x. ConfigFlags -> Rep ConfigFlags x
$cto :: forall x. Rep ConfigFlags x -> ConfigFlags
to :: forall x. Rep ConfigFlags x -> ConfigFlags
Generic, ReadPrec [ConfigFlags]
ReadPrec ConfigFlags
Int -> ReadS ConfigFlags
ReadS [ConfigFlags]
(Int -> ReadS ConfigFlags)
-> ReadS [ConfigFlags]
-> ReadPrec ConfigFlags
-> ReadPrec [ConfigFlags]
-> Read ConfigFlags
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ConfigFlags
readsPrec :: Int -> ReadS ConfigFlags
$creadList :: ReadS [ConfigFlags]
readList :: ReadS [ConfigFlags]
$creadPrec :: ReadPrec ConfigFlags
readPrec :: ReadPrec ConfigFlags
$creadListPrec :: ReadPrec [ConfigFlags]
readListPrec :: ReadPrec [ConfigFlags]
Read, Int -> ConfigFlags -> String -> String
[ConfigFlags] -> String -> String
ConfigFlags -> String
(Int -> ConfigFlags -> String -> String)
-> (ConfigFlags -> String)
-> ([ConfigFlags] -> String -> String)
-> Show ConfigFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> ConfigFlags -> String -> String
showsPrec :: Int -> ConfigFlags -> String -> String
$cshow :: ConfigFlags -> String
show :: ConfigFlags -> String
$cshowList :: [ConfigFlags] -> String -> String
showList :: [ConfigFlags] -> String -> String
Show, Typeable)

instance Binary ConfigFlags
instance Structured ConfigFlags

-- | More convenient version of 'configPrograms'. Results in an
-- 'error' if internal invariant is violated.
configPrograms :: WithCallStack (ConfigFlags -> ProgramDb)
configPrograms :: WithCallStack (ConfigFlags -> ProgramDb)
configPrograms = ProgramDb -> Maybe ProgramDb -> ProgramDb
forall a. a -> Maybe a -> a
fromMaybe (String -> ProgramDb
forall a. HasCallStack => String -> a
error String
"FIXME: remove configPrograms") (Maybe ProgramDb -> ProgramDb)
-> (ConfigFlags -> Maybe ProgramDb) -> ConfigFlags -> ProgramDb
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last' ProgramDb -> ProgramDb)
-> Maybe (Last' ProgramDb) -> Maybe ProgramDb
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Last' ProgramDb -> ProgramDb
forall a. Last' a -> a
getLast'
               (Maybe (Last' ProgramDb) -> Maybe ProgramDb)
-> (ConfigFlags -> Maybe (Last' ProgramDb))
-> ConfigFlags
-> Maybe ProgramDb
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Option' (Last' ProgramDb) -> Maybe (Last' ProgramDb)
forall a. Option' a -> Maybe a
getOption' (Option' (Last' ProgramDb) -> Maybe (Last' ProgramDb))
-> (ConfigFlags -> Option' (Last' ProgramDb))
-> ConfigFlags
-> Maybe (Last' ProgramDb)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfigFlags -> Option' (Last' ProgramDb)
configPrograms_

instance Eq ConfigFlags where
  == :: ConfigFlags -> ConfigFlags -> Bool
(==) ConfigFlags
a ConfigFlags
b =
    -- configPrograms skipped: not user specified, has no Eq instance
    (ConfigFlags -> [(String, String)]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [(String, String)]
configProgramPaths
    Bool -> Bool -> Bool
&& (ConfigFlags -> [(String, [String])]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [(String, [String])]
configProgramArgs
    Bool -> Bool -> Bool
&& (ConfigFlags -> NubList String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> NubList String
configProgramPathExtra
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag CompilerFlavor) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag CompilerFlavor
configHcFlavor
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag String
configHcPath
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag String
configHcPkg
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configVanillaLib
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configProfLib
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configSharedLib
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configStaticLib
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configDynExe
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configFullyStaticExe
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configProfExe
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configProf
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag ProfDetailLevel) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag ProfDetailLevel
configProfDetail
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag ProfDetailLevel) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag ProfDetailLevel
configProfLibDetail
    Bool -> Bool -> Bool
&& (ConfigFlags -> [String]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [String]
configConfigureArgs
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag OptimisationLevel) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag OptimisationLevel
configOptimization
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag PathTemplate) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag PathTemplate
configProgPrefix
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag PathTemplate) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag PathTemplate
configProgSuffix
    Bool -> Bool -> Bool
&& (ConfigFlags -> InstallDirs (Flag PathTemplate)) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> InstallDirs (Flag PathTemplate)
configInstallDirs
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag String
configScratchDir
    Bool -> Bool -> Bool
&& (ConfigFlags -> [String]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [String]
configExtraLibDirs
    Bool -> Bool -> Bool
&& (ConfigFlags -> [String]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [String]
configExtraLibDirsStatic
    Bool -> Bool -> Bool
&& (ConfigFlags -> [String]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [String]
configExtraIncludeDirs
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag String
configIPID
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configDeterministic
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag String
configDistPref
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Verbosity) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Verbosity
configVerbosity
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configUserInstall
    Bool -> Bool -> Bool
&& (ConfigFlags -> [Maybe PackageDB]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [Maybe PackageDB]
configPackageDBs
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configGHCiLib
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configSplitSections
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configSplitObjs
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configStripExes
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configStripLibs
    Bool -> Bool -> Bool
&& (ConfigFlags -> [PackageVersionConstraint]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [PackageVersionConstraint]
configConstraints
    Bool -> Bool -> Bool
&& (ConfigFlags -> [GivenComponent]) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> [GivenComponent]
configDependencies
    Bool -> Bool -> Bool
&& (ConfigFlags -> FlagAssignment) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> FlagAssignment
configConfigurationsFlags
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configTests
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configBenchmarks
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configCoverage
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configLibCoverage
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configExactConfiguration
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag String) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag String
configFlagError
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configRelocatable
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag DebugInfoLevel) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag DebugInfoLevel
configDebugInfo
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag DumpBuildInfo) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag DumpBuildInfo
configDumpBuildInfo
    Bool -> Bool -> Bool
&& (ConfigFlags -> Flag Bool) -> Bool
forall {b}. Eq b => (ConfigFlags -> b) -> Bool
equal ConfigFlags -> Flag Bool
configUseResponseFiles
    where
      equal :: (ConfigFlags -> b) -> Bool
equal ConfigFlags -> b
f = (b -> b -> Bool)
-> (ConfigFlags -> b) -> ConfigFlags -> ConfigFlags -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on b -> b -> Bool
forall a. Eq a => a -> a -> Bool
(==) ConfigFlags -> b
f ConfigFlags
a ConfigFlags
b

configAbsolutePaths :: ConfigFlags -> IO ConfigFlags
configAbsolutePaths :: ConfigFlags -> IO ConfigFlags
configAbsolutePaths ConfigFlags
f =
  (\[Maybe PackageDB]
v -> ConfigFlags
f { configPackageDBs :: [Maybe PackageDB]
configPackageDBs = [Maybe PackageDB]
v })
  ([Maybe PackageDB] -> ConfigFlags)
-> IO [Maybe PackageDB] -> IO ConfigFlags
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` (Maybe PackageDB -> IO (Maybe PackageDB))
-> [Maybe PackageDB] -> IO [Maybe PackageDB]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (IO (Maybe PackageDB)
-> (PackageDB -> IO (Maybe PackageDB))
-> Maybe PackageDB
-> IO (Maybe PackageDB)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe PackageDB -> IO (Maybe PackageDB)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe PackageDB
forall a. Maybe a
Nothing) ((PackageDB -> Maybe PackageDB)
-> IO PackageDB -> IO (Maybe PackageDB)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM PackageDB -> Maybe PackageDB
forall a. a -> Maybe a
Just (IO PackageDB -> IO (Maybe PackageDB))
-> (PackageDB -> IO PackageDB) -> PackageDB -> IO (Maybe PackageDB)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageDB -> IO PackageDB
absolutePackageDBPath))
  (ConfigFlags -> [Maybe PackageDB]
configPackageDBs ConfigFlags
f)

defaultConfigFlags :: ProgramDb -> ConfigFlags
defaultConfigFlags :: ProgramDb -> ConfigFlags
defaultConfigFlags ProgramDb
progDb = ConfigFlags
emptyConfigFlags {
    configArgs :: [String]
configArgs         = [],
    configPrograms_ :: Option' (Last' ProgramDb)
configPrograms_    = Maybe (Last' ProgramDb) -> Option' (Last' ProgramDb)
forall a. Maybe a -> Option' a
Option' (Last' ProgramDb -> Maybe (Last' ProgramDb)
forall a. a -> Maybe a
Just (ProgramDb -> Last' ProgramDb
forall a. a -> Last' a
Last' ProgramDb
progDb)),
    configHcFlavor :: Flag CompilerFlavor
configHcFlavor     = Flag CompilerFlavor
-> (CompilerFlavor -> Flag CompilerFlavor)
-> Maybe CompilerFlavor
-> Flag CompilerFlavor
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Flag CompilerFlavor
forall a. Flag a
NoFlag CompilerFlavor -> Flag CompilerFlavor
forall a. a -> Flag a
Flag Maybe CompilerFlavor
defaultCompilerFlavor,
    configVanillaLib :: Flag Bool
configVanillaLib   = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
True,
    configProfLib :: Flag Bool
configProfLib      = Flag Bool
forall a. Flag a
NoFlag,
    configSharedLib :: Flag Bool
configSharedLib    = Flag Bool
forall a. Flag a
NoFlag,
    configStaticLib :: Flag Bool
configStaticLib    = Flag Bool
forall a. Flag a
NoFlag,
    configDynExe :: Flag Bool
configDynExe       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configFullyStaticExe :: Flag Bool
configFullyStaticExe = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configProfExe :: Flag Bool
configProfExe      = Flag Bool
forall a. Flag a
NoFlag,
    configProf :: Flag Bool
configProf         = Flag Bool
forall a. Flag a
NoFlag,
    configProfDetail :: Flag ProfDetailLevel
configProfDetail   = Flag ProfDetailLevel
forall a. Flag a
NoFlag,
    configProfLibDetail :: Flag ProfDetailLevel
configProfLibDetail= Flag ProfDetailLevel
forall a. Flag a
NoFlag,
    configOptimization :: Flag OptimisationLevel
configOptimization = OptimisationLevel -> Flag OptimisationLevel
forall a. a -> Flag a
Flag OptimisationLevel
NormalOptimisation,
    configProgPrefix :: Flag PathTemplate
configProgPrefix   = PathTemplate -> Flag PathTemplate
forall a. a -> Flag a
Flag (String -> PathTemplate
toPathTemplate String
""),
    configProgSuffix :: Flag PathTemplate
configProgSuffix   = PathTemplate -> Flag PathTemplate
forall a. a -> Flag a
Flag (String -> PathTemplate
toPathTemplate String
""),
    configDistPref :: Flag String
configDistPref     = Flag String
forall a. Flag a
NoFlag,
    configCabalFilePath :: Flag String
configCabalFilePath = Flag String
forall a. Flag a
NoFlag,
    configVerbosity :: Flag Verbosity
configVerbosity    = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    configUserInstall :: Flag Bool
configUserInstall  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,           --TODO: reverse this
#if defined(mingw32_HOST_OS)
    -- See #8062 and GHC #21019.
    configGHCiLib      = Flag False,
#else
    configGHCiLib :: Flag Bool
configGHCiLib      = Flag Bool
forall a. Flag a
NoFlag,
#endif
    configSplitSections :: Flag Bool
configSplitSections = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configSplitObjs :: Flag Bool
configSplitObjs    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False, -- takes longer, so turn off by default
    configStripExes :: Flag Bool
configStripExes    = Flag Bool
forall a. Flag a
NoFlag,
    configStripLibs :: Flag Bool
configStripLibs    = Flag Bool
forall a. Flag a
NoFlag,
    configTests :: Flag Bool
configTests        = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configBenchmarks :: Flag Bool
configBenchmarks   = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configCoverage :: Flag Bool
configCoverage     = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configLibCoverage :: Flag Bool
configLibCoverage  = Flag Bool
forall a. Flag a
NoFlag,
    configExactConfiguration :: Flag Bool
configExactConfiguration = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configFlagError :: Flag String
configFlagError    = Flag String
forall a. Flag a
NoFlag,
    configRelocatable :: Flag Bool
configRelocatable  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    configDebugInfo :: Flag DebugInfoLevel
configDebugInfo    = DebugInfoLevel -> Flag DebugInfoLevel
forall a. a -> Flag a
Flag DebugInfoLevel
NoDebugInfo,
    configDumpBuildInfo :: Flag DumpBuildInfo
configDumpBuildInfo = Flag DumpBuildInfo
forall a. Flag a
NoFlag,
    configUseResponseFiles :: Flag Bool
configUseResponseFiles = Flag Bool
forall a. Flag a
NoFlag
  }

configureCommand :: ProgramDb -> CommandUI ConfigFlags
configureCommand :: ProgramDb -> CommandUI ConfigFlags
configureCommand ProgramDb
progDb = CommandUI
  { commandName :: String
commandName         = String
"configure"
  , commandSynopsis :: String
commandSynopsis     = String
"Prepare to build the package."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Configure how the package is built by setting "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"package (and other) flags.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"The configuration affects several other commands, "
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"including build, test, bench, run, repl.\n"
  , commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_pname -> ProgramDb -> String
programFlagsDescription ProgramDb
progDb
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" configure [FLAGS]\n"
  , commandDefaultFlags :: ConfigFlags
commandDefaultFlags = ProgramDb -> ConfigFlags
defaultConfigFlags ProgramDb
progDb
  , commandOptions :: ShowOrParseArgs -> [OptionField ConfigFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
         ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions ShowOrParseArgs
showOrParseArgs
      [OptionField ConfigFlags]
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (ConfigFlags -> [(String, String)])
-> ([(String, String)] -> ConfigFlags -> ConfigFlags)
-> [OptionField ConfigFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, String)])
-> ([(String, String)] -> flags -> flags)
-> [OptionField flags]
programDbPaths   ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
           ConfigFlags -> [(String, String)]
configProgramPaths (\[(String, String)]
v ConfigFlags
fs -> ConfigFlags
fs { configProgramPaths :: [(String, String)]
configProgramPaths = [(String, String)]
v })
      [OptionField ConfigFlags]
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (ConfigFlags -> [(String, [String])])
-> ([(String, [String])] -> ConfigFlags -> ConfigFlags)
-> [OptionField ConfigFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> flags -> flags)
-> [OptionField flags]
programDbOption ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
           ConfigFlags -> [(String, [String])]
configProgramArgs (\[(String, [String])]
v ConfigFlags
fs -> ConfigFlags
fs { configProgramArgs :: [(String, [String])]
configProgramArgs = [(String, [String])]
v })
      [OptionField ConfigFlags]
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (ConfigFlags -> [(String, [String])])
-> ([(String, [String])] -> ConfigFlags -> ConfigFlags)
-> [OptionField ConfigFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> flags -> flags)
-> [OptionField flags]
programDbOptions ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
           ConfigFlags -> [(String, [String])]
configProgramArgs (\[(String, [String])]
v ConfigFlags
fs -> ConfigFlags
fs { configProgramArgs :: [(String, [String])]
configProgramArgs = [(String, [String])]
v })
  }

-- | Inverse to 'dispModSubstEntry'.
parsecModSubstEntry :: ParsecParser (ModuleName, Module)
parsecModSubstEntry :: ParsecParser (ModuleName, Module)
parsecModSubstEntry = do
    ModuleName
k <- ParsecParser ModuleName
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m ModuleName
parsec
    Char
_ <- Char -> ParsecParser Char
forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'='
    Module
v <- ParsecParser Module
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m Module
parsec
    (ModuleName, Module) -> ParsecParser (ModuleName, Module)
forall a. a -> ParsecParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleName
k, Module
v)

-- | Pretty-print a single entry of a module substitution.
dispModSubstEntry :: (ModuleName, Module) -> Disp.Doc
dispModSubstEntry :: (ModuleName, Module) -> Doc
dispModSubstEntry (ModuleName
k, Module
v) = ModuleName -> Doc
forall a. Pretty a => a -> Doc
pretty ModuleName
k Doc -> Doc -> Doc
<<>> Char -> Doc
Disp.char Char
'=' Doc -> Doc -> Doc
<<>> Module -> Doc
forall a. Pretty a => a -> Doc
pretty Module
v

configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions ShowOrParseArgs
showOrParseArgs =
      [(ConfigFlags -> Flag Verbosity)
-> (Flag Verbosity -> ConfigFlags -> ConfigFlags)
-> OptionField ConfigFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity ConfigFlags -> Flag Verbosity
configVerbosity
       (\Flag Verbosity
v ConfigFlags
flags -> ConfigFlags
flags { configVerbosity :: Flag Verbosity
configVerbosity = Flag Verbosity
v })
      ,(ConfigFlags -> Flag String)
-> (Flag String -> ConfigFlags -> ConfigFlags)
-> ShowOrParseArgs
-> OptionField ConfigFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
         ConfigFlags -> Flag String
configDistPref (\Flag String
d ConfigFlags
flags -> ConfigFlags
flags { configDistPref :: Flag String
configDistPref = Flag String
d })
         ShowOrParseArgs
showOrParseArgs

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag CompilerFlavor)
-> (Flag CompilerFlavor -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag CompilerFlavor)
     (Flag CompilerFlavor -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option [] [String
"compiler"] String
"compiler"
         ConfigFlags -> Flag CompilerFlavor
configHcFlavor (\Flag CompilerFlavor
v ConfigFlags
flags -> ConfigFlags
flags { configHcFlavor :: Flag CompilerFlavor
configHcFlavor = Flag CompilerFlavor
v })
         ([(Flag CompilerFlavor, (String, [String]), String)]
-> MkOptDescr
     (ConfigFlags -> Flag CompilerFlavor)
     (Flag CompilerFlavor -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Eq b =>
[(b, (String, [String]), String)]
-> MkOptDescr (a -> b) (b -> a -> a) a
choiceOpt [ (CompilerFlavor -> Flag CompilerFlavor
forall a. a -> Flag a
Flag CompilerFlavor
GHC,   (String
"g", [String
"ghc"]),   String
"compile with GHC")
                    , (CompilerFlavor -> Flag CompilerFlavor
forall a. a -> Flag a
Flag CompilerFlavor
GHCJS, ([] , [String
"ghcjs"]), String
"compile with GHCJS")
                    , (CompilerFlavor -> Flag CompilerFlavor
forall a. a -> Flag a
Flag CompilerFlavor
UHC,   ([] , [String
"uhc"]),   String
"compile with UHC")
                    -- "haskell-suite" compiler id string will be replaced
                    -- by a more specific one during the configure stage
                    , (CompilerFlavor -> Flag CompilerFlavor
forall a. a -> Flag a
Flag (String -> CompilerFlavor
HaskellSuite String
"haskell-suite"), ([] , [String
"haskell-suite"]),
                        String
"compile with a haskell-suite compiler")])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag String)
-> (Flag String -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"cabal-file"]
         String
"use this Cabal file"
         ConfigFlags -> Flag String
configCabalFilePath (\Flag String
v ConfigFlags
flags -> ConfigFlags
flags { configCabalFilePath :: Flag String
configCabalFilePath = Flag String
v })
         (String
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"PATH")

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag String)
-> (Flag String -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"w" [String
"with-compiler"]
         String
"give the path to a particular compiler"
         ConfigFlags -> Flag String
configHcPath (\Flag String
v ConfigFlags
flags -> ConfigFlags
flags { configHcPath :: Flag String
configHcPath = Flag String
v })
         (String
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"PATH")

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag String)
-> (Flag String -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"with-hc-pkg"]
         String
"give the path to the package tool"
         ConfigFlags -> Flag String
configHcPkg (\Flag String
v ConfigFlags
flags -> ConfigFlags
flags { configHcPkg :: Flag String
configHcPkg = Flag String
v })
         (String
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"PATH")
      ]
   [OptionField ConfigFlags]
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. [a] -> [a] -> [a]
++ (OptionField (InstallDirs (Flag PathTemplate))
 -> OptionField ConfigFlags)
-> [OptionField (InstallDirs (Flag PathTemplate))]
-> [OptionField ConfigFlags]
forall a b. (a -> b) -> [a] -> [b]
map OptionField (InstallDirs (Flag PathTemplate))
-> OptionField ConfigFlags
liftInstallDirs [OptionField (InstallDirs (Flag PathTemplate))]
installDirsOptions
   [OptionField ConfigFlags]
-> [OptionField ConfigFlags] -> [OptionField ConfigFlags]
forall a. [a] -> [a] -> [a]
++ [String
-> [String]
-> String
-> (ConfigFlags -> Flag PathTemplate)
-> (Flag PathTemplate -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag PathTemplate)
     (Flag PathTemplate -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"program-prefix"]
          String
"prefix to be applied to installed executables"
          ConfigFlags -> Flag PathTemplate
configProgPrefix
          (\Flag PathTemplate
v ConfigFlags
flags -> ConfigFlags
flags { configProgPrefix :: Flag PathTemplate
configProgPrefix = Flag PathTemplate
v })
          (String
-> MkOptDescr
     (ConfigFlags -> Flag PathTemplate)
     (Flag PathTemplate -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall {b}.
String
-> String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
reqPathTemplateArgFlag String
"PREFIX")

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag PathTemplate)
-> (Flag PathTemplate -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag PathTemplate)
     (Flag PathTemplate -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"program-suffix"]
          String
"suffix to be applied to installed executables"
          ConfigFlags -> Flag PathTemplate
configProgSuffix (\Flag PathTemplate
v ConfigFlags
flags -> ConfigFlags
flags { configProgSuffix :: Flag PathTemplate
configProgSuffix = Flag PathTemplate
v } )
          (String
-> MkOptDescr
     (ConfigFlags -> Flag PathTemplate)
     (Flag PathTemplate -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall {b}.
String
-> String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
reqPathTemplateArgFlag String
"SUFFIX")

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"library-vanilla"]
         String
"Vanilla libraries"
         ConfigFlags -> Flag Bool
configVanillaLib (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configVanillaLib :: Flag Bool
configVanillaLib = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"p" [String
"library-profiling"]
         String
"Library profiling"
         ConfigFlags -> Flag Bool
configProfLib (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configProfLib :: Flag Bool
configProfLib = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt String
"p" [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"shared"]
         String
"Shared library"
         ConfigFlags -> Flag Bool
configSharedLib (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configSharedLib :: Flag Bool
configSharedLib = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"static"]
         String
"Static library"
         ConfigFlags -> Flag Bool
configStaticLib (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configStaticLib :: Flag Bool
configStaticLib = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"executable-dynamic"]
         String
"Executable dynamic linking"
         ConfigFlags -> Flag Bool
configDynExe (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configDynExe :: Flag Bool
configDynExe = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"executable-static"]
         String
"Executable fully static linking"
         ConfigFlags -> Flag Bool
configFullyStaticExe (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configFullyStaticExe :: Flag Bool
configFullyStaticExe = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"profiling"]
         String
"Executable and library profiling"
         ConfigFlags -> Flag Bool
configProf (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configProf :: Flag Bool
configProf = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"executable-profiling"]
         String
"Executable profiling (DEPRECATED)"
         ConfigFlags -> Flag Bool
configProfExe (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configProfExe :: Flag Bool
configProfExe = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag ProfDetailLevel)
-> (Flag ProfDetailLevel -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag ProfDetailLevel)
     (Flag ProfDetailLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"profiling-detail"]
         (String
"Profiling detail level for executable and library (default, " String -> String -> String
forall a. [a] -> [a] -> [a]
++
          String
"none, exported-functions, toplevel-functions,  all-functions).")
         ConfigFlags -> Flag ProfDetailLevel
configProfDetail (\Flag ProfDetailLevel
v ConfigFlags
flags -> ConfigFlags
flags { configProfDetail :: Flag ProfDetailLevel
configProfDetail = Flag ProfDetailLevel
v })
         (String
-> (String -> Flag ProfDetailLevel)
-> (Flag ProfDetailLevel -> [String])
-> MkOptDescr
     (ConfigFlags -> Flag ProfDetailLevel)
     (Flag ProfDetailLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"level" (ProfDetailLevel -> Flag ProfDetailLevel
forall a. a -> Flag a
Flag (ProfDetailLevel -> Flag ProfDetailLevel)
-> (String -> ProfDetailLevel) -> String -> Flag ProfDetailLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ProfDetailLevel
flagToProfDetailLevel)
                          Flag ProfDetailLevel -> [String]
showProfDetailLevelFlag)

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag ProfDetailLevel)
-> (Flag ProfDetailLevel -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag ProfDetailLevel)
     (Flag ProfDetailLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"library-profiling-detail"]
         String
"Profiling detail level for libraries only."
         ConfigFlags -> Flag ProfDetailLevel
configProfLibDetail (\Flag ProfDetailLevel
v ConfigFlags
flags -> ConfigFlags
flags { configProfLibDetail :: Flag ProfDetailLevel
configProfLibDetail = Flag ProfDetailLevel
v })
         (String
-> (String -> Flag ProfDetailLevel)
-> (Flag ProfDetailLevel -> [String])
-> MkOptDescr
     (ConfigFlags -> Flag ProfDetailLevel)
     (Flag ProfDetailLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"level" (ProfDetailLevel -> Flag ProfDetailLevel
forall a. a -> Flag a
Flag (ProfDetailLevel -> Flag ProfDetailLevel)
-> (String -> ProfDetailLevel) -> String -> Flag ProfDetailLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ProfDetailLevel
flagToProfDetailLevel)
                          Flag ProfDetailLevel -> [String]
showProfDetailLevelFlag)

      ,String
-> (ConfigFlags -> Flag OptimisationLevel)
-> (Flag OptimisationLevel -> ConfigFlags -> ConfigFlags)
-> [(ConfigFlags -> Flag OptimisationLevel)
    -> (Flag OptimisationLevel -> ConfigFlags -> ConfigFlags)
    -> OptDescr ConfigFlags]
-> OptionField ConfigFlags
forall get set a.
String -> get -> set -> [get -> set -> OptDescr a] -> OptionField a
multiOption String
"optimization"
         ConfigFlags -> Flag OptimisationLevel
configOptimization (\Flag OptimisationLevel
v ConfigFlags
flags -> ConfigFlags
flags { configOptimization :: Flag OptimisationLevel
configOptimization = Flag OptimisationLevel
v })
         [String
-> (Maybe String -> Flag OptimisationLevel)
-> (Flag OptimisationLevel -> [Maybe String])
-> MkOptDescr
     (ConfigFlags -> Flag OptimisationLevel)
     (Flag OptimisationLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (Maybe String -> b)
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg' String
"n" (OptimisationLevel -> Flag OptimisationLevel
forall a. a -> Flag a
Flag (OptimisationLevel -> Flag OptimisationLevel)
-> (Maybe String -> OptimisationLevel)
-> Maybe String
-> Flag OptimisationLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe String -> OptimisationLevel
flagToOptimisationLevel)
                     (\Flag OptimisationLevel
f -> case Flag OptimisationLevel
f of
                              Flag OptimisationLevel
NoOptimisation      -> []
                              Flag OptimisationLevel
NormalOptimisation  -> [Maybe String
forall a. Maybe a
Nothing]
                              Flag OptimisationLevel
MaximumOptimisation -> [String -> Maybe String
forall a. a -> Maybe a
Just String
"2"]
                              Flag OptimisationLevel
_                        -> [])
                 String
"O" [String
"enable-optimization",String
"enable-optimisation"]
                 String
"Build with optimization (n is 0--2, default is 1)",
          Flag OptimisationLevel
-> MkOptDescr
     (ConfigFlags -> Flag OptimisationLevel)
     (Flag OptimisationLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (OptimisationLevel -> Flag OptimisationLevel
forall a. a -> Flag a
Flag OptimisationLevel
NoOptimisation) []
                [String
"disable-optimization",String
"disable-optimisation"]
                String
"Build without optimization"
         ]

      ,String
-> (ConfigFlags -> Flag DebugInfoLevel)
-> (Flag DebugInfoLevel -> ConfigFlags -> ConfigFlags)
-> [(ConfigFlags -> Flag DebugInfoLevel)
    -> (Flag DebugInfoLevel -> ConfigFlags -> ConfigFlags)
    -> OptDescr ConfigFlags]
-> OptionField ConfigFlags
forall get set a.
String -> get -> set -> [get -> set -> OptDescr a] -> OptionField a
multiOption String
"debug-info"
         ConfigFlags -> Flag DebugInfoLevel
configDebugInfo (\Flag DebugInfoLevel
v ConfigFlags
flags -> ConfigFlags
flags { configDebugInfo :: Flag DebugInfoLevel
configDebugInfo = Flag DebugInfoLevel
v })
         [String
-> (Maybe String -> Flag DebugInfoLevel)
-> (Flag DebugInfoLevel -> [Maybe String])
-> MkOptDescr
     (ConfigFlags -> Flag DebugInfoLevel)
     (Flag DebugInfoLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (Maybe String -> b)
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg' String
"n" (DebugInfoLevel -> Flag DebugInfoLevel
forall a. a -> Flag a
Flag (DebugInfoLevel -> Flag DebugInfoLevel)
-> (Maybe String -> DebugInfoLevel)
-> Maybe String
-> Flag DebugInfoLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe String -> DebugInfoLevel
flagToDebugInfoLevel)
                     (\Flag DebugInfoLevel
f -> case Flag DebugInfoLevel
f of
                              Flag DebugInfoLevel
NoDebugInfo      -> []
                              Flag DebugInfoLevel
MinimalDebugInfo -> [String -> Maybe String
forall a. a -> Maybe a
Just String
"1"]
                              Flag DebugInfoLevel
NormalDebugInfo  -> [Maybe String
forall a. Maybe a
Nothing]
                              Flag DebugInfoLevel
MaximalDebugInfo -> [String -> Maybe String
forall a. a -> Maybe a
Just String
"3"]
                              Flag DebugInfoLevel
_                     -> [])
                 String
"" [String
"enable-debug-info"]
                 String
"Emit debug info (n is 0--3, default is 0)",
          Flag DebugInfoLevel
-> MkOptDescr
     (ConfigFlags -> Flag DebugInfoLevel)
     (Flag DebugInfoLevel -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (DebugInfoLevel -> Flag DebugInfoLevel
forall a. a -> Flag a
Flag DebugInfoLevel
NoDebugInfo) []
                [String
"disable-debug-info"]
                String
"Don't emit debug info"
         ]

      , String
-> (ConfigFlags -> Flag DumpBuildInfo)
-> (Flag DumpBuildInfo -> ConfigFlags -> ConfigFlags)
-> [(ConfigFlags -> Flag DumpBuildInfo)
    -> (Flag DumpBuildInfo -> ConfigFlags -> ConfigFlags)
    -> OptDescr ConfigFlags]
-> OptionField ConfigFlags
forall get set a.
String -> get -> set -> [get -> set -> OptDescr a] -> OptionField a
multiOption String
"build-info"
         ConfigFlags -> Flag DumpBuildInfo
configDumpBuildInfo
         (\Flag DumpBuildInfo
v ConfigFlags
flags -> ConfigFlags
flags { configDumpBuildInfo :: Flag DumpBuildInfo
configDumpBuildInfo = Flag DumpBuildInfo
v })
         [Flag DumpBuildInfo
-> MkOptDescr
     (ConfigFlags -> Flag DumpBuildInfo)
     (Flag DumpBuildInfo -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (DumpBuildInfo -> Flag DumpBuildInfo
forall a. a -> Flag a
Flag DumpBuildInfo
DumpBuildInfo) []
                [String
"enable-build-info"]
                String
"Enable build information generation during project building",
          Flag DumpBuildInfo
-> MkOptDescr
     (ConfigFlags -> Flag DumpBuildInfo)
     (Flag DumpBuildInfo -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (DumpBuildInfo -> Flag DumpBuildInfo
forall a. a -> Flag a
Flag DumpBuildInfo
NoDumpBuildInfo) []
                [String
"disable-build-info"]
                String
"Disable build information generation during project building"
         ]

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"library-for-ghci"]
         String
"compile library for use with GHCi"
         ConfigFlags -> Flag Bool
configGHCiLib (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configGHCiLib :: Flag Bool
configGHCiLib = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"split-sections"]
         String
"compile library code such that unneeded definitions can be dropped from the final executable (GHC 7.8+)"
         ConfigFlags -> Flag Bool
configSplitSections (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configSplitSections :: Flag Bool
configSplitSections = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"split-objs"]
         String
"split library into smaller objects to reduce binary sizes (GHC 6.6+)"
         ConfigFlags -> Flag Bool
configSplitObjs (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configSplitObjs :: Flag Bool
configSplitObjs = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"executable-stripping"]
         String
"strip executables upon installation to reduce binary sizes"
         ConfigFlags -> Flag Bool
configStripExes (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configStripExes :: Flag Bool
configStripExes = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"library-stripping"]
         String
"strip libraries upon installation to reduce binary sizes"
         ConfigFlags -> Flag Bool
configStripLibs (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configStripLibs :: Flag Bool
configStripLibs = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> [String])
-> ([String] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"configure-option"]
         String
"Extra option for configure"
         ConfigFlags -> [String]
configConfigureArgs (\[String]
v ConfigFlags
flags -> ConfigFlags
flags { configConfigureArgs :: [String]
configConfigureArgs = [String]
v })
         (String
-> (String -> [String])
-> ([String] -> [String])
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"OPT" (\String
x -> [String
x]) [String] -> [String]
forall a. a -> a
id)

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"user-install"]
         String
"doing a per-user installation"
         ConfigFlags -> Flag Bool
configUserInstall (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configUserInstall :: Flag Bool
configUserInstall = Flag Bool
v })
         ((String, [String])
-> (String, [String])
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
(String, [String])
-> (String, [String])
-> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt' ([],[String
"user"]) ([], [String
"global"]))

      ,String
-> [String]
-> String
-> (ConfigFlags -> [Maybe PackageDB])
-> ([Maybe PackageDB] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [Maybe PackageDB])
     ([Maybe PackageDB] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"package-db"]
         (   String
"Append the given package database to the list of package"
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" databases used (to satisfy dependencies and register into)."
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" May be a specific file, 'global' or 'user'. The initial list"
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is ['global'], ['global', 'user'], or ['global', $sandbox],"
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" depending on context. Use 'clear' to reset the list to empty."
          String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" See the user guide for details.")
         ConfigFlags -> [Maybe PackageDB]
configPackageDBs (\[Maybe PackageDB]
v ConfigFlags
flags -> ConfigFlags
flags { configPackageDBs :: [Maybe PackageDB]
configPackageDBs = [Maybe PackageDB]
v })
         (String
-> (String -> [Maybe PackageDB])
-> ([Maybe PackageDB] -> [String])
-> MkOptDescr
     (ConfigFlags -> [Maybe PackageDB])
     ([Maybe PackageDB] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"DB" String -> [Maybe PackageDB]
readPackageDbList [Maybe PackageDB] -> [String]
showPackageDbList)

      ,String
-> [String]
-> String
-> (ConfigFlags -> FlagAssignment)
-> (FlagAssignment -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> FlagAssignment)
     (FlagAssignment -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"f" [String
"flags"]
         String
"Force values for the given flags in Cabal conditionals in the .cabal file.  E.g., --flags=\"debug -usebytestrings\" forces the flag \"debug\" to true and \"usebytestrings\" to false."
         ConfigFlags -> FlagAssignment
configConfigurationsFlags (\FlagAssignment
v ConfigFlags
flags -> ConfigFlags
flags { configConfigurationsFlags :: FlagAssignment
configConfigurationsFlags = FlagAssignment
v })
         (String
-> ReadE FlagAssignment
-> (FlagAssignment -> [String])
-> MkOptDescr
     (ConfigFlags -> FlagAssignment)
     (FlagAssignment -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"FLAGS"
              ((String -> String)
-> ParsecParser FlagAssignment -> ReadE FlagAssignment
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (\String
err -> String
"Invalid flag assignment: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
err) ParsecParser FlagAssignment
forall (m :: * -> *). CabalParsing m => m FlagAssignment
legacyParsecFlagAssignment)
              FlagAssignment -> [String]
legacyShowFlagAssignment')

      ,String
-> [String]
-> String
-> (ConfigFlags -> [String])
-> ([String] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"extra-include-dirs"]
         String
"A list of directories to search for header files"
         ConfigFlags -> [String]
configExtraIncludeDirs (\[String]
v ConfigFlags
flags -> ConfigFlags
flags {configExtraIncludeDirs :: [String]
configExtraIncludeDirs = [String]
v})
         (String
-> (String -> [String])
-> ([String] -> [String])
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"PATH" (\String
x -> [String
x]) [String] -> [String]
forall a. a -> a
id)

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"deterministic"]
         String
"Try to be as deterministic as possible (used by the test suite)"
         ConfigFlags -> Flag Bool
configDeterministic (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags {configDeterministic :: Flag Bool
configDeterministic = Flag Bool
v})
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag String)
-> (Flag String -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"ipid"]
         String
"Installed package ID to compile this package as"
         ConfigFlags -> Flag String
configIPID (\Flag String
v ConfigFlags
flags -> ConfigFlags
flags {configIPID :: Flag String
configIPID = Flag String
v})
         (String
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"IPID")

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag String)
-> (Flag String -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"cid"]
         String
"Installed component ID to compile this component as"
         ((ComponentId -> String) -> Flag ComponentId -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ComponentId -> String
forall a. Pretty a => a -> String
prettyShow (Flag ComponentId -> Flag String)
-> (ConfigFlags -> Flag ComponentId) -> ConfigFlags -> Flag String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfigFlags -> Flag ComponentId
configCID) (\Flag String
v ConfigFlags
flags -> ConfigFlags
flags {configCID :: Flag ComponentId
configCID = (String -> ComponentId) -> Flag String -> Flag ComponentId
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> ComponentId
mkComponentId Flag String
v})
         (String
-> MkOptDescr
     (ConfigFlags -> Flag String)
     (Flag String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"CID")

      ,String
-> [String]
-> String
-> (ConfigFlags -> [String])
-> ([String] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"extra-lib-dirs"]
         String
"A list of directories to search for external libraries"
         ConfigFlags -> [String]
configExtraLibDirs (\[String]
v ConfigFlags
flags -> ConfigFlags
flags {configExtraLibDirs :: [String]
configExtraLibDirs = [String]
v})
         (String
-> (String -> [String])
-> ([String] -> [String])
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"PATH" (\String
x -> [String
x]) [String] -> [String]
forall a. a -> a
id)

      ,String
-> [String]
-> String
-> (ConfigFlags -> [String])
-> ([String] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"extra-lib-dirs-static"]
         String
"A list of directories to search for external libraries when linking fully static executables"
         ConfigFlags -> [String]
configExtraLibDirsStatic (\[String]
v ConfigFlags
flags -> ConfigFlags
flags {configExtraLibDirsStatic :: [String]
configExtraLibDirsStatic = [String]
v})
         (String
-> (String -> [String])
-> ([String] -> [String])
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"PATH" (\String
x -> [String
x]) [String] -> [String]
forall a. a -> a
id)

      ,String
-> [String]
-> String
-> (ConfigFlags -> [String])
-> ([String] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"extra-framework-dirs"]
         String
"A list of directories to search for external frameworks (OS X only)"
         ConfigFlags -> [String]
configExtraFrameworkDirs
         (\[String]
v ConfigFlags
flags -> ConfigFlags
flags {configExtraFrameworkDirs :: [String]
configExtraFrameworkDirs = [String]
v})
         (String
-> (String -> [String])
-> ([String] -> [String])
-> MkOptDescr
     (ConfigFlags -> [String])
     ([String] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"PATH" (\String
x -> [String
x]) [String] -> [String]
forall a. a -> a
id)

      ,String
-> [String]
-> String
-> (ConfigFlags -> NubList String)
-> (NubList String -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> NubList String)
     (NubList String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"extra-prog-path"]
         String
"A list of directories to search for required programs (in addition to the normal search locations)"
         ConfigFlags -> NubList String
configProgramPathExtra (\NubList String
v ConfigFlags
flags -> ConfigFlags
flags {configProgramPathExtra :: NubList String
configProgramPathExtra = NubList String
v})
         (String
-> (String -> NubList String)
-> (NubList String -> [String])
-> MkOptDescr
     (ConfigFlags -> NubList String)
     (NubList String -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"PATH" (\String
x -> [String] -> NubList String
forall a. Ord a => [a] -> NubList a
toNubList [String
x]) NubList String -> [String]
forall a. NubList a -> [a]
fromNubList)

      ,String
-> [String]
-> String
-> (ConfigFlags -> [PackageVersionConstraint])
-> ([PackageVersionConstraint] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [PackageVersionConstraint])
     ([PackageVersionConstraint] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"constraint"]
         String
"A list of additional constraints on the dependencies."
         ConfigFlags -> [PackageVersionConstraint]
configConstraints (\[PackageVersionConstraint]
v ConfigFlags
flags -> ConfigFlags
flags { configConstraints :: [PackageVersionConstraint]
configConstraints = [PackageVersionConstraint]
v})
         (String
-> ReadE [PackageVersionConstraint]
-> ([PackageVersionConstraint] -> [String])
-> MkOptDescr
     (ConfigFlags -> [PackageVersionConstraint])
     ([PackageVersionConstraint] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"DEPENDENCY"
                 ((String -> String)
-> ParsecParser [PackageVersionConstraint]
-> ReadE [PackageVersionConstraint]
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String -> String -> String
forall a b. a -> b -> a
const String
"dependency expected") ((\PackageVersionConstraint
x -> [PackageVersionConstraint
x]) (PackageVersionConstraint -> [PackageVersionConstraint])
-> ParsecParser PackageVersionConstraint
-> ParsecParser [PackageVersionConstraint]
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser PackageVersionConstraint
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m PackageVersionConstraint
parsec))
                 ((PackageVersionConstraint -> String)
-> [PackageVersionConstraint] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map PackageVersionConstraint -> String
forall a. Pretty a => a -> String
prettyShow))

      ,String
-> [String]
-> String
-> (ConfigFlags -> [GivenComponent])
-> ([GivenComponent] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [GivenComponent])
     ([GivenComponent] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"dependency"]
         String
"A list of exact dependencies. E.g., --dependency=\"void=void-0.5.8-177d5cdf20962d0581fe2e4932a6c309\""
         ConfigFlags -> [GivenComponent]
configDependencies (\[GivenComponent]
v ConfigFlags
flags -> ConfigFlags
flags { configDependencies :: [GivenComponent]
configDependencies = [GivenComponent]
v})
         (String
-> ReadE [GivenComponent]
-> ([GivenComponent] -> [String])
-> MkOptDescr
     (ConfigFlags -> [GivenComponent])
     ([GivenComponent] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"NAME[:COMPONENT_NAME]=CID"
                 ((String -> String)
-> ParsecParser [GivenComponent] -> ReadE [GivenComponent]
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String -> String -> String
forall a b. a -> b -> a
const String
"dependency expected") ((\GivenComponent
x -> [GivenComponent
x]) (GivenComponent -> [GivenComponent])
-> ParsecParser GivenComponent -> ParsecParser [GivenComponent]
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecParser GivenComponent
parsecGivenComponent))
                 ((GivenComponent -> String) -> [GivenComponent] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (\(GivenComponent PackageName
pn LibraryName
cn ComponentId
cid) ->
                     PackageName -> String
forall a. Pretty a => a -> String
prettyShow PackageName
pn
                     String -> String -> String
forall a. [a] -> [a] -> [a]
++ case LibraryName
cn of LibraryName
LMainLibName -> String
""
                                   LSubLibName UnqualComponentName
n -> String
":" String -> String -> String
forall a. [a] -> [a] -> [a]
++ UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow UnqualComponentName
n
                     String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ ComponentId -> String
forall a. Pretty a => a -> String
prettyShow ComponentId
cid)))

      ,String
-> [String]
-> String
-> (ConfigFlags -> [(ModuleName, Module)])
-> ([(ModuleName, Module)] -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> [(ModuleName, Module)])
     ([(ModuleName, Module)] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"instantiate-with"]
        String
"A mapping of signature names to concrete module instantiations."
        ConfigFlags -> [(ModuleName, Module)]
configInstantiateWith (\[(ModuleName, Module)]
v ConfigFlags
flags -> ConfigFlags
flags { configInstantiateWith :: [(ModuleName, Module)]
configInstantiateWith = [(ModuleName, Module)]
v  })
        (String
-> ReadE [(ModuleName, Module)]
-> ([(ModuleName, Module)] -> [String])
-> MkOptDescr
     (ConfigFlags -> [(ModuleName, Module)])
     ([(ModuleName, Module)] -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"NAME=MOD"
            ((String -> String)
-> ParsecParser [(ModuleName, Module)]
-> ReadE [(ModuleName, Module)]
forall a. (String -> String) -> ParsecParser a -> ReadE a
parsecToReadE (String
"Cannot parse module substitution: " String -> String -> String
forall a. [a] -> [a] -> [a]
++) (((ModuleName, Module) -> [(ModuleName, Module)])
-> ParsecParser (ModuleName, Module)
-> ParsecParser [(ModuleName, Module)]
forall a b. (a -> b) -> ParsecParser a -> ParsecParser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((ModuleName, Module)
-> [(ModuleName, Module)] -> [(ModuleName, Module)]
forall a. a -> [a] -> [a]
:[]) ParsecParser (ModuleName, Module)
parsecModSubstEntry))
            (((ModuleName, Module) -> String)
-> [(ModuleName, Module)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Style -> Doc -> String
Disp.renderStyle Style
defaultStyle (Doc -> String)
-> ((ModuleName, Module) -> Doc) -> (ModuleName, Module) -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModuleName, Module) -> Doc
dispModSubstEntry)))

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"tests"]
         String
"dependency checking and compilation for test suites listed in the package description file."
         ConfigFlags -> Flag Bool
configTests (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configTests :: Flag Bool
configTests = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"coverage"]
         String
"build package with Haskell Program Coverage. (GHC only)"
         ConfigFlags -> Flag Bool
configCoverage (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configCoverage :: Flag Bool
configCoverage = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"library-coverage"]
         String
"build package with Haskell Program Coverage. (GHC only) (DEPRECATED)"
         ConfigFlags -> Flag Bool
configLibCoverage (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configLibCoverage :: Flag Bool
configLibCoverage = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"exact-configuration"]
         String
"All direct dependencies and flags are provided on the command line."
         ConfigFlags -> Flag Bool
configExactConfiguration
         (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configExactConfiguration :: Flag Bool
configExactConfiguration = Flag Bool
v })
         MkOptDescr
  (ConfigFlags -> Flag Bool)
  (Flag Bool -> ConfigFlags -> ConfigFlags)
  ConfigFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"benchmarks"]
         String
"dependency checking and compilation for benchmarks listed in the package description file."
         ConfigFlags -> Flag Bool
configBenchmarks (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configBenchmarks :: Flag Bool
configBenchmarks = Flag Bool
v })
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"relocatable"]
         String
"building a package that is relocatable. (GHC only)"
         ConfigFlags -> Flag Bool
configRelocatable (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configRelocatable :: Flag Bool
configRelocatable = Flag Bool
v})
         (String
-> String
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"response-files"]
         String
"enable workaround for old versions of programs like \"ar\" that do not support @file arguments"
         ConfigFlags -> Flag Bool
configUseResponseFiles
         (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configUseResponseFiles :: Flag Bool
configUseResponseFiles = Flag Bool
v })
         ((String, [String])
-> (String, [String])
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
forall a.
(String, [String])
-> (String, [String])
-> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt' ([], [String
"disable-response-files"]) ([], []))

      ,String
-> [String]
-> String
-> (ConfigFlags -> Flag Bool)
-> (Flag Bool -> ConfigFlags -> ConfigFlags)
-> MkOptDescr
     (ConfigFlags -> Flag Bool)
     (Flag Bool -> ConfigFlags -> ConfigFlags)
     ConfigFlags
-> OptionField ConfigFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"allow-depending-on-private-libs"]
         (  String
"Allow depending on private libraries. "
         String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If set, the library visibility check MUST be done externally." )
         ConfigFlags -> Flag Bool
configAllowDependingOnPrivateLibs
         (\Flag Bool
v ConfigFlags
flags -> ConfigFlags
flags { configAllowDependingOnPrivateLibs :: Flag Bool
configAllowDependingOnPrivateLibs = Flag Bool
v })
         MkOptDescr
  (ConfigFlags -> Flag Bool)
  (Flag Bool -> ConfigFlags -> ConfigFlags)
  ConfigFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
      ]
  where
    liftInstallDirs :: OptionField (InstallDirs (Flag PathTemplate))
-> OptionField ConfigFlags
liftInstallDirs =
      (ConfigFlags -> InstallDirs (Flag PathTemplate))
-> (InstallDirs (Flag PathTemplate) -> ConfigFlags -> ConfigFlags)
-> OptionField (InstallDirs (Flag PathTemplate))
-> OptionField ConfigFlags
forall b a.
(b -> a) -> (a -> b -> b) -> OptionField a -> OptionField b
liftOption ConfigFlags -> InstallDirs (Flag PathTemplate)
configInstallDirs (\InstallDirs (Flag PathTemplate)
v ConfigFlags
flags -> ConfigFlags
flags { configInstallDirs :: InstallDirs (Flag PathTemplate)
configInstallDirs = InstallDirs (Flag PathTemplate)
v })

    reqPathTemplateArgFlag :: String
-> String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
reqPathTemplateArgFlag String
title String
_sf [String]
_lf String
d b -> Flag PathTemplate
get Flag PathTemplate -> b -> b
set =
      String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
title String
_sf [String]
_lf String
d
        ((PathTemplate -> String) -> Flag PathTemplate -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PathTemplate -> String
fromPathTemplate (Flag PathTemplate -> Flag String)
-> (b -> Flag PathTemplate) -> b -> Flag String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> Flag PathTemplate
get) (Flag PathTemplate -> b -> b
set (Flag PathTemplate -> b -> b)
-> (Flag String -> Flag PathTemplate) -> Flag String -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> PathTemplate) -> Flag String -> Flag PathTemplate
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> PathTemplate
toPathTemplate)

readPackageDbList :: String -> [Maybe PackageDB]
readPackageDbList :: String -> [Maybe PackageDB]
readPackageDbList String
str = [String -> Maybe PackageDB
readPackageDb String
str]

-- | Parse a PackageDB stack entry
--
-- @since 3.7.0.0
readPackageDb :: String -> Maybe PackageDB
readPackageDb :: String -> Maybe PackageDB
readPackageDb String
"clear"  = Maybe PackageDB
forall a. Maybe a
Nothing
readPackageDb String
"global" = PackageDB -> Maybe PackageDB
forall a. a -> Maybe a
Just PackageDB
GlobalPackageDB
readPackageDb String
"user"   = PackageDB -> Maybe PackageDB
forall a. a -> Maybe a
Just PackageDB
UserPackageDB
readPackageDb String
other    = PackageDB -> Maybe PackageDB
forall a. a -> Maybe a
Just (String -> PackageDB
SpecificPackageDB String
other)

showPackageDbList :: [Maybe PackageDB] -> [String]
showPackageDbList :: [Maybe PackageDB] -> [String]
showPackageDbList = (Maybe PackageDB -> String) -> [Maybe PackageDB] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Maybe PackageDB -> String
showPackageDb

-- | Show a PackageDB stack entry
--
-- @since 3.7.0.0
showPackageDb :: Maybe PackageDB -> String
showPackageDb :: Maybe PackageDB -> String
showPackageDb Maybe PackageDB
Nothing                       = String
"clear"
showPackageDb (Just PackageDB
GlobalPackageDB)        = String
"global"
showPackageDb (Just PackageDB
UserPackageDB)          = String
"user"
showPackageDb (Just (SpecificPackageDB String
db)) = String
db

showProfDetailLevelFlag :: Flag ProfDetailLevel -> [String]
showProfDetailLevelFlag :: Flag ProfDetailLevel -> [String]
showProfDetailLevelFlag Flag ProfDetailLevel
NoFlag    = []
showProfDetailLevelFlag (Flag ProfDetailLevel
dl) = [ProfDetailLevel -> String
showProfDetailLevel ProfDetailLevel
dl]

parsecGivenComponent :: ParsecParser GivenComponent
parsecGivenComponent :: ParsecParser GivenComponent
parsecGivenComponent = do
  PackageName
pn <- ParsecParser PackageName
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m PackageName
parsec
  LibraryName
ln <- LibraryName -> ParsecParser LibraryName -> ParsecParser LibraryName
forall (m :: * -> *) a. Alternative m => a -> m a -> m a
P.option LibraryName
LMainLibName (ParsecParser LibraryName -> ParsecParser LibraryName)
-> ParsecParser LibraryName -> ParsecParser LibraryName
forall a b. (a -> b) -> a -> b
$ do
    Char
_ <- Char -> ParsecParser Char
forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
':'
    UnqualComponentName
ucn <- ParsecParser UnqualComponentName
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m UnqualComponentName
parsec
    LibraryName -> ParsecParser LibraryName
forall a. a -> ParsecParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (LibraryName -> ParsecParser LibraryName)
-> LibraryName -> ParsecParser LibraryName
forall a b. (a -> b) -> a -> b
$ if UnqualComponentName -> String
unUnqualComponentName UnqualComponentName
ucn String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== PackageName -> String
unPackageName PackageName
pn
             then LibraryName
LMainLibName
             else UnqualComponentName -> LibraryName
LSubLibName UnqualComponentName
ucn
  Char
_ <- Char -> ParsecParser Char
forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'='
  ComponentId
cid <- ParsecParser ComponentId
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m ComponentId
parsec
  GivenComponent -> ParsecParser GivenComponent
forall a. a -> ParsecParser a
forall (m :: * -> *) a. Monad m => a -> m a
return (GivenComponent -> ParsecParser GivenComponent)
-> GivenComponent -> ParsecParser GivenComponent
forall a b. (a -> b) -> a -> b
$ PackageName -> LibraryName -> ComponentId -> GivenComponent
GivenComponent PackageName
pn LibraryName
ln ComponentId
cid

installDirsOptions :: [OptionField (InstallDirs (Flag PathTemplate))]
installDirsOptions :: [OptionField (InstallDirs (Flag PathTemplate))]
installDirsOptions =
  [ String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"prefix"]
      String
"bake this prefix in preparation of installation"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
prefix (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { prefix :: Flag PathTemplate
prefix = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"bindir"]
      String
"installation directory for executables"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
bindir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { bindir :: Flag PathTemplate
bindir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"libdir"]
      String
"installation directory for libraries"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
libdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { libdir :: Flag PathTemplate
libdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"libsubdir"]
      String
"subdirectory of libdir in which libs are installed"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
libsubdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { libsubdir :: Flag PathTemplate
libsubdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"dynlibdir"]
      String
"installation directory for dynamic libraries"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
dynlibdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { dynlibdir :: Flag PathTemplate
dynlibdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"libexecdir"]
      String
"installation directory for program executables"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
libexecdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { libexecdir :: Flag PathTemplate
libexecdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"libexecsubdir"]
      String
"subdirectory of libexecdir in which private executables are installed"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
libexecsubdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { libexecsubdir :: Flag PathTemplate
libexecsubdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"datadir"]
      String
"installation directory for read-only data"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
datadir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { datadir :: Flag PathTemplate
datadir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"datasubdir"]
      String
"subdirectory of datadir in which data files are installed"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
datasubdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { datasubdir :: Flag PathTemplate
datasubdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"docdir"]
      String
"installation directory for documentation"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
docdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { docdir :: Flag PathTemplate
docdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"htmldir"]
      String
"installation directory for HTML documentation"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
htmldir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { htmldir :: Flag PathTemplate
htmldir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"haddockdir"]
      String
"installation directory for haddock interfaces"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
haddockdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { haddockdir :: Flag PathTemplate
haddockdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg

  , String
-> [String]
-> String
-> (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
-> (Flag PathTemplate
    -> InstallDirs (Flag PathTemplate)
    -> InstallDirs (Flag PathTemplate))
-> MkOptDescr
     (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
     (Flag PathTemplate
      -> InstallDirs (Flag PathTemplate)
      -> InstallDirs (Flag PathTemplate))
     (InstallDirs (Flag PathTemplate))
-> OptionField (InstallDirs (Flag PathTemplate))
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"sysconfdir"]
      String
"installation directory for configuration files"
      InstallDirs (Flag PathTemplate) -> Flag PathTemplate
forall dir. InstallDirs dir -> dir
sysconfdir (\Flag PathTemplate
v InstallDirs (Flag PathTemplate)
flags -> InstallDirs (Flag PathTemplate)
flags { sysconfdir :: Flag PathTemplate
sysconfdir = Flag PathTemplate
v })
      MkOptDescr
  (InstallDirs (Flag PathTemplate) -> Flag PathTemplate)
  (Flag PathTemplate
   -> InstallDirs (Flag PathTemplate)
   -> InstallDirs (Flag PathTemplate))
  (InstallDirs (Flag PathTemplate))
forall {b}.
String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg
  ]
  where
    installDirArg :: String
-> [String]
-> String
-> (b -> Flag PathTemplate)
-> (Flag PathTemplate -> b -> b)
-> OptDescr b
installDirArg String
_sf [String]
_lf String
d b -> Flag PathTemplate
get Flag PathTemplate -> b -> b
set =
      String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"DIR" String
_sf [String]
_lf String
d
        ((PathTemplate -> String) -> Flag PathTemplate -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PathTemplate -> String
fromPathTemplate (Flag PathTemplate -> Flag String)
-> (b -> Flag PathTemplate) -> b -> Flag String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> Flag PathTemplate
get) (Flag PathTemplate -> b -> b
set (Flag PathTemplate -> b -> b)
-> (Flag String -> Flag PathTemplate) -> Flag String -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> PathTemplate) -> Flag String -> Flag PathTemplate
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> PathTemplate
toPathTemplate)

emptyConfigFlags :: ConfigFlags
emptyConfigFlags :: ConfigFlags
emptyConfigFlags = ConfigFlags
forall a. Monoid a => a
mempty

instance Monoid ConfigFlags where
  mempty :: ConfigFlags
mempty = ConfigFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: ConfigFlags -> ConfigFlags -> ConfigFlags
mappend = ConfigFlags -> ConfigFlags -> ConfigFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup ConfigFlags where
  <> :: ConfigFlags -> ConfigFlags -> ConfigFlags
(<>) = ConfigFlags -> ConfigFlags -> ConfigFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Copy flags
-- ------------------------------------------------------------

-- | Flags to @copy@: (destdir, copy-prefix (backwards compat), verbosity)
data CopyFlags = CopyFlags {
    CopyFlags -> Flag CopyDest
copyDest      :: Flag CopyDest,
    CopyFlags -> Flag String
copyDistPref  :: Flag FilePath,
    CopyFlags -> Flag Verbosity
copyVerbosity :: Flag Verbosity,
    -- This is the same hack as in 'buildArgs'.  But I (ezyang) don't
    -- think it's a hack, it's the right way to make hooks more robust
    -- TODO: Stop using this eventually when 'UserHooks' gets changed
    CopyFlags -> [String]
copyArgs :: [String],
    CopyFlags -> Flag String
copyCabalFilePath :: Flag FilePath
  }
  deriving (Int -> CopyFlags -> String -> String
[CopyFlags] -> String -> String
CopyFlags -> String
(Int -> CopyFlags -> String -> String)
-> (CopyFlags -> String)
-> ([CopyFlags] -> String -> String)
-> Show CopyFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> CopyFlags -> String -> String
showsPrec :: Int -> CopyFlags -> String -> String
$cshow :: CopyFlags -> String
show :: CopyFlags -> String
$cshowList :: [CopyFlags] -> String -> String
showList :: [CopyFlags] -> String -> String
Show, (forall x. CopyFlags -> Rep CopyFlags x)
-> (forall x. Rep CopyFlags x -> CopyFlags) -> Generic CopyFlags
forall x. Rep CopyFlags x -> CopyFlags
forall x. CopyFlags -> Rep CopyFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CopyFlags -> Rep CopyFlags x
from :: forall x. CopyFlags -> Rep CopyFlags x
$cto :: forall x. Rep CopyFlags x -> CopyFlags
to :: forall x. Rep CopyFlags x -> CopyFlags
Generic)

defaultCopyFlags :: CopyFlags
defaultCopyFlags :: CopyFlags
defaultCopyFlags  = CopyFlags {
    copyDest :: Flag CopyDest
copyDest      = CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag CopyDest
NoCopyDest,
    copyDistPref :: Flag String
copyDistPref  = Flag String
forall a. Flag a
NoFlag,
    copyVerbosity :: Flag Verbosity
copyVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    copyArgs :: [String]
copyArgs      = [],
    copyCabalFilePath :: Flag String
copyCabalFilePath = Flag String
forall a. Monoid a => a
mempty
  }

copyCommand :: CommandUI CopyFlags
copyCommand :: CommandUI CopyFlags
copyCommand = CommandUI
  { commandName :: String
commandName         = String
"copy"
  , commandSynopsis :: String
commandSynopsis     = String
"Copy the files of all/specific components to install locations."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
          String
"Components encompass executables and libraries. "
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Does not call register, and allows a prefix at install time. "
       String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Without the --destdir flag, configure determines location.\n"
  , commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
       String
"Examples:\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" copy           "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    All the components in the package\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" copy foo       "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    A component (i.e. lib, exe, test suite)"
  , commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"copy" ([String] -> String -> String) -> [String] -> String -> String
forall a b. (a -> b) -> a -> b
$
      [ String
"[FLAGS]"
      , String
"COMPONENTS [FLAGS]"
      ]
  , commandDefaultFlags :: CopyFlags
commandDefaultFlags = CopyFlags
defaultCopyFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField CopyFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs -> case ShowOrParseArgs
showOrParseArgs of
      ShowOrParseArgs
ShowArgs -> (OptionField CopyFlags -> Bool)
-> [OptionField CopyFlags] -> [OptionField CopyFlags]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String
"target-package-db"])
                          (String -> Bool)
-> (OptionField CopyFlags -> String)
-> OptionField CopyFlags
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OptionField CopyFlags -> String
forall a. OptionField a -> String
optionName) ([OptionField CopyFlags] -> [OptionField CopyFlags])
-> [OptionField CopyFlags] -> [OptionField CopyFlags]
forall a b. (a -> b) -> a -> b
$ ShowOrParseArgs -> [OptionField CopyFlags]
copyOptions ShowOrParseArgs
ShowArgs
      ShowOrParseArgs
ParseArgs -> ShowOrParseArgs -> [OptionField CopyFlags]
copyOptions ShowOrParseArgs
ParseArgs
}

copyOptions ::  ShowOrParseArgs -> [OptionField CopyFlags]
copyOptions :: ShowOrParseArgs -> [OptionField CopyFlags]
copyOptions ShowOrParseArgs
showOrParseArgs =
  [(CopyFlags -> Flag Verbosity)
-> (Flag Verbosity -> CopyFlags -> CopyFlags)
-> OptionField CopyFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity CopyFlags -> Flag Verbosity
copyVerbosity (\Flag Verbosity
v CopyFlags
flags -> CopyFlags
flags { copyVerbosity :: Flag Verbosity
copyVerbosity = Flag Verbosity
v })

  ,(CopyFlags -> Flag String)
-> (Flag String -> CopyFlags -> CopyFlags)
-> ShowOrParseArgs
-> OptionField CopyFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
    CopyFlags -> Flag String
copyDistPref (\Flag String
d CopyFlags
flags -> CopyFlags
flags { copyDistPref :: Flag String
copyDistPref = Flag String
d })
    ShowOrParseArgs
showOrParseArgs

  ,String
-> [String]
-> String
-> (CopyFlags -> Flag CopyDest)
-> (Flag CopyDest -> CopyFlags -> CopyFlags)
-> MkOptDescr
     (CopyFlags -> Flag CopyDest)
     (Flag CopyDest -> CopyFlags -> CopyFlags)
     CopyFlags
-> OptionField CopyFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"destdir"]
    String
"directory to copy files to, prepended to installation directories"
    CopyFlags -> Flag CopyDest
copyDest (\Flag CopyDest
v CopyFlags
flags -> case CopyFlags -> Flag CopyDest
copyDest CopyFlags
flags of
                 Flag (CopyToDb String
_) -> String -> CopyFlags
forall a. HasCallStack => String -> a
error String
"Use either 'destdir' or 'target-package-db'."
                 Flag CopyDest
_ -> CopyFlags
flags { copyDest :: Flag CopyDest
copyDest = Flag CopyDest
v })
    (String
-> ReadE (Flag CopyDest)
-> (Flag CopyDest -> [String])
-> MkOptDescr
     (CopyFlags -> Flag CopyDest)
     (Flag CopyDest -> CopyFlags -> CopyFlags)
     CopyFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"DIR" ((String -> Flag CopyDest) -> ReadE (Flag CopyDest)
forall a. (String -> a) -> ReadE a
succeedReadE (CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag (CopyDest -> Flag CopyDest)
-> (String -> CopyDest) -> String -> Flag CopyDest
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CopyDest
CopyTo))
      (\Flag CopyDest
f -> case Flag CopyDest
f of Flag (CopyTo String
p) -> [String
p]; Flag CopyDest
_ -> []))

  ,String
-> [String]
-> String
-> (CopyFlags -> Flag CopyDest)
-> (Flag CopyDest -> CopyFlags -> CopyFlags)
-> MkOptDescr
     (CopyFlags -> Flag CopyDest)
     (Flag CopyDest -> CopyFlags -> CopyFlags)
     CopyFlags
-> OptionField CopyFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"target-package-db"]
    String
"package database to copy files into. Required when using ${pkgroot} prefix."
    CopyFlags -> Flag CopyDest
copyDest (\Flag CopyDest
v CopyFlags
flags -> case CopyFlags -> Flag CopyDest
copyDest CopyFlags
flags of
                 Flag CopyDest
NoFlag -> CopyFlags
flags { copyDest :: Flag CopyDest
copyDest = Flag CopyDest
v }
                 Flag CopyDest
NoCopyDest -> CopyFlags
flags { copyDest :: Flag CopyDest
copyDest = Flag CopyDest
v }
                 Flag CopyDest
_ -> String -> CopyFlags
forall a. HasCallStack => String -> a
error String
"Use either 'destdir' or 'target-package-db'.")
    (String
-> ReadE (Flag CopyDest)
-> (Flag CopyDest -> [String])
-> MkOptDescr
     (CopyFlags -> Flag CopyDest)
     (Flag CopyDest -> CopyFlags -> CopyFlags)
     CopyFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"DATABASE" ((String -> Flag CopyDest) -> ReadE (Flag CopyDest)
forall a. (String -> a) -> ReadE a
succeedReadE (CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag (CopyDest -> Flag CopyDest)
-> (String -> CopyDest) -> String -> Flag CopyDest
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CopyDest
CopyToDb))
      (\Flag CopyDest
f -> case Flag CopyDest
f of Flag (CopyToDb String
p) -> [String
p]; Flag CopyDest
_ -> []))
  ]

emptyCopyFlags :: CopyFlags
emptyCopyFlags :: CopyFlags
emptyCopyFlags = CopyFlags
forall a. Monoid a => a
mempty

instance Monoid CopyFlags where
  mempty :: CopyFlags
mempty = CopyFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: CopyFlags -> CopyFlags -> CopyFlags
mappend = CopyFlags -> CopyFlags -> CopyFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup CopyFlags where
  <> :: CopyFlags -> CopyFlags -> CopyFlags
(<>) = CopyFlags -> CopyFlags -> CopyFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Install flags
-- ------------------------------------------------------------

-- | Flags to @install@: (package db, verbosity)
data InstallFlags = InstallFlags {
    InstallFlags -> Flag PackageDB
installPackageDB :: Flag PackageDB,
    InstallFlags -> Flag CopyDest
installDest      :: Flag CopyDest,
    InstallFlags -> Flag String
installDistPref  :: Flag FilePath,
    InstallFlags -> Flag Bool
installUseWrapper :: Flag Bool,
    InstallFlags -> Flag Bool
installInPlace    :: Flag Bool,
    InstallFlags -> Flag Verbosity
installVerbosity :: Flag Verbosity,
    -- this is only here, because we can not
    -- change the hooks API.
    InstallFlags -> Flag String
installCabalFilePath :: Flag FilePath
  }
  deriving (Int -> InstallFlags -> String -> String
[InstallFlags] -> String -> String
InstallFlags -> String
(Int -> InstallFlags -> String -> String)
-> (InstallFlags -> String)
-> ([InstallFlags] -> String -> String)
-> Show InstallFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> InstallFlags -> String -> String
showsPrec :: Int -> InstallFlags -> String -> String
$cshow :: InstallFlags -> String
show :: InstallFlags -> String
$cshowList :: [InstallFlags] -> String -> String
showList :: [InstallFlags] -> String -> String
Show, (forall x. InstallFlags -> Rep InstallFlags x)
-> (forall x. Rep InstallFlags x -> InstallFlags)
-> Generic InstallFlags
forall x. Rep InstallFlags x -> InstallFlags
forall x. InstallFlags -> Rep InstallFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InstallFlags -> Rep InstallFlags x
from :: forall x. InstallFlags -> Rep InstallFlags x
$cto :: forall x. Rep InstallFlags x -> InstallFlags
to :: forall x. Rep InstallFlags x -> InstallFlags
Generic)

defaultInstallFlags :: InstallFlags
defaultInstallFlags :: InstallFlags
defaultInstallFlags  = InstallFlags {
    installPackageDB :: Flag PackageDB
installPackageDB = Flag PackageDB
forall a. Flag a
NoFlag,
    installDest :: Flag CopyDest
installDest      = CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag CopyDest
NoCopyDest,
    installDistPref :: Flag String
installDistPref  = Flag String
forall a. Flag a
NoFlag,
    installUseWrapper :: Flag Bool
installUseWrapper = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installInPlace :: Flag Bool
installInPlace    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    installVerbosity :: Flag Verbosity
installVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    installCabalFilePath :: Flag String
installCabalFilePath = Flag String
forall a. Monoid a => a
mempty
  }

installCommand :: CommandUI InstallFlags
installCommand :: CommandUI InstallFlags
installCommand = CommandUI
  { commandName :: String
commandName         = String
"install"
  , commandSynopsis :: String
commandSynopsis     =
      String
"Copy the files into the install locations. Run register."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Unlike the copy command, install calls the register command."
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"If you want to install into a location that is not what was"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"specified in the configure step, use the copy command.\n"
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" install [FLAGS]\n"
  , commandDefaultFlags :: InstallFlags
commandDefaultFlags = InstallFlags
defaultInstallFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField InstallFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs -> case ShowOrParseArgs
showOrParseArgs of
      ShowOrParseArgs
ShowArgs -> (OptionField InstallFlags -> Bool)
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String
"target-package-db"])
                          (String -> Bool)
-> (OptionField InstallFlags -> String)
-> OptionField InstallFlags
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OptionField InstallFlags -> String
forall a. OptionField a -> String
optionName) ([OptionField InstallFlags] -> [OptionField InstallFlags])
-> [OptionField InstallFlags] -> [OptionField InstallFlags]
forall a b. (a -> b) -> a -> b
$ ShowOrParseArgs -> [OptionField InstallFlags]
installOptions ShowOrParseArgs
ShowArgs
      ShowOrParseArgs
ParseArgs -> ShowOrParseArgs -> [OptionField InstallFlags]
installOptions ShowOrParseArgs
ParseArgs
  }

installOptions ::  ShowOrParseArgs -> [OptionField InstallFlags]
installOptions :: ShowOrParseArgs -> [OptionField InstallFlags]
installOptions ShowOrParseArgs
showOrParseArgs =
  [(InstallFlags -> Flag Verbosity)
-> (Flag Verbosity -> InstallFlags -> InstallFlags)
-> OptionField InstallFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity InstallFlags -> Flag Verbosity
installVerbosity (\Flag Verbosity
v InstallFlags
flags -> InstallFlags
flags { installVerbosity :: Flag Verbosity
installVerbosity = Flag Verbosity
v })
  ,(InstallFlags -> Flag String)
-> (Flag String -> InstallFlags -> InstallFlags)
-> ShowOrParseArgs
-> OptionField InstallFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
    InstallFlags -> Flag String
installDistPref (\Flag String
d InstallFlags
flags -> InstallFlags
flags { installDistPref :: Flag String
installDistPref = Flag String
d })
    ShowOrParseArgs
showOrParseArgs

  ,String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"inplace"]
    String
"install the package in the install subdirectory of the dist prefix, so it can be used without being installed"
    InstallFlags -> Flag Bool
installInPlace (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installInPlace :: Flag Bool
installInPlace = Flag Bool
v })
    MkOptDescr
  (InstallFlags -> Flag Bool)
  (Flag Bool -> InstallFlags -> InstallFlags)
  InstallFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (InstallFlags -> Flag Bool)
-> (Flag Bool -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"shell-wrappers"]
    String
"using shell script wrappers around executables"
    InstallFlags -> Flag Bool
installUseWrapper (\Flag Bool
v InstallFlags
flags -> InstallFlags
flags { installUseWrapper :: Flag Bool
installUseWrapper = Flag Bool
v })
    (String
-> String
-> MkOptDescr
     (InstallFlags -> Flag Bool)
     (Flag Bool -> InstallFlags -> InstallFlags)
     InstallFlags
forall a.
String
-> String -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt [] [])

  ,String
-> [String]
-> String
-> (InstallFlags -> Flag PackageDB)
-> (Flag PackageDB -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag PackageDB)
     (Flag PackageDB -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"package-db"] String
""
    InstallFlags -> Flag PackageDB
installPackageDB (\Flag PackageDB
v InstallFlags
flags -> InstallFlags
flags { installPackageDB :: Flag PackageDB
installPackageDB = Flag PackageDB
v })
    ([(Flag PackageDB, (String, [String]), String)]
-> MkOptDescr
     (InstallFlags -> Flag PackageDB)
     (Flag PackageDB -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Eq b =>
[(b, (String, [String]), String)]
-> MkOptDescr (a -> b) (b -> a -> a) a
choiceOpt [ (PackageDB -> Flag PackageDB
forall a. a -> Flag a
Flag PackageDB
UserPackageDB, ([],[String
"user"]),
                   String
"upon configuration register this package in the user's local package database")
               , (PackageDB -> Flag PackageDB
forall a. a -> Flag a
Flag PackageDB
GlobalPackageDB, ([],[String
"global"]),
                   String
"(default) upon configuration register this package in the system-wide package database")])
  ,String
-> [String]
-> String
-> (InstallFlags -> Flag CopyDest)
-> (Flag CopyDest -> InstallFlags -> InstallFlags)
-> MkOptDescr
     (InstallFlags -> Flag CopyDest)
     (Flag CopyDest -> InstallFlags -> InstallFlags)
     InstallFlags
-> OptionField InstallFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"target-package-db"]
    String
"package database to install into. Required when using ${pkgroot} prefix."
    InstallFlags -> Flag CopyDest
installDest (\Flag CopyDest
v InstallFlags
flags -> InstallFlags
flags { installDest :: Flag CopyDest
installDest = Flag CopyDest
v })
    (String
-> ReadE (Flag CopyDest)
-> (Flag CopyDest -> [String])
-> MkOptDescr
     (InstallFlags -> Flag CopyDest)
     (Flag CopyDest -> InstallFlags -> InstallFlags)
     InstallFlags
forall b a.
Monoid b =>
String
-> ReadE b
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg String
"DATABASE" ((String -> Flag CopyDest) -> ReadE (Flag CopyDest)
forall a. (String -> a) -> ReadE a
succeedReadE (CopyDest -> Flag CopyDest
forall a. a -> Flag a
Flag (CopyDest -> Flag CopyDest)
-> (String -> CopyDest) -> String -> Flag CopyDest
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CopyDest
CopyToDb))
      (\Flag CopyDest
f -> case Flag CopyDest
f of Flag (CopyToDb String
p) -> [String
p]; Flag CopyDest
_ -> []))
  ]

emptyInstallFlags :: InstallFlags
emptyInstallFlags :: InstallFlags
emptyInstallFlags = InstallFlags
forall a. Monoid a => a
mempty

instance Monoid InstallFlags where
  mempty :: InstallFlags
mempty = InstallFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: InstallFlags -> InstallFlags -> InstallFlags
mappend = InstallFlags -> InstallFlags -> InstallFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup InstallFlags where
  <> :: InstallFlags -> InstallFlags -> InstallFlags
(<>) = InstallFlags -> InstallFlags -> InstallFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * SDist flags
-- ------------------------------------------------------------

-- | Flags to @sdist@: (snapshot, verbosity)
data SDistFlags = SDistFlags {
    SDistFlags -> Flag Bool
sDistSnapshot    :: Flag Bool,
    SDistFlags -> Flag String
sDistDirectory   :: Flag FilePath,
    SDistFlags -> Flag String
sDistDistPref    :: Flag FilePath,
    SDistFlags -> Flag String
sDistListSources :: Flag FilePath,
    SDistFlags -> Flag Verbosity
sDistVerbosity   :: Flag Verbosity
  }
  deriving (Int -> SDistFlags -> String -> String
[SDistFlags] -> String -> String
SDistFlags -> String
(Int -> SDistFlags -> String -> String)
-> (SDistFlags -> String)
-> ([SDistFlags] -> String -> String)
-> Show SDistFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> SDistFlags -> String -> String
showsPrec :: Int -> SDistFlags -> String -> String
$cshow :: SDistFlags -> String
show :: SDistFlags -> String
$cshowList :: [SDistFlags] -> String -> String
showList :: [SDistFlags] -> String -> String
Show, (forall x. SDistFlags -> Rep SDistFlags x)
-> (forall x. Rep SDistFlags x -> SDistFlags) -> Generic SDistFlags
forall x. Rep SDistFlags x -> SDistFlags
forall x. SDistFlags -> Rep SDistFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SDistFlags -> Rep SDistFlags x
from :: forall x. SDistFlags -> Rep SDistFlags x
$cto :: forall x. Rep SDistFlags x -> SDistFlags
to :: forall x. Rep SDistFlags x -> SDistFlags
Generic, Typeable)

defaultSDistFlags :: SDistFlags
defaultSDistFlags :: SDistFlags
defaultSDistFlags = SDistFlags {
    sDistSnapshot :: Flag Bool
sDistSnapshot    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    sDistDirectory :: Flag String
sDistDirectory   = Flag String
forall a. Monoid a => a
mempty,
    sDistDistPref :: Flag String
sDistDistPref    = Flag String
forall a. Flag a
NoFlag,
    sDistListSources :: Flag String
sDistListSources = Flag String
forall a. Monoid a => a
mempty,
    sDistVerbosity :: Flag Verbosity
sDistVerbosity   = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal
  }

sdistCommand :: CommandUI SDistFlags
sdistCommand :: CommandUI SDistFlags
sdistCommand = CommandUI
  { commandName :: String
commandName         = String
"sdist"
  , commandSynopsis :: String
commandSynopsis     =
      String
"Generate a source distribution file (.tar.gz)."
  , commandDescription :: Maybe (String -> String)
commandDescription  = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" sdist [FLAGS]\n"
  , commandDefaultFlags :: SDistFlags
commandDefaultFlags = SDistFlags
defaultSDistFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField SDistFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
      [(SDistFlags -> Flag Verbosity)
-> (Flag Verbosity -> SDistFlags -> SDistFlags)
-> OptionField SDistFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity SDistFlags -> Flag Verbosity
sDistVerbosity (\Flag Verbosity
v SDistFlags
flags -> SDistFlags
flags { sDistVerbosity :: Flag Verbosity
sDistVerbosity = Flag Verbosity
v })
      ,(SDistFlags -> Flag String)
-> (Flag String -> SDistFlags -> SDistFlags)
-> ShowOrParseArgs
-> OptionField SDistFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
         SDistFlags -> Flag String
sDistDistPref (\Flag String
d SDistFlags
flags -> SDistFlags
flags { sDistDistPref :: Flag String
sDistDistPref = Flag String
d })
         ShowOrParseArgs
showOrParseArgs

      ,String
-> [String]
-> String
-> (SDistFlags -> Flag String)
-> (Flag String -> SDistFlags -> SDistFlags)
-> MkOptDescr
     (SDistFlags -> Flag String)
     (Flag String -> SDistFlags -> SDistFlags)
     SDistFlags
-> OptionField SDistFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"list-sources"]
         String
"Just write a list of the package's sources to a file"
         SDistFlags -> Flag String
sDistListSources (\Flag String
v SDistFlags
flags -> SDistFlags
flags { sDistListSources :: Flag String
sDistListSources = Flag String
v })
         (String
-> MkOptDescr
     (SDistFlags -> Flag String)
     (Flag String -> SDistFlags -> SDistFlags)
     SDistFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"FILE")

      ,String
-> [String]
-> String
-> (SDistFlags -> Flag Bool)
-> (Flag Bool -> SDistFlags -> SDistFlags)
-> MkOptDescr
     (SDistFlags -> Flag Bool)
     (Flag Bool -> SDistFlags -> SDistFlags)
     SDistFlags
-> OptionField SDistFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"snapshot"]
         String
"Produce a snapshot source distribution"
         SDistFlags -> Flag Bool
sDistSnapshot (\Flag Bool
v SDistFlags
flags -> SDistFlags
flags { sDistSnapshot :: Flag Bool
sDistSnapshot = Flag Bool
v })
         MkOptDescr
  (SDistFlags -> Flag Bool)
  (Flag Bool -> SDistFlags -> SDistFlags)
  SDistFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (SDistFlags -> Flag String)
-> (Flag String -> SDistFlags -> SDistFlags)
-> MkOptDescr
     (SDistFlags -> Flag String)
     (Flag String -> SDistFlags -> SDistFlags)
     SDistFlags
-> OptionField SDistFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"output-directory"]
       (String
"Generate a source distribution in the given directory, "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"without creating a tarball")
         SDistFlags -> Flag String
sDistDirectory (\Flag String
v SDistFlags
flags -> SDistFlags
flags { sDistDirectory :: Flag String
sDistDirectory = Flag String
v })
         (String
-> MkOptDescr
     (SDistFlags -> Flag String)
     (Flag String -> SDistFlags -> SDistFlags)
     SDistFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"DIR")
      ]
  }

emptySDistFlags :: SDistFlags
emptySDistFlags :: SDistFlags
emptySDistFlags = SDistFlags
forall a. Monoid a => a
mempty

instance Monoid SDistFlags where
  mempty :: SDistFlags
mempty = SDistFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: SDistFlags -> SDistFlags -> SDistFlags
mappend = SDistFlags -> SDistFlags -> SDistFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup SDistFlags where
  <> :: SDistFlags -> SDistFlags -> SDistFlags
(<>) = SDistFlags -> SDistFlags -> SDistFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Register flags
-- ------------------------------------------------------------

-- | Flags to @register@ and @unregister@: (user package, gen-script,
-- in-place, verbosity)
data RegisterFlags = RegisterFlags {
    RegisterFlags -> Flag PackageDB
regPackageDB   :: Flag PackageDB,
    RegisterFlags -> Flag Bool
regGenScript   :: Flag Bool,
    RegisterFlags -> Flag (Maybe String)
regGenPkgConf  :: Flag (Maybe FilePath),
    RegisterFlags -> Flag Bool
regInPlace     :: Flag Bool,
    RegisterFlags -> Flag String
regDistPref    :: Flag FilePath,
    RegisterFlags -> Flag Bool
regPrintId     :: Flag Bool,
    RegisterFlags -> Flag Verbosity
regVerbosity   :: Flag Verbosity,
    -- Same as in 'buildArgs' and 'copyArgs'
    RegisterFlags -> [String]
regArgs        :: [String],
    RegisterFlags -> Flag String
regCabalFilePath :: Flag FilePath
  }
  deriving (Int -> RegisterFlags -> String -> String
[RegisterFlags] -> String -> String
RegisterFlags -> String
(Int -> RegisterFlags -> String -> String)
-> (RegisterFlags -> String)
-> ([RegisterFlags] -> String -> String)
-> Show RegisterFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> RegisterFlags -> String -> String
showsPrec :: Int -> RegisterFlags -> String -> String
$cshow :: RegisterFlags -> String
show :: RegisterFlags -> String
$cshowList :: [RegisterFlags] -> String -> String
showList :: [RegisterFlags] -> String -> String
Show, (forall x. RegisterFlags -> Rep RegisterFlags x)
-> (forall x. Rep RegisterFlags x -> RegisterFlags)
-> Generic RegisterFlags
forall x. Rep RegisterFlags x -> RegisterFlags
forall x. RegisterFlags -> Rep RegisterFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RegisterFlags -> Rep RegisterFlags x
from :: forall x. RegisterFlags -> Rep RegisterFlags x
$cto :: forall x. Rep RegisterFlags x -> RegisterFlags
to :: forall x. Rep RegisterFlags x -> RegisterFlags
Generic, Typeable)

defaultRegisterFlags :: RegisterFlags
defaultRegisterFlags :: RegisterFlags
defaultRegisterFlags = RegisterFlags {
    regPackageDB :: Flag PackageDB
regPackageDB   = Flag PackageDB
forall a. Flag a
NoFlag,
    regGenScript :: Flag Bool
regGenScript   = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    regGenPkgConf :: Flag (Maybe String)
regGenPkgConf  = Flag (Maybe String)
forall a. Flag a
NoFlag,
    regInPlace :: Flag Bool
regInPlace     = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    regDistPref :: Flag String
regDistPref    = Flag String
forall a. Flag a
NoFlag,
    regPrintId :: Flag Bool
regPrintId     = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    regArgs :: [String]
regArgs        = [],
    regCabalFilePath :: Flag String
regCabalFilePath = Flag String
forall a. Monoid a => a
mempty,
    regVerbosity :: Flag Verbosity
regVerbosity   = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal
  }

registerCommand :: CommandUI RegisterFlags
registerCommand :: CommandUI RegisterFlags
registerCommand = CommandUI
  { commandName :: String
commandName         = String
"register"
  , commandSynopsis :: String
commandSynopsis     =
      String
"Register this package with the compiler."
  , commandDescription :: Maybe (String -> String)
commandDescription  = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" register [FLAGS]\n"
  , commandDefaultFlags :: RegisterFlags
commandDefaultFlags = RegisterFlags
defaultRegisterFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField RegisterFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
      [(RegisterFlags -> Flag Verbosity)
-> (Flag Verbosity -> RegisterFlags -> RegisterFlags)
-> OptionField RegisterFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity RegisterFlags -> Flag Verbosity
regVerbosity (\Flag Verbosity
v RegisterFlags
flags -> RegisterFlags
flags { regVerbosity :: Flag Verbosity
regVerbosity = Flag Verbosity
v })
      ,(RegisterFlags -> Flag String)
-> (Flag String -> RegisterFlags -> RegisterFlags)
-> ShowOrParseArgs
-> OptionField RegisterFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
         RegisterFlags -> Flag String
regDistPref (\Flag String
d RegisterFlags
flags -> RegisterFlags
flags { regDistPref :: Flag String
regDistPref = Flag String
d })
         ShowOrParseArgs
showOrParseArgs

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag PackageDB)
-> (Flag PackageDB -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag PackageDB)
     (Flag PackageDB -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"packageDB"] String
""
         RegisterFlags -> Flag PackageDB
regPackageDB (\Flag PackageDB
v RegisterFlags
flags -> RegisterFlags
flags { regPackageDB :: Flag PackageDB
regPackageDB = Flag PackageDB
v })
         ([(Flag PackageDB, (String, [String]), String)]
-> MkOptDescr
     (RegisterFlags -> Flag PackageDB)
     (Flag PackageDB -> RegisterFlags -> RegisterFlags)
     RegisterFlags
forall b a.
Eq b =>
[(b, (String, [String]), String)]
-> MkOptDescr (a -> b) (b -> a -> a) a
choiceOpt [ (PackageDB -> Flag PackageDB
forall a. a -> Flag a
Flag PackageDB
UserPackageDB, ([],[String
"user"]),
                                String
"upon registration, register this package in the user's local package database")
                    , (PackageDB -> Flag PackageDB
forall a. a -> Flag a
Flag PackageDB
GlobalPackageDB, ([],[String
"global"]),
                                String
"(default)upon registration, register this package in the system-wide package database")])

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag Bool)
-> (Flag Bool -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag Bool)
     (Flag Bool -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"inplace"]
         String
"register the package in the build location, so it can be used without being installed"
         RegisterFlags -> Flag Bool
regInPlace (\Flag Bool
v RegisterFlags
flags -> RegisterFlags
flags { regInPlace :: Flag Bool
regInPlace = Flag Bool
v })
         MkOptDescr
  (RegisterFlags -> Flag Bool)
  (Flag Bool -> RegisterFlags -> RegisterFlags)
  RegisterFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag Bool)
-> (Flag Bool -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag Bool)
     (Flag Bool -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"gen-script"]
         String
"instead of registering, generate a script to register later"
         RegisterFlags -> Flag Bool
regGenScript (\Flag Bool
v RegisterFlags
flags -> RegisterFlags
flags { regGenScript :: Flag Bool
regGenScript = Flag Bool
v })
         MkOptDescr
  (RegisterFlags -> Flag Bool)
  (Flag Bool -> RegisterFlags -> RegisterFlags)
  RegisterFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag (Maybe String))
-> (Flag (Maybe String) -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag (Maybe String))
     (Flag (Maybe String) -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"gen-pkg-config"]
         String
"instead of registering, generate a package registration file/directory"
         RegisterFlags -> Flag (Maybe String)
regGenPkgConf (\Flag (Maybe String)
v RegisterFlags
flags -> RegisterFlags
flags { regGenPkgConf :: Flag (Maybe String)
regGenPkgConf  = Flag (Maybe String)
v })
         (String
-> (Maybe String -> Flag (Maybe String))
-> (Flag (Maybe String) -> [Maybe String])
-> MkOptDescr
     (RegisterFlags -> Flag (Maybe String))
     (Flag (Maybe String) -> RegisterFlags -> RegisterFlags)
     RegisterFlags
forall b a.
Monoid b =>
String
-> (Maybe String -> b)
-> (b -> [Maybe String])
-> MkOptDescr (a -> b) (b -> a -> a) a
optArg' String
"PKG" Maybe String -> Flag (Maybe String)
forall a. a -> Flag a
Flag Flag (Maybe String) -> [Maybe String]
forall a. Flag a -> [a]
flagToList)

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag Bool)
-> (Flag Bool -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag Bool)
     (Flag Bool -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"print-ipid"]
         String
"print the installed package ID calculated for this package"
         RegisterFlags -> Flag Bool
regPrintId (\Flag Bool
v RegisterFlags
flags -> RegisterFlags
flags { regPrintId :: Flag Bool
regPrintId = Flag Bool
v })
         MkOptDescr
  (RegisterFlags -> Flag Bool)
  (Flag Bool -> RegisterFlags -> RegisterFlags)
  RegisterFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
      ]
  }

unregisterCommand :: CommandUI RegisterFlags
unregisterCommand :: CommandUI RegisterFlags
unregisterCommand = CommandUI
  { commandName :: String
commandName         = String
"unregister"
  , commandSynopsis :: String
commandSynopsis     =
      String
"Unregister this package with the compiler."
  , commandDescription :: Maybe (String -> String)
commandDescription  = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" unregister [FLAGS]\n"
  , commandDefaultFlags :: RegisterFlags
commandDefaultFlags = RegisterFlags
defaultRegisterFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField RegisterFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
      [(RegisterFlags -> Flag Verbosity)
-> (Flag Verbosity -> RegisterFlags -> RegisterFlags)
-> OptionField RegisterFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity RegisterFlags -> Flag Verbosity
regVerbosity (\Flag Verbosity
v RegisterFlags
flags -> RegisterFlags
flags { regVerbosity :: Flag Verbosity
regVerbosity = Flag Verbosity
v })
      ,(RegisterFlags -> Flag String)
-> (Flag String -> RegisterFlags -> RegisterFlags)
-> ShowOrParseArgs
-> OptionField RegisterFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
         RegisterFlags -> Flag String
regDistPref (\Flag String
d RegisterFlags
flags -> RegisterFlags
flags { regDistPref :: Flag String
regDistPref = Flag String
d })
          ShowOrParseArgs
showOrParseArgs

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag PackageDB)
-> (Flag PackageDB -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag PackageDB)
     (Flag PackageDB -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"user"] String
""
         RegisterFlags -> Flag PackageDB
regPackageDB (\Flag PackageDB
v RegisterFlags
flags -> RegisterFlags
flags { regPackageDB :: Flag PackageDB
regPackageDB = Flag PackageDB
v })
         ([(Flag PackageDB, (String, [String]), String)]
-> MkOptDescr
     (RegisterFlags -> Flag PackageDB)
     (Flag PackageDB -> RegisterFlags -> RegisterFlags)
     RegisterFlags
forall b a.
Eq b =>
[(b, (String, [String]), String)]
-> MkOptDescr (a -> b) (b -> a -> a) a
choiceOpt [ (PackageDB -> Flag PackageDB
forall a. a -> Flag a
Flag PackageDB
UserPackageDB, ([],[String
"user"]),
                              String
"unregister this package in the user's local package database")
                    , (PackageDB -> Flag PackageDB
forall a. a -> Flag a
Flag PackageDB
GlobalPackageDB, ([],[String
"global"]),
                              String
"(default) unregister this package in the  system-wide package database")])

      ,String
-> [String]
-> String
-> (RegisterFlags -> Flag Bool)
-> (Flag Bool -> RegisterFlags -> RegisterFlags)
-> MkOptDescr
     (RegisterFlags -> Flag Bool)
     (Flag Bool -> RegisterFlags -> RegisterFlags)
     RegisterFlags
-> OptionField RegisterFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"gen-script"]
         String
"Instead of performing the unregister command, generate a script to unregister later"
         RegisterFlags -> Flag Bool
regGenScript (\Flag Bool
v RegisterFlags
flags -> RegisterFlags
flags { regGenScript :: Flag Bool
regGenScript = Flag Bool
v })
         MkOptDescr
  (RegisterFlags -> Flag Bool)
  (Flag Bool -> RegisterFlags -> RegisterFlags)
  RegisterFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
      ]
  }

emptyRegisterFlags :: RegisterFlags
emptyRegisterFlags :: RegisterFlags
emptyRegisterFlags = RegisterFlags
forall a. Monoid a => a
mempty

instance Monoid RegisterFlags where
  mempty :: RegisterFlags
mempty = RegisterFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: RegisterFlags -> RegisterFlags -> RegisterFlags
mappend = RegisterFlags -> RegisterFlags -> RegisterFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup RegisterFlags where
  <> :: RegisterFlags -> RegisterFlags -> RegisterFlags
(<>) = RegisterFlags -> RegisterFlags -> RegisterFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * HsColour flags
-- ------------------------------------------------------------

data HscolourFlags = HscolourFlags {
    HscolourFlags -> Flag String
hscolourCSS         :: Flag FilePath,
    HscolourFlags -> Flag Bool
hscolourExecutables :: Flag Bool,
    HscolourFlags -> Flag Bool
hscolourTestSuites  :: Flag Bool,
    HscolourFlags -> Flag Bool
hscolourBenchmarks  :: Flag Bool,
    HscolourFlags -> Flag Bool
hscolourForeignLibs :: Flag Bool,
    HscolourFlags -> Flag String
hscolourDistPref    :: Flag FilePath,
    HscolourFlags -> Flag Verbosity
hscolourVerbosity   :: Flag Verbosity,
    HscolourFlags -> Flag String
hscolourCabalFilePath :: Flag FilePath
    }
  deriving (Int -> HscolourFlags -> String -> String
[HscolourFlags] -> String -> String
HscolourFlags -> String
(Int -> HscolourFlags -> String -> String)
-> (HscolourFlags -> String)
-> ([HscolourFlags] -> String -> String)
-> Show HscolourFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> HscolourFlags -> String -> String
showsPrec :: Int -> HscolourFlags -> String -> String
$cshow :: HscolourFlags -> String
show :: HscolourFlags -> String
$cshowList :: [HscolourFlags] -> String -> String
showList :: [HscolourFlags] -> String -> String
Show, (forall x. HscolourFlags -> Rep HscolourFlags x)
-> (forall x. Rep HscolourFlags x -> HscolourFlags)
-> Generic HscolourFlags
forall x. Rep HscolourFlags x -> HscolourFlags
forall x. HscolourFlags -> Rep HscolourFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HscolourFlags -> Rep HscolourFlags x
from :: forall x. HscolourFlags -> Rep HscolourFlags x
$cto :: forall x. Rep HscolourFlags x -> HscolourFlags
to :: forall x. Rep HscolourFlags x -> HscolourFlags
Generic, Typeable)

emptyHscolourFlags :: HscolourFlags
emptyHscolourFlags :: HscolourFlags
emptyHscolourFlags = HscolourFlags
forall a. Monoid a => a
mempty

defaultHscolourFlags :: HscolourFlags
defaultHscolourFlags :: HscolourFlags
defaultHscolourFlags = HscolourFlags {
    hscolourCSS :: Flag String
hscolourCSS         = Flag String
forall a. Flag a
NoFlag,
    hscolourExecutables :: Flag Bool
hscolourExecutables = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    hscolourTestSuites :: Flag Bool
hscolourTestSuites  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    hscolourBenchmarks :: Flag Bool
hscolourBenchmarks  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    hscolourDistPref :: Flag String
hscolourDistPref    = Flag String
forall a. Flag a
NoFlag,
    hscolourForeignLibs :: Flag Bool
hscolourForeignLibs = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    hscolourVerbosity :: Flag Verbosity
hscolourVerbosity   = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    hscolourCabalFilePath :: Flag String
hscolourCabalFilePath = Flag String
forall a. Monoid a => a
mempty
  }

instance Monoid HscolourFlags where
  mempty :: HscolourFlags
mempty = HscolourFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: HscolourFlags -> HscolourFlags -> HscolourFlags
mappend = HscolourFlags -> HscolourFlags -> HscolourFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup HscolourFlags where
  <> :: HscolourFlags -> HscolourFlags -> HscolourFlags
(<>) = HscolourFlags -> HscolourFlags -> HscolourFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

hscolourCommand :: CommandUI HscolourFlags
hscolourCommand :: CommandUI HscolourFlags
hscolourCommand = CommandUI
  { commandName :: String
commandName         = String
"hscolour"
  , commandSynopsis :: String
commandSynopsis     =
      String
"Generate HsColour colourised code, in HTML format."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just (\String
_ -> String
"Requires the hscolour program.\n")
  , commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ ->
      String
"Deprecated in favour of 'cabal haddock --hyperlink-source'."
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" hscolour [FLAGS]\n"
  , commandDefaultFlags :: HscolourFlags
commandDefaultFlags = HscolourFlags
defaultHscolourFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField HscolourFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
      [(HscolourFlags -> Flag Verbosity)
-> (Flag Verbosity -> HscolourFlags -> HscolourFlags)
-> OptionField HscolourFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity HscolourFlags -> Flag Verbosity
hscolourVerbosity
       (\Flag Verbosity
v HscolourFlags
flags -> HscolourFlags
flags { hscolourVerbosity :: Flag Verbosity
hscolourVerbosity = Flag Verbosity
v })
      ,(HscolourFlags -> Flag String)
-> (Flag String -> HscolourFlags -> HscolourFlags)
-> ShowOrParseArgs
-> OptionField HscolourFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
         HscolourFlags -> Flag String
hscolourDistPref (\Flag String
d HscolourFlags
flags -> HscolourFlags
flags { hscolourDistPref :: Flag String
hscolourDistPref = Flag String
d })
         ShowOrParseArgs
showOrParseArgs

      ,String
-> [String]
-> String
-> (HscolourFlags -> Flag Bool)
-> (Flag Bool -> HscolourFlags -> HscolourFlags)
-> MkOptDescr
     (HscolourFlags -> Flag Bool)
     (Flag Bool -> HscolourFlags -> HscolourFlags)
     HscolourFlags
-> OptionField HscolourFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"executables"]
         String
"Run hscolour for Executables targets"
         HscolourFlags -> Flag Bool
hscolourExecutables (\Flag Bool
v HscolourFlags
flags -> HscolourFlags
flags { hscolourExecutables :: Flag Bool
hscolourExecutables = Flag Bool
v })
         MkOptDescr
  (HscolourFlags -> Flag Bool)
  (Flag Bool -> HscolourFlags -> HscolourFlags)
  HscolourFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (HscolourFlags -> Flag Bool)
-> (Flag Bool -> HscolourFlags -> HscolourFlags)
-> MkOptDescr
     (HscolourFlags -> Flag Bool)
     (Flag Bool -> HscolourFlags -> HscolourFlags)
     HscolourFlags
-> OptionField HscolourFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"tests"]
         String
"Run hscolour for Test Suite targets"
         HscolourFlags -> Flag Bool
hscolourTestSuites (\Flag Bool
v HscolourFlags
flags -> HscolourFlags
flags { hscolourTestSuites :: Flag Bool
hscolourTestSuites = Flag Bool
v })
         MkOptDescr
  (HscolourFlags -> Flag Bool)
  (Flag Bool -> HscolourFlags -> HscolourFlags)
  HscolourFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (HscolourFlags -> Flag Bool)
-> (Flag Bool -> HscolourFlags -> HscolourFlags)
-> MkOptDescr
     (HscolourFlags -> Flag Bool)
     (Flag Bool -> HscolourFlags -> HscolourFlags)
     HscolourFlags
-> OptionField HscolourFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"benchmarks"]
         String
"Run hscolour for Benchmark targets"
         HscolourFlags -> Flag Bool
hscolourBenchmarks (\Flag Bool
v HscolourFlags
flags -> HscolourFlags
flags { hscolourBenchmarks :: Flag Bool
hscolourBenchmarks = Flag Bool
v })
         MkOptDescr
  (HscolourFlags -> Flag Bool)
  (Flag Bool -> HscolourFlags -> HscolourFlags)
  HscolourFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (HscolourFlags -> Flag Bool)
-> (Flag Bool -> HscolourFlags -> HscolourFlags)
-> MkOptDescr
     (HscolourFlags -> Flag Bool)
     (Flag Bool -> HscolourFlags -> HscolourFlags)
     HscolourFlags
-> OptionField HscolourFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"foreign-libraries"]
         String
"Run hscolour for Foreign Library targets"
         HscolourFlags -> Flag Bool
hscolourForeignLibs (\Flag Bool
v HscolourFlags
flags -> HscolourFlags
flags { hscolourForeignLibs :: Flag Bool
hscolourForeignLibs = Flag Bool
v })
         MkOptDescr
  (HscolourFlags -> Flag Bool)
  (Flag Bool -> HscolourFlags -> HscolourFlags)
  HscolourFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (HscolourFlags -> Flag Bool)
-> (Flag Bool -> HscolourFlags -> HscolourFlags)
-> MkOptDescr
     (HscolourFlags -> Flag Bool)
     (Flag Bool -> HscolourFlags -> HscolourFlags)
     HscolourFlags
-> OptionField HscolourFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"all"]
         String
"Run hscolour for all targets"
         (\HscolourFlags
f -> [Flag Bool] -> Flag Bool
allFlags [ HscolourFlags -> Flag Bool
hscolourExecutables HscolourFlags
f
                         , HscolourFlags -> Flag Bool
hscolourTestSuites  HscolourFlags
f
                         , HscolourFlags -> Flag Bool
hscolourBenchmarks  HscolourFlags
f
                         , HscolourFlags -> Flag Bool
hscolourForeignLibs HscolourFlags
f
                         ])
         (\Flag Bool
v HscolourFlags
flags -> HscolourFlags
flags { hscolourExecutables :: Flag Bool
hscolourExecutables = Flag Bool
v
                            , hscolourTestSuites :: Flag Bool
hscolourTestSuites  = Flag Bool
v
                            , hscolourBenchmarks :: Flag Bool
hscolourBenchmarks  = Flag Bool
v
                            , hscolourForeignLibs :: Flag Bool
hscolourForeignLibs = Flag Bool
v
                            })
         MkOptDescr
  (HscolourFlags -> Flag Bool)
  (Flag Bool -> HscolourFlags -> HscolourFlags)
  HscolourFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

      ,String
-> [String]
-> String
-> (HscolourFlags -> Flag String)
-> (Flag String -> HscolourFlags -> HscolourFlags)
-> MkOptDescr
     (HscolourFlags -> Flag String)
     (Flag String -> HscolourFlags -> HscolourFlags)
     HscolourFlags
-> OptionField HscolourFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"css"]
         String
"Use a cascading style sheet"
         HscolourFlags -> Flag String
hscolourCSS (\Flag String
v HscolourFlags
flags -> HscolourFlags
flags { hscolourCSS :: Flag String
hscolourCSS = Flag String
v })
         (String
-> MkOptDescr
     (HscolourFlags -> Flag String)
     (Flag String -> HscolourFlags -> HscolourFlags)
     HscolourFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"PATH")
      ]
  }

-- ------------------------------------------------------------
-- * Haddock flags
-- ------------------------------------------------------------


-- | When we build haddock documentation, there are two cases:
--
-- 1. We build haddocks only for the current development version,
--    intended for local use and not for distribution. In this case,
--    we store the generated documentation in @<dist>/doc/html/<package name>@.
--
-- 2. We build haddocks for intended for uploading them to hackage.
--    In this case, we need to follow the layout that hackage expects
--    from documentation tarballs, and we might also want to use different
--    flags than for development builds, so in this case we store the generated
--    documentation in @<dist>/doc/html/<package id>-docs@.
data HaddockTarget = ForHackage | ForDevelopment deriving (HaddockTarget -> HaddockTarget -> Bool
(HaddockTarget -> HaddockTarget -> Bool)
-> (HaddockTarget -> HaddockTarget -> Bool) -> Eq HaddockTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HaddockTarget -> HaddockTarget -> Bool
== :: HaddockTarget -> HaddockTarget -> Bool
$c/= :: HaddockTarget -> HaddockTarget -> Bool
/= :: HaddockTarget -> HaddockTarget -> Bool
Eq, Int -> HaddockTarget -> String -> String
[HaddockTarget] -> String -> String
HaddockTarget -> String
(Int -> HaddockTarget -> String -> String)
-> (HaddockTarget -> String)
-> ([HaddockTarget] -> String -> String)
-> Show HaddockTarget
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> HaddockTarget -> String -> String
showsPrec :: Int -> HaddockTarget -> String -> String
$cshow :: HaddockTarget -> String
show :: HaddockTarget -> String
$cshowList :: [HaddockTarget] -> String -> String
showList :: [HaddockTarget] -> String -> String
Show, (forall x. HaddockTarget -> Rep HaddockTarget x)
-> (forall x. Rep HaddockTarget x -> HaddockTarget)
-> Generic HaddockTarget
forall x. Rep HaddockTarget x -> HaddockTarget
forall x. HaddockTarget -> Rep HaddockTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HaddockTarget -> Rep HaddockTarget x
from :: forall x. HaddockTarget -> Rep HaddockTarget x
$cto :: forall x. Rep HaddockTarget x -> HaddockTarget
to :: forall x. Rep HaddockTarget x -> HaddockTarget
Generic, Typeable)

instance Binary HaddockTarget
instance Structured HaddockTarget

instance Pretty HaddockTarget where
    pretty :: HaddockTarget -> Doc
pretty HaddockTarget
ForHackage     = String -> Doc
Disp.text String
"for-hackage"
    pretty HaddockTarget
ForDevelopment = String -> Doc
Disp.text String
"for-development"

instance Parsec HaddockTarget where
    parsec :: forall (m :: * -> *). CabalParsing m => m HaddockTarget
parsec = [m HaddockTarget] -> m HaddockTarget
forall (m :: * -> *) a. Alternative m => [m a] -> m a
P.choice [ m HaddockTarget -> m HaddockTarget
forall a. m a -> m a
forall (m :: * -> *) a. Parsing m => m a -> m a
P.try (m HaddockTarget -> m HaddockTarget)
-> m HaddockTarget -> m HaddockTarget
forall a b. (a -> b) -> a -> b
$ String -> m String
forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"for-hackage"     m String -> m HaddockTarget -> m HaddockTarget
forall a b. m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HaddockTarget -> m HaddockTarget
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return HaddockTarget
ForHackage
                      , String -> m String
forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"for-development" m String -> m HaddockTarget -> m HaddockTarget
forall a b. m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HaddockTarget -> m HaddockTarget
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return HaddockTarget
ForDevelopment]

data HaddockFlags = HaddockFlags {
    HaddockFlags -> [(String, String)]
haddockProgramPaths :: [(String, FilePath)],
    HaddockFlags -> [(String, [String])]
haddockProgramArgs  :: [(String, [String])],
    HaddockFlags -> Flag Bool
haddockHoogle       :: Flag Bool,
    HaddockFlags -> Flag Bool
haddockHtml         :: Flag Bool,
    HaddockFlags -> Flag String
haddockHtmlLocation :: Flag String,
    HaddockFlags -> Flag HaddockTarget
haddockForHackage   :: Flag HaddockTarget,
    HaddockFlags -> Flag Bool
haddockExecutables  :: Flag Bool,
    HaddockFlags -> Flag Bool
haddockTestSuites   :: Flag Bool,
    HaddockFlags -> Flag Bool
haddockBenchmarks   :: Flag Bool,
    HaddockFlags -> Flag Bool
haddockForeignLibs  :: Flag Bool,
    HaddockFlags -> Flag Bool
haddockInternal     :: Flag Bool,
    HaddockFlags -> Flag String
haddockCss          :: Flag FilePath,
    HaddockFlags -> Flag Bool
haddockLinkedSource :: Flag Bool,
    HaddockFlags -> Flag Bool
haddockQuickJump    :: Flag Bool,
    HaddockFlags -> Flag String
haddockHscolourCss  :: Flag FilePath,
    HaddockFlags -> Flag PathTemplate
haddockContents     :: Flag PathTemplate,
    HaddockFlags -> Flag String
haddockDistPref     :: Flag FilePath,
    HaddockFlags -> Flag Bool
haddockKeepTempFiles:: Flag Bool,
    HaddockFlags -> Flag Verbosity
haddockVerbosity    :: Flag Verbosity,
    HaddockFlags -> Flag String
haddockCabalFilePath :: Flag FilePath,
    HaddockFlags -> [String]
haddockArgs         :: [String]
  }
  deriving (Int -> HaddockFlags -> String -> String
[HaddockFlags] -> String -> String
HaddockFlags -> String
(Int -> HaddockFlags -> String -> String)
-> (HaddockFlags -> String)
-> ([HaddockFlags] -> String -> String)
-> Show HaddockFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> HaddockFlags -> String -> String
showsPrec :: Int -> HaddockFlags -> String -> String
$cshow :: HaddockFlags -> String
show :: HaddockFlags -> String
$cshowList :: [HaddockFlags] -> String -> String
showList :: [HaddockFlags] -> String -> String
Show, (forall x. HaddockFlags -> Rep HaddockFlags x)
-> (forall x. Rep HaddockFlags x -> HaddockFlags)
-> Generic HaddockFlags
forall x. Rep HaddockFlags x -> HaddockFlags
forall x. HaddockFlags -> Rep HaddockFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HaddockFlags -> Rep HaddockFlags x
from :: forall x. HaddockFlags -> Rep HaddockFlags x
$cto :: forall x. Rep HaddockFlags x -> HaddockFlags
to :: forall x. Rep HaddockFlags x -> HaddockFlags
Generic, Typeable)

defaultHaddockFlags :: HaddockFlags
defaultHaddockFlags :: HaddockFlags
defaultHaddockFlags  = HaddockFlags {
    haddockProgramPaths :: [(String, String)]
haddockProgramPaths = [(String, String)]
forall a. Monoid a => a
mempty,
    haddockProgramArgs :: [(String, [String])]
haddockProgramArgs  = [],
    haddockHoogle :: Flag Bool
haddockHoogle       = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockHtml :: Flag Bool
haddockHtml         = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockHtmlLocation :: Flag String
haddockHtmlLocation = Flag String
forall a. Flag a
NoFlag,
    haddockForHackage :: Flag HaddockTarget
haddockForHackage   = Flag HaddockTarget
forall a. Flag a
NoFlag,
    haddockExecutables :: Flag Bool
haddockExecutables  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockTestSuites :: Flag Bool
haddockTestSuites   = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockBenchmarks :: Flag Bool
haddockBenchmarks   = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockForeignLibs :: Flag Bool
haddockForeignLibs  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockInternal :: Flag Bool
haddockInternal     = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockCss :: Flag String
haddockCss          = Flag String
forall a. Flag a
NoFlag,
    haddockLinkedSource :: Flag Bool
haddockLinkedSource = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockQuickJump :: Flag Bool
haddockQuickJump    = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockHscolourCss :: Flag String
haddockHscolourCss  = Flag String
forall a. Flag a
NoFlag,
    haddockContents :: Flag PathTemplate
haddockContents     = Flag PathTemplate
forall a. Flag a
NoFlag,
    haddockDistPref :: Flag String
haddockDistPref     = Flag String
forall a. Flag a
NoFlag,
    haddockKeepTempFiles :: Flag Bool
haddockKeepTempFiles= Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    haddockVerbosity :: Flag Verbosity
haddockVerbosity    = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    haddockCabalFilePath :: Flag String
haddockCabalFilePath = Flag String
forall a. Monoid a => a
mempty,
    haddockArgs :: [String]
haddockArgs         = [String]
forall a. Monoid a => a
mempty
  }

haddockCommand :: CommandUI HaddockFlags
haddockCommand :: CommandUI HaddockFlags
haddockCommand = CommandUI
  { commandName :: String
commandName         = String
"haddock"
  , commandSynopsis :: String
commandSynopsis     = String
"Generate Haddock HTML documentation."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ ->
      String
"Requires the program haddock, version 2.x.\n"
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"haddock" ([String] -> String -> String) -> [String] -> String -> String
forall a b. (a -> b) -> a -> b
$
      [ String
"[FLAGS]"
      , String
"COMPONENTS [FLAGS]"
      ]
  , commandDefaultFlags :: HaddockFlags
commandDefaultFlags = HaddockFlags
defaultHaddockFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
         ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions ShowOrParseArgs
showOrParseArgs
      [OptionField HaddockFlags]
-> [OptionField HaddockFlags] -> [OptionField HaddockFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (HaddockFlags -> [(String, String)])
-> ([(String, String)] -> HaddockFlags -> HaddockFlags)
-> [OptionField HaddockFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, String)])
-> ([(String, String)] -> flags -> flags)
-> [OptionField flags]
programDbPaths   ProgramDb
progDb ShowOrParseArgs
ParseArgs
             HaddockFlags -> [(String, String)]
haddockProgramPaths (\[(String, String)]
v HaddockFlags
flags -> HaddockFlags
flags { haddockProgramPaths :: [(String, String)]
haddockProgramPaths = [(String, String)]
v})
      [OptionField HaddockFlags]
-> [OptionField HaddockFlags] -> [OptionField HaddockFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (HaddockFlags -> [(String, [String])])
-> ([(String, [String])] -> HaddockFlags -> HaddockFlags)
-> [OptionField HaddockFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> flags -> flags)
-> [OptionField flags]
programDbOption  ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
             HaddockFlags -> [(String, [String])]
haddockProgramArgs (\[(String, [String])]
v HaddockFlags
fs -> HaddockFlags
fs { haddockProgramArgs :: [(String, [String])]
haddockProgramArgs = [(String, [String])]
v })
      [OptionField HaddockFlags]
-> [OptionField HaddockFlags] -> [OptionField HaddockFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (HaddockFlags -> [(String, [String])])
-> ([(String, [String])] -> HaddockFlags -> HaddockFlags)
-> [OptionField HaddockFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> flags -> flags)
-> [OptionField flags]
programDbOptions ProgramDb
progDb ShowOrParseArgs
ParseArgs
             HaddockFlags -> [(String, [String])]
haddockProgramArgs  (\[(String, [String])]
v HaddockFlags
flags -> HaddockFlags
flags { haddockProgramArgs :: [(String, [String])]
haddockProgramArgs = [(String, [String])]
v})
  }
  where
    progDb :: ProgramDb
progDb = Program -> ProgramDb -> ProgramDb
addKnownProgram Program
haddockProgram
             (ProgramDb -> ProgramDb) -> ProgramDb -> ProgramDb
forall a b. (a -> b) -> a -> b
$ Program -> ProgramDb -> ProgramDb
addKnownProgram Program
ghcProgram
             (ProgramDb -> ProgramDb) -> ProgramDb -> ProgramDb
forall a b. (a -> b) -> a -> b
$ ProgramDb
emptyProgramDb

haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags]
haddockOptions ShowOrParseArgs
showOrParseArgs =
  [(HaddockFlags -> Flag Verbosity)
-> (Flag Verbosity -> HaddockFlags -> HaddockFlags)
-> OptionField HaddockFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity HaddockFlags -> Flag Verbosity
haddockVerbosity
   (\Flag Verbosity
v HaddockFlags
flags -> HaddockFlags
flags { haddockVerbosity :: Flag Verbosity
haddockVerbosity = Flag Verbosity
v })
  ,(HaddockFlags -> Flag String)
-> (Flag String -> HaddockFlags -> HaddockFlags)
-> ShowOrParseArgs
-> OptionField HaddockFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
   HaddockFlags -> Flag String
haddockDistPref (\Flag String
d HaddockFlags
flags -> HaddockFlags
flags { haddockDistPref :: Flag String
haddockDistPref = Flag String
d })
   ShowOrParseArgs
showOrParseArgs

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"keep-temp-files"]
   String
"Keep temporary files"
   HaddockFlags -> Flag Bool
haddockKeepTempFiles (\Flag Bool
b HaddockFlags
flags -> HaddockFlags
flags { haddockKeepTempFiles :: Flag Bool
haddockKeepTempFiles = Flag Bool
b })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"hoogle"]
   String
"Generate a hoogle database"
   HaddockFlags -> Flag Bool
haddockHoogle (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockHoogle :: Flag Bool
haddockHoogle = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"html"]
   String
"Generate HTML documentation (the default)"
   HaddockFlags -> Flag Bool
haddockHtml (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockHtml :: Flag Bool
haddockHtml = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag String)
-> (Flag String -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag String)
     (Flag String -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"html-location"]
   String
"Location of HTML documentation for pre-requisite packages"
   HaddockFlags -> Flag String
haddockHtmlLocation (\Flag String
v HaddockFlags
flags -> HaddockFlags
flags { haddockHtmlLocation :: Flag String
haddockHtmlLocation = Flag String
v })
   (String
-> MkOptDescr
     (HaddockFlags -> Flag String)
     (Flag String -> HaddockFlags -> HaddockFlags)
     HaddockFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"URL")

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag HaddockTarget)
-> (Flag HaddockTarget -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag HaddockTarget)
     (Flag HaddockTarget -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"for-hackage"]
   String
"Collection of flags to generate documentation suitable for upload to hackage"
   HaddockFlags -> Flag HaddockTarget
haddockForHackage (\Flag HaddockTarget
v HaddockFlags
flags -> HaddockFlags
flags { haddockForHackage :: Flag HaddockTarget
haddockForHackage = Flag HaddockTarget
v })
   (Flag HaddockTarget
-> MkOptDescr
     (HaddockFlags -> Flag HaddockTarget)
     (Flag HaddockTarget -> HaddockFlags -> HaddockFlags)
     HaddockFlags
forall b a. Eq b => b -> MkOptDescr (a -> b) (b -> a -> a) a
noArg (HaddockTarget -> Flag HaddockTarget
forall a. a -> Flag a
Flag HaddockTarget
ForHackage))

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"executables"]
   String
"Run haddock for Executables targets"
   HaddockFlags -> Flag Bool
haddockExecutables (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockExecutables :: Flag Bool
haddockExecutables = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"tests"]
   String
"Run haddock for Test Suite targets"
   HaddockFlags -> Flag Bool
haddockTestSuites (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockTestSuites :: Flag Bool
haddockTestSuites = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"benchmarks"]
   String
"Run haddock for Benchmark targets"
   HaddockFlags -> Flag Bool
haddockBenchmarks (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockBenchmarks :: Flag Bool
haddockBenchmarks = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"foreign-libraries"]
   String
"Run haddock for Foreign Library targets"
   HaddockFlags -> Flag Bool
haddockForeignLibs (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockForeignLibs :: Flag Bool
haddockForeignLibs = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"all"]
   String
"Run haddock for all targets"
   (\HaddockFlags
f -> [Flag Bool] -> Flag Bool
allFlags [ HaddockFlags -> Flag Bool
haddockExecutables HaddockFlags
f
                   , HaddockFlags -> Flag Bool
haddockTestSuites  HaddockFlags
f
                   , HaddockFlags -> Flag Bool
haddockBenchmarks  HaddockFlags
f
                   , HaddockFlags -> Flag Bool
haddockForeignLibs HaddockFlags
f
                   ])
         (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockExecutables :: Flag Bool
haddockExecutables = Flag Bool
v
                            , haddockTestSuites :: Flag Bool
haddockTestSuites  = Flag Bool
v
                            , haddockBenchmarks :: Flag Bool
haddockBenchmarks  = Flag Bool
v
                            , haddockForeignLibs :: Flag Bool
haddockForeignLibs = Flag Bool
v
                            })
         MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"internal"]
   String
"Run haddock for internal modules and include all symbols"
   HaddockFlags -> Flag Bool
haddockInternal (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockInternal :: Flag Bool
haddockInternal = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag String)
-> (Flag String -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag String)
     (Flag String -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"css"]
   String
"Use PATH as the haddock stylesheet"
   HaddockFlags -> Flag String
haddockCss (\Flag String
v HaddockFlags
flags -> HaddockFlags
flags { haddockCss :: Flag String
haddockCss = Flag String
v })
   (String
-> MkOptDescr
     (HaddockFlags -> Flag String)
     (Flag String -> HaddockFlags -> HaddockFlags)
     HaddockFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"PATH")

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"hyperlink-source",String
"hyperlink-sources",String
"hyperlinked-source"]
   String
"Hyperlink the documentation to the source code"
   HaddockFlags -> Flag Bool
haddockLinkedSource (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockLinkedSource :: Flag Bool
haddockLinkedSource = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag Bool)
-> (Flag Bool -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag Bool)
     (Flag Bool -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"quickjump"]
   String
"Generate an index for interactive documentation navigation"
   HaddockFlags -> Flag Bool
haddockQuickJump (\Flag Bool
v HaddockFlags
flags -> HaddockFlags
flags { haddockQuickJump :: Flag Bool
haddockQuickJump = Flag Bool
v })
   MkOptDescr
  (HaddockFlags -> Flag Bool)
  (Flag Bool -> HaddockFlags -> HaddockFlags)
  HaddockFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag String)
-> (Flag String -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag String)
     (Flag String -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"hscolour-css"]
   String
"Use PATH as the HsColour stylesheet"
   HaddockFlags -> Flag String
haddockHscolourCss (\Flag String
v HaddockFlags
flags -> HaddockFlags
flags { haddockHscolourCss :: Flag String
haddockHscolourCss = Flag String
v })
   (String
-> MkOptDescr
     (HaddockFlags -> Flag String)
     (Flag String -> HaddockFlags -> HaddockFlags)
     HaddockFlags
forall b.
String
-> String
-> [String]
-> String
-> (b -> Flag String)
-> (Flag String -> b -> b)
-> OptDescr b
reqArgFlag String
"PATH")

  ,String
-> [String]
-> String
-> (HaddockFlags -> Flag PathTemplate)
-> (Flag PathTemplate -> HaddockFlags -> HaddockFlags)
-> MkOptDescr
     (HaddockFlags -> Flag PathTemplate)
     (Flag PathTemplate -> HaddockFlags -> HaddockFlags)
     HaddockFlags
-> OptionField HaddockFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"" [String
"contents-location"]
   String
"Bake URL in as the location for the contents page"
   HaddockFlags -> Flag PathTemplate
haddockContents (\Flag PathTemplate
v HaddockFlags
flags -> HaddockFlags
flags { haddockContents :: Flag PathTemplate
haddockContents = Flag PathTemplate
v })
   (String
-> (String -> Flag PathTemplate)
-> (Flag PathTemplate -> [String])
-> MkOptDescr
     (HaddockFlags -> Flag PathTemplate)
     (Flag PathTemplate -> HaddockFlags -> HaddockFlags)
     HaddockFlags
forall b a.
Monoid b =>
String
-> (String -> b)
-> (b -> [String])
-> MkOptDescr (a -> b) (b -> a -> a) a
reqArg' String
"URL"
    (PathTemplate -> Flag PathTemplate
forall a. a -> Flag a
toFlag (PathTemplate -> Flag PathTemplate)
-> (String -> PathTemplate) -> String -> Flag PathTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> PathTemplate
toPathTemplate)
    (Flag String -> [String]
forall a. Flag a -> [a]
flagToList (Flag String -> [String])
-> (Flag PathTemplate -> Flag String)
-> Flag PathTemplate
-> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PathTemplate -> String) -> Flag PathTemplate -> Flag String
forall a b. (a -> b) -> Flag a -> Flag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PathTemplate -> String
fromPathTemplate))
  ]

emptyHaddockFlags :: HaddockFlags
emptyHaddockFlags :: HaddockFlags
emptyHaddockFlags = HaddockFlags
forall a. Monoid a => a
mempty

instance Monoid HaddockFlags where
  mempty :: HaddockFlags
mempty = HaddockFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: HaddockFlags -> HaddockFlags -> HaddockFlags
mappend = HaddockFlags -> HaddockFlags -> HaddockFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup HaddockFlags where
  <> :: HaddockFlags -> HaddockFlags -> HaddockFlags
(<>) = HaddockFlags -> HaddockFlags -> HaddockFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Clean flags
-- ------------------------------------------------------------

data CleanFlags = CleanFlags {
    CleanFlags -> Flag Bool
cleanSaveConf  :: Flag Bool,
    CleanFlags -> Flag String
cleanDistPref  :: Flag FilePath,
    CleanFlags -> Flag Verbosity
cleanVerbosity :: Flag Verbosity,
    CleanFlags -> Flag String
cleanCabalFilePath :: Flag FilePath
  }
  deriving (Int -> CleanFlags -> String -> String
[CleanFlags] -> String -> String
CleanFlags -> String
(Int -> CleanFlags -> String -> String)
-> (CleanFlags -> String)
-> ([CleanFlags] -> String -> String)
-> Show CleanFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> CleanFlags -> String -> String
showsPrec :: Int -> CleanFlags -> String -> String
$cshow :: CleanFlags -> String
show :: CleanFlags -> String
$cshowList :: [CleanFlags] -> String -> String
showList :: [CleanFlags] -> String -> String
Show, (forall x. CleanFlags -> Rep CleanFlags x)
-> (forall x. Rep CleanFlags x -> CleanFlags) -> Generic CleanFlags
forall x. Rep CleanFlags x -> CleanFlags
forall x. CleanFlags -> Rep CleanFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CleanFlags -> Rep CleanFlags x
from :: forall x. CleanFlags -> Rep CleanFlags x
$cto :: forall x. Rep CleanFlags x -> CleanFlags
to :: forall x. Rep CleanFlags x -> CleanFlags
Generic, Typeable)

defaultCleanFlags :: CleanFlags
defaultCleanFlags :: CleanFlags
defaultCleanFlags  = CleanFlags {
    cleanSaveConf :: Flag Bool
cleanSaveConf  = Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False,
    cleanDistPref :: Flag String
cleanDistPref  = Flag String
forall a. Flag a
NoFlag,
    cleanVerbosity :: Flag Verbosity
cleanVerbosity = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    cleanCabalFilePath :: Flag String
cleanCabalFilePath = Flag String
forall a. Monoid a => a
mempty
  }

cleanCommand :: CommandUI CleanFlags
cleanCommand :: CommandUI CleanFlags
cleanCommand = CommandUI
  { commandName :: String
commandName         = String
"clean"
  , commandSynopsis :: String
commandSynopsis     = String
"Clean up after a build."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ ->
      String
"Removes .hi, .o, preprocessed sources, etc.\n"
  , commandNotes :: Maybe (String -> String)
commandNotes        = Maybe (String -> String)
forall a. Maybe a
Nothing
  , commandUsage :: String -> String
commandUsage        = \String
pname ->
      String
"Usage: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" clean [FLAGS]\n"
  , commandDefaultFlags :: CleanFlags
commandDefaultFlags = CleanFlags
defaultCleanFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField CleanFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
      [(CleanFlags -> Flag Verbosity)
-> (Flag Verbosity -> CleanFlags -> CleanFlags)
-> OptionField CleanFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity CleanFlags -> Flag Verbosity
cleanVerbosity (\Flag Verbosity
v CleanFlags
flags -> CleanFlags
flags { cleanVerbosity :: Flag Verbosity
cleanVerbosity = Flag Verbosity
v })
      ,(CleanFlags -> Flag String)
-> (Flag String -> CleanFlags -> CleanFlags)
-> ShowOrParseArgs
-> OptionField CleanFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
         CleanFlags -> Flag String
cleanDistPref (\Flag String
d CleanFlags
flags -> CleanFlags
flags { cleanDistPref :: Flag String
cleanDistPref = Flag String
d })
         ShowOrParseArgs
showOrParseArgs

      ,String
-> [String]
-> String
-> (CleanFlags -> Flag Bool)
-> (Flag Bool -> CleanFlags -> CleanFlags)
-> MkOptDescr
     (CleanFlags -> Flag Bool)
     (Flag Bool -> CleanFlags -> CleanFlags)
     CleanFlags
-> OptionField CleanFlags
forall get set a.
String
-> [String]
-> String
-> get
-> set
-> MkOptDescr get set a
-> OptionField a
option String
"s" [String
"save-configure"]
         String
"Do not remove the configuration file (dist/setup-config) during cleaning.  Saves need to reconfigure."
         CleanFlags -> Flag Bool
cleanSaveConf (\Flag Bool
v CleanFlags
flags -> CleanFlags
flags { cleanSaveConf :: Flag Bool
cleanSaveConf = Flag Bool
v })
         MkOptDescr
  (CleanFlags -> Flag Bool)
  (Flag Bool -> CleanFlags -> CleanFlags)
  CleanFlags
forall a. MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg
      ]
  }

emptyCleanFlags :: CleanFlags
emptyCleanFlags :: CleanFlags
emptyCleanFlags = CleanFlags
forall a. Monoid a => a
mempty

instance Monoid CleanFlags where
  mempty :: CleanFlags
mempty = CleanFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: CleanFlags -> CleanFlags -> CleanFlags
mappend = CleanFlags -> CleanFlags -> CleanFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup CleanFlags where
  <> :: CleanFlags -> CleanFlags -> CleanFlags
(<>) = CleanFlags -> CleanFlags -> CleanFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * Build flags
-- ------------------------------------------------------------

data BuildFlags = BuildFlags {
    BuildFlags -> [(String, String)]
buildProgramPaths :: [(String, FilePath)],
    BuildFlags -> [(String, [String])]
buildProgramArgs :: [(String, [String])],
    BuildFlags -> Flag String
buildDistPref    :: Flag FilePath,
    BuildFlags -> Flag Verbosity
buildVerbosity   :: Flag Verbosity,
    BuildFlags -> Flag (Maybe Int)
buildNumJobs     :: Flag (Maybe Int),
    -- TODO: this one should not be here, it's just that the silly
    -- UserHooks stop us from passing extra info in other ways
    BuildFlags -> [String]
buildArgs :: [String],
    BuildFlags -> Flag String
buildCabalFilePath :: Flag FilePath
  }
  deriving (ReadPrec [BuildFlags]
ReadPrec BuildFlags
Int -> ReadS BuildFlags
ReadS [BuildFlags]
(Int -> ReadS BuildFlags)
-> ReadS [BuildFlags]
-> ReadPrec BuildFlags
-> ReadPrec [BuildFlags]
-> Read BuildFlags
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS BuildFlags
readsPrec :: Int -> ReadS BuildFlags
$creadList :: ReadS [BuildFlags]
readList :: ReadS [BuildFlags]
$creadPrec :: ReadPrec BuildFlags
readPrec :: ReadPrec BuildFlags
$creadListPrec :: ReadPrec [BuildFlags]
readListPrec :: ReadPrec [BuildFlags]
Read, Int -> BuildFlags -> String -> String
[BuildFlags] -> String -> String
BuildFlags -> String
(Int -> BuildFlags -> String -> String)
-> (BuildFlags -> String)
-> ([BuildFlags] -> String -> String)
-> Show BuildFlags
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> BuildFlags -> String -> String
showsPrec :: Int -> BuildFlags -> String -> String
$cshow :: BuildFlags -> String
show :: BuildFlags -> String
$cshowList :: [BuildFlags] -> String -> String
showList :: [BuildFlags] -> String -> String
Show, (forall x. BuildFlags -> Rep BuildFlags x)
-> (forall x. Rep BuildFlags x -> BuildFlags) -> Generic BuildFlags
forall x. Rep BuildFlags x -> BuildFlags
forall x. BuildFlags -> Rep BuildFlags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BuildFlags -> Rep BuildFlags x
from :: forall x. BuildFlags -> Rep BuildFlags x
$cto :: forall x. Rep BuildFlags x -> BuildFlags
to :: forall x. Rep BuildFlags x -> BuildFlags
Generic, Typeable)

defaultBuildFlags :: BuildFlags
defaultBuildFlags :: BuildFlags
defaultBuildFlags  = BuildFlags {
    buildProgramPaths :: [(String, String)]
buildProgramPaths = [(String, String)]
forall a. Monoid a => a
mempty,
    buildProgramArgs :: [(String, [String])]
buildProgramArgs = [],
    buildDistPref :: Flag String
buildDistPref    = Flag String
forall a. Monoid a => a
mempty,
    buildVerbosity :: Flag Verbosity
buildVerbosity   = Verbosity -> Flag Verbosity
forall a. a -> Flag a
Flag Verbosity
normal,
    buildNumJobs :: Flag (Maybe Int)
buildNumJobs     = Flag (Maybe Int)
forall a. Monoid a => a
mempty,
    buildArgs :: [String]
buildArgs        = [],
    buildCabalFilePath :: Flag String
buildCabalFilePath = Flag String
forall a. Monoid a => a
mempty
  }

buildCommand :: ProgramDb -> CommandUI BuildFlags
buildCommand :: ProgramDb -> CommandUI BuildFlags
buildCommand ProgramDb
progDb = CommandUI
  { commandName :: String
commandName         = String
"build"
  , commandSynopsis :: String
commandSynopsis     = String
"Compile all/specific components."
  , commandDescription :: Maybe (String -> String)
commandDescription  = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
_ -> String -> String
wrapText (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
         String
"Components encompass executables, tests, and benchmarks.\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n"
      String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Affected by configuration options, see `configure`.\n"
  , commandNotes :: Maybe (String -> String)
commandNotes        = (String -> String) -> Maybe (String -> String)
forall a. a -> Maybe a
Just ((String -> String) -> Maybe (String -> String))
-> (String -> String) -> Maybe (String -> String)
forall a b. (a -> b) -> a -> b
$ \String
pname ->
       String
"Examples:\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" build           "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    All the components in the package\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"  " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pname String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" build foo       "
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"    A component (i.e. lib, exe, test suite)\n\n"
        String -> String -> String
forall a. [a] -> [a] -> [a]
++ ProgramDb -> String
programFlagsDescription ProgramDb
progDb
--TODO: re-enable once we have support for module/file targets
--        ++ "  " ++ pname ++ " build Foo.Bar   "
--        ++ "    A module\n"
--        ++ "  " ++ pname ++ " build Foo/Bar.hs"
--        ++ "    A file\n\n"
--        ++ "If a target is ambiguous it can be qualified with the component "
--        ++ "name, e.g.\n"
--        ++ "  " ++ pname ++ " build foo:Foo.Bar\n"
--        ++ "  " ++ pname ++ " build testsuite1:Foo/Bar.hs\n"
  , commandUsage :: String -> String
commandUsage        = String -> [String] -> String -> String
usageAlternatives String
"build" ([String] -> String -> String) -> [String] -> String -> String
forall a b. (a -> b) -> a -> b
$
      [ String
"[FLAGS]"
      , String
"COMPONENTS [FLAGS]"
      ]
  , commandDefaultFlags :: BuildFlags
commandDefaultFlags = BuildFlags
defaultBuildFlags
  , commandOptions :: ShowOrParseArgs -> [OptionField BuildFlags]
commandOptions      = \ShowOrParseArgs
showOrParseArgs ->
      [ (BuildFlags -> Flag Verbosity)
-> (Flag Verbosity -> BuildFlags -> BuildFlags)
-> OptionField BuildFlags
forall flags.
(flags -> Flag Verbosity)
-> (Flag Verbosity -> flags -> flags) -> OptionField flags
optionVerbosity
        BuildFlags -> Flag Verbosity
buildVerbosity (\Flag Verbosity
v BuildFlags
flags -> BuildFlags
flags { buildVerbosity :: Flag Verbosity
buildVerbosity = Flag Verbosity
v })

      , (BuildFlags -> Flag String)
-> (Flag String -> BuildFlags -> BuildFlags)
-> ShowOrParseArgs
-> OptionField BuildFlags
forall flags.
(flags -> Flag String)
-> (Flag String -> flags -> flags)
-> ShowOrParseArgs
-> OptionField flags
optionDistPref
        BuildFlags -> Flag String
buildDistPref (\Flag String
d BuildFlags
flags -> BuildFlags
flags { buildDistPref :: Flag String
buildDistPref = Flag String
d }) ShowOrParseArgs
showOrParseArgs
      ]
      [OptionField BuildFlags]
-> [OptionField BuildFlags] -> [OptionField BuildFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb -> ShowOrParseArgs -> [OptionField BuildFlags]
buildOptions ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
  }

buildOptions :: ProgramDb -> ShowOrParseArgs
                -> [OptionField BuildFlags]
buildOptions :: ProgramDb -> ShowOrParseArgs -> [OptionField BuildFlags]
buildOptions ProgramDb
progDb ShowOrParseArgs
showOrParseArgs =
  [ (BuildFlags -> Flag (Maybe Int))
-> (Flag (Maybe Int) -> BuildFlags -> BuildFlags)
-> OptionField BuildFlags
forall flags.
(flags -> Flag (Maybe Int))
-> (Flag (Maybe Int) -> flags -> flags) -> OptionField flags
optionNumJobs
      BuildFlags -> Flag (Maybe Int)
buildNumJobs (\Flag (Maybe Int)
v BuildFlags
flags -> BuildFlags
flags { buildNumJobs :: Flag (Maybe Int)
buildNumJobs = Flag (Maybe Int)
v })
  ]

  [OptionField BuildFlags]
-> [OptionField BuildFlags] -> [OptionField BuildFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (BuildFlags -> [(String, String)])
-> ([(String, String)] -> BuildFlags -> BuildFlags)
-> [OptionField BuildFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, String)])
-> ([(String, String)] -> flags -> flags)
-> [OptionField flags]
programDbPaths ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
       BuildFlags -> [(String, String)]
buildProgramPaths (\[(String, String)]
v BuildFlags
flags -> BuildFlags
flags { buildProgramPaths :: [(String, String)]
buildProgramPaths = [(String, String)]
v})

  [OptionField BuildFlags]
-> [OptionField BuildFlags] -> [OptionField BuildFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (BuildFlags -> [(String, [String])])
-> ([(String, [String])] -> BuildFlags -> BuildFlags)
-> [OptionField BuildFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> flags -> flags)
-> [OptionField flags]
programDbOption ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
       BuildFlags -> [(String, [String])]
buildProgramArgs (\[(String, [String])]
v BuildFlags
fs -> BuildFlags
fs { buildProgramArgs :: [(String, [String])]
buildProgramArgs = [(String, [String])]
v })

  [OptionField BuildFlags]
-> [OptionField BuildFlags] -> [OptionField BuildFlags]
forall a. [a] -> [a] -> [a]
++ ProgramDb
-> ShowOrParseArgs
-> (BuildFlags -> [(String, [String])])
-> ([(String, [String])] -> BuildFlags -> BuildFlags)
-> [OptionField BuildFlags]
forall flags.
ProgramDb
-> ShowOrParseArgs
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> flags -> flags)
-> [OptionField flags]
programDbOptions ProgramDb
progDb ShowOrParseArgs
showOrParseArgs
       BuildFlags -> [(String, [String])]
buildProgramArgs (\[(String, [String])]
v BuildFlags
flags -> BuildFlags
flags { buildProgramArgs :: [(String, [String])]
buildProgramArgs = [(String, [String])]
v})

emptyBuildFlags :: BuildFlags
emptyBuildFlags :: BuildFlags
emptyBuildFlags = BuildFlags
forall a. Monoid a => a
mempty

instance Monoid BuildFlags where
  mempty :: BuildFlags
mempty = BuildFlags
forall a. (Generic a, GMonoid (Rep a)) => a
gmempty
  mappend :: BuildFlags -> BuildFlags -> BuildFlags
mappend = BuildFlags -> BuildFlags -> BuildFlags
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup BuildFlags where
  <> :: BuildFlags -> BuildFlags -> BuildFlags
(<>) = BuildFlags -> BuildFlags -> BuildFlags
forall a. (Generic a, GSemigroup (Rep a)) => a -> a -> a
gmappend

-- ------------------------------------------------------------
-- * REPL Flags
-- ------------------------------------------------------------

data ReplOptions = ReplOptions {
    ReplOptions -> [String]
replOptionsFlags :: [String],
    ReplOptions -> Flag Bool
replOptionsNoLoad :: Flag Bool
  }
  deriving (Int -> ReplOptions -> String -> String
[ReplOptions] -> String -> String
ReplOptions -> String
(Int -> ReplOptions -> String -> String)
-> (ReplOptions -> String)
-> ([ReplOptions] -> String -> String)
-> Show ReplOptions
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> ReplOptions -> String -> String
showsPrec :: Int -> ReplOptions -> String -> String
$cshow :: ReplOptions -> String
show :: ReplOptions -> String
$cshowList :: [ReplOptions] -> String -> String
showList :: [ReplOptions] -> String -> String
Show, (forall x. ReplOptions -> Rep ReplOptions x)
-> (forall x. Rep ReplOptions x -> ReplOptions)
-> Generic ReplOptions
forall x. Rep ReplOptions x -> ReplOptions
forall x. ReplOptions -> Rep ReplOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReplOptions -> Rep ReplOptions x
from :: forall x. ReplOptions -> Rep ReplOptions x
$cto :: forall x. Rep ReplOptions x -> ReplOptions
to :: forall x. Rep ReplOptions x -> ReplOptions
Generic, Typeable)

instance Binary ReplOptions
instance Structured ReplOptions


instance Monoid ReplOptions where
  mempty :: ReplOptions
mempty = [String] -> Flag Bool -> ReplOptions
ReplOptions [String]
forall a. Monoid a => a
mempty (Bool -> Flag Bool
forall a. a -> Flag a
Flag Bool
False)
  mappend :: ReplOptions -> ReplOptions -> ReplOptions
mappend = ReplOptions -> ReplOptions -> ReplOptions
forall a. Semigroup a => a -> a -> a
(<>)