{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards   #-}

-- | Configuration options for building.

module Stack.Types.BuildOpts
  ( BuildOpts (..)
  , buildOptsHaddockL
  , buildOptsInstallExesL
  , BuildCommand (..)
  , defaultBuildOpts
  , defaultBuildOptsCLI
  , BuildOptsCLI (..)
  , boptsCLIAllProgOptions
  , BuildOptsMonoid (..)
  , ProgressBarFormat (..)
  , readProgressBarFormat
  , buildOptsMonoidBenchmarksL
  , buildOptsMonoidHaddockL
  , buildOptsMonoidInstallExesL
  , buildOptsMonoidTestsL
  , TestOpts (..)
  , defaultTestOpts
  , TestOptsMonoid (..)
  , HaddockOpts (..)
  , defaultHaddockOpts
  , HaddockOptsMonoid (..)
  , BenchmarkOpts (..)
  , defaultBenchmarkOpts
  , BenchmarkOptsMonoid (..)
  , FileWatchOpts (..)
  , BuildSubset (..)
  , ApplyCLIFlag (..)
  , boptsCLIFlagsByName
  , CabalVerbosity (..)
  , toFirstCabalVerbosity
  ) where

import           Data.Aeson.Types ( FromJSON (..), withText )
import           Data.Aeson.WarningParser
                   ( WithJSONWarnings, (..:?), (..!=), jsonSubWarnings
                   , withObjectWarnings
                   )
import qualified Data.Map.Strict as Map
import qualified Data.Text as T
import           Distribution.Parsec ( Parsec (..), simpleParsec )
import           Distribution.Verbosity ( Verbosity, normal, verbose )
import           Generics.Deriving.Monoid ( mappenddefault, memptydefault )
import           Stack.Prelude

-- | Build options that is interpreted by the build command. This is built up

-- from BuildOptsCLI and BuildOptsMonoid

data BuildOpts = BuildOpts
  { BuildOpts -> Bool
boptsLibProfile :: !Bool
  , BuildOpts -> Bool
boptsExeProfile :: !Bool
  , BuildOpts -> Bool
boptsLibStrip :: !Bool
  , BuildOpts -> Bool
boptsExeStrip :: !Bool
  , BuildOpts -> Bool
boptsHaddock :: !Bool
    -- ^ Build haddocks?

  , BuildOpts -> HaddockOpts
boptsHaddockOpts :: !HaddockOpts
    -- ^ Options to pass to haddock

  , BuildOpts -> Bool
boptsOpenHaddocks :: !Bool
    -- ^ Open haddocks in the browser?

  , BuildOpts -> Maybe Bool
boptsHaddockDeps :: !(Maybe Bool)
    -- ^ Build haddocks for dependencies?

  , BuildOpts -> Bool
boptsHaddockInternal :: !Bool
    -- ^ Build haddocks for all symbols and packages, like

    -- @cabal haddock --internal@

  , BuildOpts -> Bool
boptsHaddockHyperlinkSource :: !Bool
    -- ^ Build hyperlinked source. Disable for no sources.

  , BuildOpts -> Bool
boptsHaddockForHackage :: !Bool
    -- ^ Build with flags to generate Haddock documentation suitable to upload

    -- to Hackage.

  , BuildOpts -> Bool
boptsInstallExes :: !Bool
    -- ^ Install executables to user path after building?

  , BuildOpts -> Bool
boptsInstallCompilerTool :: !Bool
    -- ^ Install executables to compiler tools path after building?

  , BuildOpts -> Bool
boptsPreFetch :: !Bool
    -- ^ Fetch all packages immediately

    -- ^ Watch files for changes and automatically rebuild

  , BuildOpts -> Maybe Bool
boptsKeepGoing :: !(Maybe Bool)
    -- ^ Keep building/running after failure

  , BuildOpts -> Bool
boptsKeepTmpFiles :: !Bool
    -- ^ Keep intermediate files and build directories

  , BuildOpts -> Bool
boptsForceDirty :: !Bool
    -- ^ Force treating all local packages as having dirty files

  , BuildOpts -> Bool
boptsTests :: !Bool
    -- ^ Turn on tests for local targets

  , BuildOpts -> TestOpts
boptsTestOpts :: !TestOpts
    -- ^ Additional test arguments

  , BuildOpts -> Bool
boptsBenchmarks :: !Bool
    -- ^ Turn on benchmarks for local targets

  , BuildOpts -> BenchmarkOpts
boptsBenchmarkOpts :: !BenchmarkOpts
    -- ^ Additional test arguments

    -- ^ Commands (with arguments) to run after a successful build

    -- ^ Only perform the configure step when building

  , BuildOpts -> Bool
boptsReconfigure :: !Bool
    -- ^ Perform the configure step even if already configured

  , BuildOpts -> CabalVerbosity
boptsCabalVerbose :: !CabalVerbosity
    -- ^ Ask Cabal to be verbose in its builds

  , BuildOpts -> Bool
boptsSplitObjs :: !Bool
    -- ^ Whether to enable split-objs.

  , BuildOpts -> [Text]
boptsSkipComponents :: ![Text]
    -- ^ Which components to skip when building

  , BuildOpts -> Bool
boptsInterleavedOutput :: !Bool
    -- ^ Should we use the interleaved GHC output when building

    -- multiple packages?

  , BuildOpts -> ProgressBarFormat
boptsProgressBar :: !ProgressBarFormat
    -- ^ Format of the progress bar

  , BuildOpts -> Maybe Text
boptsDdumpDir :: !(Maybe Text)
  }
  deriving Int -> BuildOpts -> ShowS
[BuildOpts] -> ShowS
BuildOpts -> String
(Int -> BuildOpts -> ShowS)
-> (BuildOpts -> String)
-> ([BuildOpts] -> ShowS)
-> Show BuildOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildOpts -> ShowS
showsPrec :: Int -> BuildOpts -> ShowS
$cshow :: BuildOpts -> String
show :: BuildOpts -> String
$cshowList :: [BuildOpts] -> ShowS
showList :: [BuildOpts] -> ShowS
Show

defaultBuildOpts :: BuildOpts
defaultBuildOpts :: BuildOpts
defaultBuildOpts = BuildOpts
  { boptsLibProfile :: Bool
boptsLibProfile = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidLibProfile
  , boptsExeProfile :: Bool
boptsExeProfile = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidExeProfile
  , boptsLibStrip :: Bool
boptsLibStrip = (BuildOptsMonoid -> FirstTrue) -> Bool
forall a. (a -> FirstTrue) -> Bool
defaultFirstTrue BuildOptsMonoid -> FirstTrue
buildMonoidLibStrip
  , boptsExeStrip :: Bool
boptsExeStrip = (BuildOptsMonoid -> FirstTrue) -> Bool
forall a. (a -> FirstTrue) -> Bool
defaultFirstTrue BuildOptsMonoid -> FirstTrue
buildMonoidExeStrip
  , boptsHaddock :: Bool
boptsHaddock = Bool
False
  , boptsHaddockOpts :: HaddockOpts
boptsHaddockOpts = HaddockOpts
defaultHaddockOpts
  , boptsOpenHaddocks :: Bool
boptsOpenHaddocks = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidOpenHaddocks
  , boptsHaddockDeps :: Maybe Bool
boptsHaddockDeps = Maybe Bool
forall a. Maybe a
Nothing
  , boptsHaddockInternal :: Bool
boptsHaddockInternal = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidHaddockInternal
  , boptsHaddockHyperlinkSource :: Bool
boptsHaddockHyperlinkSource =
      (BuildOptsMonoid -> FirstTrue) -> Bool
forall a. (a -> FirstTrue) -> Bool
defaultFirstTrue BuildOptsMonoid -> FirstTrue
buildMonoidHaddockHyperlinkSource
  , boptsHaddockForHackage :: Bool
boptsHaddockForHackage = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidHaddockForHackage
  , boptsInstallExes :: Bool
boptsInstallExes = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidInstallExes
  , boptsInstallCompilerTool :: Bool
boptsInstallCompilerTool = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidInstallCompilerTool
  , boptsPreFetch :: Bool
boptsPreFetch = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidPreFetch
  , boptsKeepGoing :: Maybe Bool
boptsKeepGoing = Maybe Bool
forall a. Maybe a
Nothing
  , boptsKeepTmpFiles :: Bool
boptsKeepTmpFiles = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidKeepTmpFiles
  , boptsForceDirty :: Bool
boptsForceDirty = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidForceDirty
  , boptsTests :: Bool
boptsTests = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidTests
  , boptsTestOpts :: TestOpts
boptsTestOpts = TestOpts
defaultTestOpts
  , boptsBenchmarks :: Bool
boptsBenchmarks = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidBenchmarks
  , boptsBenchmarkOpts :: BenchmarkOpts
boptsBenchmarkOpts = BenchmarkOpts
defaultBenchmarkOpts
  , boptsReconfigure :: Bool
boptsReconfigure = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidReconfigure
  , boptsCabalVerbose :: CabalVerbosity
boptsCabalVerbose = Verbosity -> CabalVerbosity
CabalVerbosity Verbosity
normal
  , boptsSplitObjs :: Bool
boptsSplitObjs = (BuildOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse BuildOptsMonoid -> FirstFalse
buildMonoidSplitObjs
  , boptsSkipComponents :: [Text]
boptsSkipComponents = []
  , boptsInterleavedOutput :: Bool
boptsInterleavedOutput = (BuildOptsMonoid -> FirstTrue) -> Bool
forall a. (a -> FirstTrue) -> Bool
defaultFirstTrue BuildOptsMonoid -> FirstTrue
buildMonoidInterleavedOutput
  , boptsProgressBar :: ProgressBarFormat
boptsProgressBar = ProgressBarFormat
CappedBar
  , boptsDdumpDir :: Maybe Text
boptsDdumpDir = Maybe Text
forall a. Maybe a
Nothing
  }

defaultBuildOptsCLI ::BuildOptsCLI
defaultBuildOptsCLI :: BuildOptsCLI
defaultBuildOptsCLI = BuildOptsCLI
  { boptsCLITargets :: [Text]
boptsCLITargets = []
  , boptsCLIDryrun :: Bool
boptsCLIDryrun = Bool
False
  , boptsCLIFlags :: Map ApplyCLIFlag (Map FlagName Bool)
boptsCLIFlags = Map ApplyCLIFlag (Map FlagName Bool)
forall k a. Map k a
Map.empty
  , boptsCLIGhcOptions :: [Text]
boptsCLIGhcOptions = []
  , boptsCLIProgsOptions :: [(Text, [Text])]
boptsCLIProgsOptions = []
  , boptsCLIBuildSubset :: BuildSubset
boptsCLIBuildSubset = BuildSubset
BSAll
  , boptsCLIFileWatch :: FileWatchOpts
boptsCLIFileWatch = FileWatchOpts
NoFileWatch
  , boptsCLIWatchAll :: Bool
boptsCLIWatchAll = Bool
False
  , boptsCLIExec :: [(String, [String])]
boptsCLIExec = []
  , boptsCLIOnlyConfigure :: Bool
boptsCLIOnlyConfigure = Bool
False
  , boptsCLICommand :: BuildCommand
boptsCLICommand = BuildCommand
Build
  , boptsCLIInitialBuildSteps :: Bool
boptsCLIInitialBuildSteps = Bool
False
  }

-- | How to apply a CLI flag

data ApplyCLIFlag
  = ACFAllProjectPackages
    -- ^ Apply to all project packages which have such a flag name available.

  | ACFByName !PackageName
    -- ^ Apply to the specified package only.

  deriving (ApplyCLIFlag -> ApplyCLIFlag -> Bool
(ApplyCLIFlag -> ApplyCLIFlag -> Bool)
-> (ApplyCLIFlag -> ApplyCLIFlag -> Bool) -> Eq ApplyCLIFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
== :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
$c/= :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
/= :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
Eq, Eq ApplyCLIFlag
Eq ApplyCLIFlag
-> (ApplyCLIFlag -> ApplyCLIFlag -> Ordering)
-> (ApplyCLIFlag -> ApplyCLIFlag -> Bool)
-> (ApplyCLIFlag -> ApplyCLIFlag -> Bool)
-> (ApplyCLIFlag -> ApplyCLIFlag -> Bool)
-> (ApplyCLIFlag -> ApplyCLIFlag -> Bool)
-> (ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag)
-> (ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag)
-> Ord ApplyCLIFlag
ApplyCLIFlag -> ApplyCLIFlag -> Bool
ApplyCLIFlag -> ApplyCLIFlag -> Ordering
ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ApplyCLIFlag -> ApplyCLIFlag -> Ordering
compare :: ApplyCLIFlag -> ApplyCLIFlag -> Ordering
$c< :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
< :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
$c<= :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
<= :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
$c> :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
> :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
$c>= :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
>= :: ApplyCLIFlag -> ApplyCLIFlag -> Bool
$cmax :: ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag
max :: ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag
$cmin :: ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag
min :: ApplyCLIFlag -> ApplyCLIFlag -> ApplyCLIFlag
Ord, Int -> ApplyCLIFlag -> ShowS
[ApplyCLIFlag] -> ShowS
ApplyCLIFlag -> String
(Int -> ApplyCLIFlag -> ShowS)
-> (ApplyCLIFlag -> String)
-> ([ApplyCLIFlag] -> ShowS)
-> Show ApplyCLIFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ApplyCLIFlag -> ShowS
showsPrec :: Int -> ApplyCLIFlag -> ShowS
$cshow :: ApplyCLIFlag -> String
show :: ApplyCLIFlag -> String
$cshowList :: [ApplyCLIFlag] -> ShowS
showList :: [ApplyCLIFlag] -> ShowS
Show)

-- | Only flags set via 'ACFByName'

boptsCLIFlagsByName :: BuildOptsCLI -> Map PackageName (Map FlagName Bool)
boptsCLIFlagsByName :: BuildOptsCLI -> Map PackageName (Map FlagName Bool)
boptsCLIFlagsByName =
  [(PackageName, Map FlagName Bool)]
-> Map PackageName (Map FlagName Bool)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(PackageName, Map FlagName Bool)]
 -> Map PackageName (Map FlagName Bool))
-> (BuildOptsCLI -> [(PackageName, Map FlagName Bool)])
-> BuildOptsCLI
-> Map PackageName (Map FlagName Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  ((ApplyCLIFlag, Map FlagName Bool)
 -> Maybe (PackageName, Map FlagName Bool))
-> [(ApplyCLIFlag, Map FlagName Bool)]
-> [(PackageName, Map FlagName Bool)]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (ApplyCLIFlag, Map FlagName Bool)
-> Maybe (PackageName, Map FlagName Bool)
forall {b}. (ApplyCLIFlag, b) -> Maybe (PackageName, b)
go ([(ApplyCLIFlag, Map FlagName Bool)]
 -> [(PackageName, Map FlagName Bool)])
-> (BuildOptsCLI -> [(ApplyCLIFlag, Map FlagName Bool)])
-> BuildOptsCLI
-> [(PackageName, Map FlagName Bool)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  Map ApplyCLIFlag (Map FlagName Bool)
-> [(ApplyCLIFlag, Map FlagName Bool)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map ApplyCLIFlag (Map FlagName Bool)
 -> [(ApplyCLIFlag, Map FlagName Bool)])
-> (BuildOptsCLI -> Map ApplyCLIFlag (Map FlagName Bool))
-> BuildOptsCLI
-> [(ApplyCLIFlag, Map FlagName Bool)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  BuildOptsCLI -> Map ApplyCLIFlag (Map FlagName Bool)
boptsCLIFlags
 where
  go :: (ApplyCLIFlag, b) -> Maybe (PackageName, b)
go (ApplyCLIFlag
ACFAllProjectPackages, b
_) = Maybe (PackageName, b)
forall a. Maybe a
Nothing
  go (ACFByName PackageName
name, b
flags) = (PackageName, b) -> Maybe (PackageName, b)
forall a. a -> Maybe a
Just (PackageName
name, b
flags)

-- | Build options that may only be specified from the CLI

data BuildOptsCLI = BuildOptsCLI
  { BuildOptsCLI -> [Text]
boptsCLITargets :: ![Text]
  , BuildOptsCLI -> Bool
boptsCLIDryrun :: !Bool
  , BuildOptsCLI -> [Text]
boptsCLIGhcOptions :: ![Text]
  , BuildOptsCLI -> [(Text, [Text])]
boptsCLIProgsOptions :: ![(Text, [Text])]
  , BuildOptsCLI -> Map ApplyCLIFlag (Map FlagName Bool)
boptsCLIFlags :: !(Map ApplyCLIFlag (Map FlagName Bool))
  , BuildOptsCLI -> BuildSubset
boptsCLIBuildSubset :: !BuildSubset
  , BuildOptsCLI -> FileWatchOpts
boptsCLIFileWatch :: !FileWatchOpts
  , BuildOptsCLI -> Bool
boptsCLIWatchAll :: !Bool
  , BuildOptsCLI -> [(String, [String])]
boptsCLIExec :: ![(String, [String])]
  , BuildOptsCLI -> Bool
boptsCLIOnlyConfigure :: !Bool
  , BuildOptsCLI -> BuildCommand
boptsCLICommand :: !BuildCommand
  , BuildOptsCLI -> Bool
boptsCLIInitialBuildSteps :: !Bool
  }
  deriving Int -> BuildOptsCLI -> ShowS
[BuildOptsCLI] -> ShowS
BuildOptsCLI -> String
(Int -> BuildOptsCLI -> ShowS)
-> (BuildOptsCLI -> String)
-> ([BuildOptsCLI] -> ShowS)
-> Show BuildOptsCLI
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildOptsCLI -> ShowS
showsPrec :: Int -> BuildOptsCLI -> ShowS
$cshow :: BuildOptsCLI -> String
show :: BuildOptsCLI -> String
$cshowList :: [BuildOptsCLI] -> ShowS
showList :: [BuildOptsCLI] -> ShowS
Show

-- | Generate a list of --PROG-option="<argument>" arguments for all PROGs.

boptsCLIAllProgOptions :: BuildOptsCLI -> [Text]
boptsCLIAllProgOptions :: BuildOptsCLI -> [Text]
boptsCLIAllProgOptions BuildOptsCLI
boptsCLI =
  ((Text, [Text]) -> [Text]) -> [(Text, [Text])] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Text, [Text]) -> [Text]
progOptionArgs (BuildOptsCLI -> [(Text, [Text])]
boptsCLIProgsOptions BuildOptsCLI
boptsCLI)
 where
  -- Generate a list of --PROG-option="<argument>" arguments for a PROG.

  progOptionArgs :: (Text, [Text]) -> [Text]
  progOptionArgs :: (Text, [Text]) -> [Text]
progOptionArgs (Text
prog, [Text]
opts) = (Text -> Text) -> [Text] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
progOptionArg [Text]
opts
   where
    -- Generate a --PROG-option="<argument>" argument for a PROG and option.

    progOptionArg :: Text -> Text
    progOptionArg :: Text -> Text
progOptionArg Text
opt = [Text] -> Text
T.concat
      [ Text
"--"
      , Text
prog
      , Text
"-option=\""
      , Text
opt
      , Text
"\""
      ]

-- | Command sum type for conditional arguments.

data BuildCommand
  = Build
  | Test
  | Haddock
  | Bench
  | Install
  deriving (BuildCommand -> BuildCommand -> Bool
(BuildCommand -> BuildCommand -> Bool)
-> (BuildCommand -> BuildCommand -> Bool) -> Eq BuildCommand
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BuildCommand -> BuildCommand -> Bool
== :: BuildCommand -> BuildCommand -> Bool
$c/= :: BuildCommand -> BuildCommand -> Bool
/= :: BuildCommand -> BuildCommand -> Bool
Eq, Int -> BuildCommand -> ShowS
[BuildCommand] -> ShowS
BuildCommand -> String
(Int -> BuildCommand -> ShowS)
-> (BuildCommand -> String)
-> ([BuildCommand] -> ShowS)
-> Show BuildCommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildCommand -> ShowS
showsPrec :: Int -> BuildCommand -> ShowS
$cshow :: BuildCommand -> String
show :: BuildCommand -> String
$cshowList :: [BuildCommand] -> ShowS
showList :: [BuildCommand] -> ShowS
Show)

-- | Build options that may be specified in the stack.yaml or from the CLI

data BuildOptsMonoid = BuildOptsMonoid
  { BuildOptsMonoid -> Any
buildMonoidTrace :: !Any
  , BuildOptsMonoid -> Any
buildMonoidProfile :: !Any
  , BuildOptsMonoid -> Any
buildMonoidNoStrip :: !Any
  , BuildOptsMonoid -> FirstFalse
buildMonoidLibProfile :: !FirstFalse
  , BuildOptsMonoid -> FirstFalse
buildMonoidExeProfile :: !FirstFalse
  , BuildOptsMonoid -> FirstTrue
buildMonoidLibStrip :: !FirstTrue
  , BuildOptsMonoid -> FirstTrue
buildMonoidExeStrip :: !FirstTrue
  , BuildOptsMonoid -> FirstFalse
buildMonoidHaddock :: !FirstFalse
  , BuildOptsMonoid -> HaddockOptsMonoid
buildMonoidHaddockOpts :: !HaddockOptsMonoid
  , BuildOptsMonoid -> FirstFalse
buildMonoidOpenHaddocks :: !FirstFalse
  , BuildOptsMonoid -> First Bool
buildMonoidHaddockDeps :: !(First Bool)
  , BuildOptsMonoid -> FirstFalse
buildMonoidHaddockInternal :: !FirstFalse
  , BuildOptsMonoid -> FirstTrue
buildMonoidHaddockHyperlinkSource :: !FirstTrue
  , BuildOptsMonoid -> FirstFalse
buildMonoidHaddockForHackage :: !FirstFalse
  , BuildOptsMonoid -> FirstFalse
buildMonoidInstallExes :: !FirstFalse
  , BuildOptsMonoid -> FirstFalse
buildMonoidInstallCompilerTool :: !FirstFalse
  , BuildOptsMonoid -> FirstFalse
buildMonoidPreFetch :: !FirstFalse
  , BuildOptsMonoid -> First Bool
buildMonoidKeepGoing :: !(First Bool)
  , BuildOptsMonoid -> FirstFalse
buildMonoidKeepTmpFiles :: !FirstFalse
  , BuildOptsMonoid -> FirstFalse
buildMonoidForceDirty :: !FirstFalse
  , BuildOptsMonoid -> FirstFalse
buildMonoidTests :: !FirstFalse
  , BuildOptsMonoid -> TestOptsMonoid
buildMonoidTestOpts :: !TestOptsMonoid
  , BuildOptsMonoid -> FirstFalse
buildMonoidBenchmarks :: !FirstFalse
  , BuildOptsMonoid -> BenchmarkOptsMonoid
buildMonoidBenchmarkOpts :: !BenchmarkOptsMonoid
  , BuildOptsMonoid -> FirstFalse
buildMonoidReconfigure :: !FirstFalse
  , BuildOptsMonoid -> First CabalVerbosity
buildMonoidCabalVerbose :: !(First CabalVerbosity)
  , BuildOptsMonoid -> FirstFalse
buildMonoidSplitObjs :: !FirstFalse
  , BuildOptsMonoid -> [Text]
buildMonoidSkipComponents :: ![Text]
  , BuildOptsMonoid -> FirstTrue
buildMonoidInterleavedOutput :: !FirstTrue
  , BuildOptsMonoid -> First ProgressBarFormat
buildMonoidProgressBar :: !(First ProgressBarFormat)
  , BuildOptsMonoid -> First Text
buildMonoidDdumpDir :: !(First Text)
  }
  deriving ((forall x. BuildOptsMonoid -> Rep BuildOptsMonoid x)
-> (forall x. Rep BuildOptsMonoid x -> BuildOptsMonoid)
-> Generic BuildOptsMonoid
forall x. Rep BuildOptsMonoid x -> BuildOptsMonoid
forall x. BuildOptsMonoid -> Rep BuildOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BuildOptsMonoid -> Rep BuildOptsMonoid x
from :: forall x. BuildOptsMonoid -> Rep BuildOptsMonoid x
$cto :: forall x. Rep BuildOptsMonoid x -> BuildOptsMonoid
to :: forall x. Rep BuildOptsMonoid x -> BuildOptsMonoid
Generic, Int -> BuildOptsMonoid -> ShowS
[BuildOptsMonoid] -> ShowS
BuildOptsMonoid -> String
(Int -> BuildOptsMonoid -> ShowS)
-> (BuildOptsMonoid -> String)
-> ([BuildOptsMonoid] -> ShowS)
-> Show BuildOptsMonoid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildOptsMonoid -> ShowS
showsPrec :: Int -> BuildOptsMonoid -> ShowS
$cshow :: BuildOptsMonoid -> String
show :: BuildOptsMonoid -> String
$cshowList :: [BuildOptsMonoid] -> ShowS
showList :: [BuildOptsMonoid] -> ShowS
Show)

instance FromJSON (WithJSONWarnings BuildOptsMonoid) where
  parseJSON :: Value -> Parser (WithJSONWarnings BuildOptsMonoid)
parseJSON = String
-> (Object -> WarningParser BuildOptsMonoid)
-> Value
-> Parser (WithJSONWarnings BuildOptsMonoid)
forall a.
String
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings String
"BuildOptsMonoid" ((Object -> WarningParser BuildOptsMonoid)
 -> Value -> Parser (WithJSONWarnings BuildOptsMonoid))
-> (Object -> WarningParser BuildOptsMonoid)
-> Value
-> Parser (WithJSONWarnings BuildOptsMonoid)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    let buildMonoidTrace :: Any
buildMonoidTrace = Bool -> Any
Any Bool
False
        buildMonoidProfile :: Any
buildMonoidProfile = Bool -> Any
Any Bool
False
        buildMonoidNoStrip :: Any
buildMonoidNoStrip = Bool -> Any
Any Bool
False
    FirstFalse
buildMonoidLibProfile <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidLibProfileArgName
    FirstFalse
buildMonoidExeProfile <-Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidExeProfileArgName
    FirstTrue
buildMonoidLibStrip <- Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidLibStripArgName
    FirstTrue
buildMonoidExeStrip <-Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidExeStripArgName
    FirstFalse
buildMonoidHaddock <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidHaddockArgName
    HaddockOptsMonoid
buildMonoidHaddockOpts <-
      WarningParser (WithJSONWarnings HaddockOptsMonoid)
-> WarningParser HaddockOptsMonoid
forall a. WarningParser (WithJSONWarnings a) -> WarningParser a
jsonSubWarnings (Object
o Object
-> Text
-> WarningParser (Maybe (WithJSONWarnings HaddockOptsMonoid))
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidHaddockOptsArgName WarningParser (Maybe (WithJSONWarnings HaddockOptsMonoid))
-> WithJSONWarnings HaddockOptsMonoid
-> WarningParser (WithJSONWarnings HaddockOptsMonoid)
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= WithJSONWarnings HaddockOptsMonoid
forall a. Monoid a => a
mempty)
    FirstFalse
buildMonoidOpenHaddocks <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidOpenHaddocksArgName
    First Bool
buildMonoidHaddockDeps <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidHaddockDepsArgName
    FirstFalse
buildMonoidHaddockInternal <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidHaddockInternalArgName
    FirstTrue
buildMonoidHaddockHyperlinkSource <-
      Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidHaddockHyperlinkSourceArgName
    FirstFalse
buildMonoidHaddockForHackage <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidHaddockForHackageArgName
    FirstFalse
buildMonoidInstallExes <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidInstallExesArgName
    FirstFalse
buildMonoidInstallCompilerTool <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidInstallCompilerToolArgName
    FirstFalse
buildMonoidPreFetch <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidPreFetchArgName
    First Bool
buildMonoidKeepGoing <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidKeepGoingArgName
    FirstFalse
buildMonoidKeepTmpFiles <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidKeepTmpFilesArgName
    FirstFalse
buildMonoidForceDirty <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidForceDirtyArgName
    FirstFalse
buildMonoidTests <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidTestsArgName
    TestOptsMonoid
buildMonoidTestOpts <-
      WarningParser (WithJSONWarnings TestOptsMonoid)
-> WarningParser TestOptsMonoid
forall a. WarningParser (WithJSONWarnings a) -> WarningParser a
jsonSubWarnings (Object
o Object
-> Text -> WarningParser (Maybe (WithJSONWarnings TestOptsMonoid))
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidTestOptsArgName WarningParser (Maybe (WithJSONWarnings TestOptsMonoid))
-> WithJSONWarnings TestOptsMonoid
-> WarningParser (WithJSONWarnings TestOptsMonoid)
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= WithJSONWarnings TestOptsMonoid
forall a. Monoid a => a
mempty)
    FirstFalse
buildMonoidBenchmarks <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidBenchmarksArgName
    BenchmarkOptsMonoid
buildMonoidBenchmarkOpts <-
      WarningParser (WithJSONWarnings BenchmarkOptsMonoid)
-> WarningParser BenchmarkOptsMonoid
forall a. WarningParser (WithJSONWarnings a) -> WarningParser a
jsonSubWarnings (Object
o Object
-> Text
-> WarningParser (Maybe (WithJSONWarnings BenchmarkOptsMonoid))
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidBenchmarkOptsArgName WarningParser (Maybe (WithJSONWarnings BenchmarkOptsMonoid))
-> WithJSONWarnings BenchmarkOptsMonoid
-> WarningParser (WithJSONWarnings BenchmarkOptsMonoid)
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= WithJSONWarnings BenchmarkOptsMonoid
forall a. Monoid a => a
mempty)
    FirstFalse
buildMonoidReconfigure <-
      Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidReconfigureArgName
    First CabalVerbosity
cabalVerbosity <- Maybe CabalVerbosity -> First CabalVerbosity
forall a. Maybe a -> First a
First (Maybe CabalVerbosity -> First CabalVerbosity)
-> WriterT WarningParserMonoid Parser (Maybe CabalVerbosity)
-> WriterT WarningParserMonoid Parser (First CabalVerbosity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object
-> Text
-> WriterT WarningParserMonoid Parser (Maybe CabalVerbosity)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidCabalVerbosityArgName
    FirstFalse
cabalVerbose <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidCabalVerboseArgName
    let buildMonoidCabalVerbose :: First CabalVerbosity
buildMonoidCabalVerbose =
          First CabalVerbosity
cabalVerbosity First CabalVerbosity
-> First CabalVerbosity -> First CabalVerbosity
forall a. Semigroup a => a -> a -> a
<> FirstFalse -> First CabalVerbosity
toFirstCabalVerbosity FirstFalse
cabalVerbose
    FirstFalse
buildMonoidSplitObjs <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidSplitObjsName
    [Text]
buildMonoidSkipComponents <-
      Object
o Object -> Text -> WarningParser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidSkipComponentsName WarningParser (Maybe [Text]) -> [Text] -> WarningParser [Text]
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= [Text]
forall a. Monoid a => a
mempty
    FirstTrue
buildMonoidInterleavedOutput <-
      Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidInterleavedOutputName
    First ProgressBarFormat
buildMonoidProgressBar <-
      Maybe ProgressBarFormat -> First ProgressBarFormat
forall a. Maybe a -> First a
First (Maybe ProgressBarFormat -> First ProgressBarFormat)
-> WriterT WarningParserMonoid Parser (Maybe ProgressBarFormat)
-> WriterT WarningParserMonoid Parser (First ProgressBarFormat)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object
-> Text
-> WriterT WarningParserMonoid Parser (Maybe ProgressBarFormat)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidProgressBarName
    First Text
buildMonoidDdumpDir <- Object
o Object -> Text -> WarningParser (Maybe (First Text))
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
buildMonoidDdumpDirName WarningParser (Maybe (First Text))
-> First Text -> WarningParser (First Text)
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= First Text
forall a. Monoid a => a
mempty
    BuildOptsMonoid -> WarningParser BuildOptsMonoid
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BuildOptsMonoid{[Text]
Any
First Bool
First Text
First ProgressBarFormat
First CabalVerbosity
FirstFalse
FirstTrue
BenchmarkOptsMonoid
HaddockOptsMonoid
TestOptsMonoid
buildMonoidLibProfile :: FirstFalse
buildMonoidExeProfile :: FirstFalse
buildMonoidLibStrip :: FirstTrue
buildMonoidExeStrip :: FirstTrue
buildMonoidOpenHaddocks :: FirstFalse
buildMonoidHaddockInternal :: FirstFalse
buildMonoidHaddockHyperlinkSource :: FirstTrue
buildMonoidHaddockForHackage :: FirstFalse
buildMonoidInstallExes :: FirstFalse
buildMonoidInstallCompilerTool :: FirstFalse
buildMonoidPreFetch :: FirstFalse
buildMonoidKeepTmpFiles :: FirstFalse
buildMonoidForceDirty :: FirstFalse
buildMonoidTests :: FirstFalse
buildMonoidBenchmarks :: FirstFalse
buildMonoidReconfigure :: FirstFalse
buildMonoidSplitObjs :: FirstFalse
buildMonoidInterleavedOutput :: FirstTrue
buildMonoidTrace :: Any
buildMonoidProfile :: Any
buildMonoidNoStrip :: Any
buildMonoidHaddock :: FirstFalse
buildMonoidHaddockOpts :: HaddockOptsMonoid
buildMonoidHaddockDeps :: First Bool
buildMonoidKeepGoing :: First Bool
buildMonoidTestOpts :: TestOptsMonoid
buildMonoidBenchmarkOpts :: BenchmarkOptsMonoid
buildMonoidCabalVerbose :: First CabalVerbosity
buildMonoidSkipComponents :: [Text]
buildMonoidProgressBar :: First ProgressBarFormat
buildMonoidDdumpDir :: First Text
buildMonoidTrace :: Any
buildMonoidProfile :: Any
buildMonoidNoStrip :: Any
buildMonoidLibProfile :: FirstFalse
buildMonoidExeProfile :: FirstFalse
buildMonoidLibStrip :: FirstTrue
buildMonoidExeStrip :: FirstTrue
buildMonoidHaddock :: FirstFalse
buildMonoidHaddockOpts :: HaddockOptsMonoid
buildMonoidOpenHaddocks :: FirstFalse
buildMonoidHaddockDeps :: First Bool
buildMonoidHaddockInternal :: FirstFalse
buildMonoidHaddockHyperlinkSource :: FirstTrue
buildMonoidHaddockForHackage :: FirstFalse
buildMonoidInstallExes :: FirstFalse
buildMonoidInstallCompilerTool :: FirstFalse
buildMonoidPreFetch :: FirstFalse
buildMonoidKeepGoing :: First Bool
buildMonoidKeepTmpFiles :: FirstFalse
buildMonoidForceDirty :: FirstFalse
buildMonoidTests :: FirstFalse
buildMonoidTestOpts :: TestOptsMonoid
buildMonoidBenchmarks :: FirstFalse
buildMonoidBenchmarkOpts :: BenchmarkOptsMonoid
buildMonoidReconfigure :: FirstFalse
buildMonoidCabalVerbose :: First CabalVerbosity
buildMonoidSplitObjs :: FirstFalse
buildMonoidSkipComponents :: [Text]
buildMonoidInterleavedOutput :: FirstTrue
buildMonoidProgressBar :: First ProgressBarFormat
buildMonoidDdumpDir :: First Text
..}

buildMonoidLibProfileArgName :: Text
buildMonoidLibProfileArgName :: Text
buildMonoidLibProfileArgName = Text
"library-profiling"

buildMonoidExeProfileArgName :: Text
buildMonoidExeProfileArgName :: Text
buildMonoidExeProfileArgName = Text
"executable-profiling"

buildMonoidLibStripArgName :: Text
buildMonoidLibStripArgName :: Text
buildMonoidLibStripArgName = Text
"library-stripping"

buildMonoidExeStripArgName :: Text
buildMonoidExeStripArgName :: Text
buildMonoidExeStripArgName = Text
"executable-stripping"

buildMonoidHaddockArgName :: Text
buildMonoidHaddockArgName :: Text
buildMonoidHaddockArgName = Text
"haddock"

buildMonoidHaddockOptsArgName :: Text
buildMonoidHaddockOptsArgName :: Text
buildMonoidHaddockOptsArgName = Text
"haddock-arguments"

buildMonoidOpenHaddocksArgName :: Text
buildMonoidOpenHaddocksArgName :: Text
buildMonoidOpenHaddocksArgName = Text
"open-haddocks"

buildMonoidHaddockDepsArgName :: Text
buildMonoidHaddockDepsArgName :: Text
buildMonoidHaddockDepsArgName = Text
"haddock-deps"

buildMonoidHaddockInternalArgName :: Text
buildMonoidHaddockInternalArgName :: Text
buildMonoidHaddockInternalArgName = Text
"haddock-internal"

buildMonoidHaddockHyperlinkSourceArgName :: Text
buildMonoidHaddockHyperlinkSourceArgName :: Text
buildMonoidHaddockHyperlinkSourceArgName = Text
"haddock-hyperlink-source"

buildMonoidHaddockForHackageArgName :: Text
buildMonoidHaddockForHackageArgName :: Text
buildMonoidHaddockForHackageArgName = Text
"haddock-for-hackage"

buildMonoidInstallExesArgName :: Text
buildMonoidInstallExesArgName :: Text
buildMonoidInstallExesArgName = Text
"copy-bins"

buildMonoidInstallCompilerToolArgName :: Text
buildMonoidInstallCompilerToolArgName :: Text
buildMonoidInstallCompilerToolArgName = Text
"copy-compiler-tool"

buildMonoidPreFetchArgName :: Text
buildMonoidPreFetchArgName :: Text
buildMonoidPreFetchArgName = Text
"prefetch"

buildMonoidKeepGoingArgName :: Text
buildMonoidKeepGoingArgName :: Text
buildMonoidKeepGoingArgName = Text
"keep-going"

buildMonoidKeepTmpFilesArgName :: Text
buildMonoidKeepTmpFilesArgName :: Text
buildMonoidKeepTmpFilesArgName = Text
"keep-tmp-files"

buildMonoidForceDirtyArgName :: Text
buildMonoidForceDirtyArgName :: Text
buildMonoidForceDirtyArgName = Text
"force-dirty"

buildMonoidTestsArgName :: Text
buildMonoidTestsArgName :: Text
buildMonoidTestsArgName = Text
"test"

buildMonoidTestOptsArgName :: Text
buildMonoidTestOptsArgName :: Text
buildMonoidTestOptsArgName = Text
"test-arguments"

buildMonoidBenchmarksArgName :: Text
buildMonoidBenchmarksArgName :: Text
buildMonoidBenchmarksArgName = Text
"bench"

buildMonoidBenchmarkOptsArgName :: Text
buildMonoidBenchmarkOptsArgName :: Text
buildMonoidBenchmarkOptsArgName = Text
"benchmark-opts"

buildMonoidReconfigureArgName :: Text
buildMonoidReconfigureArgName :: Text
buildMonoidReconfigureArgName = Text
"reconfigure"

buildMonoidCabalVerbosityArgName :: Text
buildMonoidCabalVerbosityArgName :: Text
buildMonoidCabalVerbosityArgName = Text
"cabal-verbosity"

buildMonoidCabalVerboseArgName :: Text
buildMonoidCabalVerboseArgName :: Text
buildMonoidCabalVerboseArgName = Text
"cabal-verbose"

buildMonoidSplitObjsName :: Text
buildMonoidSplitObjsName :: Text
buildMonoidSplitObjsName = Text
"split-objs"

buildMonoidSkipComponentsName :: Text
buildMonoidSkipComponentsName :: Text
buildMonoidSkipComponentsName = Text
"skip-components"

buildMonoidInterleavedOutputName :: Text
buildMonoidInterleavedOutputName :: Text
buildMonoidInterleavedOutputName = Text
"interleaved-output"

buildMonoidProgressBarName :: Text
buildMonoidProgressBarName :: Text
buildMonoidProgressBarName = Text
"progress-bar"

buildMonoidDdumpDirName :: Text
buildMonoidDdumpDirName :: Text
buildMonoidDdumpDirName = Text
"ddump-dir"

instance Semigroup BuildOptsMonoid where
  <> :: BuildOptsMonoid -> BuildOptsMonoid -> BuildOptsMonoid
(<>) = BuildOptsMonoid -> BuildOptsMonoid -> BuildOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault

instance Monoid BuildOptsMonoid where
  mempty :: BuildOptsMonoid
mempty = BuildOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
  mappend :: BuildOptsMonoid -> BuildOptsMonoid -> BuildOptsMonoid
mappend = BuildOptsMonoid -> BuildOptsMonoid -> BuildOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)

-- | Which subset of packages to build

data BuildSubset
  = BSAll
  | BSOnlySnapshot
    -- ^ Only install packages in the snapshot database, skipping

    -- packages intended for the local database.

  | BSOnlyDependencies
  | BSOnlyLocals
    -- ^ Refuse to build anything in the snapshot database, see

    -- https://github.com/commercialhaskell/stack/issues/5272

  deriving (Int -> BuildSubset -> ShowS
[BuildSubset] -> ShowS
BuildSubset -> String
(Int -> BuildSubset -> ShowS)
-> (BuildSubset -> String)
-> ([BuildSubset] -> ShowS)
-> Show BuildSubset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildSubset -> ShowS
showsPrec :: Int -> BuildSubset -> ShowS
$cshow :: BuildSubset -> String
show :: BuildSubset -> String
$cshowList :: [BuildSubset] -> ShowS
showList :: [BuildSubset] -> ShowS
Show, BuildSubset -> BuildSubset -> Bool
(BuildSubset -> BuildSubset -> Bool)
-> (BuildSubset -> BuildSubset -> Bool) -> Eq BuildSubset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BuildSubset -> BuildSubset -> Bool
== :: BuildSubset -> BuildSubset -> Bool
$c/= :: BuildSubset -> BuildSubset -> Bool
/= :: BuildSubset -> BuildSubset -> Bool
Eq)

-- | Options for the 'FinalAction' 'DoTests'

data TestOpts = TestOpts
  { TestOpts -> Bool
toRerunTests :: !Bool -- ^ Whether successful tests will be run gain

  , TestOpts -> [String]
toAdditionalArgs :: ![String] -- ^ Arguments passed to the test program

  , TestOpts -> Bool
toCoverage :: !Bool -- ^ Generate a code coverage report

  , TestOpts -> Bool
toDisableRun :: !Bool -- ^ Disable running of tests

  , TestOpts -> Maybe Int
toMaximumTimeSeconds :: !(Maybe Int) -- ^ test suite timeout in seconds

  , TestOpts -> Bool
toAllowStdin :: !Bool -- ^ Whether to allow standard input

  }
  deriving (TestOpts -> TestOpts -> Bool
(TestOpts -> TestOpts -> Bool)
-> (TestOpts -> TestOpts -> Bool) -> Eq TestOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestOpts -> TestOpts -> Bool
== :: TestOpts -> TestOpts -> Bool
$c/= :: TestOpts -> TestOpts -> Bool
/= :: TestOpts -> TestOpts -> Bool
Eq, Int -> TestOpts -> ShowS
[TestOpts] -> ShowS
TestOpts -> String
(Int -> TestOpts -> ShowS)
-> (TestOpts -> String) -> ([TestOpts] -> ShowS) -> Show TestOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestOpts -> ShowS
showsPrec :: Int -> TestOpts -> ShowS
$cshow :: TestOpts -> String
show :: TestOpts -> String
$cshowList :: [TestOpts] -> ShowS
showList :: [TestOpts] -> ShowS
Show)

defaultTestOpts :: TestOpts
defaultTestOpts :: TestOpts
defaultTestOpts = TestOpts
  { toRerunTests :: Bool
toRerunTests = (TestOptsMonoid -> FirstTrue) -> Bool
forall a. (a -> FirstTrue) -> Bool
defaultFirstTrue TestOptsMonoid -> FirstTrue
toMonoidRerunTests
  , toAdditionalArgs :: [String]
toAdditionalArgs = []
  , toCoverage :: Bool
toCoverage = (TestOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse TestOptsMonoid -> FirstFalse
toMonoidCoverage
  , toDisableRun :: Bool
toDisableRun = (TestOptsMonoid -> FirstFalse) -> Bool
forall a. (a -> FirstFalse) -> Bool
defaultFirstFalse TestOptsMonoid -> FirstFalse
toMonoidDisableRun
  , toMaximumTimeSeconds :: Maybe Int
toMaximumTimeSeconds = Maybe Int
forall a. Maybe a
Nothing
  , toAllowStdin :: Bool
toAllowStdin = (TestOptsMonoid -> FirstTrue) -> Bool
forall a. (a -> FirstTrue) -> Bool
defaultFirstTrue TestOptsMonoid -> FirstTrue
toMonoidAllowStdin
  }

data TestOptsMonoid = TestOptsMonoid
  { TestOptsMonoid -> FirstTrue
toMonoidRerunTests :: !FirstTrue
  , TestOptsMonoid -> [String]
toMonoidAdditionalArgs :: ![String]
  , TestOptsMonoid -> FirstFalse
toMonoidCoverage :: !FirstFalse
  , TestOptsMonoid -> FirstFalse
toMonoidDisableRun :: !FirstFalse
  , TestOptsMonoid -> First (Maybe Int)
toMonoidMaximumTimeSeconds :: !(First (Maybe Int))
  , TestOptsMonoid -> FirstTrue
toMonoidAllowStdin :: !FirstTrue
  }
  deriving (Int -> TestOptsMonoid -> ShowS
[TestOptsMonoid] -> ShowS
TestOptsMonoid -> String
(Int -> TestOptsMonoid -> ShowS)
-> (TestOptsMonoid -> String)
-> ([TestOptsMonoid] -> ShowS)
-> Show TestOptsMonoid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestOptsMonoid -> ShowS
showsPrec :: Int -> TestOptsMonoid -> ShowS
$cshow :: TestOptsMonoid -> String
show :: TestOptsMonoid -> String
$cshowList :: [TestOptsMonoid] -> ShowS
showList :: [TestOptsMonoid] -> ShowS
Show, (forall x. TestOptsMonoid -> Rep TestOptsMonoid x)
-> (forall x. Rep TestOptsMonoid x -> TestOptsMonoid)
-> Generic TestOptsMonoid
forall x. Rep TestOptsMonoid x -> TestOptsMonoid
forall x. TestOptsMonoid -> Rep TestOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TestOptsMonoid -> Rep TestOptsMonoid x
from :: forall x. TestOptsMonoid -> Rep TestOptsMonoid x
$cto :: forall x. Rep TestOptsMonoid x -> TestOptsMonoid
to :: forall x. Rep TestOptsMonoid x -> TestOptsMonoid
Generic)

instance FromJSON (WithJSONWarnings TestOptsMonoid) where
  parseJSON :: Value -> Parser (WithJSONWarnings TestOptsMonoid)
parseJSON = String
-> (Object -> WarningParser TestOptsMonoid)
-> Value
-> Parser (WithJSONWarnings TestOptsMonoid)
forall a.
String
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings String
"TestOptsMonoid" ((Object -> WarningParser TestOptsMonoid)
 -> Value -> Parser (WithJSONWarnings TestOptsMonoid))
-> (Object -> WarningParser TestOptsMonoid)
-> Value
-> Parser (WithJSONWarnings TestOptsMonoid)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    FirstTrue
toMonoidRerunTests <- Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
toMonoidRerunTestsArgName
    [String]
toMonoidAdditionalArgs <- Object
o Object -> Text -> WarningParser (Maybe [String])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
toMonoidAdditionalArgsName WarningParser (Maybe [String])
-> [String] -> WarningParser [String]
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= []
    FirstFalse
toMonoidCoverage <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
toMonoidCoverageArgName
    FirstFalse
toMonoidDisableRun <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
toMonoidDisableRunArgName
    First (Maybe Int)
toMonoidMaximumTimeSeconds <-
      Maybe (Maybe Int) -> First (Maybe Int)
forall a. Maybe a -> First a
First (Maybe (Maybe Int) -> First (Maybe Int))
-> WriterT WarningParserMonoid Parser (Maybe (Maybe Int))
-> WriterT WarningParserMonoid Parser (First (Maybe Int))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object
-> Text -> WriterT WarningParserMonoid Parser (Maybe (Maybe Int))
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
toMonoidMaximumTimeSecondsArgName
    FirstTrue
toMonoidAllowStdin <- Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
toMonoidTestsAllowStdinName
    TestOptsMonoid -> WarningParser TestOptsMonoid
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TestOptsMonoid{[String]
First (Maybe Int)
FirstFalse
FirstTrue
toMonoidRerunTests :: FirstTrue
toMonoidCoverage :: FirstFalse
toMonoidDisableRun :: FirstFalse
toMonoidAllowStdin :: FirstTrue
toMonoidAdditionalArgs :: [String]
toMonoidMaximumTimeSeconds :: First (Maybe Int)
toMonoidRerunTests :: FirstTrue
toMonoidAdditionalArgs :: [String]
toMonoidCoverage :: FirstFalse
toMonoidDisableRun :: FirstFalse
toMonoidMaximumTimeSeconds :: First (Maybe Int)
toMonoidAllowStdin :: FirstTrue
..}

toMonoidRerunTestsArgName :: Text
toMonoidRerunTestsArgName :: Text
toMonoidRerunTestsArgName = Text
"rerun-tests"

toMonoidAdditionalArgsName :: Text
toMonoidAdditionalArgsName :: Text
toMonoidAdditionalArgsName = Text
"additional-args"

toMonoidCoverageArgName :: Text
toMonoidCoverageArgName :: Text
toMonoidCoverageArgName = Text
"coverage"

toMonoidDisableRunArgName :: Text
toMonoidDisableRunArgName :: Text
toMonoidDisableRunArgName = Text
"no-run-tests"

toMonoidMaximumTimeSecondsArgName :: Text
toMonoidMaximumTimeSecondsArgName :: Text
toMonoidMaximumTimeSecondsArgName = Text
"test-suite-timeout"

toMonoidTestsAllowStdinName :: Text
toMonoidTestsAllowStdinName :: Text
toMonoidTestsAllowStdinName = Text
"tests-allow-stdin"

instance Semigroup TestOptsMonoid where
  <> :: TestOptsMonoid -> TestOptsMonoid -> TestOptsMonoid
(<>) = TestOptsMonoid -> TestOptsMonoid -> TestOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault

instance Monoid TestOptsMonoid where
  mempty :: TestOptsMonoid
mempty = TestOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
  mappend :: TestOptsMonoid -> TestOptsMonoid -> TestOptsMonoid
mappend = TestOptsMonoid -> TestOptsMonoid -> TestOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)

-- | Haddock Options

newtype HaddockOpts = HaddockOpts
  { HaddockOpts -> [String]
hoAdditionalArgs :: [String] -- ^ Arguments passed to haddock program

  }
  deriving (HaddockOpts -> HaddockOpts -> Bool
(HaddockOpts -> HaddockOpts -> Bool)
-> (HaddockOpts -> HaddockOpts -> Bool) -> Eq HaddockOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HaddockOpts -> HaddockOpts -> Bool
== :: HaddockOpts -> HaddockOpts -> Bool
$c/= :: HaddockOpts -> HaddockOpts -> Bool
/= :: HaddockOpts -> HaddockOpts -> Bool
Eq, Int -> HaddockOpts -> ShowS
[HaddockOpts] -> ShowS
HaddockOpts -> String
(Int -> HaddockOpts -> ShowS)
-> (HaddockOpts -> String)
-> ([HaddockOpts] -> ShowS)
-> Show HaddockOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HaddockOpts -> ShowS
showsPrec :: Int -> HaddockOpts -> ShowS
$cshow :: HaddockOpts -> String
show :: HaddockOpts -> String
$cshowList :: [HaddockOpts] -> ShowS
showList :: [HaddockOpts] -> ShowS
Show)

newtype HaddockOptsMonoid = HaddockOptsMonoid
  { HaddockOptsMonoid -> [String]
hoMonoidAdditionalArgs :: [String]
  }
  deriving ((forall x. HaddockOptsMonoid -> Rep HaddockOptsMonoid x)
-> (forall x. Rep HaddockOptsMonoid x -> HaddockOptsMonoid)
-> Generic HaddockOptsMonoid
forall x. Rep HaddockOptsMonoid x -> HaddockOptsMonoid
forall x. HaddockOptsMonoid -> Rep HaddockOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HaddockOptsMonoid -> Rep HaddockOptsMonoid x
from :: forall x. HaddockOptsMonoid -> Rep HaddockOptsMonoid x
$cto :: forall x. Rep HaddockOptsMonoid x -> HaddockOptsMonoid
to :: forall x. Rep HaddockOptsMonoid x -> HaddockOptsMonoid
Generic, Int -> HaddockOptsMonoid -> ShowS
[HaddockOptsMonoid] -> ShowS
HaddockOptsMonoid -> String
(Int -> HaddockOptsMonoid -> ShowS)
-> (HaddockOptsMonoid -> String)
-> ([HaddockOptsMonoid] -> ShowS)
-> Show HaddockOptsMonoid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HaddockOptsMonoid -> ShowS
showsPrec :: Int -> HaddockOptsMonoid -> ShowS
$cshow :: HaddockOptsMonoid -> String
show :: HaddockOptsMonoid -> String
$cshowList :: [HaddockOptsMonoid] -> ShowS
showList :: [HaddockOptsMonoid] -> ShowS
Show)

defaultHaddockOpts :: HaddockOpts
defaultHaddockOpts :: HaddockOpts
defaultHaddockOpts = HaddockOpts {hoAdditionalArgs :: [String]
hoAdditionalArgs = []}

instance FromJSON (WithJSONWarnings HaddockOptsMonoid) where
  parseJSON :: Value -> Parser (WithJSONWarnings HaddockOptsMonoid)
parseJSON = String
-> (Object -> WarningParser HaddockOptsMonoid)
-> Value
-> Parser (WithJSONWarnings HaddockOptsMonoid)
forall a.
String
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings String
"HaddockOptsMonoid" ((Object -> WarningParser HaddockOptsMonoid)
 -> Value -> Parser (WithJSONWarnings HaddockOptsMonoid))
-> (Object -> WarningParser HaddockOptsMonoid)
-> Value
-> Parser (WithJSONWarnings HaddockOptsMonoid)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    [String]
hoMonoidAdditionalArgs <- Object
o Object -> Text -> WarningParser (Maybe [String])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
hoMonoidAdditionalArgsName WarningParser (Maybe [String])
-> [String] -> WarningParser [String]
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= []
    HaddockOptsMonoid -> WarningParser HaddockOptsMonoid
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HaddockOptsMonoid{[String]
hoMonoidAdditionalArgs :: [String]
hoMonoidAdditionalArgs :: [String]
..}

instance Semigroup HaddockOptsMonoid where
  <> :: HaddockOptsMonoid -> HaddockOptsMonoid -> HaddockOptsMonoid
(<>) = HaddockOptsMonoid -> HaddockOptsMonoid -> HaddockOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault

instance Monoid HaddockOptsMonoid where
  mempty :: HaddockOptsMonoid
mempty = HaddockOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
  mappend :: HaddockOptsMonoid -> HaddockOptsMonoid -> HaddockOptsMonoid
mappend = HaddockOptsMonoid -> HaddockOptsMonoid -> HaddockOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)

hoMonoidAdditionalArgsName :: Text
hoMonoidAdditionalArgsName :: Text
hoMonoidAdditionalArgsName = Text
"haddock-args"

-- | Options for the 'FinalAction' 'DoBenchmarks'

data BenchmarkOpts = BenchmarkOpts
  { BenchmarkOpts -> Maybe String
beoAdditionalArgs :: !(Maybe String)
    -- ^ Arguments passed to the benchmark program

  , BenchmarkOpts -> Bool
beoDisableRun :: !Bool
    -- ^ Disable running of benchmarks

  }
  deriving (BenchmarkOpts -> BenchmarkOpts -> Bool
(BenchmarkOpts -> BenchmarkOpts -> Bool)
-> (BenchmarkOpts -> BenchmarkOpts -> Bool) -> Eq BenchmarkOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BenchmarkOpts -> BenchmarkOpts -> Bool
== :: BenchmarkOpts -> BenchmarkOpts -> Bool
$c/= :: BenchmarkOpts -> BenchmarkOpts -> Bool
/= :: BenchmarkOpts -> BenchmarkOpts -> Bool
Eq, Int -> BenchmarkOpts -> ShowS
[BenchmarkOpts] -> ShowS
BenchmarkOpts -> String
(Int -> BenchmarkOpts -> ShowS)
-> (BenchmarkOpts -> String)
-> ([BenchmarkOpts] -> ShowS)
-> Show BenchmarkOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BenchmarkOpts -> ShowS
showsPrec :: Int -> BenchmarkOpts -> ShowS
$cshow :: BenchmarkOpts -> String
show :: BenchmarkOpts -> String
$cshowList :: [BenchmarkOpts] -> ShowS
showList :: [BenchmarkOpts] -> ShowS
Show)

defaultBenchmarkOpts :: BenchmarkOpts
defaultBenchmarkOpts :: BenchmarkOpts
defaultBenchmarkOpts = BenchmarkOpts
  { beoAdditionalArgs :: Maybe String
beoAdditionalArgs = Maybe String
forall a. Maybe a
Nothing
  , beoDisableRun :: Bool
beoDisableRun = Bool
False
  }

data BenchmarkOptsMonoid = BenchmarkOptsMonoid
  { BenchmarkOptsMonoid -> First String
beoMonoidAdditionalArgs :: !(First String)
  , BenchmarkOptsMonoid -> First Bool
beoMonoidDisableRun :: !(First Bool)
  }
  deriving ((forall x. BenchmarkOptsMonoid -> Rep BenchmarkOptsMonoid x)
-> (forall x. Rep BenchmarkOptsMonoid x -> BenchmarkOptsMonoid)
-> Generic BenchmarkOptsMonoid
forall x. Rep BenchmarkOptsMonoid x -> BenchmarkOptsMonoid
forall x. BenchmarkOptsMonoid -> Rep BenchmarkOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BenchmarkOptsMonoid -> Rep BenchmarkOptsMonoid x
from :: forall x. BenchmarkOptsMonoid -> Rep BenchmarkOptsMonoid x
$cto :: forall x. Rep BenchmarkOptsMonoid x -> BenchmarkOptsMonoid
to :: forall x. Rep BenchmarkOptsMonoid x -> BenchmarkOptsMonoid
Generic, Int -> BenchmarkOptsMonoid -> ShowS
[BenchmarkOptsMonoid] -> ShowS
BenchmarkOptsMonoid -> String
(Int -> BenchmarkOptsMonoid -> ShowS)
-> (BenchmarkOptsMonoid -> String)
-> ([BenchmarkOptsMonoid] -> ShowS)
-> Show BenchmarkOptsMonoid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BenchmarkOptsMonoid -> ShowS
showsPrec :: Int -> BenchmarkOptsMonoid -> ShowS
$cshow :: BenchmarkOptsMonoid -> String
show :: BenchmarkOptsMonoid -> String
$cshowList :: [BenchmarkOptsMonoid] -> ShowS
showList :: [BenchmarkOptsMonoid] -> ShowS
Show)

instance FromJSON (WithJSONWarnings BenchmarkOptsMonoid) where
  parseJSON :: Value -> Parser (WithJSONWarnings BenchmarkOptsMonoid)
parseJSON = String
-> (Object -> WarningParser BenchmarkOptsMonoid)
-> Value
-> Parser (WithJSONWarnings BenchmarkOptsMonoid)
forall a.
String
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings String
"BenchmarkOptsMonoid" ((Object -> WarningParser BenchmarkOptsMonoid)
 -> Value -> Parser (WithJSONWarnings BenchmarkOptsMonoid))
-> (Object -> WarningParser BenchmarkOptsMonoid)
-> Value
-> Parser (WithJSONWarnings BenchmarkOptsMonoid)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    First String
beoMonoidAdditionalArgs <- Maybe String -> First String
forall a. Maybe a -> First a
First (Maybe String -> First String)
-> WriterT WarningParserMonoid Parser (Maybe String)
-> WriterT WarningParserMonoid Parser (First String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe String)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
beoMonoidAdditionalArgsArgName
    First Bool
beoMonoidDisableRun <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
beoMonoidDisableRunArgName
    BenchmarkOptsMonoid -> WarningParser BenchmarkOptsMonoid
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BenchmarkOptsMonoid{First Bool
First String
beoMonoidAdditionalArgs :: First String
beoMonoidDisableRun :: First Bool
beoMonoidAdditionalArgs :: First String
beoMonoidDisableRun :: First Bool
..}

beoMonoidAdditionalArgsArgName :: Text
beoMonoidAdditionalArgsArgName :: Text
beoMonoidAdditionalArgsArgName = Text
"benchmark-arguments"

beoMonoidDisableRunArgName :: Text
beoMonoidDisableRunArgName :: Text
beoMonoidDisableRunArgName = Text
"no-run-benchmarks"

instance Semigroup BenchmarkOptsMonoid where
  <> :: BenchmarkOptsMonoid -> BenchmarkOptsMonoid -> BenchmarkOptsMonoid
(<>) = BenchmarkOptsMonoid -> BenchmarkOptsMonoid -> BenchmarkOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault

instance Monoid BenchmarkOptsMonoid where
  mempty :: BenchmarkOptsMonoid
mempty = BenchmarkOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
  mappend :: BenchmarkOptsMonoid -> BenchmarkOptsMonoid -> BenchmarkOptsMonoid
mappend = BenchmarkOptsMonoid -> BenchmarkOptsMonoid -> BenchmarkOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)

data FileWatchOpts
  = NoFileWatch
  | FileWatch
  | FileWatchPoll
  deriving (Int -> FileWatchOpts -> ShowS
[FileWatchOpts] -> ShowS
FileWatchOpts -> String
(Int -> FileWatchOpts -> ShowS)
-> (FileWatchOpts -> String)
-> ([FileWatchOpts] -> ShowS)
-> Show FileWatchOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileWatchOpts -> ShowS
showsPrec :: Int -> FileWatchOpts -> ShowS
$cshow :: FileWatchOpts -> String
show :: FileWatchOpts -> String
$cshowList :: [FileWatchOpts] -> ShowS
showList :: [FileWatchOpts] -> ShowS
Show, FileWatchOpts -> FileWatchOpts -> Bool
(FileWatchOpts -> FileWatchOpts -> Bool)
-> (FileWatchOpts -> FileWatchOpts -> Bool) -> Eq FileWatchOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileWatchOpts -> FileWatchOpts -> Bool
== :: FileWatchOpts -> FileWatchOpts -> Bool
$c/= :: FileWatchOpts -> FileWatchOpts -> Bool
/= :: FileWatchOpts -> FileWatchOpts -> Bool
Eq)

newtype CabalVerbosity
  = CabalVerbosity Verbosity
  deriving (CabalVerbosity -> CabalVerbosity -> Bool
(CabalVerbosity -> CabalVerbosity -> Bool)
-> (CabalVerbosity -> CabalVerbosity -> Bool) -> Eq CabalVerbosity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CabalVerbosity -> CabalVerbosity -> Bool
== :: CabalVerbosity -> CabalVerbosity -> Bool
$c/= :: CabalVerbosity -> CabalVerbosity -> Bool
/= :: CabalVerbosity -> CabalVerbosity -> Bool
Eq, Int -> CabalVerbosity -> ShowS
[CabalVerbosity] -> ShowS
CabalVerbosity -> String
(Int -> CabalVerbosity -> ShowS)
-> (CabalVerbosity -> String)
-> ([CabalVerbosity] -> ShowS)
-> Show CabalVerbosity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CabalVerbosity -> ShowS
showsPrec :: Int -> CabalVerbosity -> ShowS
$cshow :: CabalVerbosity -> String
show :: CabalVerbosity -> String
$cshowList :: [CabalVerbosity] -> ShowS
showList :: [CabalVerbosity] -> ShowS
Show)

toFirstCabalVerbosity :: FirstFalse -> First CabalVerbosity
toFirstCabalVerbosity :: FirstFalse -> First CabalVerbosity
toFirstCabalVerbosity FirstFalse
vf = Maybe CabalVerbosity -> First CabalVerbosity
forall a. Maybe a -> First a
First (Maybe CabalVerbosity -> First CabalVerbosity)
-> Maybe CabalVerbosity -> First CabalVerbosity
forall a b. (a -> b) -> a -> b
$ FirstFalse -> Maybe Bool
getFirstFalse FirstFalse
vf Maybe Bool -> (Bool -> CabalVerbosity) -> Maybe CabalVerbosity
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Bool
p ->
  if Bool
p then CabalVerbosity
verboseLevel else CabalVerbosity
normalLevel
 where
  verboseLevel :: CabalVerbosity
verboseLevel = Verbosity -> CabalVerbosity
CabalVerbosity Verbosity
verbose
  normalLevel :: CabalVerbosity
normalLevel  = Verbosity -> CabalVerbosity
CabalVerbosity Verbosity
normal

instance FromJSON CabalVerbosity where

  parseJSON :: Value -> Parser CabalVerbosity
parseJSON = String
-> (Text -> Parser CabalVerbosity)
-> Value
-> Parser CabalVerbosity
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"CabalVerbosity" ((Text -> Parser CabalVerbosity) -> Value -> Parser CabalVerbosity)
-> (Text -> Parser CabalVerbosity)
-> Value
-> Parser CabalVerbosity
forall a b. (a -> b) -> a -> b
$ \Text
t ->
    let s :: String
s = Text -> String
T.unpack Text
t
        errMsg :: Parser a
errMsg = String -> Parser a
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser a) -> String -> Parser a
forall a b. (a -> b) -> a -> b
$ String
"Unrecognised Cabal verbosity: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
    in  Parser CabalVerbosity
-> (CabalVerbosity -> Parser CabalVerbosity)
-> Maybe CabalVerbosity
-> Parser CabalVerbosity
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Parser CabalVerbosity
forall {a}. Parser a
errMsg CabalVerbosity -> Parser CabalVerbosity
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> Maybe CabalVerbosity
forall a. Parsec a => String -> Maybe a
simpleParsec String
s)

instance Parsec CabalVerbosity where
  parsec :: forall (m :: * -> *). CabalParsing m => m CabalVerbosity
parsec = Verbosity -> CabalVerbosity
CabalVerbosity (Verbosity -> CabalVerbosity) -> m Verbosity -> m CabalVerbosity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Verbosity
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m Verbosity
parsec

buildOptsMonoidHaddockL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidHaddockL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidHaddockL =
  (BuildOptsMonoid -> Maybe Bool)
-> (BuildOptsMonoid -> Maybe Bool -> BuildOptsMonoid)
-> Lens' BuildOptsMonoid (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (FirstFalse -> Maybe Bool
getFirstFalse (FirstFalse -> Maybe Bool)
-> (BuildOptsMonoid -> FirstFalse) -> BuildOptsMonoid -> Maybe Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildOptsMonoid -> FirstFalse
buildMonoidHaddock)
    (\BuildOptsMonoid
buildMonoid Maybe Bool
t -> BuildOptsMonoid
buildMonoid {buildMonoidHaddock :: FirstFalse
buildMonoidHaddock = Maybe Bool -> FirstFalse
FirstFalse Maybe Bool
t})

buildOptsMonoidTestsL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidTestsL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidTestsL =
  (BuildOptsMonoid -> Maybe Bool)
-> (BuildOptsMonoid -> Maybe Bool -> BuildOptsMonoid)
-> Lens' BuildOptsMonoid (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (FirstFalse -> Maybe Bool
getFirstFalse (FirstFalse -> Maybe Bool)
-> (BuildOptsMonoid -> FirstFalse) -> BuildOptsMonoid -> Maybe Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildOptsMonoid -> FirstFalse
buildMonoidTests)
    (\BuildOptsMonoid
buildMonoid Maybe Bool
t -> BuildOptsMonoid
buildMonoid {buildMonoidTests :: FirstFalse
buildMonoidTests = Maybe Bool -> FirstFalse
FirstFalse Maybe Bool
t})

buildOptsMonoidBenchmarksL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidBenchmarksL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidBenchmarksL =
  (BuildOptsMonoid -> Maybe Bool)
-> (BuildOptsMonoid -> Maybe Bool -> BuildOptsMonoid)
-> Lens' BuildOptsMonoid (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (FirstFalse -> Maybe Bool
getFirstFalse (FirstFalse -> Maybe Bool)
-> (BuildOptsMonoid -> FirstFalse) -> BuildOptsMonoid -> Maybe Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildOptsMonoid -> FirstFalse
buildMonoidBenchmarks)
    (\BuildOptsMonoid
buildMonoid Maybe Bool
t -> BuildOptsMonoid
buildMonoid {buildMonoidBenchmarks :: FirstFalse
buildMonoidBenchmarks = Maybe Bool -> FirstFalse
FirstFalse Maybe Bool
t})

buildOptsMonoidInstallExesL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidInstallExesL :: Lens' BuildOptsMonoid (Maybe Bool)
buildOptsMonoidInstallExesL =
  (BuildOptsMonoid -> Maybe Bool)
-> (BuildOptsMonoid -> Maybe Bool -> BuildOptsMonoid)
-> Lens' BuildOptsMonoid (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (FirstFalse -> Maybe Bool
getFirstFalse (FirstFalse -> Maybe Bool)
-> (BuildOptsMonoid -> FirstFalse) -> BuildOptsMonoid -> Maybe Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildOptsMonoid -> FirstFalse
buildMonoidInstallExes)
    (\BuildOptsMonoid
buildMonoid Maybe Bool
t -> BuildOptsMonoid
buildMonoid {buildMonoidInstallExes :: FirstFalse
buildMonoidInstallExes = Maybe Bool -> FirstFalse
FirstFalse Maybe Bool
t})

buildOptsInstallExesL :: Lens' BuildOpts Bool
buildOptsInstallExesL :: Lens' BuildOpts Bool
buildOptsInstallExesL =
  (BuildOpts -> Bool)
-> (BuildOpts -> Bool -> BuildOpts) -> Lens' BuildOpts Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens BuildOpts -> Bool
boptsInstallExes
    (\BuildOpts
bopts Bool
t -> BuildOpts
bopts {boptsInstallExes :: Bool
boptsInstallExes = Bool
t})

buildOptsHaddockL :: Lens' BuildOpts Bool
buildOptsHaddockL :: Lens' BuildOpts Bool
buildOptsHaddockL =
  (BuildOpts -> Bool)
-> (BuildOpts -> Bool -> BuildOpts) -> Lens' BuildOpts Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens BuildOpts -> Bool
boptsHaddock
    (\BuildOpts
bopts Bool
t -> BuildOpts
bopts {boptsHaddock :: Bool
boptsHaddock = Bool
t})

-- Type representing formats of Stack's progress bar when building.

data ProgressBarFormat
  = NoBar -- No progress bar at all.

  | CountOnlyBar -- A bar that only counts packages.

  | CappedBar -- A bar capped at a length equivalent to the terminal's width.

  | FullBar -- A full progress bar.

  deriving (ProgressBarFormat -> ProgressBarFormat -> Bool
(ProgressBarFormat -> ProgressBarFormat -> Bool)
-> (ProgressBarFormat -> ProgressBarFormat -> Bool)
-> Eq ProgressBarFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProgressBarFormat -> ProgressBarFormat -> Bool
== :: ProgressBarFormat -> ProgressBarFormat -> Bool
$c/= :: ProgressBarFormat -> ProgressBarFormat -> Bool
/= :: ProgressBarFormat -> ProgressBarFormat -> Bool
Eq, Int -> ProgressBarFormat -> ShowS
[ProgressBarFormat] -> ShowS
ProgressBarFormat -> String
(Int -> ProgressBarFormat -> ShowS)
-> (ProgressBarFormat -> String)
-> ([ProgressBarFormat] -> ShowS)
-> Show ProgressBarFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProgressBarFormat -> ShowS
showsPrec :: Int -> ProgressBarFormat -> ShowS
$cshow :: ProgressBarFormat -> String
show :: ProgressBarFormat -> String
$cshowList :: [ProgressBarFormat] -> ShowS
showList :: [ProgressBarFormat] -> ShowS
Show)

instance FromJSON ProgressBarFormat where
  parseJSON :: Value -> Parser ProgressBarFormat
parseJSON = String
-> (Text -> Parser ProgressBarFormat)
-> Value
-> Parser ProgressBarFormat
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"ProgressBarFormat" ((Text -> Parser ProgressBarFormat)
 -> Value -> Parser ProgressBarFormat)
-> (Text -> Parser ProgressBarFormat)
-> Value
-> Parser ProgressBarFormat
forall a b. (a -> b) -> a -> b
$ \Text
t -> (String -> Parser ProgressBarFormat)
-> (ProgressBarFormat -> Parser ProgressBarFormat)
-> Either String ProgressBarFormat
-> Parser ProgressBarFormat
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
    String -> Parser ProgressBarFormat
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
    ProgressBarFormat -> Parser ProgressBarFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    (String -> Either String ProgressBarFormat
readProgressBarFormat (String -> Either String ProgressBarFormat)
-> String -> Either String ProgressBarFormat
forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
t)

-- | Parse ProgressBarFormat from a String.

readProgressBarFormat :: String -> Either String ProgressBarFormat
readProgressBarFormat :: String -> Either String ProgressBarFormat
readProgressBarFormat String
s
  | String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"none" = ProgressBarFormat -> Either String ProgressBarFormat
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProgressBarFormat
NoBar
  | String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"count-only" = ProgressBarFormat -> Either String ProgressBarFormat
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProgressBarFormat
CountOnlyBar
  | String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"capped" = ProgressBarFormat -> Either String ProgressBarFormat
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProgressBarFormat
CappedBar
  | String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"full" = ProgressBarFormat -> Either String ProgressBarFormat
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProgressBarFormat
FullBar
  | Bool
otherwise = String -> Either String ProgressBarFormat
forall a b. a -> Either a b
Left (String -> Either String ProgressBarFormat)
-> String -> Either String ProgressBarFormat
forall a b. (a -> b) -> a -> b
$ String
"Invalid progress bar format: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s