{-# LANGUAGE NoImplicitPrelude #-}
module Stack.Options.ConfigParser where

import           Data.Char
import           Options.Applicative
import           Options.Applicative.Builder.Extra
import           Path
import           Stack.Constants
import           Stack.Options.BuildMonoidParser
import           Stack.Options.DockerParser
import           Stack.Options.GhcBuildParser
import           Stack.Options.GhcVariantParser
import           Stack.Options.NixParser
import           Stack.Options.Utils
import           Stack.Prelude
import           Stack.Types.Config
import qualified System.FilePath as FilePath

-- | Command-line arguments parser for configuration.
configOptsParser :: FilePath -> GlobalOptsContext -> Parser ConfigMonoid
configOptsParser :: FilePath -> GlobalOptsContext -> Parser ConfigMonoid
configOptsParser FilePath
currentDir GlobalOptsContext
hide0 =
    (\First (Path Abs Dir)
stackRoot First (Path Rel Dir)
workDir BuildOptsMonoid
buildOpts DockerOptsMonoid
dockerOpts NixOptsMonoid
nixOpts First Bool
systemGHC FirstTrue
installGHC First FilePath
arch
        First GHCVariant
ghcVariant First CompilerBuild
ghcBuild First Int
jobs [FilePath]
includes [FilePath]
libs First (Path Abs File)
overrideGccPath First FilePath
overrideHpack
        FirstFalse
skipGHCCheck FirstFalse
skipMsys First FilePath
localBin [FilePath]
setupInfoLocations FirstTrue
modifyCodePage
        First Bool
allowDifferentUser First DumpLogs
dumpLogs First ColorWhen
colorWhen First Text
snapLoc -> ConfigMonoid
forall a. Monoid a => a
mempty
            { configMonoidStackRoot :: First (Path Abs Dir)
configMonoidStackRoot = First (Path Abs Dir)
stackRoot
            , configMonoidWorkDir :: First (Path Rel Dir)
configMonoidWorkDir = First (Path Rel Dir)
workDir
            , configMonoidBuildOpts :: BuildOptsMonoid
configMonoidBuildOpts = BuildOptsMonoid
buildOpts
            , configMonoidDockerOpts :: DockerOptsMonoid
configMonoidDockerOpts = DockerOptsMonoid
dockerOpts
            , configMonoidNixOpts :: NixOptsMonoid
configMonoidNixOpts = NixOptsMonoid
nixOpts
            , configMonoidSystemGHC :: First Bool
configMonoidSystemGHC = First Bool
systemGHC
            , configMonoidInstallGHC :: FirstTrue
configMonoidInstallGHC = FirstTrue
installGHC
            , configMonoidSkipGHCCheck :: FirstFalse
configMonoidSkipGHCCheck = FirstFalse
skipGHCCheck
            , configMonoidArch :: First FilePath
configMonoidArch = First FilePath
arch
            , configMonoidGHCVariant :: First GHCVariant
configMonoidGHCVariant = First GHCVariant
ghcVariant
            , configMonoidGHCBuild :: First CompilerBuild
configMonoidGHCBuild = First CompilerBuild
ghcBuild
            , configMonoidJobs :: First Int
configMonoidJobs = First Int
jobs
            , configMonoidExtraIncludeDirs :: [FilePath]
configMonoidExtraIncludeDirs = [FilePath]
includes
            , configMonoidExtraLibDirs :: [FilePath]
configMonoidExtraLibDirs = [FilePath]
libs
            , configMonoidOverrideGccPath :: First (Path Abs File)
configMonoidOverrideGccPath = First (Path Abs File)
overrideGccPath
            , configMonoidOverrideHpack :: First FilePath
configMonoidOverrideHpack = First FilePath
overrideHpack
            , configMonoidSkipMsys :: FirstFalse
configMonoidSkipMsys = FirstFalse
skipMsys
            , configMonoidLocalBinPath :: First FilePath
configMonoidLocalBinPath = First FilePath
localBin
            , configMonoidSetupInfoLocations :: [FilePath]
configMonoidSetupInfoLocations = [FilePath]
setupInfoLocations
            , configMonoidModifyCodePage :: FirstTrue
configMonoidModifyCodePage = FirstTrue
modifyCodePage
            , configMonoidAllowDifferentUser :: First Bool
configMonoidAllowDifferentUser = First Bool
allowDifferentUser
            , configMonoidDumpLogs :: First DumpLogs
configMonoidDumpLogs = First DumpLogs
dumpLogs
            , configMonoidColorWhen :: First ColorWhen
configMonoidColorWhen = First ColorWhen
colorWhen
            , configMonoidSnapshotLocation :: First Text
configMonoidSnapshotLocation = First Text
snapLoc
            })
    (First (Path Abs Dir)
 -> First (Path Rel Dir)
 -> BuildOptsMonoid
 -> DockerOptsMonoid
 -> NixOptsMonoid
 -> First Bool
 -> FirstTrue
 -> First FilePath
 -> First GHCVariant
 -> First CompilerBuild
 -> First Int
 -> [FilePath]
 -> [FilePath]
 -> First (Path Abs File)
 -> First FilePath
 -> FirstFalse
 -> FirstFalse
 -> First FilePath
 -> [FilePath]
 -> FirstTrue
 -> First Bool
 -> First DumpLogs
 -> First ColorWhen
 -> First Text
 -> ConfigMonoid)
-> Parser (First (Path Abs Dir))
-> Parser
     (First (Path Rel Dir)
      -> BuildOptsMonoid
      -> DockerOptsMonoid
      -> NixOptsMonoid
      -> First Bool
      -> FirstTrue
      -> First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Path Abs Dir) -> Parser (First (Path Abs Dir))
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Mod OptionFields (Path Abs Dir) -> Parser (Path Abs Dir)
absDirOption
            ( FilePath -> Mod OptionFields (Path Abs Dir)
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
stackRootOptionName
            Mod OptionFields (Path Abs Dir)
-> Mod OptionFields (Path Abs Dir)
-> Mod OptionFields (Path Abs Dir)
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields (Path Abs Dir)
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar ((Char -> Char) -> FilePath -> FilePath
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper FilePath
stackRootOptionName)
            Mod OptionFields (Path Abs Dir)
-> Mod OptionFields (Path Abs Dir)
-> Mod OptionFields (Path Abs Dir)
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields (Path Abs Dir)
forall (f :: * -> *) a. FilePath -> Mod f a
help (FilePath
"Absolute path to the global stack root directory " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
                     FilePath
"(Overrides any STACK_ROOT environment variable)")
            Mod OptionFields (Path Abs Dir)
-> Mod OptionFields (Path Abs Dir)
-> Mod OptionFields (Path Abs Dir)
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields (Path Abs Dir)
forall (f :: * -> *) a. Mod f a
hide
            ))
    Parser
  (First (Path Rel Dir)
   -> BuildOptsMonoid
   -> DockerOptsMonoid
   -> NixOptsMonoid
   -> First Bool
   -> FirstTrue
   -> First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First (Path Rel Dir))
-> Parser
     (BuildOptsMonoid
      -> DockerOptsMonoid
      -> NixOptsMonoid
      -> First Bool
      -> FirstTrue
      -> First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Path Rel Dir) -> Parser (First (Path Rel Dir))
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (ReadM (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir) -> Parser (Path Rel Dir)
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ((FilePath -> Either FilePath (Path Rel Dir))
-> ReadM (Path Rel Dir)
forall a. (FilePath -> Either FilePath a) -> ReadM a
eitherReader ((SomeException -> FilePath)
-> Either SomeException (Path Rel Dir)
-> Either FilePath (Path Rel Dir)
forall a1 a2 b. (a1 -> a2) -> Either a1 b -> Either a2 b
mapLeft SomeException -> FilePath
forall a. Show a => a -> FilePath
showWorkDirError (Either SomeException (Path Rel Dir)
 -> Either FilePath (Path Rel Dir))
-> (FilePath -> Either SomeException (Path Rel Dir))
-> FilePath
-> Either FilePath (Path Rel Dir)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Either SomeException (Path Rel Dir)
forall (m :: * -> *). MonadThrow m => FilePath -> m (Path Rel Dir)
parseRelDir))
            ( FilePath -> Mod OptionFields (Path Rel Dir)
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"work-dir"
            Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields (Path Rel Dir)
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"WORK-DIR"
            Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields (Path Rel Dir)
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
completer (PathCompleterOpts -> Completer
pathCompleterWith (PathCompleterOpts
defaultPathCompleterOpts { pcoAbsolute :: Bool
pcoAbsolute = Bool
False, pcoFileFilter :: FilePath -> Bool
pcoFileFilter = Bool -> FilePath -> Bool
forall a b. a -> b -> a
const Bool
False }))
            Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields (Path Rel Dir)
forall (f :: * -> *) a. FilePath -> Mod f a
help (FilePath
"Relative path of work directory " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
                     FilePath
"(Overrides any STACK_WORK environment variable, default is '.stack-work')")
            Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
-> Mod OptionFields (Path Rel Dir)
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields (Path Rel Dir)
forall (f :: * -> *) a. Mod f a
hide
            ))
    Parser
  (BuildOptsMonoid
   -> DockerOptsMonoid
   -> NixOptsMonoid
   -> First Bool
   -> FirstTrue
   -> First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser BuildOptsMonoid
-> Parser
     (DockerOptsMonoid
      -> NixOptsMonoid
      -> First Bool
      -> FirstTrue
      -> First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GlobalOptsContext -> Parser BuildOptsMonoid
buildOptsMonoidParser GlobalOptsContext
hide0
    Parser
  (DockerOptsMonoid
   -> NixOptsMonoid
   -> First Bool
   -> FirstTrue
   -> First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser DockerOptsMonoid
-> Parser
     (NixOptsMonoid
      -> First Bool
      -> FirstTrue
      -> First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser DockerOptsMonoid
dockerOptsParser Bool
True
    Parser
  (NixOptsMonoid
   -> First Bool
   -> FirstTrue
   -> First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser NixOptsMonoid
-> Parser
     (First Bool
      -> FirstTrue
      -> First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser NixOptsMonoid
nixOptsParser Bool
True
    Parser
  (First Bool
   -> FirstTrue
   -> First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First Bool)
-> Parser
     (FirstTrue
      -> First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FilePath
-> FilePath -> Mod FlagFields (Maybe Bool) -> Parser (First Bool)
firstBoolFlagsNoDefault
            FilePath
"system-ghc"
            FilePath
"using the system installed GHC (on the PATH) if it is available and its version matches. Disabled by default."
            Mod FlagFields (Maybe Bool)
forall (f :: * -> *) a. Mod f a
hide
    Parser
  (FirstTrue
   -> First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser FirstTrue
-> Parser
     (First FilePath
      -> First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FilePath
-> FilePath -> Mod FlagFields FirstTrue -> Parser FirstTrue
firstBoolFlagsTrue
            FilePath
"install-ghc"
            FilePath
"downloading and installing GHC if necessary (can be done manually with stack setup)"
            Mod FlagFields FirstTrue
forall (f :: * -> *) a. Mod f a
hide
    Parser
  (First FilePath
   -> First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First FilePath)
-> Parser
     (First GHCVariant
      -> First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath -> Parser (First FilePath)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Mod OptionFields FilePath -> Parser FilePath
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
            ( FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"arch"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"ARCH"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"System architecture, e.g. i386, x86_64"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields FilePath
forall (f :: * -> *) a. Mod f a
hide
            ))
    Parser
  (First GHCVariant
   -> First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First GHCVariant)
-> Parser
     (First CompilerBuild
      -> First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser GHCVariant -> Parser (First GHCVariant)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Bool -> Parser GHCVariant
ghcVariantParser (GlobalOptsContext
hide0 GlobalOptsContext -> GlobalOptsContext -> Bool
forall a. Eq a => a -> a -> Bool
/= GlobalOptsContext
OuterGlobalOpts))
    Parser
  (First CompilerBuild
   -> First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First CompilerBuild)
-> Parser
     (First Int
      -> [FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser CompilerBuild -> Parser (First CompilerBuild)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Bool -> Parser CompilerBuild
ghcBuildParser (GlobalOptsContext
hide0 GlobalOptsContext -> GlobalOptsContext -> Bool
forall a. Eq a => a -> a -> Bool
/= GlobalOptsContext
OuterGlobalOpts))
    Parser
  (First Int
   -> [FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First Int)
-> Parser
     ([FilePath]
      -> [FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Int -> Parser (First Int)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto
            ( FilePath -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"jobs"
           Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'j'
           Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"JOBS"
           Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields Int
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Number of concurrent jobs to run"
           Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields Int
forall (f :: * -> *) a. Mod f a
hide
            ))
    Parser
  ([FilePath]
   -> [FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser [FilePath]
-> Parser
     ([FilePath]
      -> First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath -> Parser [FilePath]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ((FilePath
currentDir FilePath -> FilePath -> FilePath
FilePath.</>) (FilePath -> FilePath) -> Parser FilePath -> Parser FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod OptionFields FilePath -> Parser FilePath
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
            ( FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"extra-include-dirs"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"DIR"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
completer Completer
dirCompleter
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Extra directories to check for C header files"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields FilePath
forall (f :: * -> *) a. Mod f a
hide
            ))
    Parser
  ([FilePath]
   -> First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser [FilePath]
-> Parser
     (First (Path Abs File)
      -> First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath -> Parser [FilePath]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ((FilePath
currentDir FilePath -> FilePath -> FilePath
FilePath.</>) (FilePath -> FilePath) -> Parser FilePath -> Parser FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod OptionFields FilePath -> Parser FilePath
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
            ( FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"extra-lib-dirs"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"DIR"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
completer Completer
dirCompleter
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Extra directories to check for libraries"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields FilePath
forall (f :: * -> *) a. Mod f a
hide
            ))
    Parser
  (First (Path Abs File)
   -> First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First (Path Abs File))
-> Parser
     (First FilePath
      -> FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Path Abs File) -> Parser (First (Path Abs File))
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Mod OptionFields (Path Abs File) -> Parser (Path Abs File)
absFileOption
             ( FilePath -> Mod OptionFields (Path Abs File)
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"with-gcc"
            Mod OptionFields (Path Abs File)
-> Mod OptionFields (Path Abs File)
-> Mod OptionFields (Path Abs File)
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields (Path Abs File)
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"PATH-TO-GCC"
            Mod OptionFields (Path Abs File)
-> Mod OptionFields (Path Abs File)
-> Mod OptionFields (Path Abs File)
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields (Path Abs File)
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Use gcc found at PATH-TO-GCC"
            Mod OptionFields (Path Abs File)
-> Mod OptionFields (Path Abs File)
-> Mod OptionFields (Path Abs File)
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields (Path Abs File)
forall (f :: * -> *) a. Mod f a
hide
             ))
    Parser
  (First FilePath
   -> FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First FilePath)
-> Parser
     (FirstFalse
      -> FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath -> Parser (First FilePath)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Mod OptionFields FilePath -> Parser FilePath
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
             ( FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"with-hpack"
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"HPACK"
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Use HPACK executable (overrides bundled Hpack)"
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields FilePath
forall (f :: * -> *) a. Mod f a
hide
             ))
    Parser
  (FirstFalse
   -> FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser FirstFalse
-> Parser
     (FirstFalse
      -> First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FilePath
-> FilePath -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
            FilePath
"skip-ghc-check"
            FilePath
"skipping the GHC version and architecture check"
            Mod FlagFields FirstFalse
forall (f :: * -> *) a. Mod f a
hide
    Parser
  (FirstFalse
   -> First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser FirstFalse
-> Parser
     (First FilePath
      -> [FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FilePath
-> FilePath -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
            FilePath
"skip-msys"
            FilePath
"skipping the local MSYS installation (Windows only)"
            Mod FlagFields FirstFalse
forall (f :: * -> *) a. Mod f a
hide
    Parser
  (First FilePath
   -> [FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser (First FilePath)
-> Parser
     ([FilePath]
      -> FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath -> Parser (First FilePath)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst ((FilePath
currentDir FilePath -> FilePath -> FilePath
FilePath.</>) (FilePath -> FilePath) -> Parser FilePath -> Parser FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod OptionFields FilePath -> Parser FilePath
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
             ( FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"local-bin-path"
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"DIR"
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
completer Completer
dirCompleter
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Install binaries to DIR"
            Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields FilePath
forall (f :: * -> *) a. Mod f a
hide
             ))
    Parser
  ([FilePath]
   -> FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser [FilePath]
-> Parser
     (FirstTrue
      -> First Bool
      -> First DumpLogs
      -> First ColorWhen
      -> First Text
      -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FilePath -> Parser [FilePath]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (
        Mod OptionFields FilePath -> Parser FilePath
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
            ( FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"setup-info-yaml"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Alternate URL or relative / absolute path for stack dependencies"
           Mod OptionFields FilePath
-> Mod OptionFields FilePath -> Mod OptionFields FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields FilePath
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"URL" ))
    Parser
  (FirstTrue
   -> First Bool
   -> First DumpLogs
   -> First ColorWhen
   -> First Text
   -> ConfigMonoid)
-> Parser FirstTrue
-> Parser
     (First Bool
      -> First DumpLogs -> First ColorWhen -> First Text -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FilePath
-> FilePath -> Mod FlagFields FirstTrue -> Parser FirstTrue
firstBoolFlagsTrue
            FilePath
"modify-code-page"
            FilePath
"setting the codepage to support UTF-8 (Windows only)"
            Mod FlagFields FirstTrue
forall (f :: * -> *) a. Mod f a
hide
    Parser
  (First Bool
   -> First DumpLogs -> First ColorWhen -> First Text -> ConfigMonoid)
-> Parser (First Bool)
-> Parser
     (First DumpLogs -> First ColorWhen -> First Text -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FilePath
-> FilePath -> Mod FlagFields (Maybe Bool) -> Parser (First Bool)
firstBoolFlagsNoDefault
            FilePath
"allow-different-user"
            (FilePath
"permission for users other than the owner of the stack root " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
                FilePath
"directory to use a stack installation (POSIX only) " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
                FilePath
"(default: true inside Docker, otherwise false)")
            Mod FlagFields (Maybe Bool)
forall (f :: * -> *) a. Mod f a
hide
    Parser
  (First DumpLogs -> First ColorWhen -> First Text -> ConfigMonoid)
-> Parser (First DumpLogs)
-> Parser (First ColorWhen -> First Text -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (First Bool -> First DumpLogs)
-> Parser (First Bool) -> Parser (First DumpLogs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap First Bool -> First DumpLogs
toDumpLogs
            (FilePath
-> FilePath -> Mod FlagFields (Maybe Bool) -> Parser (First Bool)
firstBoolFlagsNoDefault
             FilePath
"dump-logs"
             FilePath
"dump the build output logs for local packages to the console (default: dump warning logs)"
             Mod FlagFields (Maybe Bool)
forall (f :: * -> *) a. Mod f a
hide)
    Parser (First ColorWhen -> First Text -> ConfigMonoid)
-> Parser (First ColorWhen) -> Parser (First Text -> ConfigMonoid)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser ColorWhen -> Parser (First ColorWhen)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (ReadM ColorWhen -> Mod OptionFields ColorWhen -> Parser ColorWhen
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM ColorWhen
readColorWhen
             ( FilePath -> Mod OptionFields ColorWhen
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"color"
            Mod OptionFields ColorWhen
-> Mod OptionFields ColorWhen -> Mod OptionFields ColorWhen
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields ColorWhen
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"colour"
            Mod OptionFields ColorWhen
-> Mod OptionFields ColorWhen -> Mod OptionFields ColorWhen
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields ColorWhen
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"WHEN"
            Mod OptionFields ColorWhen
-> Mod OptionFields ColorWhen -> Mod OptionFields ColorWhen
forall a. Semigroup a => a -> a -> a
<> [FilePath] -> Mod OptionFields ColorWhen
forall (f :: * -> *) a. HasCompleter f => [FilePath] -> Mod f a
completeWith [FilePath
"always", FilePath
"never", FilePath
"auto"]
            Mod OptionFields ColorWhen
-> Mod OptionFields ColorWhen -> Mod OptionFields ColorWhen
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields ColorWhen
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"Specify when to use color in output; WHEN is 'always', \
                    \'never', or 'auto'. On Windows versions before Windows \
                    \10, for terminals that do not support color codes, the \
                    \default is 'never'; color may work on terminals that \
                    \support color codes"
            Mod OptionFields ColorWhen
-> Mod OptionFields ColorWhen -> Mod OptionFields ColorWhen
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields ColorWhen
forall (f :: * -> *) a. Mod f a
hide
             ))
    Parser (First Text -> ConfigMonoid)
-> Parser (First Text) -> Parser ConfigMonoid
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Text -> Parser (First Text)
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst (Mod OptionFields Text -> Parser Text
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
            ( FilePath -> Mod OptionFields Text
forall (f :: * -> *) a. HasName f => FilePath -> Mod f a
long FilePath
"snapshot-location-base"
           Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields Text
forall (f :: * -> *) a. FilePath -> Mod f a
help FilePath
"The base location of LTS/Nightly snapshots"
           Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Mod OptionFields Text
forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a
metavar FilePath
"URL"
            ))
  where
    hide :: Mod f a
hide = Bool -> Mod f a
forall (f :: * -> *) a. Bool -> Mod f a
hideMods (GlobalOptsContext
hide0 GlobalOptsContext -> GlobalOptsContext -> Bool
forall a. Eq a => a -> a -> Bool
/= GlobalOptsContext
OuterGlobalOpts)
    toDumpLogs :: First Bool -> First DumpLogs
toDumpLogs (First (Just Bool
True)) = Maybe DumpLogs -> First DumpLogs
forall a. Maybe a -> First a
First (DumpLogs -> Maybe DumpLogs
forall a. a -> Maybe a
Just DumpLogs
DumpAllLogs)
    toDumpLogs (First (Just Bool
False)) = Maybe DumpLogs -> First DumpLogs
forall a. Maybe a -> First a
First (DumpLogs -> Maybe DumpLogs
forall a. a -> Maybe a
Just DumpLogs
DumpNoLogs)
    toDumpLogs (First Maybe Bool
Nothing) = Maybe DumpLogs -> First DumpLogs
forall a. Maybe a -> First a
First Maybe DumpLogs
forall a. Maybe a
Nothing
    showWorkDirError :: a -> FilePath
showWorkDirError a
err = a -> FilePath
forall a. Show a => a -> FilePath
show a
err FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
        FilePath
"\nNote that --work-dir must be a relative child directory, because work-dirs outside of the package are not supported by Cabal." FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
        FilePath
"\nSee https://github.com/commercialhaskell/stack/issues/2954"