    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE DeriveFunctor #-}
    {-# LANGUAGE DeriveFoldable #-}
    {-# LANGUAGE DeriveTraversable #-}
    {-# LANGUAGE DeriveAnyClass #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE LambdaCase #-}
    {-# LANGUAGE LiberalTypeSynonyms #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE CPP #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE ViewPatterns #-}
    {-# LANGUAGE RankNTypes #-}
    {-# LANGUAGE FlexibleContexts #-}
    module Hpack.Config (
    -- | /__NOTE:__/ This module is exposed to allow integration of Hpack into
    -- other tools.  It is not meant for general use by end users.  The following
    -- caveats apply:
    --
    -- * The API is undocumented, consult the source instead.
    --
    -- * The exposed types and functions primarily serve Hpack's own needs, not
    -- that of a public API.  Breaking changes can happen as Hpack evolves.
    --
    -- As an Hpack user you either want to use the @hpack@ executable or a build
    -- tool that supports Hpack (e.g. @stack@ or @cabal2nix@).

      DecodeOptions(..)
    , ProgramName(..)
    , defaultDecodeOptions
    , packageConfig
    , DecodeResult(..)
    , readPackageConfig

    , renamePackage
    , packageDependencies
    , package
    , section
    , Package(..)
    , Dependencies(..)
    , DependencyInfo(..)
    , VersionConstraint(..)
    , DependencyVersion(..)
    , SourceDependency(..)
    , GitRef
    , GitUrl
    , BuildTool(..)
    , SystemBuildTools(..)
    , GhcOption
    , Verbatim(..)
    , VerbatimValue(..)
    , verbatimValueToString
    , CustomSetup(..)
    , Section(..)
    , Library(..)
    , Executable(..)
    , Conditional(..)
    , Flag(..)
    , SourceRepository(..)
    , BuildType(..)
    , GhcProfOption
    , GhcjsOption
    , CppOption
    , CcOption
    , LdOption
    , Path(..)
    #ifdef TEST
    , renameDependencies
    , Empty(..)
    , getModules
    , pathsModuleFromPackageName
    , Cond(..)

    , LibrarySection(..)
    , fromLibrarySectionInConditional
    , formatOrList

    , toBuildTool
    #endif
    ) where

    import           Control.Applicative
    import           Control.Arrow ((>>>), (&&&))
    import           Control.Monad
    import           Data.Either
    import           Data.Bifunctor
    import           Data.Bitraversable
    import           Data.Map.Lazy (Map)
    import qualified Data.Map.Lazy as Map
    import qualified Data.HashMap.Lazy as HashMap
    import           Data.List (nub, (\\), sortBy, intercalate)
    import           Data.Maybe
    import           Data.Semigroup (Semigroup(..))
    import           Data.Ord
    import           Data.String
    import           Data.Text (Text)
    import qualified Data.Text as T
    import           Data.Scientific (Scientific)
    import           System.Directory
    import           System.FilePath
    import           Control.Monad.Trans.Class
    import           Control.Monad.Trans.Writer
    import           Control.Monad.Trans.Except
    import           Control.Monad.IO.Class
    import           Data.Version (Version, makeVersion, showVersion)

    import           Distribution.Pretty (prettyShow)
    import qualified Distribution.SPDX.License as SPDX

    import           Data.Aeson.Config.Types
    import           Data.Aeson.Config.FromValue hiding (decodeValue)
    import qualified Data.Aeson.Config.FromValue as Config

    import           Hpack.Syntax.Defaults
    import           Hpack.Util hiding (expandGlobs)
    import qualified Hpack.Util as Util
    import           Hpack.Defaults
    import qualified Hpack.Yaml as Yaml
    import           Hpack.Syntax.DependencyVersion
    import           Hpack.Syntax.Dependencies
    import           Hpack.Syntax.BuildTools
    import           Hpack.License
    import           Hpack.CabalFile (parseVersion)

    import qualified Paths_hpack as Hpack (version)

    package :: String -> String -> Package
    package :: String -> String -> Package
    package name :: String
    name version :: String
    version = Package :: String
    -> String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> [String]
    -> [String]
    -> [String]
    -> BuildType
    -> Maybe String
    -> [String]
    -> Maybe String
    -> [Flag]
    -> [Path]
    -> [Path]
    -> [Path]
    -> Maybe String
    -> Maybe SourceRepository
    -> Maybe CustomSetup
    -> Maybe (Section Library)
    -> Map String (Section Library)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    -> [Verbatim]
    -> Package
    Package {
        packageName :: String
    packageName = String
    name
      , packageVersion :: String
    packageVersion = String
    version
      , packageSynopsis :: Maybe String
    packageSynopsis = Maybe String
    forall a. Maybe a
    Nothing
      , packageDescription :: Maybe String
    packageDescription = Maybe String
    forall a. Maybe a
    Nothing
      , packageHomepage :: Maybe String
    packageHomepage = Maybe String
    forall a. Maybe a
    Nothing
      , packageBugReports :: Maybe String
    packageBugReports = Maybe String
    forall a. Maybe a
    Nothing
      , packageCategory :: Maybe String
    packageCategory = Maybe String
    forall a. Maybe a
    Nothing
      , packageStability :: Maybe String
    packageStability = Maybe String
    forall a. Maybe a
    Nothing
      , packageAuthor :: [String]
    packageAuthor = []
      , packageMaintainer :: [String]
    packageMaintainer = []
      , packageCopyright :: [String]
    packageCopyright = []
      , packageBuildType :: BuildType
    packageBuildType = BuildType
    Simple
      , packageLicense :: Maybe String
    packageLicense = Maybe String
    forall a. Maybe a
    Nothing
      , packageLicenseFile :: [String]
    packageLicenseFile = []
      , packageTestedWith :: Maybe String
    packageTestedWith = Maybe String
    forall a. Maybe a
    Nothing
      , packageFlags :: [Flag]
    packageFlags = []
      , packageExtraSourceFiles :: [Path]
    packageExtraSourceFiles = []
      , packageExtraDocFiles :: [Path]
    packageExtraDocFiles = []
      , packageDataFiles :: [Path]
    packageDataFiles = []
      , packageDataDir :: Maybe String
    packageDataDir = Maybe String
    forall a. Maybe a
    Nothing
      , packageSourceRepository :: Maybe SourceRepository
    packageSourceRepository = Maybe SourceRepository
    forall a. Maybe a
    Nothing
      , packageCustomSetup :: Maybe CustomSetup
    packageCustomSetup = Maybe CustomSetup
    forall a. Maybe a
    Nothing
      , packageLibrary :: Maybe (Section Library)
    packageLibrary = Maybe (Section Library)
    forall a. Maybe a
    Nothing
      , packageInternalLibraries :: Map String (Section Library)
    packageInternalLibraries = Map String (Section Library)
    forall a. Monoid a => a
    mempty
      , packageExecutables :: Map String (Section Executable)
    packageExecutables = Map String (Section Executable)
    forall a. Monoid a => a
    mempty
      , packageTests :: Map String (Section Executable)
    packageTests = Map String (Section Executable)
    forall a. Monoid a => a
    mempty
      , packageBenchmarks :: Map String (Section Executable)
    packageBenchmarks = Map String (Section Executable)
    forall a. Monoid a => a
    mempty
      , packageVerbatim :: [Verbatim]
    packageVerbatim = []
      }

    renamePackage :: String -> Package -> Package
    renamePackage :: String -> Package -> Package
    renamePackage name :: String
    name p :: Package
    p@Package{..} = Package
    p {
        packageName :: String
    packageName = String
    name
      , packageExecutables :: Map String (Section Executable)
    packageExecutables = (Section Executable -> Section Executable)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (String -> String -> Section Executable -> Section Executable
    forall a. String -> String -> Section a -> Section a
    renameDependencies String
    packageName String
    name) Map String (Section Executable)
    packageExecutables
      , packageTests :: Map String (Section Executable)
    packageTests = (Section Executable -> Section Executable)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (String -> String -> Section Executable -> Section Executable
    forall a. String -> String -> Section a -> Section a
    renameDependencies String
    packageName String
    name) Map String (Section Executable)
    packageTests
      , packageBenchmarks :: Map String (Section Executable)
    packageBenchmarks = (Section Executable -> Section Executable)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (String -> String -> Section Executable -> Section Executable
    forall a. String -> String -> Section a -> Section a
    renameDependencies String
    packageName String
    name) Map String (Section Executable)
    packageBenchmarks
      }

    renameDependencies :: String -> String -> Section a -> Section a
    renameDependencies :: String -> String -> Section a -> Section a
    renameDependencies old :: String
    old new :: String
    new sect :: Section a
    sect@Section{..} = Section a
    sect {sectionDependencies :: Dependencies
    sectionDependencies = (Map String DependencyInfo -> Dependencies
    Dependencies (Map String DependencyInfo -> Dependencies)
    -> (Dependencies -> Map String DependencyInfo)
    -> Dependencies
    -> Dependencies
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [(String, DependencyInfo)] -> Map String DependencyInfo
    forall k a. Ord k => [(k, a)] -> Map k a
    Map.fromList ([(String, DependencyInfo)] -> Map String DependencyInfo)
    -> (Dependencies -> [(String, DependencyInfo)])
    -> Dependencies
    -> Map String DependencyInfo
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((String, DependencyInfo) -> (String, DependencyInfo))
    -> [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a b. (a -> b) -> [a] -> [b]
    map (String, DependencyInfo) -> (String, DependencyInfo)
    forall b. (String, b) -> (String, b)
    rename ([(String, DependencyInfo)] -> [(String, DependencyInfo)])
    -> (Dependencies -> [(String, DependencyInfo)])
    -> Dependencies
    -> [(String, DependencyInfo)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map String DependencyInfo -> [(String, DependencyInfo)]
    forall k a. Map k a -> [(k, a)]
    Map.toList (Map String DependencyInfo -> [(String, DependencyInfo)])
    -> (Dependencies -> Map String DependencyInfo)
    -> Dependencies
    -> [(String, DependencyInfo)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Dependencies -> Map String DependencyInfo
    unDependencies) Dependencies
    sectionDependencies, sectionConditionals :: [Conditional (Section a)]
    sectionConditionals = (Conditional (Section a) -> Conditional (Section a))
    -> [Conditional (Section a)] -> [Conditional (Section a)]
    forall a b. (a -> b) -> [a] -> [b]
    map Conditional (Section a) -> Conditional (Section a)
    forall a. Conditional (Section a) -> Conditional (Section a)
    renameConditional [Conditional (Section a)]
    sectionConditionals}
      where
        rename :: (String, b) -> (String, b)
    rename dep :: (String, b)
    dep@(name :: String
    name, version :: b
    version)
          | String
    name String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    old = (String
    new, b
    version)
          | Bool
    otherwise = (String, b)
    dep

        renameConditional :: Conditional (Section a) -> Conditional (Section a)
        renameConditional :: Conditional (Section a) -> Conditional (Section a)
    renameConditional (Conditional condition :: String
    condition then_ :: Section a
    then_ else_ :: Maybe (Section a)
    else_) = String -> Section a -> Maybe (Section a) -> Conditional (Section a)
    forall a. String -> a -> Maybe a -> Conditional a
    Conditional String
    condition (String -> String -> Section a -> Section a
    forall a. String -> String -> Section a -> Section a
    renameDependencies String
    old String
    new Section a
    then_) (String -> String -> Section a -> Section a
    forall a. String -> String -> Section a -> Section a
    renameDependencies String
    old String
    new (Section a -> Section a) -> Maybe (Section a) -> Maybe (Section a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe (Section a)
    else_)

    packageDependencies :: Package -> [(String, DependencyInfo)]
    packageDependencies :: Package -> [(String, DependencyInfo)]
    packageDependencies Package{..} = [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a. Eq a => [a] -> [a]
    nub ([(String, DependencyInfo)] -> [(String, DependencyInfo)])
    -> ([(String, DependencyInfo)] -> [(String, DependencyInfo)])
    -> [(String, DependencyInfo)]
    -> [(String, DependencyInfo)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((String, DependencyInfo) -> (String, DependencyInfo) -> Ordering)
    -> [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a. (a -> a -> Ordering) -> [a] -> [a]
    sortBy (((String, DependencyInfo) -> (String, String))
    -> (String, DependencyInfo) -> (String, DependencyInfo) -> Ordering
    forall a b. Ord a => (b -> a) -> b -> b -> Ordering
    comparing (String -> (String, String)
    lexicographically (String -> (String, String))
    -> ((String, DependencyInfo) -> String)
    -> (String, DependencyInfo)
    -> (String, String)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String, DependencyInfo) -> String
    forall a b. (a, b) -> a
    fst)) ([(String, DependencyInfo)] -> [(String, DependencyInfo)])
    -> [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a b. (a -> b) -> a -> b
    $
         ((Section Executable -> [(String, DependencyInfo)])
    -> Map String (Section Executable) -> [(String, DependencyInfo)]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Executable -> [(String, DependencyInfo)]
    forall a. Section a -> [(String, DependencyInfo)]
    deps Map String (Section Executable)
    packageExecutables)
      [(String, DependencyInfo)]
    -> [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a. [a] -> [a] -> [a]
    ++ ((Section Executable -> [(String, DependencyInfo)])
    -> Map String (Section Executable) -> [(String, DependencyInfo)]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Executable -> [(String, DependencyInfo)]
    forall a. Section a -> [(String, DependencyInfo)]
    deps Map String (Section Executable)
    packageTests)
      [(String, DependencyInfo)]
    -> [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a. [a] -> [a] -> [a]
    ++ ((Section Executable -> [(String, DependencyInfo)])
    -> Map String (Section Executable) -> [(String, DependencyInfo)]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Executable -> [(String, DependencyInfo)]
    forall a. Section a -> [(String, DependencyInfo)]
    deps Map String (Section Executable)
    packageBenchmarks)
      [(String, DependencyInfo)]
    -> [(String, DependencyInfo)] -> [(String, DependencyInfo)]
    forall a. [a] -> [a] -> [a]
    ++ [(String, DependencyInfo)]
    -> (Section Library -> [(String, DependencyInfo)])
    -> Maybe (Section Library)
    -> [(String, DependencyInfo)]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [] Section Library -> [(String, DependencyInfo)]
    forall a. Section a -> [(String, DependencyInfo)]
    deps Maybe (Section Library)
    packageLibrary
      where
        deps :: Section a -> [(String, DependencyInfo)]
    deps xs :: Section a
    xs = [(String
    name, DependencyInfo
    info) | (name :: String
    name, info :: DependencyInfo
    info) <- (Map String DependencyInfo -> [(String, DependencyInfo)]
    forall k a. Map k a -> [(k, a)]
    Map.toList (Map String DependencyInfo -> [(String, DependencyInfo)])
    -> (Section a -> Map String DependencyInfo)
    -> Section a
    -> [(String, DependencyInfo)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Dependencies -> Map String DependencyInfo
    unDependencies (Dependencies -> Map String DependencyInfo)
    -> (Section a -> Dependencies)
    -> Section a
    -> Map String DependencyInfo
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section a -> Dependencies
    forall a. Section a -> Dependencies
    sectionDependencies) Section a
    xs]

    section :: a -> Section a
    section :: a -> Section a
    section a :: a
    a = a
    -> [String]
    -> Dependencies
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [Path]
    -> [String]
    -> [Path]
    -> [Path]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> Maybe Bool
    -> [Conditional (Section a)]
    -> Map BuildTool DependencyVersion
    -> SystemBuildTools
    -> [Verbatim]
    -> Section a
    forall a.
    a
    -> [String]
    -> Dependencies
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [Path]
    -> [String]
    -> [Path]
    -> [Path]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> Maybe Bool
    -> [Conditional (Section a)]
    -> Map BuildTool DependencyVersion
    -> SystemBuildTools
    -> [Verbatim]
    -> Section a
    Section a
    a [] Dependencies
    forall a. Monoid a => a
    mempty [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Maybe Bool
    forall a. Maybe a
    Nothing [] Map BuildTool DependencyVersion
    forall a. Monoid a => a
    mempty SystemBuildTools
    forall a. Monoid a => a
    mempty []

    packageConfig :: FilePath
    packageConfig :: String
    packageConfig = "package.yaml"

    data CustomSetupSection = CustomSetupSection {
      CustomSetupSection -> Maybe Dependencies
    customSetupSectionDependencies :: Maybe Dependencies
    } deriving (CustomSetupSection -> CustomSetupSection -> Bool
    (CustomSetupSection -> CustomSetupSection -> Bool)
    -> (CustomSetupSection -> CustomSetupSection -> Bool)
    -> Eq CustomSetupSection
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: CustomSetupSection -> CustomSetupSection -> Bool
    $c/= :: CustomSetupSection -> CustomSetupSection -> Bool
    == :: CustomSetupSection -> CustomSetupSection -> Bool
    $c== :: CustomSetupSection -> CustomSetupSection -> Bool
    Eq, Int -> CustomSetupSection -> ShowS
    [CustomSetupSection] -> ShowS
    CustomSetupSection -> String
    (Int -> CustomSetupSection -> ShowS)
    -> (CustomSetupSection -> String)
    -> ([CustomSetupSection] -> ShowS)
    -> Show CustomSetupSection
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [CustomSetupSection] -> ShowS
    $cshowList :: [CustomSetupSection] -> ShowS
    show :: CustomSetupSection -> String
    $cshow :: CustomSetupSection -> String
    showsPrec :: Int -> CustomSetupSection -> ShowS
    $cshowsPrec :: Int -> CustomSetupSection -> ShowS
    Show, (forall x. CustomSetupSection -> Rep CustomSetupSection x)
    -> (forall x. Rep CustomSetupSection x -> CustomSetupSection)
    -> Generic CustomSetupSection
    forall x. Rep CustomSetupSection x -> CustomSetupSection
    forall x. CustomSetupSection -> Rep CustomSetupSection x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep CustomSetupSection x -> CustomSetupSection
    $cfrom :: forall x. CustomSetupSection -> Rep CustomSetupSection x
    Generic, Value -> Parser CustomSetupSection
    (Value -> Parser CustomSetupSection)
    -> FromValue CustomSetupSection
    forall a. (Value -> Parser a) -> FromValue a
    fromValue :: Value -> Parser CustomSetupSection
    $cfromValue :: Value -> Parser CustomSetupSection
    FromValue)

    data LibrarySection = LibrarySection {
      LibrarySection -> Maybe Bool
    librarySectionExposed :: Maybe Bool
    , LibrarySection -> Maybe String
    librarySectionVisibility :: Maybe String
    , LibrarySection -> Maybe (List String)
    librarySectionExposedModules :: Maybe (List String)
    , LibrarySection -> Maybe (List String)
    librarySectionGeneratedExposedModules :: Maybe (List String)
    , LibrarySection -> Maybe (List String)
    librarySectionOtherModules :: Maybe (List String)
    , LibrarySection -> Maybe (List String)
    librarySectionGeneratedOtherModules :: Maybe (List String)
    , LibrarySection -> Maybe (List String)
    librarySectionReexportedModules :: Maybe (List String)
    , LibrarySection -> Maybe (List String)
    librarySectionSignatures :: Maybe (List String)
    } deriving (LibrarySection -> LibrarySection -> Bool
    (LibrarySection -> LibrarySection -> Bool)
    -> (LibrarySection -> LibrarySection -> Bool) -> Eq LibrarySection
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: LibrarySection -> LibrarySection -> Bool
    $c/= :: LibrarySection -> LibrarySection -> Bool
    == :: LibrarySection -> LibrarySection -> Bool
    $c== :: LibrarySection -> LibrarySection -> Bool
    Eq, Int -> LibrarySection -> ShowS
    [LibrarySection] -> ShowS
    LibrarySection -> String
    (Int -> LibrarySection -> ShowS)
    -> (LibrarySection -> String)
    -> ([LibrarySection] -> ShowS)
    -> Show LibrarySection
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [LibrarySection] -> ShowS
    $cshowList :: [LibrarySection] -> ShowS
    show :: LibrarySection -> String
    $cshow :: LibrarySection -> String
    showsPrec :: Int -> LibrarySection -> ShowS
    $cshowsPrec :: Int -> LibrarySection -> ShowS
    Show, (forall x. LibrarySection -> Rep LibrarySection x)
    -> (forall x. Rep LibrarySection x -> LibrarySection)
    -> Generic LibrarySection
    forall x. Rep LibrarySection x -> LibrarySection
    forall x. LibrarySection -> Rep LibrarySection x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep LibrarySection x -> LibrarySection
    $cfrom :: forall x. LibrarySection -> Rep LibrarySection x
    Generic, Value -> Parser LibrarySection
    (Value -> Parser LibrarySection) -> FromValue LibrarySection
    forall a. (Value -> Parser a) -> FromValue a
    fromValue :: Value -> Parser LibrarySection
    $cfromValue :: Value -> Parser LibrarySection
    FromValue)

    instance Monoid LibrarySection where
      mempty :: LibrarySection
    mempty = Maybe Bool
    -> Maybe String
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> LibrarySection
    LibrarySection Maybe Bool
    forall a. Maybe a
    Nothing Maybe String
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing
      mappend :: LibrarySection -> LibrarySection -> LibrarySection
    mappend = LibrarySection -> LibrarySection -> LibrarySection
    forall a. Semigroup a => a -> a -> a
    (<>)

    instance Semigroup LibrarySection where
      a :: LibrarySection
    a <> :: LibrarySection -> LibrarySection -> LibrarySection
    <> b :: LibrarySection
    b = LibrarySection :: Maybe Bool
    -> Maybe String
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> LibrarySection
    LibrarySection {
          librarySectionExposed :: Maybe Bool
    librarySectionExposed = LibrarySection -> Maybe Bool
    librarySectionExposed LibrarySection
    b Maybe Bool -> Maybe Bool -> Maybe Bool
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> LibrarySection -> Maybe Bool
    librarySectionExposed LibrarySection
    a
        , librarySectionVisibility :: Maybe String
    librarySectionVisibility = LibrarySection -> Maybe String
    librarySectionVisibility LibrarySection
    b Maybe String -> Maybe String -> Maybe String
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> LibrarySection -> Maybe String
    librarySectionVisibility LibrarySection
    a
        , librarySectionExposedModules :: Maybe (List String)
    librarySectionExposedModules = LibrarySection -> Maybe (List String)
    librarySectionExposedModules LibrarySection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> LibrarySection -> Maybe (List String)
    librarySectionExposedModules LibrarySection
    b
        , librarySectionGeneratedExposedModules :: Maybe (List String)
    librarySectionGeneratedExposedModules = LibrarySection -> Maybe (List String)
    librarySectionGeneratedExposedModules LibrarySection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> LibrarySection -> Maybe (List String)
    librarySectionGeneratedExposedModules LibrarySection
    b
        , librarySectionOtherModules :: Maybe (List String)
    librarySectionOtherModules = LibrarySection -> Maybe (List String)
    librarySectionOtherModules LibrarySection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> LibrarySection -> Maybe (List String)
    librarySectionOtherModules LibrarySection
    b
        , librarySectionGeneratedOtherModules :: Maybe (List String)
    librarySectionGeneratedOtherModules = LibrarySection -> Maybe (List String)
    librarySectionGeneratedOtherModules LibrarySection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> LibrarySection -> Maybe (List String)
    librarySectionGeneratedOtherModules LibrarySection
    b
        , librarySectionReexportedModules :: Maybe (List String)
    librarySectionReexportedModules = LibrarySection -> Maybe (List String)
    librarySectionReexportedModules LibrarySection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> LibrarySection -> Maybe (List String)
    librarySectionReexportedModules LibrarySection
    b
        , librarySectionSignatures :: Maybe (List String)
    librarySectionSignatures = LibrarySection -> Maybe (List String)
    librarySectionSignatures LibrarySection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> LibrarySection -> Maybe (List String)
    librarySectionSignatures LibrarySection
    b
        }

    data ExecutableSection = ExecutableSection {
      ExecutableSection -> Maybe String
    executableSectionMain :: Maybe FilePath
    , ExecutableSection -> Maybe (List String)
    executableSectionOtherModules :: Maybe (List String)
    , ExecutableSection -> Maybe (List String)
    executableSectionGeneratedOtherModules :: Maybe (List String)
    } deriving (ExecutableSection -> ExecutableSection -> Bool
    (ExecutableSection -> ExecutableSection -> Bool)
    -> (ExecutableSection -> ExecutableSection -> Bool)
    -> Eq ExecutableSection
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ExecutableSection -> ExecutableSection -> Bool
    $c/= :: ExecutableSection -> ExecutableSection -> Bool
    == :: ExecutableSection -> ExecutableSection -> Bool
    $c== :: ExecutableSection -> ExecutableSection -> Bool
    Eq, Int -> ExecutableSection -> ShowS
    [ExecutableSection] -> ShowS
    ExecutableSection -> String
    (Int -> ExecutableSection -> ShowS)
    -> (ExecutableSection -> String)
    -> ([ExecutableSection] -> ShowS)
    -> Show ExecutableSection
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ExecutableSection] -> ShowS
    $cshowList :: [ExecutableSection] -> ShowS
    show :: ExecutableSection -> String
    $cshow :: ExecutableSection -> String
    showsPrec :: Int -> ExecutableSection -> ShowS
    $cshowsPrec :: Int -> ExecutableSection -> ShowS
    Show, (forall x. ExecutableSection -> Rep ExecutableSection x)
    -> (forall x. Rep ExecutableSection x -> ExecutableSection)
    -> Generic ExecutableSection
    forall x. Rep ExecutableSection x -> ExecutableSection
    forall x. ExecutableSection -> Rep ExecutableSection x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep ExecutableSection x -> ExecutableSection
    $cfrom :: forall x. ExecutableSection -> Rep ExecutableSection x
    Generic, Value -> Parser ExecutableSection
    (Value -> Parser ExecutableSection) -> FromValue ExecutableSection
    forall a. (Value -> Parser a) -> FromValue a
    fromValue :: Value -> Parser ExecutableSection
    $cfromValue :: Value -> Parser ExecutableSection
    FromValue)

    instance Monoid ExecutableSection where
      mempty :: ExecutableSection
    mempty = Maybe String
    -> Maybe (List String) -> Maybe (List String) -> ExecutableSection
    ExecutableSection Maybe String
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing Maybe (List String)
    forall a. Maybe a
    Nothing
      mappend :: ExecutableSection -> ExecutableSection -> ExecutableSection
    mappend = ExecutableSection -> ExecutableSection -> ExecutableSection
    forall a. Semigroup a => a -> a -> a
    (<>)

    instance Semigroup ExecutableSection where
      a :: ExecutableSection
    a <> :: ExecutableSection -> ExecutableSection -> ExecutableSection
    <> b :: ExecutableSection
    b = ExecutableSection :: Maybe String
    -> Maybe (List String) -> Maybe (List String) -> ExecutableSection
    ExecutableSection {
          executableSectionMain :: Maybe String
    executableSectionMain = ExecutableSection -> Maybe String
    executableSectionMain ExecutableSection
    b Maybe String -> Maybe String -> Maybe String
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ExecutableSection -> Maybe String
    executableSectionMain ExecutableSection
    a
        , executableSectionOtherModules :: Maybe (List String)
    executableSectionOtherModules = ExecutableSection -> Maybe (List String)
    executableSectionOtherModules ExecutableSection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> ExecutableSection -> Maybe (List String)
    executableSectionOtherModules ExecutableSection
    b
        , executableSectionGeneratedOtherModules :: Maybe (List String)
    executableSectionGeneratedOtherModules = ExecutableSection -> Maybe (List String)
    executableSectionGeneratedOtherModules ExecutableSection
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> ExecutableSection -> Maybe (List String)
    executableSectionGeneratedOtherModules ExecutableSection
    b
        }

    data VerbatimValue =
        VerbatimString String
      | VerbatimNumber Scientific
      | VerbatimBool Bool
      | VerbatimNull
      deriving (VerbatimValue -> VerbatimValue -> Bool
    (VerbatimValue -> VerbatimValue -> Bool)
    -> (VerbatimValue -> VerbatimValue -> Bool) -> Eq VerbatimValue
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: VerbatimValue -> VerbatimValue -> Bool
    $c/= :: VerbatimValue -> VerbatimValue -> Bool
    == :: VerbatimValue -> VerbatimValue -> Bool
    $c== :: VerbatimValue -> VerbatimValue -> Bool
    Eq, Int -> VerbatimValue -> ShowS
    [VerbatimValue] -> ShowS
    VerbatimValue -> String
    (Int -> VerbatimValue -> ShowS)
    -> (VerbatimValue -> String)
    -> ([VerbatimValue] -> ShowS)
    -> Show VerbatimValue
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [VerbatimValue] -> ShowS
    $cshowList :: [VerbatimValue] -> ShowS
    show :: VerbatimValue -> String
    $cshow :: VerbatimValue -> String
    showsPrec :: Int -> VerbatimValue -> ShowS
    $cshowsPrec :: Int -> VerbatimValue -> ShowS
    Show)

    instance FromValue VerbatimValue where
      fromValue :: Value -> Parser VerbatimValue
    fromValue v :: Value
    v = case Value
    v of
        String s :: Text
    s -> VerbatimValue -> Parser VerbatimValue
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> VerbatimValue
    VerbatimString (String -> VerbatimValue) -> String -> VerbatimValue
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    s)
        Number n :: Scientific
    n -> VerbatimValue -> Parser VerbatimValue
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Scientific -> VerbatimValue
    VerbatimNumber Scientific
    n)
        Bool b :: Bool
    b -> VerbatimValue -> Parser VerbatimValue
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Bool -> VerbatimValue
    VerbatimBool Bool
    b)
        Null -> VerbatimValue -> Parser VerbatimValue
    forall (m :: * -> *) a. Monad m => a -> m a
    return VerbatimValue
    VerbatimNull
        Object _ -> Parser VerbatimValue
    forall a. Parser a
    err
        Array _ -> Parser VerbatimValue
    forall a. Parser a
    err
        where
          err :: Parser a
    err = String -> Value -> Parser a
    forall a. String -> Value -> Parser a
    typeMismatch ([String] -> String
    formatOrList ["String", "Number", "Bool", "Null"]) Value
    v

    data Verbatim = VerbatimLiteral String | VerbatimObject (Map String VerbatimValue)
      deriving (Verbatim -> Verbatim -> Bool
    (Verbatim -> Verbatim -> Bool)
    -> (Verbatim -> Verbatim -> Bool) -> Eq Verbatim
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Verbatim -> Verbatim -> Bool
    $c/= :: Verbatim -> Verbatim -> Bool
    == :: Verbatim -> Verbatim -> Bool
    $c== :: Verbatim -> Verbatim -> Bool
    Eq, Int -> Verbatim -> ShowS
    [Verbatim] -> ShowS
    Verbatim -> String
    (Int -> Verbatim -> ShowS)
    -> (Verbatim -> String) -> ([Verbatim] -> ShowS) -> Show Verbatim
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Verbatim] -> ShowS
    $cshowList :: [Verbatim] -> ShowS
    show :: Verbatim -> String
    $cshow :: Verbatim -> String
    showsPrec :: Int -> Verbatim -> ShowS
    $cshowsPrec :: Int -> Verbatim -> ShowS
    Show)

    instance FromValue Verbatim where
      fromValue :: Value -> Parser Verbatim
    fromValue v :: Value
    v = case Value
    v of
        String s :: Text
    s -> Verbatim -> Parser Verbatim
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> Verbatim
    VerbatimLiteral (String -> Verbatim) -> String -> Verbatim
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    s)
        Object _ -> Map String VerbatimValue -> Verbatim
    VerbatimObject (Map String VerbatimValue -> Verbatim)
    -> Parser (Map String VerbatimValue) -> Parser Verbatim
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Value -> Parser (Map String VerbatimValue)
    forall a. FromValue a => Value -> Parser a
    fromValue Value
    v
        _ -> String -> Value -> Parser Verbatim
    forall a. String -> Value -> Parser a
    typeMismatch ([String] -> String
    formatOrList ["String", "Object"]) Value
    v

    data CommonOptions cSources cxxSources jsSources a = CommonOptions {
      CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsSourceDirs :: Maybe (List FilePath)
    , CommonOptions cSources cxxSources jsSources a -> Maybe Dependencies
    commonOptionsDependencies :: Maybe Dependencies
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsPkgConfigDependencies :: Maybe (List String)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsDefaultExtensions :: Maybe (List String)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsOtherExtensions :: Maybe (List String)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcOptions :: Maybe (List GhcOption)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcProfOptions :: Maybe (List GhcProfOption)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcjsOptions :: Maybe (List GhcjsOption)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCppOptions :: Maybe (List CppOption)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCcOptions :: Maybe (List CcOption)
    , CommonOptions cSources cxxSources jsSources a -> cSources
    commonOptionsCSources :: cSources
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCxxOptions :: Maybe (List CxxOption)
    , CommonOptions cSources cxxSources jsSources a -> cxxSources
    commonOptionsCxxSources :: cxxSources
    , CommonOptions cSources cxxSources jsSources a -> jsSources
    commonOptionsJsSources :: jsSources
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraLibDirs :: Maybe (List FilePath)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraLibraries :: Maybe (List FilePath)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraFrameworksDirs :: Maybe (List FilePath)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsFrameworks :: Maybe (List String)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsIncludeDirs :: Maybe (List FilePath)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsInstallIncludes :: Maybe (List FilePath)
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsLdOptions :: Maybe (List LdOption)
    , CommonOptions cSources cxxSources jsSources a -> Maybe Bool
    commonOptionsBuildable :: Maybe Bool
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    commonOptionsWhen :: Maybe (List (ConditionalSection cSources cxxSources jsSources a))
    , CommonOptions cSources cxxSources jsSources a -> Maybe BuildTools
    commonOptionsBuildTools :: Maybe BuildTools
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe SystemBuildTools
    commonOptionsSystemBuildTools :: Maybe SystemBuildTools
    , CommonOptions cSources cxxSources jsSources a
    -> Maybe (List Verbatim)
    commonOptionsVerbatim :: Maybe (List Verbatim)
    } deriving (a
    -> CommonOptions cSources cxxSources jsSources b
    -> CommonOptions cSources cxxSources jsSources a
    (a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    (forall a b.
     (a -> b)
     -> CommonOptions cSources cxxSources jsSources a
     -> CommonOptions cSources cxxSources jsSources b)
    -> (forall a b.
        a
        -> CommonOptions cSources cxxSources jsSources b
        -> CommonOptions cSources cxxSources jsSources a)
    -> Functor (CommonOptions cSources cxxSources jsSources)
    forall a b.
    a
    -> CommonOptions cSources cxxSources jsSources b
    -> CommonOptions cSources cxxSources jsSources a
    forall a b.
    (a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    forall cSources cxxSources jsSources a b.
    a
    -> CommonOptions cSources cxxSources jsSources b
    -> CommonOptions cSources cxxSources jsSources a
    forall cSources cxxSources jsSources a b.
    (a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a
    -> CommonOptions cSources cxxSources jsSources b
    -> CommonOptions cSources cxxSources jsSources a
    $c<$ :: forall cSources cxxSources jsSources a b.
    a
    -> CommonOptions cSources cxxSources jsSources b
    -> CommonOptions cSources cxxSources jsSources a
    fmap :: (a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    $cfmap :: forall cSources cxxSources jsSources a b.
    (a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    Functor, (forall x.
     CommonOptions cSources cxxSources jsSources a
     -> Rep (CommonOptions cSources cxxSources jsSources a) x)
    -> (forall x.
        Rep (CommonOptions cSources cxxSources jsSources a) x
        -> CommonOptions cSources cxxSources jsSources a)
    -> Generic (CommonOptions cSources cxxSources jsSources a)
    forall x.
    Rep (CommonOptions cSources cxxSources jsSources a) x
    -> CommonOptions cSources cxxSources jsSources a
    forall x.
    CommonOptions cSources cxxSources jsSources a
    -> Rep (CommonOptions cSources cxxSources jsSources a) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall cSources cxxSources jsSources a x.
    Rep (CommonOptions cSources cxxSources jsSources a) x
    -> CommonOptions cSources cxxSources jsSources a
    forall cSources cxxSources jsSources a x.
    CommonOptions cSources cxxSources jsSources a
    -> Rep (CommonOptions cSources cxxSources jsSources a) x
    $cto :: forall cSources cxxSources jsSources a x.
    Rep (CommonOptions cSources cxxSources jsSources a) x
    -> CommonOptions cSources cxxSources jsSources a
    $cfrom :: forall cSources cxxSources jsSources a x.
    CommonOptions cSources cxxSources jsSources a
    -> Rep (CommonOptions cSources cxxSources jsSources a) x
    Generic)

    type ParseCommonOptions = CommonOptions ParseCSources ParseCxxSources ParseJsSources
    instance FromValue a => FromValue (ParseCommonOptions a)

    instance (Semigroup cSources, Semigroup cxxSources, Semigroup jsSources, Monoid cSources, Monoid cxxSources, Monoid jsSources) => Monoid (CommonOptions cSources cxxSources jsSources a) where
      mempty :: CommonOptions cSources cxxSources jsSources a
    mempty = CommonOptions :: forall cSources cxxSources jsSources a.
    Maybe (List String)
    -> Maybe Dependencies
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> cSources
    -> Maybe (List String)
    -> cxxSources
    -> jsSources
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe Bool
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    -> Maybe BuildTools
    -> Maybe SystemBuildTools
    -> Maybe (List Verbatim)
    -> CommonOptions cSources cxxSources jsSources a
    CommonOptions {
        commonOptionsSourceDirs :: Maybe (List String)
    commonOptionsSourceDirs = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsDependencies :: Maybe Dependencies
    commonOptionsDependencies = Maybe Dependencies
    forall a. Maybe a
    Nothing
      , commonOptionsPkgConfigDependencies :: Maybe (List String)
    commonOptionsPkgConfigDependencies = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsDefaultExtensions :: Maybe (List String)
    commonOptionsDefaultExtensions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsOtherExtensions :: Maybe (List String)
    commonOptionsOtherExtensions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsGhcOptions :: Maybe (List String)
    commonOptionsGhcOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsGhcProfOptions :: Maybe (List String)
    commonOptionsGhcProfOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsGhcjsOptions :: Maybe (List String)
    commonOptionsGhcjsOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsCppOptions :: Maybe (List String)
    commonOptionsCppOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsCcOptions :: Maybe (List String)
    commonOptionsCcOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsCSources :: cSources
    commonOptionsCSources = cSources
    forall a. Monoid a => a
    mempty
      , commonOptionsCxxOptions :: Maybe (List String)
    commonOptionsCxxOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsCxxSources :: cxxSources
    commonOptionsCxxSources = cxxSources
    forall a. Monoid a => a
    mempty
      , commonOptionsJsSources :: jsSources
    commonOptionsJsSources = jsSources
    forall a. Monoid a => a
    mempty
      , commonOptionsExtraLibDirs :: Maybe (List String)
    commonOptionsExtraLibDirs = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsExtraLibraries :: Maybe (List String)
    commonOptionsExtraLibraries = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsExtraFrameworksDirs :: Maybe (List String)
    commonOptionsExtraFrameworksDirs = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsFrameworks :: Maybe (List String)
    commonOptionsFrameworks = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsIncludeDirs :: Maybe (List String)
    commonOptionsIncludeDirs = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsInstallIncludes :: Maybe (List String)
    commonOptionsInstallIncludes = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsLdOptions :: Maybe (List String)
    commonOptionsLdOptions = Maybe (List String)
    forall a. Maybe a
    Nothing
      , commonOptionsBuildable :: Maybe Bool
    commonOptionsBuildable = Maybe Bool
    forall a. Maybe a
    Nothing
      , commonOptionsWhen :: Maybe (List (ConditionalSection cSources cxxSources jsSources a))
    commonOptionsWhen = Maybe (List (ConditionalSection cSources cxxSources jsSources a))
    forall a. Maybe a
    Nothing
      , commonOptionsBuildTools :: Maybe BuildTools
    commonOptionsBuildTools = Maybe BuildTools
    forall a. Maybe a
    Nothing
      , commonOptionsSystemBuildTools :: Maybe SystemBuildTools
    commonOptionsSystemBuildTools = Maybe SystemBuildTools
    forall a. Maybe a
    Nothing
      , commonOptionsVerbatim :: Maybe (List Verbatim)
    commonOptionsVerbatim = Maybe (List Verbatim)
    forall a. Maybe a
    Nothing
      }
      mappend :: CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources a
    mappend = CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources a
    forall a. Semigroup a => a -> a -> a
    (<>)

    instance (Semigroup cSources, Semigroup cxxSources, Semigroup jsSources) => Semigroup (CommonOptions cSources cxxSources jsSources a) where
      a :: CommonOptions cSources cxxSources jsSources a
    a <> :: CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources a
    <> b :: CommonOptions cSources cxxSources jsSources a
    b = CommonOptions :: forall cSources cxxSources jsSources a.
    Maybe (List String)
    -> Maybe Dependencies
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> cSources
    -> Maybe (List String)
    -> cxxSources
    -> jsSources
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe Bool
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    -> Maybe BuildTools
    -> Maybe SystemBuildTools
    -> Maybe (List Verbatim)
    -> CommonOptions cSources cxxSources jsSources a
    CommonOptions {
        commonOptionsSourceDirs :: Maybe (List String)
    commonOptionsSourceDirs = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsSourceDirs CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsSourceDirs CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsDependencies :: Maybe Dependencies
    commonOptionsDependencies = CommonOptions cSources cxxSources jsSources a -> Maybe Dependencies
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> Maybe Dependencies
    commonOptionsDependencies CommonOptions cSources cxxSources jsSources a
    b Maybe Dependencies -> Maybe Dependencies -> Maybe Dependencies
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a -> Maybe Dependencies
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> Maybe Dependencies
    commonOptionsDependencies CommonOptions cSources cxxSources jsSources a
    a
      , commonOptionsPkgConfigDependencies :: Maybe (List String)
    commonOptionsPkgConfigDependencies = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsPkgConfigDependencies CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsPkgConfigDependencies CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsDefaultExtensions :: Maybe (List String)
    commonOptionsDefaultExtensions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsDefaultExtensions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsDefaultExtensions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsOtherExtensions :: Maybe (List String)
    commonOptionsOtherExtensions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsOtherExtensions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsOtherExtensions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsGhcOptions :: Maybe (List String)
    commonOptionsGhcOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsGhcProfOptions :: Maybe (List String)
    commonOptionsGhcProfOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcProfOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcProfOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsGhcjsOptions :: Maybe (List String)
    commonOptionsGhcjsOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcjsOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsGhcjsOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsCppOptions :: Maybe (List String)
    commonOptionsCppOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCppOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCppOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsCcOptions :: Maybe (List String)
    commonOptionsCcOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCcOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCcOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsCSources :: cSources
    commonOptionsCSources = CommonOptions cSources cxxSources jsSources a -> cSources
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> cSources
    commonOptionsCSources CommonOptions cSources cxxSources jsSources a
    a cSources -> cSources -> cSources
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a -> cSources
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> cSources
    commonOptionsCSources CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsCxxOptions :: Maybe (List String)
    commonOptionsCxxOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCxxOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsCxxOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsCxxSources :: cxxSources
    commonOptionsCxxSources = CommonOptions cSources cxxSources jsSources a -> cxxSources
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> cxxSources
    commonOptionsCxxSources CommonOptions cSources cxxSources jsSources a
    a cxxSources -> cxxSources -> cxxSources
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a -> cxxSources
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> cxxSources
    commonOptionsCxxSources CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsJsSources :: jsSources
    commonOptionsJsSources = CommonOptions cSources cxxSources jsSources a -> jsSources
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> jsSources
    commonOptionsJsSources CommonOptions cSources cxxSources jsSources a
    a jsSources -> jsSources -> jsSources
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a -> jsSources
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> jsSources
    commonOptionsJsSources CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsExtraLibDirs :: Maybe (List String)
    commonOptionsExtraLibDirs = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraLibDirs CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraLibDirs CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsExtraLibraries :: Maybe (List String)
    commonOptionsExtraLibraries = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraLibraries CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraLibraries CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsExtraFrameworksDirs :: Maybe (List String)
    commonOptionsExtraFrameworksDirs = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraFrameworksDirs CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsExtraFrameworksDirs CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsFrameworks :: Maybe (List String)
    commonOptionsFrameworks = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsFrameworks CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsFrameworks CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsIncludeDirs :: Maybe (List String)
    commonOptionsIncludeDirs = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsIncludeDirs CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsIncludeDirs CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsInstallIncludes :: Maybe (List String)
    commonOptionsInstallIncludes = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsInstallIncludes CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsInstallIncludes CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsLdOptions :: Maybe (List String)
    commonOptionsLdOptions = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsLdOptions CommonOptions cSources cxxSources jsSources a
    a Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List String)
    commonOptionsLdOptions CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsBuildable :: Maybe Bool
    commonOptionsBuildable = CommonOptions cSources cxxSources jsSources a -> Maybe Bool
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> Maybe Bool
    commonOptionsBuildable CommonOptions cSources cxxSources jsSources a
    b Maybe Bool -> Maybe Bool -> Maybe Bool
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> CommonOptions cSources cxxSources jsSources a -> Maybe Bool
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> Maybe Bool
    commonOptionsBuildable CommonOptions cSources cxxSources jsSources a
    a
      , commonOptionsWhen :: Maybe (List (ConditionalSection cSources cxxSources jsSources a))
    commonOptionsWhen = CommonOptions cSources cxxSources jsSources a
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    commonOptionsWhen CommonOptions cSources cxxSources jsSources a
    a Maybe (List (ConditionalSection cSources cxxSources jsSources a))
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    commonOptionsWhen CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsBuildTools :: Maybe BuildTools
    commonOptionsBuildTools = CommonOptions cSources cxxSources jsSources a -> Maybe BuildTools
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> Maybe BuildTools
    commonOptionsBuildTools CommonOptions cSources cxxSources jsSources a
    a Maybe BuildTools -> Maybe BuildTools -> Maybe BuildTools
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a -> Maybe BuildTools
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a -> Maybe BuildTools
    commonOptionsBuildTools CommonOptions cSources cxxSources jsSources a
    b
      , commonOptionsSystemBuildTools :: Maybe SystemBuildTools
    commonOptionsSystemBuildTools = CommonOptions cSources cxxSources jsSources a
    -> Maybe SystemBuildTools
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe SystemBuildTools
    commonOptionsSystemBuildTools CommonOptions cSources cxxSources jsSources a
    b Maybe SystemBuildTools
    -> Maybe SystemBuildTools -> Maybe SystemBuildTools
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe SystemBuildTools
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe SystemBuildTools
    commonOptionsSystemBuildTools CommonOptions cSources cxxSources jsSources a
    a
      , commonOptionsVerbatim :: Maybe (List Verbatim)
    commonOptionsVerbatim = CommonOptions cSources cxxSources jsSources a
    -> Maybe (List Verbatim)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List Verbatim)
    commonOptionsVerbatim CommonOptions cSources cxxSources jsSources a
    a Maybe (List Verbatim)
    -> Maybe (List Verbatim) -> Maybe (List Verbatim)
    forall a. Semigroup a => a -> a -> a
    <> CommonOptions cSources cxxSources jsSources a
    -> Maybe (List Verbatim)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List Verbatim)
    commonOptionsVerbatim CommonOptions cSources cxxSources jsSources a
    b
      }

    type ParseCSources = Maybe (List FilePath)
    type ParseCxxSources = Maybe (List FilePath)
    type ParseJsSources = Maybe (List FilePath)

    type CSources = [Path]
    type CxxSources = [Path]
    type JsSources = [Path]

    type WithCommonOptions cSources cxxSources jsSources a = Product (CommonOptions cSources cxxSources jsSources a) a

    data Traverse m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_ = Traverse {
      Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> cSources -> m cSources_
    traverseCSources :: cSources -> m cSources_
    , Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> cxxSources -> m cxxSources_
    traverseCxxSources :: cxxSources -> m cxxSources_
    , Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> jsSources -> m jsSources_
    traverseJsSources :: jsSources -> m jsSources_
    }

    type Traversal t = forall m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_. Monad m
      => Traverse m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
      -> t cSources cxxSources jsSources
      -> m (t cSources_ cxxSources_ jsSources_)

    type Traversal_ t = forall m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_ a. Monad m
      => Traverse m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
      -> t cSources cxxSources jsSources a
      -> m (t cSources_ cxxSources_ jsSources_ a)

    traverseCommonOptions :: Traversal_ CommonOptions
    traverseCommonOptions :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> CommonOptions cSources cxxSources jsSources a
    -> m (CommonOptions cSources_ cxxSources_ jsSources_ a)
    traverseCommonOptions t :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t@Traverse{..} c :: CommonOptions cSources cxxSources jsSources a
    c@CommonOptions{..} = do
      cSources_
    cSources <- cSources -> m cSources_
    traverseCSources cSources
    commonOptionsCSources
      cxxSources_
    cxxSources <- cxxSources -> m cxxSources_
    traverseCxxSources cxxSources
    commonOptionsCxxSources
      jsSources_
    jsSources <- jsSources -> m jsSources_
    traverseJsSources jsSources
    commonOptionsJsSources
      Maybe
      (List (ConditionalSection cSources_ cxxSources_ jsSources_ a))
    xs <- (List (ConditionalSection cSources cxxSources jsSources a)
     -> m (List
             (ConditionalSection cSources_ cxxSources_ jsSources_ a)))
    -> Maybe
         (List (ConditionalSection cSources cxxSources jsSources a))
    -> m (Maybe
            (List (ConditionalSection cSources_ cxxSources_ jsSources_ a)))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((ConditionalSection cSources cxxSources jsSources a
     -> m (ConditionalSection cSources_ cxxSources_ jsSources_ a))
    -> List (ConditionalSection cSources cxxSources jsSources a)
    -> m (List (ConditionalSection cSources_ cxxSources_ jsSources_ a))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> ConditionalSection cSources cxxSources jsSources a
    -> m (ConditionalSection cSources_ cxxSources_ jsSources_ a)
    Traversal_ ConditionalSection
    traverseConditionalSection Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t)) Maybe (List (ConditionalSection cSources cxxSources jsSources a))
    commonOptionsWhen
      CommonOptions cSources_ cxxSources_ jsSources_ a
    -> m (CommonOptions cSources_ cxxSources_ jsSources_ a)
    forall (m :: * -> *) a. Monad m => a -> m a
    return CommonOptions cSources cxxSources jsSources a
    c {
          commonOptionsCSources :: cSources_
    commonOptionsCSources = cSources_
    cSources
        , commonOptionsCxxSources :: cxxSources_
    commonOptionsCxxSources = cxxSources_
    cxxSources
        , commonOptionsJsSources :: jsSources_
    commonOptionsJsSources = jsSources_
    jsSources
        , commonOptionsWhen :: Maybe
      (List (ConditionalSection cSources_ cxxSources_ jsSources_ a))
    commonOptionsWhen = Maybe
      (List (ConditionalSection cSources_ cxxSources_ jsSources_ a))
    xs
        }

    traverseConditionalSection :: Traversal_ ConditionalSection
    traverseConditionalSection :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> ConditionalSection cSources cxxSources jsSources a
    -> m (ConditionalSection cSources_ cxxSources_ jsSources_ a)
    traverseConditionalSection t :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t@Traverse{..} = \ case
      ThenElseConditional c :: Product (ThenElse cSources cxxSources jsSources a) Condition
    c -> Product (ThenElse cSources_ cxxSources_ jsSources_ a) Condition
    -> ConditionalSection cSources_ cxxSources_ jsSources_ a
    forall cSources cxxSources jsSources a.
    Product (ThenElse cSources cxxSources jsSources a) Condition
    -> ConditionalSection cSources cxxSources jsSources a
    ThenElseConditional (Product (ThenElse cSources_ cxxSources_ jsSources_ a) Condition
     -> ConditionalSection cSources_ cxxSources_ jsSources_ a)
    -> m (Product
            (ThenElse cSources_ cxxSources_ jsSources_ a) Condition)
    -> m (ConditionalSection cSources_ cxxSources_ jsSources_ a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ThenElse cSources cxxSources jsSources a
     -> m (ThenElse cSources_ cxxSources_ jsSources_ a))
    -> (Condition -> m Condition)
    -> Product (ThenElse cSources cxxSources jsSources a) Condition
    -> m (Product
            (ThenElse cSources_ cxxSources_ jsSources_ a) Condition)
    forall (t :: * -> * -> *) (f :: * -> *) a c b d.
    (Bitraversable t, Applicative f) =>
    (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
    bitraverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> ThenElse cSources cxxSources jsSources a
    -> m (ThenElse cSources_ cxxSources_ jsSources_ a)
    Traversal_ ThenElse
    traverseThenElse Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t) Condition -> m Condition
    forall (m :: * -> *) a. Monad m => a -> m a
    return Product (ThenElse cSources cxxSources jsSources a) Condition
    c
      FlatConditional c :: Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    c -> Product
      (WithCommonOptions cSources_ cxxSources_ jsSources_ a) Condition
    -> ConditionalSection cSources_ cxxSources_ jsSources_ a
    forall cSources cxxSources jsSources a.
    Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    -> ConditionalSection cSources cxxSources jsSources a
    FlatConditional (Product
       (WithCommonOptions cSources_ cxxSources_ jsSources_ a) Condition
     -> ConditionalSection cSources_ cxxSources_ jsSources_ a)
    -> m (Product
            (WithCommonOptions cSources_ cxxSources_ jsSources_ a) Condition)
    -> m (ConditionalSection cSources_ cxxSources_ jsSources_ a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (WithCommonOptions cSources cxxSources jsSources a
     -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a))
    -> (Condition -> m Condition)
    -> Product
         (WithCommonOptions cSources cxxSources jsSources a) Condition
    -> m (Product
            (WithCommonOptions cSources_ cxxSources_ jsSources_ a) Condition)
    forall (t :: * -> * -> *) (f :: * -> *) a c b d.
    (Bitraversable t, Applicative f) =>
    (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
    bitraverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions cSources cxxSources jsSources a
    -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a)
    Traversal_ WithCommonOptions
    traverseWithCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t) Condition -> m Condition
    forall (m :: * -> *) a. Monad m => a -> m a
    return Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    c

    traverseThenElse :: Traversal_ ThenElse
    traverseThenElse :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> ThenElse cSources cxxSources jsSources a
    -> m (ThenElse cSources_ cxxSources_ jsSources_ a)
    traverseThenElse t :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t@Traverse{..} c :: ThenElse cSources cxxSources jsSources a
    c@ThenElse{..} = do
      WithCommonOptions cSources_ cxxSources_ jsSources_ a
    then_ <- Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions cSources cxxSources jsSources a
    -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a)
    Traversal_ WithCommonOptions
    traverseWithCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t WithCommonOptions cSources cxxSources jsSources a
    thenElseThen
      WithCommonOptions cSources_ cxxSources_ jsSources_ a
    else_ <- Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions cSources cxxSources jsSources a
    -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a)
    Traversal_ WithCommonOptions
    traverseWithCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t WithCommonOptions cSources cxxSources jsSources a
    thenElseElse
      ThenElse cSources_ cxxSources_ jsSources_ a
    -> m (ThenElse cSources_ cxxSources_ jsSources_ a)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ThenElse cSources cxxSources jsSources a
    c{thenElseThen :: WithCommonOptions cSources_ cxxSources_ jsSources_ a
    thenElseThen = WithCommonOptions cSources_ cxxSources_ jsSources_ a
    then_, thenElseElse :: WithCommonOptions cSources_ cxxSources_ jsSources_ a
    thenElseElse = WithCommonOptions cSources_ cxxSources_ jsSources_ a
    else_}

    traverseWithCommonOptions :: Traversal_ WithCommonOptions
    traverseWithCommonOptions :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions cSources cxxSources jsSources a
    -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a)
    traverseWithCommonOptions t :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t = (CommonOptions cSources cxxSources jsSources a
     -> m (CommonOptions cSources_ cxxSources_ jsSources_ a))
    -> (a -> m a)
    -> WithCommonOptions cSources cxxSources jsSources a
    -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a)
    forall (t :: * -> * -> *) (f :: * -> *) a c b d.
    (Bitraversable t, Applicative f) =>
    (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
    bitraverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> CommonOptions cSources cxxSources jsSources a
    -> m (CommonOptions cSources_ cxxSources_ jsSources_ a)
    Traversal_ CommonOptions
    traverseCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t) a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return

    data ConditionalSection cSources cxxSources jsSources a =
        ThenElseConditional (Product (ThenElse cSources cxxSources jsSources a) Condition)
      | FlatConditional (Product (WithCommonOptions cSources cxxSources jsSources a) Condition)

    instance Functor (ConditionalSection cSources cxxSources jsSources) where
      fmap :: (a -> b)
    -> ConditionalSection cSources cxxSources jsSources a
    -> ConditionalSection cSources cxxSources jsSources b
    fmap f :: a -> b
    f = \ case
        ThenElseConditional c :: Product (ThenElse cSources cxxSources jsSources a) Condition
    c -> Product (ThenElse cSources cxxSources jsSources b) Condition
    -> ConditionalSection cSources cxxSources jsSources b
    forall cSources cxxSources jsSources a.
    Product (ThenElse cSources cxxSources jsSources a) Condition
    -> ConditionalSection cSources cxxSources jsSources a
    ThenElseConditional ((ThenElse cSources cxxSources jsSources a
     -> ThenElse cSources cxxSources jsSources b)
    -> Product (ThenElse cSources cxxSources jsSources a) Condition
    -> Product (ThenElse cSources cxxSources jsSources b) Condition
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first ((a -> b)
    -> ThenElse cSources cxxSources jsSources a
    -> ThenElse cSources cxxSources jsSources b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap a -> b
    f) Product (ThenElse cSources cxxSources jsSources a) Condition
    c)
        FlatConditional c :: Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    c -> Product
      (WithCommonOptions cSources cxxSources jsSources b) Condition
    -> ConditionalSection cSources cxxSources jsSources b
    forall cSources cxxSources jsSources a.
    Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    -> ConditionalSection cSources cxxSources jsSources a
    FlatConditional ((WithCommonOptions cSources cxxSources jsSources a
     -> WithCommonOptions cSources cxxSources jsSources b)
    -> Product
         (WithCommonOptions cSources cxxSources jsSources a) Condition
    -> Product
         (WithCommonOptions cSources cxxSources jsSources b) Condition
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first ((CommonOptions cSources cxxSources jsSources a
     -> CommonOptions cSources cxxSources jsSources b)
    -> (a -> b)
    -> WithCommonOptions cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources b
    forall (p :: * -> * -> *) a b c d.
    Bifunctor p =>
    (a -> b) -> (c -> d) -> p a c -> p b d
    bimap ((a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap a -> b
    f) a -> b
    f) Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    c)

    type ParseConditionalSection = ConditionalSection ParseCSources ParseCxxSources ParseJsSources

    instance FromValue a => FromValue (ParseConditionalSection a) where
      fromValue :: Value -> Parser (ParseConditionalSection a)
    fromValue v :: Value
    v
        | Text -> Value -> Bool
    hasKey "then" Value
    v Bool -> Bool -> Bool
    || Text -> Value -> Bool
    hasKey "else" Value
    v = Product
      (ThenElse
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         a)
      Condition
    -> ParseConditionalSection a
    forall cSources cxxSources jsSources a.
    Product (ThenElse cSources cxxSources jsSources a) Condition
    -> ConditionalSection cSources cxxSources jsSources a
    ThenElseConditional (Product
       (ThenElse
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          a)
       Condition
     -> ParseConditionalSection a)
    -> Parser
         (Product
            (ThenElse
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               a)
            Condition)
    -> Parser (ParseConditionalSection a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Value
    -> Parser
         (Product
            (ThenElse
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               a)
            Condition)
    forall a. FromValue a => Value -> Parser a
    fromValue Value
    v
        | Bool
    otherwise = Product
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         a)
      Condition
    -> ParseConditionalSection a
    forall cSources cxxSources jsSources a.
    Product
      (WithCommonOptions cSources cxxSources jsSources a) Condition
    -> ConditionalSection cSources cxxSources jsSources a
    FlatConditional (Product
       (WithCommonOptions
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          a)
       Condition
     -> ParseConditionalSection a)
    -> Parser
         (Product
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               a)
            Condition)
    -> Parser (ParseConditionalSection a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Value
    -> Parser
         (Product
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               a)
            Condition)
    forall a. FromValue a => Value -> Parser a
    fromValue Value
    v

    hasKey :: Text -> Value -> Bool
    hasKey :: Text -> Value -> Bool
    hasKey key :: Text
    key (Object o :: Object
    o) = Text -> Object -> Bool
    forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
    HashMap.member Text
    key Object
    o
    hasKey _ _ = Bool
    False

    newtype Condition = Condition {
      Condition -> Cond
    _conditionCondition :: Cond
    } deriving (Condition -> Condition -> Bool
    (Condition -> Condition -> Bool)
    -> (Condition -> Condition -> Bool) -> Eq Condition
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Condition -> Condition -> Bool
    $c/= :: Condition -> Condition -> Bool
    == :: Condition -> Condition -> Bool
    $c== :: Condition -> Condition -> Bool
    Eq, Int -> Condition -> ShowS
    [Condition] -> ShowS
    Condition -> String
    (Int -> Condition -> ShowS)
    -> (Condition -> String)
    -> ([Condition] -> ShowS)
    -> Show Condition
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Condition] -> ShowS
    $cshowList :: [Condition] -> ShowS
    show :: Condition -> String
    $cshow :: Condition -> String
    showsPrec :: Int -> Condition -> ShowS
    $cshowsPrec :: Int -> Condition -> ShowS
    Show, (forall x. Condition -> Rep Condition x)
    -> (forall x. Rep Condition x -> Condition) -> Generic Condition
    forall x. Rep Condition x -> Condition
    forall x. Condition -> Rep Condition x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep Condition x -> Condition
    $cfrom :: forall x. Condition -> Rep Condition x
    Generic, Value -> Parser Condition
    (Value -> Parser Condition) -> FromValue Condition
    forall a. (Value -> Parser a) -> FromValue a
    fromValue :: Value -> Parser Condition
    $cfromValue :: Value -> Parser Condition
    FromValue)

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

    instance FromValue Cond where
      fromValue :: Value -> Parser Cond
    fromValue v :: Value
    v = case Value
    v of
        String s :: Text
    s -> Cond -> Parser Cond
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> Cond
    Cond (String -> Cond) -> String -> Cond
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    s)
        Bool True -> Cond -> Parser Cond
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> Cond
    Cond "true")
        Bool False -> Cond -> Parser Cond
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> Cond
    Cond "false")
        _ -> String -> Value -> Parser Cond
    forall a. String -> Value -> Parser a
    typeMismatch "Boolean or String" Value
    v

    data ThenElse cSources cxxSources jsSources a = ThenElse {
      ThenElse cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources a
    thenElseThen :: WithCommonOptions cSources cxxSources jsSources a
    , ThenElse cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources a
    thenElseElse :: WithCommonOptions cSources cxxSources jsSources a
    } deriving (forall x.
     ThenElse cSources cxxSources jsSources a
     -> Rep (ThenElse cSources cxxSources jsSources a) x)
    -> (forall x.
        Rep (ThenElse cSources cxxSources jsSources a) x
        -> ThenElse cSources cxxSources jsSources a)
    -> Generic (ThenElse cSources cxxSources jsSources a)
    forall x.
    Rep (ThenElse cSources cxxSources jsSources a) x
    -> ThenElse cSources cxxSources jsSources a
    forall x.
    ThenElse cSources cxxSources jsSources a
    -> Rep (ThenElse cSources cxxSources jsSources a) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall cSources cxxSources jsSources a x.
    Rep (ThenElse cSources cxxSources jsSources a) x
    -> ThenElse cSources cxxSources jsSources a
    forall cSources cxxSources jsSources a x.
    ThenElse cSources cxxSources jsSources a
    -> Rep (ThenElse cSources cxxSources jsSources a) x
    $cto :: forall cSources cxxSources jsSources a x.
    Rep (ThenElse cSources cxxSources jsSources a) x
    -> ThenElse cSources cxxSources jsSources a
    $cfrom :: forall cSources cxxSources jsSources a x.
    ThenElse cSources cxxSources jsSources a
    -> Rep (ThenElse cSources cxxSources jsSources a) x
    Generic

    instance Functor (ThenElse cSources cxxSources jsSources) where
      fmap :: (a -> b)
    -> ThenElse cSources cxxSources jsSources a
    -> ThenElse cSources cxxSources jsSources b
    fmap f :: a -> b
    f c :: ThenElse cSources cxxSources jsSources a
    c@ThenElse{..} = ThenElse cSources cxxSources jsSources a
    c{thenElseThen :: WithCommonOptions cSources cxxSources jsSources b
    thenElseThen = WithCommonOptions cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources b
    map_ WithCommonOptions cSources cxxSources jsSources a
    thenElseThen, thenElseElse :: WithCommonOptions cSources cxxSources jsSources b
    thenElseElse = WithCommonOptions cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources b
    map_ WithCommonOptions cSources cxxSources jsSources a
    thenElseElse}
        where
          map_ :: WithCommonOptions cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources b
    map_ = (CommonOptions cSources cxxSources jsSources a
     -> CommonOptions cSources cxxSources jsSources b)
    -> (a -> b)
    -> WithCommonOptions cSources cxxSources jsSources a
    -> WithCommonOptions cSources cxxSources jsSources b
    forall (p :: * -> * -> *) a b c d.
    Bifunctor p =>
    (a -> b) -> (c -> d) -> p a c -> p b d
    bimap ((a -> b)
    -> CommonOptions cSources cxxSources jsSources a
    -> CommonOptions cSources cxxSources jsSources b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap a -> b
    f) a -> b
    f

    type ParseThenElse = ThenElse ParseCSources ParseCxxSources ParseJsSources

    instance FromValue a => FromValue (ParseThenElse a)

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

    instance Monoid Empty where
      mempty :: Empty
    mempty = Empty
    Empty
      mappend :: Empty -> Empty -> Empty
    mappend = Empty -> Empty -> Empty
    forall a. Semigroup a => a -> a -> a
    (<>)

    instance Semigroup Empty where
      Empty <> :: Empty -> Empty -> Empty
    <> Empty = Empty
    Empty

    instance FromValue Empty where
      fromValue :: Value -> Parser Empty
    fromValue _ = Empty -> Parser Empty
    forall (m :: * -> *) a. Monad m => a -> m a
    return Empty
    Empty

    data BuildType =
        Simple
      | Configure
      | Make
      | Custom
      deriving (BuildType -> BuildType -> Bool
    (BuildType -> BuildType -> Bool)
    -> (BuildType -> BuildType -> Bool) -> Eq BuildType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: BuildType -> BuildType -> Bool
    $c/= :: BuildType -> BuildType -> Bool
    == :: BuildType -> BuildType -> Bool
    $c== :: BuildType -> BuildType -> Bool
    Eq, Int -> BuildType -> ShowS
    [BuildType] -> ShowS
    BuildType -> String
    (Int -> BuildType -> ShowS)
    -> (BuildType -> String)
    -> ([BuildType] -> ShowS)
    -> Show BuildType
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [BuildType] -> ShowS
    $cshowList :: [BuildType] -> ShowS
    show :: BuildType -> String
    $cshow :: BuildType -> String
    showsPrec :: Int -> BuildType -> ShowS
    $cshowsPrec :: Int -> BuildType -> ShowS
    Show, (forall x. BuildType -> Rep BuildType x)
    -> (forall x. Rep BuildType x -> BuildType) -> Generic BuildType
    forall x. Rep BuildType x -> BuildType
    forall x. BuildType -> Rep BuildType x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep BuildType x -> BuildType
    $cfrom :: forall x. BuildType -> Rep BuildType x
    Generic, Int -> BuildType
    BuildType -> Int
    BuildType -> [BuildType]
    BuildType -> BuildType
    BuildType -> BuildType -> [BuildType]
    BuildType -> BuildType -> BuildType -> [BuildType]
    (BuildType -> BuildType)
    -> (BuildType -> BuildType)
    -> (Int -> BuildType)
    -> (BuildType -> Int)
    -> (BuildType -> [BuildType])
    -> (BuildType -> BuildType -> [BuildType])
    -> (BuildType -> BuildType -> [BuildType])
    -> (BuildType -> BuildType -> BuildType -> [BuildType])
    -> Enum BuildType
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    enumFromThenTo :: BuildType -> BuildType -> BuildType -> [BuildType]
    $cenumFromThenTo :: BuildType -> BuildType -> BuildType -> [BuildType]
    enumFromTo :: BuildType -> BuildType -> [BuildType]
    $cenumFromTo :: BuildType -> BuildType -> [BuildType]
    enumFromThen :: BuildType -> BuildType -> [BuildType]
    $cenumFromThen :: BuildType -> BuildType -> [BuildType]
    enumFrom :: BuildType -> [BuildType]
    $cenumFrom :: BuildType -> [BuildType]
    fromEnum :: BuildType -> Int
    $cfromEnum :: BuildType -> Int
    toEnum :: Int -> BuildType
    $ctoEnum :: Int -> BuildType
    pred :: BuildType -> BuildType
    $cpred :: BuildType -> BuildType
    succ :: BuildType -> BuildType
    $csucc :: BuildType -> BuildType
    Enum, BuildType
    BuildType -> BuildType -> Bounded BuildType
    forall a. a -> a -> Bounded a
    maxBound :: BuildType
    $cmaxBound :: BuildType
    minBound :: BuildType
    $cminBound :: BuildType
    Bounded)

    instance FromValue BuildType where
      fromValue :: Value -> Parser BuildType
    fromValue = (Text -> Parser BuildType) -> Value -> Parser BuildType
    forall a. (Text -> Parser a) -> Value -> Parser a
    withText ((Text -> Parser BuildType) -> Value -> Parser BuildType)
    -> (Text -> Parser BuildType) -> Value -> Parser BuildType
    forall a b. (a -> b) -> a -> b
    $ \ (Text -> String
    T.unpack -> String
    t) -> do
        Parser BuildType
    -> (BuildType -> Parser BuildType)
    -> Maybe BuildType
    -> Parser BuildType
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Parser BuildType
    forall a. Parser a
    err BuildType -> Parser BuildType
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> [(String, BuildType)] -> Maybe BuildType
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup String
    t [(String, BuildType)]
    options)
        where
          err :: Parser a
    err = String -> Parser a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail ("expected one of " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [String] -> String
    formatOrList [String]
    buildTypesAsString)
          buildTypes :: [BuildType]
    buildTypes = [BuildType
    forall a. Bounded a => a
    minBound .. BuildType
    forall a. Bounded a => a
    maxBound]
          buildTypesAsString :: [String]
    buildTypesAsString = (BuildType -> String) -> [BuildType] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map BuildType -> String
    forall a. Show a => a -> String
    show [BuildType]
    buildTypes
          options :: [(String, BuildType)]
    options = [String] -> [BuildType] -> [(String, BuildType)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip [String]
    buildTypesAsString [BuildType]
    buildTypes

    formatOrList :: [String] -> String
    formatOrList :: [String] -> String
    formatOrList xs :: [String]
    xs = case [String] -> [String]
    forall a. [a] -> [a]
    reverse [String]
    xs of
      [] -> ""
      x :: String
    x : [] -> String
    x
      y :: String
    y : x :: String
    x : [] -> String
    x String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " or " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    y
      x :: String
    x : ys :: [String]
    ys@(_:_:_) -> String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate ", " ([String] -> String)
    -> ([String] -> [String]) -> [String] -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [String] -> [String]
    forall a. [a] -> [a]
    reverse ([String] -> String) -> [String] -> String
    forall a b. (a -> b) -> a -> b
    $ ("or " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    x) String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : [String]
    ys

    type SectionConfigWithDefaluts cSources cxxSources jsSources a = Product DefaultsConfig (WithCommonOptions cSources cxxSources jsSources a)

    type PackageConfigWithDefaults cSources cxxSources jsSources = PackageConfig_
      (SectionConfigWithDefaluts cSources cxxSources jsSources LibrarySection)
      (SectionConfigWithDefaluts cSources cxxSources jsSources ExecutableSection)

    type PackageConfig cSources cxxSources jsSources = PackageConfig_
      (WithCommonOptions cSources cxxSources jsSources LibrarySection)
      (WithCommonOptions cSources cxxSources jsSources ExecutableSection)

    data PackageVersion = PackageVersion {PackageVersion -> String
    unPackageVersion :: String}

    instance FromValue PackageVersion where
      fromValue :: Value -> Parser PackageVersion
    fromValue v :: Value
    v = String -> PackageVersion
    PackageVersion (String -> PackageVersion)
    -> Parser String -> Parser PackageVersion
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> case Value
    v of
        Number n :: Scientific
    n -> String -> Parser String
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Scientific -> String
    scientificToVersion Scientific
    n)
        String s :: Text
    s -> String -> Parser String
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> String
    T.unpack Text
    s)
        _ -> String -> Value -> Parser String
    forall a. String -> Value -> Parser a
    typeMismatch "Number or String" Value
    v

    data PackageConfig_ library executable = PackageConfig {
      PackageConfig_ library executable -> Maybe String
    packageConfigName :: Maybe String
    , PackageConfig_ library executable -> Maybe PackageVersion
    packageConfigVersion :: Maybe PackageVersion
    , PackageConfig_ library executable -> Maybe String
    packageConfigSynopsis :: Maybe String
    , PackageConfig_ library executable -> Maybe String
    packageConfigDescription :: Maybe String
    , PackageConfig_ library executable -> Maybe (Maybe String)
    packageConfigHomepage :: Maybe (Maybe String)
    , PackageConfig_ library executable -> Maybe (Maybe String)
    packageConfigBugReports :: Maybe (Maybe String)
    , PackageConfig_ library executable -> Maybe String
    packageConfigCategory :: Maybe String
    , PackageConfig_ library executable -> Maybe String
    packageConfigStability :: Maybe String
    , PackageConfig_ library executable -> Maybe (List String)
    packageConfigAuthor :: Maybe (List String)
    , PackageConfig_ library executable -> Maybe (Maybe (List String))
    packageConfigMaintainer :: Maybe (Maybe (List String))
    , PackageConfig_ library executable -> Maybe (List String)
    packageConfigCopyright :: Maybe (List String)
    , PackageConfig_ library executable -> Maybe BuildType
    packageConfigBuildType :: Maybe BuildType
    , PackageConfig_ library executable -> Maybe (Maybe String)
    packageConfigLicense :: Maybe (Maybe String)
    , PackageConfig_ library executable -> Maybe (List String)
    packageConfigLicenseFile :: Maybe (List String)
    , PackageConfig_ library executable -> Maybe String
    packageConfigTestedWith :: Maybe String
    , PackageConfig_ library executable -> Maybe (Map String FlagSection)
    packageConfigFlags :: Maybe (Map String FlagSection)
    , PackageConfig_ library executable -> Maybe (List String)
    packageConfigExtraSourceFiles :: Maybe (List FilePath)
    , PackageConfig_ library executable -> Maybe (List String)
    packageConfigExtraDocFiles :: Maybe (List FilePath)
    , PackageConfig_ library executable -> Maybe (List String)
    packageConfigDataFiles :: Maybe (List FilePath)
    , PackageConfig_ library executable -> Maybe String
    packageConfigDataDir :: Maybe FilePath
    , PackageConfig_ library executable -> Maybe GitHub
    packageConfigGithub :: Maybe GitHub
    , PackageConfig_ library executable -> Maybe String
    packageConfigGit :: Maybe String
    , PackageConfig_ library executable -> Maybe CustomSetupSection
    packageConfigCustomSetup :: Maybe CustomSetupSection
    , PackageConfig_ library executable -> Maybe library
    packageConfigLibrary :: Maybe library
    , PackageConfig_ library executable -> Maybe (Map String library)
    packageConfigInternalLibraries :: Maybe (Map String library)
    , PackageConfig_ library executable -> Maybe executable
    packageConfigExecutable :: Maybe executable
    , PackageConfig_ library executable -> Maybe (Map String executable)
    packageConfigExecutables :: Maybe (Map String executable)
    , PackageConfig_ library executable -> Maybe (Map String executable)
    packageConfigTests :: Maybe (Map String executable)
    , PackageConfig_ library executable -> Maybe (Map String executable)
    packageConfigBenchmarks :: Maybe (Map String executable)
    } deriving (forall x.
     PackageConfig_ library executable
     -> Rep (PackageConfig_ library executable) x)
    -> (forall x.
        Rep (PackageConfig_ library executable) x
        -> PackageConfig_ library executable)
    -> Generic (PackageConfig_ library executable)
    forall x.
    Rep (PackageConfig_ library executable) x
    -> PackageConfig_ library executable
    forall x.
    PackageConfig_ library executable
    -> Rep (PackageConfig_ library executable) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall library executable x.
    Rep (PackageConfig_ library executable) x
    -> PackageConfig_ library executable
    forall library executable x.
    PackageConfig_ library executable
    -> Rep (PackageConfig_ library executable) x
    $cto :: forall library executable x.
    Rep (PackageConfig_ library executable) x
    -> PackageConfig_ library executable
    $cfrom :: forall library executable x.
    PackageConfig_ library executable
    -> Rep (PackageConfig_ library executable) x
    Generic

    data GitHub = GitHub {
      GitHub -> String
    _gitHubOwner :: String
    , GitHub -> String
    _gitHubRepo :: String
    , GitHub -> Maybe String
    _gitHubSubdir :: Maybe String
    }

    instance FromValue GitHub where
      fromValue :: Value -> Parser GitHub
    fromValue v :: Value
    v = do
        Text
    input <- Value -> Parser Text
    forall a. FromValue a => Value -> Parser a
    fromValue Value
    v
        case (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    T.unpack ([Text] -> [String]) -> [Text] -> [String]
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> [Text]
    T.splitOn "/" Text
    input of
          [owner :: String
    owner, repo :: String
    repo, subdir :: String
    subdir] -> GitHub -> Parser GitHub
    forall (m :: * -> *) a. Monad m => a -> m a
    return (GitHub -> Parser GitHub) -> GitHub -> Parser GitHub
    forall a b. (a -> b) -> a -> b
    $ String -> String -> Maybe String -> GitHub
    GitHub String
    owner String
    repo (String -> Maybe String
    forall a. a -> Maybe a
    Just String
    subdir)
          [owner :: String
    owner, repo :: String
    repo] -> GitHub -> Parser GitHub
    forall (m :: * -> *) a. Monad m => a -> m a
    return (GitHub -> Parser GitHub) -> GitHub -> Parser GitHub
    forall a b. (a -> b) -> a -> b
    $ String -> String -> Maybe String -> GitHub
    GitHub String
    owner String
    repo Maybe String
    forall a. Maybe a
    Nothing
          _ -> String -> Parser GitHub
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> Parser GitHub) -> String -> Parser GitHub
    forall a b. (a -> b) -> a -> b
    $ "expected owner/repo or owner/repo/subdir, but encountered " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Text -> String
    forall a. Show a => a -> String
    show Text
    input

    data DefaultsConfig = DefaultsConfig {
      DefaultsConfig -> Maybe (List Defaults)
    defaultsConfigDefaults :: Maybe (List Defaults)
    } deriving ((forall x. DefaultsConfig -> Rep DefaultsConfig x)
    -> (forall x. Rep DefaultsConfig x -> DefaultsConfig)
    -> Generic DefaultsConfig
    forall x. Rep DefaultsConfig x -> DefaultsConfig
    forall x. DefaultsConfig -> Rep DefaultsConfig x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep DefaultsConfig x -> DefaultsConfig
    $cfrom :: forall x. DefaultsConfig -> Rep DefaultsConfig x
    Generic, Value -> Parser DefaultsConfig
    (Value -> Parser DefaultsConfig) -> FromValue DefaultsConfig
    forall a. (Value -> Parser a) -> FromValue a
    fromValue :: Value -> Parser DefaultsConfig
    $cfromValue :: Value -> Parser DefaultsConfig
    FromValue)

    traversePackageConfig :: Traversal PackageConfig
    traversePackageConfig :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> PackageConfig cSources cxxSources jsSources
    -> m (PackageConfig cSources_ cxxSources_ jsSources_)
    traversePackageConfig t :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t@Traverse{..} p :: PackageConfig cSources cxxSources jsSources
    p@PackageConfig{..} = do
      Maybe
      (WithCommonOptions cSources_ cxxSources_ jsSources_ LibrarySection)
    library <- (WithCommonOptions cSources cxxSources jsSources LibrarySection
     -> m (WithCommonOptions
             cSources_ cxxSources_ jsSources_ LibrarySection))
    -> Maybe
         (WithCommonOptions cSources cxxSources jsSources LibrarySection)
    -> m (Maybe
            (WithCommonOptions
               cSources_ cxxSources_ jsSources_ LibrarySection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions cSources cxxSources jsSources LibrarySection
    -> m (WithCommonOptions
            cSources_ cxxSources_ jsSources_ LibrarySection)
    Traversal_ WithCommonOptions
    traverseWithCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t) Maybe
      (WithCommonOptions cSources cxxSources jsSources LibrarySection)
    packageConfigLibrary
      Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ LibrarySection))
    internalLibraries <- Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map
            String
            (WithCommonOptions cSources cxxSources jsSources LibrarySection))
    -> m (Maybe
            (Map
               String
               (WithCommonOptions
                  cSources_ cxxSources_ jsSources_ LibrarySection)))
    forall cSources cSources_ cxxSources cxxSources_ jsSources
           jsSources_ a.
    Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    traverseNamedConfigs Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t Maybe
      (Map
         String
         (WithCommonOptions cSources cxxSources jsSources LibrarySection))
    packageConfigInternalLibraries
      Maybe
      (WithCommonOptions
         cSources_ cxxSources_ jsSources_ ExecutableSection)
    executable <- (WithCommonOptions cSources cxxSources jsSources ExecutableSection
     -> m (WithCommonOptions
             cSources_ cxxSources_ jsSources_ ExecutableSection))
    -> Maybe
         (WithCommonOptions cSources cxxSources jsSources ExecutableSection)
    -> m (Maybe
            (WithCommonOptions
               cSources_ cxxSources_ jsSources_ ExecutableSection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions
         cSources cxxSources jsSources ExecutableSection
    -> m (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection)
    Traversal_ WithCommonOptions
    traverseWithCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t) Maybe
      (WithCommonOptions cSources cxxSources jsSources ExecutableSection)
    packageConfigExecutable
      Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    executables <- Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map
            String
            (WithCommonOptions
               cSources cxxSources jsSources ExecutableSection))
    -> m (Maybe
            (Map
               String
               (WithCommonOptions
                  cSources_ cxxSources_ jsSources_ ExecutableSection)))
    forall cSources cSources_ cxxSources cxxSources_ jsSources
           jsSources_ a.
    Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    traverseNamedConfigs Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t Maybe
      (Map
         String
         (WithCommonOptions
            cSources cxxSources jsSources ExecutableSection))
    packageConfigExecutables
      Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    tests <- Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map
            String
            (WithCommonOptions
               cSources cxxSources jsSources ExecutableSection))
    -> m (Maybe
            (Map
               String
               (WithCommonOptions
                  cSources_ cxxSources_ jsSources_ ExecutableSection)))
    forall cSources cSources_ cxxSources cxxSources_ jsSources
           jsSources_ a.
    Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    traverseNamedConfigs Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t Maybe
      (Map
         String
         (WithCommonOptions
            cSources cxxSources jsSources ExecutableSection))
    packageConfigTests
      Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    benchmarks <- Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map
            String
            (WithCommonOptions
               cSources cxxSources jsSources ExecutableSection))
    -> m (Maybe
            (Map
               String
               (WithCommonOptions
                  cSources_ cxxSources_ jsSources_ ExecutableSection)))
    forall cSources cSources_ cxxSources cxxSources_ jsSources
           jsSources_ a.
    Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    traverseNamedConfigs Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t Maybe
      (Map
         String
         (WithCommonOptions
            cSources cxxSources jsSources ExecutableSection))
    packageConfigBenchmarks
      PackageConfig cSources_ cxxSources_ jsSources_
    -> m (PackageConfig cSources_ cxxSources_ jsSources_)
    forall (m :: * -> *) a. Monad m => a -> m a
    return PackageConfig cSources cxxSources jsSources
    p {
          packageConfigLibrary :: Maybe
      (WithCommonOptions cSources_ cxxSources_ jsSources_ LibrarySection)
    packageConfigLibrary = Maybe
      (WithCommonOptions cSources_ cxxSources_ jsSources_ LibrarySection)
    library
        , packageConfigInternalLibraries :: Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ LibrarySection))
    packageConfigInternalLibraries = Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ LibrarySection))
    internalLibraries
        , packageConfigExecutable :: Maybe
      (WithCommonOptions
         cSources_ cxxSources_ jsSources_ ExecutableSection)
    packageConfigExecutable = Maybe
      (WithCommonOptions
         cSources_ cxxSources_ jsSources_ ExecutableSection)
    executable
        , packageConfigExecutables :: Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    packageConfigExecutables = Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    executables
        , packageConfigTests :: Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    packageConfigTests = Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    tests
        , packageConfigBenchmarks :: Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    packageConfigBenchmarks = Maybe
      (Map
         String
         (WithCommonOptions
            cSources_ cxxSources_ jsSources_ ExecutableSection))
    benchmarks
        }
      where
        traverseNamedConfigs :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    traverseNamedConfigs = (Map String (WithCommonOptions cSources cxxSources jsSources a)
     -> m (Map
             String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((Map String (WithCommonOptions cSources cxxSources jsSources a)
      -> m (Map
              String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
     -> Maybe
          (Map String (WithCommonOptions cSources cxxSources jsSources a))
     -> m (Maybe
             (Map
                String (WithCommonOptions cSources_ cxxSources_ jsSources_ a))))
    -> (Traverse
          m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
        -> Map String (WithCommonOptions cSources cxxSources jsSources a)
        -> m (Map
                String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    -> Traverse
         m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Maybe
         (Map String (WithCommonOptions cSources cxxSources jsSources a))
    -> m (Maybe
            (Map
               String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (WithCommonOptions cSources cxxSources jsSources a
     -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a))
    -> Map String (WithCommonOptions cSources cxxSources jsSources a)
    -> m (Map
            String (WithCommonOptions cSources_ cxxSources_ jsSources_ a))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((WithCommonOptions cSources cxxSources jsSources a
      -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a))
     -> Map String (WithCommonOptions cSources cxxSources jsSources a)
     -> m (Map
             String (WithCommonOptions cSources_ cxxSources_ jsSources_ a)))
    -> (Traverse
          m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
        -> WithCommonOptions cSources cxxSources jsSources a
        -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a))
    -> Traverse
         m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Map String (WithCommonOptions cSources cxxSources jsSources a)
    -> m (Map
            String (WithCommonOptions cSources_ cxxSources_ jsSources_ a))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> WithCommonOptions cSources cxxSources jsSources a
    -> m (WithCommonOptions cSources_ cxxSources_ jsSources_ a)
    Traversal_ WithCommonOptions
    traverseWithCommonOptions

    type ParsePackageConfig = PackageConfigWithDefaults ParseCSources ParseCxxSources ParseJsSources

    instance FromValue ParsePackageConfig

    type Warnings m = WriterT [String] m
    type Errors = ExceptT String

    decodeYaml :: FromValue a => ProgramName -> FilePath -> Warnings (Errors IO) a
    decodeYaml :: ProgramName -> String -> Warnings (Errors IO) a
    decodeYaml programName :: ProgramName
    programName file :: String
    file = do
      (warnings :: [String]
    warnings, a :: Value
    a) <- ExceptT String IO ([String], Value)
    -> WriterT [String] (Errors IO) ([String], Value)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (IO (Either String ([String], Value))
    -> ExceptT String IO ([String], Value)
    forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
    ExceptT (IO (Either String ([String], Value))
     -> ExceptT String IO ([String], Value))
    -> IO (Either String ([String], Value))
    -> ExceptT String IO ([String], Value)
    forall a b. (a -> b) -> a -> b
    $ String -> IO (Either String ([String], Value))
    Yaml.decodeYaml String
    file)
      [String] -> WriterT [String] (Errors IO) ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell [String]
    warnings
      ProgramName -> String -> Value -> Warnings (Errors IO) a
    forall a.
    FromValue a =>
    ProgramName -> String -> Value -> Warnings (Errors IO) a
    decodeValue ProgramName
    programName String
    file Value
    a

    data DecodeOptions = DecodeOptions {
      DecodeOptions -> ProgramName
    decodeOptionsProgramName :: ProgramName
    , DecodeOptions -> String
    decodeOptionsTarget :: FilePath
    , DecodeOptions -> Maybe String
    decodeOptionsUserDataDir :: Maybe FilePath
    , DecodeOptions -> String -> IO (Either String ([String], Value))
    decodeOptionsDecode :: FilePath -> IO (Either String ([String], Value))
    }

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

    instance IsString ProgramName where
      fromString :: String -> ProgramName
    fromString = String -> ProgramName
    ProgramName

    defaultDecodeOptions :: DecodeOptions
    defaultDecodeOptions :: DecodeOptions
    defaultDecodeOptions = ProgramName
    -> String
    -> Maybe String
    -> (String -> IO (Either String ([String], Value)))
    -> DecodeOptions
    DecodeOptions "hpack" String
    packageConfig Maybe String
    forall a. Maybe a
    Nothing String -> IO (Either String ([String], Value))
    Yaml.decodeYaml

    data DecodeResult = DecodeResult {
      DecodeResult -> Package
    decodeResultPackage :: Package
    , DecodeResult -> String
    decodeResultCabalVersion :: String
    , DecodeResult -> String
    decodeResultCabalFile :: FilePath
    , DecodeResult -> [String]
    decodeResultWarnings :: [String]
    } deriving (DecodeResult -> DecodeResult -> Bool
    (DecodeResult -> DecodeResult -> Bool)
    -> (DecodeResult -> DecodeResult -> Bool) -> Eq DecodeResult
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: DecodeResult -> DecodeResult -> Bool
    $c/= :: DecodeResult -> DecodeResult -> Bool
    == :: DecodeResult -> DecodeResult -> Bool
    $c== :: DecodeResult -> DecodeResult -> Bool
    Eq, Int -> DecodeResult -> ShowS
    [DecodeResult] -> ShowS
    DecodeResult -> String
    (Int -> DecodeResult -> ShowS)
    -> (DecodeResult -> String)
    -> ([DecodeResult] -> ShowS)
    -> Show DecodeResult
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [DecodeResult] -> ShowS
    $cshowList :: [DecodeResult] -> ShowS
    show :: DecodeResult -> String
    $cshow :: DecodeResult -> String
    showsPrec :: Int -> DecodeResult -> ShowS
    $cshowsPrec :: Int -> DecodeResult -> ShowS
    Show)

    readPackageConfig :: DecodeOptions -> IO (Either String DecodeResult)
    readPackageConfig :: DecodeOptions -> IO (Either String DecodeResult)
    readPackageConfig (DecodeOptions programName :: ProgramName
    programName file :: String
    file mUserDataDir :: Maybe String
    mUserDataDir readValue :: String -> IO (Either String ([String], Value))
    readValue) = ExceptT String IO DecodeResult -> IO (Either String DecodeResult)
    forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
    runExceptT (ExceptT String IO DecodeResult -> IO (Either String DecodeResult))
    -> ExceptT String IO DecodeResult
    -> IO (Either String DecodeResult)
    forall a b. (a -> b) -> a -> b
    $ (((Package, String), [String]) -> DecodeResult)
    -> ExceptT String IO ((Package, String), [String])
    -> ExceptT String IO DecodeResult
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Package, String), [String]) -> DecodeResult
    addCabalFile (ExceptT String IO ((Package, String), [String])
     -> ExceptT String IO DecodeResult)
    -> (WriterT [String] (Errors IO) (Package, String)
        -> ExceptT String IO ((Package, String), [String]))
    -> WriterT [String] (Errors IO) (Package, String)
    -> ExceptT String IO DecodeResult
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . WriterT [String] (Errors IO) (Package, String)
    -> ExceptT String IO ((Package, String), [String])
    forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
    runWriterT (WriterT [String] (Errors IO) (Package, String)
     -> ExceptT String IO DecodeResult)
    -> WriterT [String] (Errors IO) (Package, String)
    -> ExceptT String IO DecodeResult
    forall a b. (a -> b) -> a -> b
    $ do
      (warnings :: [String]
    warnings, value :: Value
    value) <- ExceptT String IO ([String], Value)
    -> WriterT [String] (Errors IO) ([String], Value)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (ExceptT String IO ([String], Value)
     -> WriterT [String] (Errors IO) ([String], Value))
    -> (IO (Either String ([String], Value))
        -> ExceptT String IO ([String], Value))
    -> IO (Either String ([String], Value))
    -> WriterT [String] (Errors IO) ([String], Value)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IO (Either String ([String], Value))
    -> ExceptT String IO ([String], Value)
    forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
    ExceptT (IO (Either String ([String], Value))
     -> WriterT [String] (Errors IO) ([String], Value))
    -> IO (Either String ([String], Value))
    -> WriterT [String] (Errors IO) ([String], Value)
    forall a b. (a -> b) -> a -> b
    $ String -> IO (Either String ([String], Value))
    readValue String
    file
      [String] -> WriterT [String] (Errors IO) ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell [String]
    warnings
      ConfigWithDefaults
    config <- ProgramName
    -> String -> Value -> Warnings (Errors IO) ConfigWithDefaults
    forall a.
    FromValue a =>
    ProgramName -> String -> Value -> Warnings (Errors IO) a
    decodeValue ProgramName
    programName String
    file Value
    value
      String
    dir <- IO String -> WriterT [String] (Errors IO) String
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO String -> WriterT [String] (Errors IO) String)
    -> IO String -> WriterT [String] (Errors IO) String
    forall a b. (a -> b) -> a -> b
    $ ShowS
    takeDirectory ShowS -> IO String -> IO String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> IO String
    canonicalizePath String
    file
      String
    userDataDir <- IO String -> WriterT [String] (Errors IO) String
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO String -> WriterT [String] (Errors IO) String)
    -> IO String -> WriterT [String] (Errors IO) String
    forall a b. (a -> b) -> a -> b
    $ IO String -> (String -> IO String) -> Maybe String -> IO String
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (String -> IO String
    getAppUserDataDirectory "hpack") String -> IO String
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe String
    mUserDataDir
      ProgramName
    -> String
    -> String
    -> ConfigWithDefaults
    -> WriterT [String] (Errors IO) (Package, String)
    toPackage ProgramName
    programName String
    userDataDir String
    dir ConfigWithDefaults
    config
      where
        addCabalFile :: ((Package, String), [String]) -> DecodeResult
        addCabalFile :: ((Package, String), [String]) -> DecodeResult
    addCabalFile ((pkg :: Package
    pkg, cabalVersion :: String
    cabalVersion), warnings :: [String]
    warnings) = Package -> String -> String -> [String] -> DecodeResult
    DecodeResult Package
    pkg String
    cabalVersion (ShowS
    takeDirectory_ String
    file String -> ShowS
    </> (Package -> String
    packageName Package
    pkg String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ".cabal")) [String]
    warnings

        takeDirectory_ :: FilePath -> FilePath
        takeDirectory_ :: ShowS
    takeDirectory_ p :: String
    p
          | ShowS
    takeFileName String
    p String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    p = ""
          | Bool
    otherwise = ShowS
    takeDirectory String
    p

    deleteVerbatimField :: String -> [Verbatim] -> [Verbatim]
    deleteVerbatimField :: String -> [Verbatim] -> [Verbatim]
    deleteVerbatimField name :: String
    name = (Verbatim -> Verbatim) -> [Verbatim] -> [Verbatim]
    forall a b. (a -> b) -> [a] -> [b]
    map ((Verbatim -> Verbatim) -> [Verbatim] -> [Verbatim])
    -> (Verbatim -> Verbatim) -> [Verbatim] -> [Verbatim]
    forall a b. (a -> b) -> a -> b
    $ \ case
      literal :: Verbatim
    literal@VerbatimLiteral {} -> Verbatim
    literal
      VerbatimObject o :: Map String VerbatimValue
    o -> Map String VerbatimValue -> Verbatim
    VerbatimObject (String -> Map String VerbatimValue -> Map String VerbatimValue
    forall k a. Ord k => k -> Map k a -> Map k a
    Map.delete String
    name Map String VerbatimValue
    o)

    verbatimValueToString :: VerbatimValue -> String
    verbatimValueToString :: VerbatimValue -> String
    verbatimValueToString = \ case
      VerbatimString s :: String
    s -> String
    s
      VerbatimNumber n :: Scientific
    n -> Scientific -> String
    scientificToVersion Scientific
    n
      VerbatimBool b :: Bool
    b -> Bool -> String
    forall a. Show a => a -> String
    show Bool
    b
      VerbatimNull -> ""

    determineCabalVersion :: Maybe (License SPDX.License) -> Package -> (Package, String)
    determineCabalVersion :: Maybe (License License) -> Package -> (Package, String)
    determineCabalVersion inferredLicense :: Maybe (License License)
    inferredLicense pkg :: Package
    pkg@Package{..} = (
        Package
    pkg {
            packageVerbatim :: [Verbatim]
    packageVerbatim = String -> [Verbatim] -> [Verbatim]
    deleteVerbatimField "cabal-version" [Verbatim]
    packageVerbatim
          , packageLicense :: Maybe String
    packageLicense = License String -> String
    formatLicense (License String -> String)
    -> Maybe (License String) -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe (License String)
    license
          }
      , "cabal-version: " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String -> Maybe String -> String
    forall a. a -> Maybe a -> a
    fromMaybe String
    inferredCabalVersion Maybe String
    verbatimCabalVersion String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "\n\n"
      )
      where
        license :: Maybe (License String)
    license = (License -> String) -> License License -> License String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap License -> String
    forall a. Pretty a => a -> String
    prettyShow (License License -> License String)
    -> Maybe (License License) -> Maybe (License String)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Maybe (License License)
    parsedLicense Maybe (License License)
    -> Maybe (License License) -> Maybe (License License)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Maybe (License License)
    inferredLicense)

        parsedLicense :: Maybe (License License)
    parsedLicense = String -> License License
    parseLicense (String -> License License)
    -> Maybe String -> Maybe (License License)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe String
    packageLicense

        formatLicense :: License String -> String
    formatLicense = \ case
          MustSPDX spdx :: String
    spdx -> String
    spdx
          CanSPDX _ spdx :: String
    spdx | Version
    version Version -> Version -> Bool
    forall a. Ord a => a -> a -> Bool
    >= [Int] -> Version
    makeVersion [2,2] -> String
    spdx
          CanSPDX cabal :: License
    cabal _ -> License -> String
    forall a. Pretty a => a -> String
    prettyShow License
    cabal
          DontTouch original :: String
    original -> String
    original

        mustSPDX :: Bool
        mustSPDX :: Bool
    mustSPDX = Bool -> (License String -> Bool) -> Maybe (License String) -> Bool
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Bool
    False License String -> Bool
    forall a. License a -> Bool
    f Maybe (License String)
    license
          where
            f :: License a -> Bool
    f = \case
              DontTouch _ -> Bool
    False
              CanSPDX _ _ -> Bool
    False
              MustSPDX _ -> Bool
    True

        verbatimCabalVersion :: Maybe String
        verbatimCabalVersion :: Maybe String
    verbatimCabalVersion = [String] -> Maybe String
    forall a. [a] -> Maybe a
    listToMaybe ((Verbatim -> Maybe String) -> [Verbatim] -> [String]
    forall a b. (a -> Maybe b) -> [a] -> [b]
    mapMaybe Verbatim -> Maybe String
    f [Verbatim]
    packageVerbatim)
          where
            f :: Verbatim -> Maybe String
            f :: Verbatim -> Maybe String
    f = \ case
              VerbatimLiteral _ -> Maybe String
    forall a. Maybe a
    Nothing
              VerbatimObject o :: Map String VerbatimValue
    o -> case String -> Map String VerbatimValue -> Maybe VerbatimValue
    forall k a. Ord k => k -> Map k a -> Maybe a
    Map.lookup "cabal-version" Map String VerbatimValue
    o of
                Just v :: VerbatimValue
    v -> String -> Maybe String
    forall a. a -> Maybe a
    Just (VerbatimValue -> String
    verbatimValueToString VerbatimValue
    v)
                Nothing -> Maybe String
    forall a. Maybe a
    Nothing

        inferredCabalVersion :: String
        inferredCabalVersion :: String
    inferredCabalVersion = Version -> String
    showVersion Version
    version

        version :: Version
    version = Version -> Maybe Version -> Version
    forall a. a -> Maybe a -> a
    fromMaybe ([Int] -> Version
    makeVersion [1,12]) (Maybe Version -> Version) -> Maybe Version -> Version
    forall a b. (a -> b) -> a -> b
    $ [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum [
            Maybe Version
    packageCabalVersion
          , Maybe (Section Library)
    packageLibrary Maybe (Section Library)
    -> (Section Library -> Maybe Version) -> Maybe Version
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Section Library -> Maybe Version
    libraryCabalVersion
          , Map String (Section Library) -> Maybe Version
    internalLibsCabalVersion Map String (Section Library)
    packageInternalLibraries
          , Map String (Section Executable) -> Maybe Version
    executablesCabalVersion Map String (Section Executable)
    packageExecutables
          , Map String (Section Executable) -> Maybe Version
    executablesCabalVersion Map String (Section Executable)
    packageTests
          , Map String (Section Executable) -> Maybe Version
    executablesCabalVersion Map String (Section Executable)
    packageBenchmarks
          ]

        packageCabalVersion :: Maybe Version
        packageCabalVersion :: Maybe Version
    packageCabalVersion = [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum [
            Maybe Version
    forall a. Maybe a
    Nothing
          , [Int] -> Version
    makeVersion [2,2] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard Bool
    mustSPDX
          , [Int] -> Version
    makeVersion [1,24] Version -> Maybe CustomSetup -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Maybe CustomSetup
    packageCustomSetup
          , [Int] -> Version
    makeVersion [1,18] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> Bool
    not ([Path] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Path]
    packageExtraDocFiles))
          ]

        libraryCabalVersion :: Section Library -> Maybe Version
        libraryCabalVersion :: Section Library -> Maybe Version
    libraryCabalVersion sect :: Section Library
    sect = [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum [
            [Int] -> Version
    makeVersion [1,22] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Library -> [String]) -> Bool
    forall (t :: * -> *) a. Foldable t => (Library -> t a) -> Bool
    has Library -> [String]
    libraryReexportedModules)
          , [Int] -> Version
    makeVersion [2,0]  Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Library -> [String]) -> Bool
    forall (t :: * -> *) a. Foldable t => (Library -> t a) -> Bool
    has Library -> [String]
    librarySignatures)
          , [Int] -> Version
    makeVersion [2,0] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Library -> [String]) -> Bool
    forall (t :: * -> *) a. Foldable t => (Library -> t a) -> Bool
    has Library -> [String]
    libraryGeneratedModules)
          , [Int] -> Version
    makeVersion [3,0] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Library -> Maybe String) -> Bool
    forall (t :: * -> *) a. Foldable t => (Library -> t a) -> Bool
    has Library -> Maybe String
    libraryVisibility)
          , Section Library -> Maybe Version
    forall a. Section a -> Maybe Version
    sectionCabalVersion Section Library
    sect
          ]
          where
            has :: (Library -> t a) -> Bool
    has field :: Library -> t a
    field = (Library -> Bool) -> Section Library -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any (Bool -> Bool
    not (Bool -> Bool) -> (Library -> Bool) -> Library -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . t a -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (t a -> Bool) -> (Library -> t a) -> Library -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Library -> t a
    field) Section Library
    sect

        internalLibsCabalVersion :: Map String (Section Library) -> Maybe Version
        internalLibsCabalVersion :: Map String (Section Library) -> Maybe Version
    internalLibsCabalVersion internalLibraries :: Map String (Section Library)
    internalLibraries
          | Map String (Section Library) -> Bool
    forall k a. Map k a -> Bool
    Map.null Map String (Section Library)
    internalLibraries = Maybe Version
    forall a. Maybe a
    Nothing
          | Bool
    otherwise = (Maybe Version -> Maybe Version -> Maybe Version)
    -> Maybe Version -> [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Maybe Version -> Maybe Version -> Maybe Version
    forall a. Ord a => a -> a -> a
    max (Version -> Maybe Version
    forall a. a -> Maybe a
    Just (Version -> Maybe Version) -> Version -> Maybe Version
    forall a b. (a -> b) -> a -> b
    $ [Int] -> Version
    makeVersion [2,0]) [Maybe Version]
    versions
          where
            versions :: [Maybe Version]
    versions = Section Library -> Maybe Version
    libraryCabalVersion (Section Library -> Maybe Version)
    -> [Section Library] -> [Maybe Version]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Map String (Section Library) -> [Section Library]
    forall k a. Map k a -> [a]
    Map.elems Map String (Section Library)
    internalLibraries

        executablesCabalVersion :: Map String (Section Executable) -> Maybe Version
        executablesCabalVersion :: Map String (Section Executable) -> Maybe Version
    executablesCabalVersion = (Maybe Version -> Maybe Version -> Maybe Version)
    -> Maybe Version -> [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Maybe Version -> Maybe Version -> Maybe Version
    forall a. Ord a => a -> a -> a
    max Maybe Version
    forall a. Maybe a
    Nothing ([Maybe Version] -> Maybe Version)
    -> (Map String (Section Executable) -> [Maybe Version])
    -> Map String (Section Executable)
    -> Maybe Version
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Section Executable -> Maybe Version)
    -> [Section Executable] -> [Maybe Version]
    forall a b. (a -> b) -> [a] -> [b]
    map Section Executable -> Maybe Version
    executableCabalVersion ([Section Executable] -> [Maybe Version])
    -> (Map String (Section Executable) -> [Section Executable])
    -> Map String (Section Executable)
    -> [Maybe Version]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map String (Section Executable) -> [Section Executable]
    forall k a. Map k a -> [a]
    Map.elems

        executableCabalVersion :: Section Executable -> Maybe Version
        executableCabalVersion :: Section Executable -> Maybe Version
    executableCabalVersion sect :: Section Executable
    sect = [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum [
            [Int] -> Version
    makeVersion [2,0] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Section Executable -> Bool
    executableHasGeneratedModules Section Executable
    sect)
          , Section Executable -> Maybe Version
    forall a. Section a -> Maybe Version
    sectionCabalVersion Section Executable
    sect
          ]

        executableHasGeneratedModules :: Section Executable -> Bool
        executableHasGeneratedModules :: Section Executable -> Bool
    executableHasGeneratedModules = (Executable -> Bool) -> Section Executable -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any (Bool -> Bool
    not (Bool -> Bool) -> (Executable -> Bool) -> Executable -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null ([String] -> Bool)
    -> (Executable -> [String]) -> Executable -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Executable -> [String]
    executableGeneratedModules)

        sectionCabalVersion :: Section a -> Maybe Version
        sectionCabalVersion :: Section a -> Maybe Version
    sectionCabalVersion sect :: Section a
    sect = [Maybe Version] -> Maybe Version
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum ([Maybe Version] -> Maybe Version)
    -> [Maybe Version] -> Maybe Version
    forall a b. (a -> b) -> a -> b
    $ [
            [Int] -> Version
    makeVersion [2,2] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Section a -> Bool) -> Section a -> Bool
    forall a. (Section a -> Bool) -> Section a -> Bool
    sectionSatisfies (Bool -> Bool
    not (Bool -> Bool) -> (Section a -> Bool) -> Section a -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Path] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null ([Path] -> Bool) -> (Section a -> [Path]) -> Section a -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section a -> [Path]
    forall a. Section a -> [Path]
    sectionCxxSources) Section a
    sect)
          , [Int] -> Version
    makeVersion [2,2] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Section a -> Bool) -> Section a -> Bool
    forall a. (Section a -> Bool) -> Section a -> Bool
    sectionSatisfies (Bool -> Bool
    not (Bool -> Bool) -> (Section a -> Bool) -> Section a -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null ([String] -> Bool) -> (Section a -> [String]) -> Section a -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section a -> [String]
    forall a. Section a -> [String]
    sectionCxxOptions) Section a
    sect)
          , [Int] -> Version
    makeVersion [2,0] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Section a -> Bool) -> Section a -> Bool
    forall a. (Section a -> Bool) -> Section a -> Bool
    sectionSatisfies ((DependencyInfo -> Bool) -> Map String DependencyInfo -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any DependencyInfo -> Bool
    hasMixins (Map String DependencyInfo -> Bool)
    -> (Section a -> Map String DependencyInfo) -> Section a -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Dependencies -> Map String DependencyInfo
    unDependencies (Dependencies -> Map String DependencyInfo)
    -> (Section a -> Dependencies)
    -> Section a
    -> Map String DependencyInfo
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section a -> Dependencies
    forall a. Section a -> Dependencies
    sectionDependencies) Section a
    sect)
          , [Int] -> Version
    makeVersion [3,0] Version -> Maybe () -> Maybe Version
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ((Section a -> Bool) -> Section a -> Bool
    forall a. (Section a -> Bool) -> Section a -> Bool
    sectionSatisfies ((String -> Bool) -> [String] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any String -> Bool
    hasSubcomponents ([String] -> Bool) -> (Section a -> [String]) -> Section a -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map String DependencyInfo -> [String]
    forall k a. Map k a -> [k]
    Map.keys (Map String DependencyInfo -> [String])
    -> (Section a -> Map String DependencyInfo)
    -> Section a
    -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Dependencies -> Map String DependencyInfo
    unDependencies (Dependencies -> Map String DependencyInfo)
    -> (Section a -> Dependencies)
    -> Section a
    -> Map String DependencyInfo
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section a -> Dependencies
    forall a. Section a -> Dependencies
    sectionDependencies) Section a
    sect)
          ] [Maybe Version] -> [Maybe Version] -> [Maybe Version]
    forall a. [a] -> [a] -> [a]
    ++ (String -> Maybe Version) -> [String] -> [Maybe Version]
    forall a b. (a -> b) -> [a] -> [b]
    map String -> Maybe Version
    versionFromSystemBuildTool [String]
    systemBuildTools
          where
            versionFromSystemBuildTool :: String -> Maybe Version
    versionFromSystemBuildTool name :: String
    name
              | String
    name String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    known_1_10 = Maybe Version
    forall a. Maybe a
    Nothing
              | String
    name String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    known_1_14 = Version -> Maybe Version
    forall a. a -> Maybe a
    Just ([Int] -> Version
    makeVersion [1,14])
              | String
    name String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    known_1_22 = Version -> Maybe Version
    forall a. a -> Maybe a
    Just ([Int] -> Version
    makeVersion [1,22])
              | Bool
    otherwise = Version -> Maybe Version
    forall a. a -> Maybe a
    Just ([Int] -> Version
    makeVersion [2,0])

            known_1_10 :: [String]
    known_1_10 = [
                "ghc"
              , "ghc-pkg"
              , "hugs"
              , "ffihugs"
              , "nhc98"
              , "hmake"
              , "jhc"
              , "lhc"
              , "lhc-pkg"
              , "uhc"
              , "gcc"
              , "ranlib"
              , "ar"
              , "strip"
              , "ld"
              , "tar"
              , "pkg-config"
              ] [String] -> [String] -> [String]
    forall a. Eq a => [a] -> [a] -> [a]
    \\ [
              -- Support for these build tools has been removed from Cabal at some point
                "hugs"
              , "ffihugs"
              , "nhc98"
              , "ranlib"
              , "lhc"
              , "lhc-pkg"
              ]
            known_1_14 :: [String]
    known_1_14 = [
                "hpc"
              ]
            known_1_22 :: [String]
    known_1_22 = [
                "ghcjs"
              , "ghcjs-pkg"
              -- , "haskell-suite" // not a real build tool
              -- , "haskell-suite-pkg" // not a real build tool
              ]

            systemBuildTools :: [String]
            systemBuildTools :: [String]
    systemBuildTools = Map String VersionConstraint -> [String]
    forall k a. Map k a -> [k]
    Map.keys (Map String VersionConstraint -> [String])
    -> Map String VersionConstraint -> [String]
    forall a b. (a -> b) -> a -> b
    $ SystemBuildTools -> Map String VersionConstraint
    unSystemBuildTools (SystemBuildTools -> Map String VersionConstraint)
    -> SystemBuildTools -> Map String VersionConstraint
    forall a b. (a -> b) -> a -> b
    $ (Section a -> SystemBuildTools) -> Section a -> SystemBuildTools
    forall b a.
    (Semigroup b, Monoid b) =>
    (Section a -> b) -> Section a -> b
    sectionAll Section a -> SystemBuildTools
    forall a. Section a -> SystemBuildTools
    sectionSystemBuildTools Section a
    sect

        sectionSatisfies :: (Section a -> Bool) -> Section a -> Bool
        sectionSatisfies :: (Section a -> Bool) -> Section a -> Bool
    sectionSatisfies p :: Section a -> Bool
    p sect :: Section a
    sect = [Bool] -> Bool
    forall (t :: * -> *). Foldable t => t Bool -> Bool
    or [
            Section a -> Bool
    p Section a
    sect
          , (Conditional (Section a) -> Bool)
    -> [Conditional (Section a)] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any ((Section a -> Bool) -> Conditional (Section a) -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any ((Section a -> Bool) -> Section a -> Bool
    forall a. (Section a -> Bool) -> Section a -> Bool
    sectionSatisfies Section a -> Bool
    p)) (Section a -> [Conditional (Section a)]
    forall a. Section a -> [Conditional (Section a)]
    sectionConditionals Section a
    sect)
          ]
        sectionAll :: (Semigroup b, Monoid b) => (Section a -> b) -> Section a -> b
        sectionAll :: (Section a -> b) -> Section a -> b
    sectionAll f :: Section a -> b
    f sect :: Section a
    sect = Section a -> b
    f Section a
    sect b -> b -> b
    forall a. Semigroup a => a -> a -> a
    <> (Conditional (Section a) -> b) -> [Conditional (Section a)] -> b
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    foldMap ((Section a -> b) -> Conditional (Section a) -> b
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    foldMap ((Section a -> b) -> Conditional (Section a) -> b)
    -> (Section a -> b) -> Conditional (Section a) -> b
    forall a b. (a -> b) -> a -> b
    $ (Section a -> b) -> Section a -> b
    forall b a.
    (Semigroup b, Monoid b) =>
    (Section a -> b) -> Section a -> b
    sectionAll Section a -> b
    f) (Section a -> [Conditional (Section a)]
    forall a. Section a -> [Conditional (Section a)]
    sectionConditionals Section a
    sect)

        hasMixins :: DependencyInfo -> Bool
        hasMixins :: DependencyInfo -> Bool
    hasMixins (DependencyInfo mixins :: [String]
    mixins _) = Bool -> Bool
    not ([String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [String]
    mixins)

        hasSubcomponents :: String -> Bool
        hasSubcomponents :: String -> Bool
    hasSubcomponents = Char -> String -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    elem ':'

    decodeValue :: FromValue a => ProgramName -> FilePath -> Value -> Warnings (Errors IO) a
    decodeValue :: ProgramName -> String -> Value -> Warnings (Errors IO) a
    decodeValue (ProgramName programName :: String
    programName) file :: String
    file value :: Value
    value = do
      (r :: CheckSpecVersion a
    r, unknown :: [String]
    unknown) <- ExceptT String IO (CheckSpecVersion a, [String])
    -> WriterT [String] (Errors IO) (CheckSpecVersion a, [String])
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (ExceptT String IO (CheckSpecVersion a, [String])
     -> WriterT [String] (Errors IO) (CheckSpecVersion a, [String]))
    -> (Either String (CheckSpecVersion a, [String])
        -> ExceptT String IO (CheckSpecVersion a, [String]))
    -> Either String (CheckSpecVersion a, [String])
    -> WriterT [String] (Errors IO) (CheckSpecVersion a, [String])
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IO (Either String (CheckSpecVersion a, [String]))
    -> ExceptT String IO (CheckSpecVersion a, [String])
    forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
    ExceptT (IO (Either String (CheckSpecVersion a, [String]))
     -> ExceptT String IO (CheckSpecVersion a, [String]))
    -> (Either String (CheckSpecVersion a, [String])
        -> IO (Either String (CheckSpecVersion a, [String])))
    -> Either String (CheckSpecVersion a, [String])
    -> ExceptT String IO (CheckSpecVersion a, [String])
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Either String (CheckSpecVersion a, [String])
    -> IO (Either String (CheckSpecVersion a, [String]))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Either String (CheckSpecVersion a, [String])
     -> WriterT [String] (Errors IO) (CheckSpecVersion a, [String]))
    -> Either String (CheckSpecVersion a, [String])
    -> WriterT [String] (Errors IO) (CheckSpecVersion a, [String])
    forall a b. (a -> b) -> a -> b
    $ ShowS
    -> Either String (CheckSpecVersion a, [String])
    -> Either String (CheckSpecVersion a, [String])
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first (String
    prefix String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++) (Value -> Either String (CheckSpecVersion a, [String])
    forall a. FromValue a => Value -> Result a
    Config.decodeValue Value
    value)
      case CheckSpecVersion a
    r of
        UnsupportedSpecVersion v :: Version
    v -> do
          ExceptT String IO a -> Warnings (Errors IO) a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (ExceptT String IO a -> Warnings (Errors IO) a)
    -> ExceptT String IO a -> Warnings (Errors IO) a
    forall a b. (a -> b) -> a -> b
    $ String -> ExceptT String IO a
    forall (m :: * -> *) e a. Monad m => e -> ExceptT e m a
    throwE ("The file " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    file String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " requires version " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Version -> String
    showVersion Version
    v String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " of the Hpack package specification, however this version of " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    programName String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " only supports versions up to " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Version -> String
    showVersion Version
    Hpack.version String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ". Upgrading to the latest version of " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    programName String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " may resolve this issue.")
        SupportedSpecVersion a :: a
    a -> do
          [String] -> WriterT [String] (Errors IO) ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell (ShowS -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map ShowS
    formatUnknownField [String]
    unknown)
          a -> Warnings (Errors IO) a
    forall (m :: * -> *) a. Monad m => a -> m a
    return a
    a
      where
        prefix :: String
    prefix = String
    file String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ": "
        formatUnknownField :: ShowS
    formatUnknownField name :: String
    name = String
    prefix String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "Ignoring unrecognized field " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    name

    data CheckSpecVersion a = SupportedSpecVersion a | UnsupportedSpecVersion Version

    instance FromValue a => FromValue (CheckSpecVersion a) where
      fromValue :: Value -> Parser (CheckSpecVersion a)
    fromValue = (Object -> Parser (CheckSpecVersion a))
    -> Value -> Parser (CheckSpecVersion a)
    forall a. (Object -> Parser a) -> Value -> Parser a
    withObject ((Object -> Parser (CheckSpecVersion a))
     -> Value -> Parser (CheckSpecVersion a))
    -> (Object -> Parser (CheckSpecVersion a))
    -> Value
    -> Parser (CheckSpecVersion a)
    forall a b. (a -> b) -> a -> b
    $ \ o :: Object
    o -> Object
    o Object -> Text -> Parser (Maybe ParseSpecVersion)
    forall a. FromValue a => Object -> Text -> Parser (Maybe a)
    .:? "spec-version" Parser (Maybe ParseSpecVersion)
    -> (Maybe ParseSpecVersion -> Parser (CheckSpecVersion a))
    -> Parser (CheckSpecVersion a)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \ case
        Just (ParseSpecVersion v :: Version
    v) | Version
    Hpack.version Version -> Version -> Bool
    forall a. Ord a => a -> a -> Bool
    < Version
    v -> CheckSpecVersion a -> Parser (CheckSpecVersion a)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (CheckSpecVersion a -> Parser (CheckSpecVersion a))
    -> CheckSpecVersion a -> Parser (CheckSpecVersion a)
    forall a b. (a -> b) -> a -> b
    $ Version -> CheckSpecVersion a
    forall a. Version -> CheckSpecVersion a
    UnsupportedSpecVersion Version
    v
        _ -> a -> CheckSpecVersion a
    forall a. a -> CheckSpecVersion a
    SupportedSpecVersion (a -> CheckSpecVersion a)
    -> Parser a -> Parser (CheckSpecVersion a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Value -> Parser a
    forall a. FromValue a => Value -> Parser a
    fromValue (Object -> Value
    Object Object
    o)

    newtype ParseSpecVersion = ParseSpecVersion Version

    instance FromValue ParseSpecVersion where
      fromValue :: Value -> Parser ParseSpecVersion
    fromValue value :: Value
    value = do
        String
    s <- case Value
    value of
          Number n :: Scientific
    n -> String -> Parser String
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Scientific -> String
    scientificToVersion Scientific
    n)
          String s :: Text
    s -> String -> Parser String
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> String
    T.unpack Text
    s)
          _ -> String -> Value -> Parser String
    forall a. String -> Value -> Parser a
    typeMismatch "Number or String" Value
    value
        case String -> Maybe Version
    parseVersion String
    s of
          Just v :: Version
    v -> ParseSpecVersion -> Parser ParseSpecVersion
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Version -> ParseSpecVersion
    ParseSpecVersion Version
    v)
          Nothing -> String -> Parser ParseSpecVersion
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail ("invalid value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ShowS
    forall a. Show a => a -> String
    show String
    s)

    data Package = Package {
      Package -> String
    packageName :: String
    , Package -> String
    packageVersion :: String
    , Package -> Maybe String
    packageSynopsis :: Maybe String
    , Package -> Maybe String
    packageDescription :: Maybe String
    , Package -> Maybe String
    packageHomepage :: Maybe String
    , Package -> Maybe String
    packageBugReports :: Maybe String
    , Package -> Maybe String
    packageCategory :: Maybe String
    , Package -> Maybe String
    packageStability :: Maybe String
    , Package -> [String]
    packageAuthor :: [String]
    , Package -> [String]
    packageMaintainer :: [String]
    , Package -> [String]
    packageCopyright :: [String]
    , Package -> BuildType
    packageBuildType :: BuildType
    , Package -> Maybe String
    packageLicense :: Maybe String
    , Package -> [String]
    packageLicenseFile :: [FilePath]
    , Package -> Maybe String
    packageTestedWith :: Maybe String
    , Package -> [Flag]
    packageFlags :: [Flag]
    , Package -> [Path]
    packageExtraSourceFiles :: [Path]
    , Package -> [Path]
    packageExtraDocFiles :: [Path]
    , Package -> [Path]
    packageDataFiles :: [Path]
    , Package -> Maybe String
    packageDataDir :: Maybe FilePath
    , Package -> Maybe SourceRepository
    packageSourceRepository :: Maybe SourceRepository
    , Package -> Maybe CustomSetup
    packageCustomSetup :: Maybe CustomSetup
    , Package -> Maybe (Section Library)
    packageLibrary :: Maybe (Section Library)
    , Package -> Map String (Section Library)
    packageInternalLibraries :: Map String (Section Library)
    , Package -> Map String (Section Executable)
    packageExecutables :: Map String (Section Executable)
    , Package -> Map String (Section Executable)
    packageTests :: Map String (Section Executable)
    , Package -> Map String (Section Executable)
    packageBenchmarks :: Map String (Section Executable)
    , Package -> [Verbatim]
    packageVerbatim :: [Verbatim]
    } deriving (Package -> Package -> Bool
    (Package -> Package -> Bool)
    -> (Package -> Package -> Bool) -> Eq Package
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Package -> Package -> Bool
    $c/= :: Package -> Package -> Bool
    == :: Package -> Package -> Bool
    $c== :: Package -> Package -> Bool
    Eq, Int -> Package -> ShowS
    [Package] -> ShowS
    Package -> String
    (Int -> Package -> ShowS)
    -> (Package -> String) -> ([Package] -> ShowS) -> Show Package
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Package] -> ShowS
    $cshowList :: [Package] -> ShowS
    show :: Package -> String
    $cshow :: Package -> String
    showsPrec :: Int -> Package -> ShowS
    $cshowsPrec :: Int -> Package -> ShowS
    Show)

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

    data Library = Library {
      Library -> Maybe Bool
    libraryExposed :: Maybe Bool
    , Library -> Maybe String
    libraryVisibility :: Maybe String
    , Library -> [String]
    libraryExposedModules :: [String]
    , Library -> [String]
    libraryOtherModules :: [String]
    , Library -> [String]
    libraryGeneratedModules :: [String]
    , Library -> [String]
    libraryReexportedModules :: [String]
    , Library -> [String]
    librarySignatures :: [String]
    } deriving (Library -> Library -> Bool
    (Library -> Library -> Bool)
    -> (Library -> Library -> Bool) -> Eq Library
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Library -> Library -> Bool
    $c/= :: Library -> Library -> Bool
    == :: Library -> Library -> Bool
    $c== :: Library -> Library -> Bool
    Eq, Int -> Library -> ShowS
    [Library] -> ShowS
    Library -> String
    (Int -> Library -> ShowS)
    -> (Library -> String) -> ([Library] -> ShowS) -> Show Library
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Library] -> ShowS
    $cshowList :: [Library] -> ShowS
    show :: Library -> String
    $cshow :: Library -> String
    showsPrec :: Int -> Library -> ShowS
    $cshowsPrec :: Int -> Library -> ShowS
    Show)

    data Executable = Executable {
      Executable -> Maybe String
    executableMain :: Maybe FilePath
    , Executable -> [String]
    executableOtherModules :: [String]
    , Executable -> [String]
    executableGeneratedModules :: [String]
    } deriving (Executable -> Executable -> Bool
    (Executable -> Executable -> Bool)
    -> (Executable -> Executable -> Bool) -> Eq Executable
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Executable -> Executable -> Bool
    $c/= :: Executable -> Executable -> Bool
    == :: Executable -> Executable -> Bool
    $c== :: Executable -> Executable -> Bool
    Eq, Int -> Executable -> ShowS
    [Executable] -> ShowS
    Executable -> String
    (Int -> Executable -> ShowS)
    -> (Executable -> String)
    -> ([Executable] -> ShowS)
    -> Show Executable
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Executable] -> ShowS
    $cshowList :: [Executable] -> ShowS
    show :: Executable -> String
    $cshow :: Executable -> String
    showsPrec :: Int -> Executable -> ShowS
    $cshowsPrec :: Int -> Executable -> ShowS
    Show)

    data BuildTool = BuildTool String String | LocalBuildTool String
      deriving (Int -> BuildTool -> ShowS
    [BuildTool] -> ShowS
    BuildTool -> String
    (Int -> BuildTool -> ShowS)
    -> (BuildTool -> String)
    -> ([BuildTool] -> ShowS)
    -> Show BuildTool
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [BuildTool] -> ShowS
    $cshowList :: [BuildTool] -> ShowS
    show :: BuildTool -> String
    $cshow :: BuildTool -> String
    showsPrec :: Int -> BuildTool -> ShowS
    $cshowsPrec :: Int -> BuildTool -> ShowS
    Show, BuildTool -> BuildTool -> Bool
    (BuildTool -> BuildTool -> Bool)
    -> (BuildTool -> BuildTool -> Bool) -> Eq BuildTool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: BuildTool -> BuildTool -> Bool
    $c/= :: BuildTool -> BuildTool -> Bool
    == :: BuildTool -> BuildTool -> Bool
    $c== :: BuildTool -> BuildTool -> Bool
    Eq, Eq BuildTool
    Eq BuildTool =>
    (BuildTool -> BuildTool -> Ordering)
    -> (BuildTool -> BuildTool -> Bool)
    -> (BuildTool -> BuildTool -> Bool)
    -> (BuildTool -> BuildTool -> Bool)
    -> (BuildTool -> BuildTool -> Bool)
    -> (BuildTool -> BuildTool -> BuildTool)
    -> (BuildTool -> BuildTool -> BuildTool)
    -> Ord BuildTool
    BuildTool -> BuildTool -> Bool
    BuildTool -> BuildTool -> Ordering
    BuildTool -> BuildTool -> BuildTool
    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
    min :: BuildTool -> BuildTool -> BuildTool
    $cmin :: BuildTool -> BuildTool -> BuildTool
    max :: BuildTool -> BuildTool -> BuildTool
    $cmax :: BuildTool -> BuildTool -> BuildTool
    >= :: BuildTool -> BuildTool -> Bool
    $c>= :: BuildTool -> BuildTool -> Bool
    > :: BuildTool -> BuildTool -> Bool
    $c> :: BuildTool -> BuildTool -> Bool
    <= :: BuildTool -> BuildTool -> Bool
    $c<= :: BuildTool -> BuildTool -> Bool
    < :: BuildTool -> BuildTool -> Bool
    $c< :: BuildTool -> BuildTool -> Bool
    compare :: BuildTool -> BuildTool -> Ordering
    $ccompare :: BuildTool -> BuildTool -> Ordering
    $cp1Ord :: Eq BuildTool
    Ord)

    data Section a = Section {
      Section a -> a
    sectionData :: a
    , Section a -> [String]
    sectionSourceDirs :: [FilePath]
    , Section a -> Dependencies
    sectionDependencies :: Dependencies
    , Section a -> [String]
    sectionPkgConfigDependencies :: [String]
    , Section a -> [String]
    sectionDefaultExtensions :: [String]
    , Section a -> [String]
    sectionOtherExtensions :: [String]
    , Section a -> [String]
    sectionGhcOptions :: [GhcOption]
    , Section a -> [String]
    sectionGhcProfOptions :: [GhcProfOption]
    , Section a -> [String]
    sectionGhcjsOptions :: [GhcjsOption]
    , Section a -> [String]
    sectionCppOptions :: [CppOption]
    , Section a -> [String]
    sectionCcOptions :: [CcOption]
    , Section a -> [Path]
    sectionCSources :: [Path]
    , Section a -> [String]
    sectionCxxOptions :: [CxxOption]
    , Section a -> [Path]
    sectionCxxSources :: [Path]
    , Section a -> [Path]
    sectionJsSources :: [Path]
    , Section a -> [String]
    sectionExtraLibDirs :: [FilePath]
    , Section a -> [String]
    sectionExtraLibraries :: [FilePath]
    , Section a -> [String]
    sectionExtraFrameworksDirs :: [FilePath]
    , Section a -> [String]
    sectionFrameworks :: [FilePath]
    , Section a -> [String]
    sectionIncludeDirs :: [FilePath]
    , Section a -> [String]
    sectionInstallIncludes :: [FilePath]
    , Section a -> [String]
    sectionLdOptions :: [LdOption]
    , Section a -> Maybe Bool
    sectionBuildable :: Maybe Bool
    , Section a -> [Conditional (Section a)]
    sectionConditionals :: [Conditional (Section a)]
    , Section a -> Map BuildTool DependencyVersion
    sectionBuildTools :: Map BuildTool DependencyVersion
    , Section a -> SystemBuildTools
    sectionSystemBuildTools :: SystemBuildTools
    , Section a -> [Verbatim]
    sectionVerbatim :: [Verbatim]
    } deriving (Section a -> Section a -> Bool
    (Section a -> Section a -> Bool)
    -> (Section a -> Section a -> Bool) -> Eq (Section a)
    forall a. Eq a => Section a -> Section a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Section a -> Section a -> Bool
    $c/= :: forall a. Eq a => Section a -> Section a -> Bool
    == :: Section a -> Section a -> Bool
    $c== :: forall a. Eq a => Section a -> Section a -> Bool
    Eq, Int -> Section a -> ShowS
    [Section a] -> ShowS
    Section a -> String
    (Int -> Section a -> ShowS)
    -> (Section a -> String)
    -> ([Section a] -> ShowS)
    -> Show (Section a)
    forall a. Show a => Int -> Section a -> ShowS
    forall a. Show a => [Section a] -> ShowS
    forall a. Show a => Section a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Section a] -> ShowS
    $cshowList :: forall a. Show a => [Section a] -> ShowS
    show :: Section a -> String
    $cshow :: forall a. Show a => Section a -> String
    showsPrec :: Int -> Section a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> Section a -> ShowS
    Show, a -> Section b -> Section a
    (a -> b) -> Section a -> Section b
    (forall a b. (a -> b) -> Section a -> Section b)
    -> (forall a b. a -> Section b -> Section a) -> Functor Section
    forall a b. a -> Section b -> Section a
    forall a b. (a -> b) -> Section a -> Section b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Section b -> Section a
    $c<$ :: forall a b. a -> Section b -> Section a
    fmap :: (a -> b) -> Section a -> Section b
    $cfmap :: forall a b. (a -> b) -> Section a -> Section b
    Functor, Section a -> Bool
    (a -> m) -> Section a -> m
    (a -> b -> b) -> b -> Section a -> b
    (forall m. Monoid m => Section m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Section a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Section a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Section a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Section a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Section a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Section a -> b)
    -> (forall a. (a -> a -> a) -> Section a -> a)
    -> (forall a. (a -> a -> a) -> Section a -> a)
    -> (forall a. Section a -> [a])
    -> (forall a. Section a -> Bool)
    -> (forall a. Section a -> Int)
    -> (forall a. Eq a => a -> Section a -> Bool)
    -> (forall a. Ord a => Section a -> a)
    -> (forall a. Ord a => Section a -> a)
    -> (forall a. Num a => Section a -> a)
    -> (forall a. Num a => Section a -> a)
    -> Foldable Section
    forall a. Eq a => a -> Section a -> Bool
    forall a. Num a => Section a -> a
    forall a. Ord a => Section a -> a
    forall m. Monoid m => Section m -> m
    forall a. Section a -> Bool
    forall a. Section a -> Int
    forall a. Section a -> [a]
    forall a. (a -> a -> a) -> Section a -> a
    forall m a. Monoid m => (a -> m) -> Section a -> m
    forall b a. (b -> a -> b) -> b -> Section a -> b
    forall a b. (a -> b -> b) -> b -> Section a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    product :: Section a -> a
    $cproduct :: forall a. Num a => Section a -> a
    sum :: Section a -> a
    $csum :: forall a. Num a => Section a -> a
    minimum :: Section a -> a
    $cminimum :: forall a. Ord a => Section a -> a
    maximum :: Section a -> a
    $cmaximum :: forall a. Ord a => Section a -> a
    elem :: a -> Section a -> Bool
    $celem :: forall a. Eq a => a -> Section a -> Bool
    length :: Section a -> Int
    $clength :: forall a. Section a -> Int
    null :: Section a -> Bool
    $cnull :: forall a. Section a -> Bool
    toList :: Section a -> [a]
    $ctoList :: forall a. Section a -> [a]
    foldl1 :: (a -> a -> a) -> Section a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Section a -> a
    foldr1 :: (a -> a -> a) -> Section a -> a
    $cfoldr1 :: forall a. (a -> a -> a) -> Section a -> a
    foldl' :: (b -> a -> b) -> b -> Section a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Section a -> b
    foldl :: (b -> a -> b) -> b -> Section a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Section a -> b
    foldr' :: (a -> b -> b) -> b -> Section a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Section a -> b
    foldr :: (a -> b -> b) -> b -> Section a -> b
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Section a -> b
    foldMap' :: (a -> m) -> Section a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Section a -> m
    foldMap :: (a -> m) -> Section a -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Section a -> m
    fold :: Section m -> m
    $cfold :: forall m. Monoid m => Section m -> m
    Foldable, Functor Section
    Foldable Section
    (Functor Section, Foldable Section) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Section a -> f (Section b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Section (f a) -> f (Section a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Section a -> m (Section b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        Section (m a) -> m (Section a))
    -> Traversable Section
    (a -> f b) -> Section a -> f (Section b)
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => Section (m a) -> m (Section a)
    forall (f :: * -> *) a.
    Applicative f =>
    Section (f a) -> f (Section a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Section a -> m (Section b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Section a -> f (Section b)
    sequence :: Section (m a) -> m (Section a)
    $csequence :: forall (m :: * -> *) a. Monad m => Section (m a) -> m (Section a)
    mapM :: (a -> m b) -> Section a -> m (Section b)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Section a -> m (Section b)
    sequenceA :: Section (f a) -> f (Section a)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Section (f a) -> f (Section a)
    traverse :: (a -> f b) -> Section a -> f (Section b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Section a -> f (Section b)
    $cp2Traversable :: Foldable Section
    $cp1Traversable :: Functor Section
    Traversable)

    data Conditional a = Conditional {
      Conditional a -> String
    conditionalCondition :: String
    , Conditional a -> a
    conditionalThen :: a
    , Conditional a -> Maybe a
    conditionalElse :: Maybe a
    } deriving (Conditional a -> Conditional a -> Bool
    (Conditional a -> Conditional a -> Bool)
    -> (Conditional a -> Conditional a -> Bool) -> Eq (Conditional a)
    forall a. Eq a => Conditional a -> Conditional a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Conditional a -> Conditional a -> Bool
    $c/= :: forall a. Eq a => Conditional a -> Conditional a -> Bool
    == :: Conditional a -> Conditional a -> Bool
    $c== :: forall a. Eq a => Conditional a -> Conditional a -> Bool
    Eq, Int -> Conditional a -> ShowS
    [Conditional a] -> ShowS
    Conditional a -> String
    (Int -> Conditional a -> ShowS)
    -> (Conditional a -> String)
    -> ([Conditional a] -> ShowS)
    -> Show (Conditional a)
    forall a. Show a => Int -> Conditional a -> ShowS
    forall a. Show a => [Conditional a] -> ShowS
    forall a. Show a => Conditional a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Conditional a] -> ShowS
    $cshowList :: forall a. Show a => [Conditional a] -> ShowS
    show :: Conditional a -> String
    $cshow :: forall a. Show a => Conditional a -> String
    showsPrec :: Int -> Conditional a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> Conditional a -> ShowS
    Show, a -> Conditional b -> Conditional a
    (a -> b) -> Conditional a -> Conditional b
    (forall a b. (a -> b) -> Conditional a -> Conditional b)
    -> (forall a b. a -> Conditional b -> Conditional a)
    -> Functor Conditional
    forall a b. a -> Conditional b -> Conditional a
    forall a b. (a -> b) -> Conditional a -> Conditional b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Conditional b -> Conditional a
    $c<$ :: forall a b. a -> Conditional b -> Conditional a
    fmap :: (a -> b) -> Conditional a -> Conditional b
    $cfmap :: forall a b. (a -> b) -> Conditional a -> Conditional b
    Functor, Conditional a -> Bool
    (a -> m) -> Conditional a -> m
    (a -> b -> b) -> b -> Conditional a -> b
    (forall m. Monoid m => Conditional m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Conditional a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Conditional a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Conditional a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Conditional a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Conditional a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Conditional a -> b)
    -> (forall a. (a -> a -> a) -> Conditional a -> a)
    -> (forall a. (a -> a -> a) -> Conditional a -> a)
    -> (forall a. Conditional a -> [a])
    -> (forall a. Conditional a -> Bool)
    -> (forall a. Conditional a -> Int)
    -> (forall a. Eq a => a -> Conditional a -> Bool)
    -> (forall a. Ord a => Conditional a -> a)
    -> (forall a. Ord a => Conditional a -> a)
    -> (forall a. Num a => Conditional a -> a)
    -> (forall a. Num a => Conditional a -> a)
    -> Foldable Conditional
    forall a. Eq a => a -> Conditional a -> Bool
    forall a. Num a => Conditional a -> a
    forall a. Ord a => Conditional a -> a
    forall m. Monoid m => Conditional m -> m
    forall a. Conditional a -> Bool
    forall a. Conditional a -> Int
    forall a. Conditional a -> [a]
    forall a. (a -> a -> a) -> Conditional a -> a
    forall m a. Monoid m => (a -> m) -> Conditional a -> m
    forall b a. (b -> a -> b) -> b -> Conditional a -> b
    forall a b. (a -> b -> b) -> b -> Conditional a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    product :: Conditional a -> a
    $cproduct :: forall a. Num a => Conditional a -> a
    sum :: Conditional a -> a
    $csum :: forall a. Num a => Conditional a -> a
    minimum :: Conditional a -> a
    $cminimum :: forall a. Ord a => Conditional a -> a
    maximum :: Conditional a -> a
    $cmaximum :: forall a. Ord a => Conditional a -> a
    elem :: a -> Conditional a -> Bool
    $celem :: forall a. Eq a => a -> Conditional a -> Bool
    length :: Conditional a -> Int
    $clength :: forall a. Conditional a -> Int
    null :: Conditional a -> Bool
    $cnull :: forall a. Conditional a -> Bool
    toList :: Conditional a -> [a]
    $ctoList :: forall a. Conditional a -> [a]
    foldl1 :: (a -> a -> a) -> Conditional a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Conditional a -> a
    foldr1 :: (a -> a -> a) -> Conditional a -> a
    $cfoldr1 :: forall a. (a -> a -> a) -> Conditional a -> a
    foldl' :: (b -> a -> b) -> b -> Conditional a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Conditional a -> b
    foldl :: (b -> a -> b) -> b -> Conditional a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Conditional a -> b
    foldr' :: (a -> b -> b) -> b -> Conditional a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Conditional a -> b
    foldr :: (a -> b -> b) -> b -> Conditional a -> b
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Conditional a -> b
    foldMap' :: (a -> m) -> Conditional a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Conditional a -> m
    foldMap :: (a -> m) -> Conditional a -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Conditional a -> m
    fold :: Conditional m -> m
    $cfold :: forall m. Monoid m => Conditional m -> m
    Foldable, Functor Conditional
    Foldable Conditional
    (Functor Conditional, Foldable Conditional) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Conditional a -> f (Conditional b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Conditional (f a) -> f (Conditional a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Conditional a -> m (Conditional b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        Conditional (m a) -> m (Conditional a))
    -> Traversable Conditional
    (a -> f b) -> Conditional a -> f (Conditional b)
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a.
    Monad m =>
    Conditional (m a) -> m (Conditional a)
    forall (f :: * -> *) a.
    Applicative f =>
    Conditional (f a) -> f (Conditional a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Conditional a -> m (Conditional b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Conditional a -> f (Conditional b)
    sequence :: Conditional (m a) -> m (Conditional a)
    $csequence :: forall (m :: * -> *) a.
    Monad m =>
    Conditional (m a) -> m (Conditional a)
    mapM :: (a -> m b) -> Conditional a -> m (Conditional b)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Conditional a -> m (Conditional b)
    sequenceA :: Conditional (f a) -> f (Conditional a)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Conditional (f a) -> f (Conditional a)
    traverse :: (a -> f b) -> Conditional a -> f (Conditional b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Conditional a -> f (Conditional b)
    $cp2Traversable :: Foldable Conditional
    $cp1Traversable :: Functor Conditional
    Traversable)

    data FlagSection = FlagSection {
      FlagSection -> Maybe String
    _flagSectionDescription :: Maybe String
    , FlagSection -> Bool
    _flagSectionManual :: Bool
    , FlagSection -> Bool
    _flagSectionDefault :: Bool
    } deriving (FlagSection -> FlagSection -> Bool
    (FlagSection -> FlagSection -> Bool)
    -> (FlagSection -> FlagSection -> Bool) -> Eq FlagSection
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: FlagSection -> FlagSection -> Bool
    $c/= :: FlagSection -> FlagSection -> Bool
    == :: FlagSection -> FlagSection -> Bool
    $c== :: FlagSection -> FlagSection -> Bool
    Eq, Int -> FlagSection -> ShowS
    [FlagSection] -> ShowS
    FlagSection -> String
    (Int -> FlagSection -> ShowS)
    -> (FlagSection -> String)
    -> ([FlagSection] -> ShowS)
    -> Show FlagSection
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [FlagSection] -> ShowS
    $cshowList :: [FlagSection] -> ShowS
    show :: FlagSection -> String
    $cshow :: FlagSection -> String
    showsPrec :: Int -> FlagSection -> ShowS
    $cshowsPrec :: Int -> FlagSection -> ShowS
    Show, (forall x. FlagSection -> Rep FlagSection x)
    -> (forall x. Rep FlagSection x -> FlagSection)
    -> Generic FlagSection
    forall x. Rep FlagSection x -> FlagSection
    forall x. FlagSection -> Rep FlagSection x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep FlagSection x -> FlagSection
    $cfrom :: forall x. FlagSection -> Rep FlagSection x
    Generic, Value -> Parser FlagSection
    (Value -> Parser FlagSection) -> FromValue FlagSection
    forall a. (Value -> Parser a) -> FromValue a
    fromValue :: Value -> Parser FlagSection
    $cfromValue :: Value -> Parser FlagSection
    FromValue)

    data Flag = Flag {
      Flag -> String
    flagName :: String
    , Flag -> Maybe String
    flagDescription :: Maybe String
    , Flag -> Bool
    flagManual :: Bool
    , Flag -> Bool
    flagDefault :: Bool
    } deriving (Flag -> Flag -> Bool
    (Flag -> Flag -> Bool) -> (Flag -> Flag -> Bool) -> Eq Flag
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Flag -> Flag -> Bool
    $c/= :: Flag -> Flag -> Bool
    == :: Flag -> Flag -> Bool
    $c== :: Flag -> Flag -> Bool
    Eq, Int -> Flag -> ShowS
    [Flag] -> ShowS
    Flag -> String
    (Int -> Flag -> ShowS)
    -> (Flag -> String) -> ([Flag] -> ShowS) -> Show Flag
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Flag] -> ShowS
    $cshowList :: [Flag] -> ShowS
    show :: Flag -> String
    $cshow :: Flag -> String
    showsPrec :: Int -> Flag -> ShowS
    $cshowsPrec :: Int -> Flag -> ShowS
    Show)

    toFlag :: (String, FlagSection) -> Flag
    toFlag :: (String, FlagSection) -> Flag
    toFlag (name :: String
    name, FlagSection description :: Maybe String
    description manual :: Bool
    manual def :: Bool
    def) = String -> Maybe String -> Bool -> Bool -> Flag
    Flag String
    name Maybe String
    description Bool
    manual Bool
    def

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

    type Config cSources cxxSources jsSources =
      Product (CommonOptions cSources cxxSources jsSources Empty) (PackageConfig cSources cxxSources jsSources)

    traverseConfig :: Traversal Config
    traverseConfig :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> Config cSources cxxSources jsSources
    -> m (Config cSources_ cxxSources_ jsSources_)
    traverseConfig t :: Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t = (CommonOptions cSources cxxSources jsSources Empty
     -> m (CommonOptions cSources_ cxxSources_ jsSources_ Empty))
    -> (PackageConfig cSources cxxSources jsSources
        -> m (PackageConfig cSources_ cxxSources_ jsSources_))
    -> Config cSources cxxSources jsSources
    -> m (Config cSources_ cxxSources_ jsSources_)
    forall (t :: * -> * -> *) (f :: * -> *) a c b d.
    (Bitraversable t, Applicative f) =>
    (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
    bitraverse (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> CommonOptions cSources cxxSources jsSources Empty
    -> m (CommonOptions cSources_ cxxSources_ jsSources_ Empty)
    Traversal_ CommonOptions
    traverseCommonOptions Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t) (Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    -> PackageConfig cSources cxxSources jsSources
    -> m (PackageConfig cSources_ cxxSources_ jsSources_)
    Traversal PackageConfig
    traversePackageConfig Traverse
      m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    t)

    type ConfigWithDefaults = Product
      (CommonOptionsWithDefaults Empty)
      (PackageConfigWithDefaults ParseCSources ParseCxxSources ParseJsSources)

    type CommonOptionsWithDefaults a = Product DefaultsConfig (CommonOptions ParseCSources ParseCxxSources ParseJsSources a)
    type WithCommonOptionsWithDefaults a = Product DefaultsConfig (WithCommonOptions ParseCSources ParseCxxSources ParseJsSources a)

    toPackage :: ProgramName -> FilePath -> FilePath -> ConfigWithDefaults -> Warnings (Errors IO) (Package, String)
    toPackage :: ProgramName
    -> String
    -> String
    -> ConfigWithDefaults
    -> WriterT [String] (Errors IO) (Package, String)
    toPackage programName :: ProgramName
    programName userDataDir :: String
    userDataDir dir :: String
    dir =
          ProgramName
    -> String
    -> String
    -> ConfigWithDefaults
    -> Warnings
         (Errors IO)
         (Config
            (Maybe (List String)) (Maybe (List String)) (Maybe (List String)))
    expandDefaultsInConfig ProgramName
    programName String
    userDataDir String
    dir
      (ConfigWithDefaults
     -> Warnings
          (Errors IO)
          (Config
             (Maybe (List String)) (Maybe (List String)) (Maybe (List String))))
    -> (Config
          (Maybe (List String)) (Maybe (List String)) (Maybe (List String))
        -> WriterT [String] (Errors IO) (Package, String))
    -> ConfigWithDefaults
    -> WriterT [String] (Errors IO) (Package, String)
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Traverse
      (Warnings (Errors IO))
      (Maybe (List String))
      [Path]
      (Maybe (List String))
      [Path]
      (Maybe (List String))
      [Path]
    -> Config
         (Maybe (List String)) (Maybe (List String)) (Maybe (List String))
    -> Warnings (Errors IO) (Config [Path] [Path] [Path])
    Traversal Config
    traverseConfig (String
    -> Traverse
         (Warnings (Errors IO))
         (Maybe (List String))
         [Path]
         (Maybe (List String))
         [Path]
         (Maybe (List String))
         [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String
    -> Traverse
         (Warnings m)
         (Maybe (List String))
         [Path]
         (Maybe (List String))
         [Path]
         (Maybe (List String))
         [Path]
    expandForeignSources String
    dir)
      (Config
       (Maybe (List String)) (Maybe (List String)) (Maybe (List String))
     -> Warnings (Errors IO) (Config [Path] [Path] [Path]))
    -> (Config [Path] [Path] [Path]
        -> WriterT [String] (Errors IO) (Package, String))
    -> Config
         (Maybe (List String)) (Maybe (List String)) (Maybe (List String))
    -> WriterT [String] (Errors IO) (Package, String)
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> String
    -> Config [Path] [Path] [Path]
    -> WriterT [String] (Errors IO) (Package, String)
    forall (m :: * -> *).
    MonadIO m =>
    String
    -> Config [Path] [Path] [Path] -> Warnings m (Package, String)
    toPackage_ String
    dir

    expandDefaultsInConfig
      :: ProgramName
      -> FilePath
      -> FilePath
      -> ConfigWithDefaults
      -> Warnings (Errors IO) (Config ParseCSources ParseCxxSources ParseJsSources)
    expandDefaultsInConfig :: ProgramName
    -> String
    -> String
    -> ConfigWithDefaults
    -> Warnings
         (Errors IO)
         (Config
            (Maybe (List String)) (Maybe (List String)) (Maybe (List String)))
    expandDefaultsInConfig programName :: ProgramName
    programName userDataDir :: String
    userDataDir dir :: String
    dir = (CommonOptionsWithDefaults Empty
     -> WriterT
          [String]
          (Errors IO)
          (CommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             Empty))
    -> (ParsePackageConfig
        -> WriterT
             [String]
             (Errors IO)
             (PackageConfig
                (Maybe (List String)) (Maybe (List String)) (Maybe (List String))))
    -> ConfigWithDefaults
    -> Warnings
         (Errors IO)
         (Config
            (Maybe (List String)) (Maybe (List String)) (Maybe (List String)))
    forall (t :: * -> * -> *) (f :: * -> *) a c b d.
    (Bitraversable t, Applicative f) =>
    (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
    bitraverse (ProgramName
    -> String
    -> String
    -> CommonOptionsWithDefaults Empty
    -> WriterT
         [String]
         (Errors IO)
         (CommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            Empty)
    expandGlobalDefaults ProgramName
    programName String
    userDataDir String
    dir) (ProgramName
    -> String
    -> String
    -> ParsePackageConfig
    -> WriterT
         [String]
         (Errors IO)
         (PackageConfig
            (Maybe (List String)) (Maybe (List String)) (Maybe (List String)))
    expandSectionDefaults ProgramName
    programName String
    userDataDir String
    dir)

    expandGlobalDefaults
      :: ProgramName
      -> FilePath
      -> FilePath
      -> CommonOptionsWithDefaults Empty
      -> Warnings (Errors IO) (CommonOptions ParseCSources ParseCxxSources ParseJsSources Empty)
    expandGlobalDefaults :: ProgramName
    -> String
    -> String
    -> CommonOptionsWithDefaults Empty
    -> WriterT
         [String]
         (Errors IO)
         (CommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            Empty)
    expandGlobalDefaults programName :: ProgramName
    programName userDataDir :: String
    userDataDir dir :: String
    dir = do
      (CommonOptions
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       Empty
     -> Product
          (CommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             Empty)
          Empty)
    -> CommonOptionsWithDefaults Empty
    -> Product
         DefaultsConfig
         (Product
            (CommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               Empty)
            Empty)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (CommonOptions
      (Maybe (List String))
      (Maybe (List String))
      (Maybe (List String))
      Empty
    -> Empty
    -> Product
         (CommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            Empty)
         Empty
    forall a b. a -> b -> Product a b
    `Product` Empty
    Empty) (CommonOptionsWithDefaults Empty
     -> Product
          DefaultsConfig
          (Product
             (CommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                Empty)
             Empty))
    -> (Product
          DefaultsConfig
          (Product
             (CommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                Empty)
             Empty)
        -> WriterT
             [String]
             (Errors IO)
             (CommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                Empty))
    -> CommonOptionsWithDefaults Empty
    -> WriterT
         [String]
         (Errors IO)
         (CommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            Empty)
    forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>> ProgramName
    -> String
    -> String
    -> Product
         DefaultsConfig
         (Product
            (CommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               Empty)
            Empty)
    -> Warnings
         (Errors IO)
         (Product
            (CommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               Empty)
            Empty)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir (Product
       DefaultsConfig
       (Product
          (CommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             Empty)
          Empty)
     -> Warnings
          (Errors IO)
          (Product
             (CommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                Empty)
             Empty))
    -> (Product
          (CommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             Empty)
          Empty
        -> WriterT
             [String]
             (Errors IO)
             (CommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                Empty))
    -> Product
         DefaultsConfig
         (Product
            (CommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               Empty)
            Empty)
    -> WriterT
         [String]
         (Errors IO)
         (CommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            Empty)
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> \ (Product c :: CommonOptions
      (Maybe (List String))
      (Maybe (List String))
      (Maybe (List String))
      Empty
    c Empty) -> CommonOptions
      (Maybe (List String))
      (Maybe (List String))
      (Maybe (List String))
      Empty
    -> WriterT
         [String]
         (Errors IO)
         (CommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            Empty)
    forall (m :: * -> *) a. Monad m => a -> m a
    return CommonOptions
      (Maybe (List String))
      (Maybe (List String))
      (Maybe (List String))
      Empty
    c

    expandSectionDefaults
      :: ProgramName
      -> FilePath
      -> FilePath
      -> PackageConfigWithDefaults ParseCSources ParseCxxSources ParseJsSources
      -> Warnings (Errors IO) (PackageConfig ParseCSources ParseCxxSources ParseJsSources)
    expandSectionDefaults :: ProgramName
    -> String
    -> String
    -> ParsePackageConfig
    -> WriterT
         [String]
         (Errors IO)
         (PackageConfig
            (Maybe (List String)) (Maybe (List String)) (Maybe (List String)))
    expandSectionDefaults programName :: ProgramName
    programName userDataDir :: String
    userDataDir dir :: String
    dir p :: ParsePackageConfig
    p@PackageConfig{..} = do
      Maybe
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         LibrarySection)
    library <- (SectionConfigWithDefaluts
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       LibrarySection
     -> WriterT
          [String]
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             LibrarySection))
    -> Maybe
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection)
    -> WriterT
         [String]
         (Errors IO)
         (Maybe
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               LibrarySection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (ProgramName
    -> String
    -> String
    -> SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         LibrarySection
    -> WriterT
         [String]
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir) Maybe
      (SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         LibrarySection)
    packageConfigLibrary
      Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection))
    internalLibraries <- (Map
       String
       (SectionConfigWithDefaluts
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          LibrarySection)
     -> WriterT
          [String]
          (Errors IO)
          (Map
             String
             (WithCommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                LibrarySection)))
    -> Maybe
         (Map
            String
            (SectionConfigWithDefaluts
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               LibrarySection))
    -> WriterT
         [String]
         (Errors IO)
         (Maybe
            (Map
               String
               (WithCommonOptions
                  (Maybe (List String))
                  (Maybe (List String))
                  (Maybe (List String))
                  LibrarySection)))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((SectionConfigWithDefaluts
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       LibrarySection
     -> WriterT
          [String]
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             LibrarySection))
    -> Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection)
    -> WriterT
         [String]
         (Errors IO)
         (Map
            String
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               LibrarySection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (ProgramName
    -> String
    -> String
    -> SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         LibrarySection
    -> WriterT
         [String]
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir)) Maybe
      (Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection))
    packageConfigInternalLibraries
      Maybe
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection)
    executable <- (SectionConfigWithDefaluts
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       ExecutableSection
     -> WriterT
          [String]
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             ExecutableSection))
    -> Maybe
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    -> WriterT
         [String]
         (Errors IO)
         (Maybe
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (ProgramName
    -> String
    -> String
    -> SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection
    -> WriterT
         [String]
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir) Maybe
      (SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection)
    packageConfigExecutable
      Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    executables <- (Map
       String
       (SectionConfigWithDefaluts
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          ExecutableSection)
     -> WriterT
          [String]
          (Errors IO)
          (Map
             String
             (WithCommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                ExecutableSection)))
    -> Maybe
         (Map
            String
            (SectionConfigWithDefaluts
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    -> WriterT
         [String]
         (Errors IO)
         (Maybe
            (Map
               String
               (WithCommonOptions
                  (Maybe (List String))
                  (Maybe (List String))
                  (Maybe (List String))
                  ExecutableSection)))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((SectionConfigWithDefaluts
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       ExecutableSection
     -> WriterT
          [String]
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             ExecutableSection))
    -> Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    -> WriterT
         [String]
         (Errors IO)
         (Map
            String
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (ProgramName
    -> String
    -> String
    -> SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection
    -> WriterT
         [String]
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir)) Maybe
      (Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    packageConfigExecutables
      Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    tests <- (Map
       String
       (SectionConfigWithDefaluts
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          ExecutableSection)
     -> WriterT
          [String]
          (Errors IO)
          (Map
             String
             (WithCommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                ExecutableSection)))
    -> Maybe
         (Map
            String
            (SectionConfigWithDefaluts
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    -> WriterT
         [String]
         (Errors IO)
         (Maybe
            (Map
               String
               (WithCommonOptions
                  (Maybe (List String))
                  (Maybe (List String))
                  (Maybe (List String))
                  ExecutableSection)))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((SectionConfigWithDefaluts
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       ExecutableSection
     -> WriterT
          [String]
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             ExecutableSection))
    -> Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    -> WriterT
         [String]
         (Errors IO)
         (Map
            String
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (ProgramName
    -> String
    -> String
    -> SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection
    -> WriterT
         [String]
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir)) Maybe
      (Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    packageConfigTests
      Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    benchmarks <- (Map
       String
       (SectionConfigWithDefaluts
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          ExecutableSection)
     -> WriterT
          [String]
          (Errors IO)
          (Map
             String
             (WithCommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                ExecutableSection)))
    -> Maybe
         (Map
            String
            (SectionConfigWithDefaluts
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    -> WriterT
         [String]
         (Errors IO)
         (Maybe
            (Map
               String
               (WithCommonOptions
                  (Maybe (List String))
                  (Maybe (List String))
                  (Maybe (List String))
                  ExecutableSection)))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((SectionConfigWithDefaluts
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       ExecutableSection
     -> WriterT
          [String]
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             ExecutableSection))
    -> Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    -> WriterT
         [String]
         (Errors IO)
         (Map
            String
            (WithCommonOptions
               (Maybe (List String))
               (Maybe (List String))
               (Maybe (List String))
               ExecutableSection))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse (ProgramName
    -> String
    -> String
    -> SectionConfigWithDefaluts
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection
    -> WriterT
         [String]
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults ProgramName
    programName String
    userDataDir String
    dir)) Maybe
      (Map
         String
         (SectionConfigWithDefaluts
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    packageConfigBenchmarks
      PackageConfig
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String))
    -> WriterT
         [String]
         (Errors IO)
         (PackageConfig
            (Maybe (List String)) (Maybe (List String)) (Maybe (List String)))
    forall (m :: * -> *) a. Monad m => a -> m a
    return ParsePackageConfig
    p{
          packageConfigLibrary :: Maybe
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         LibrarySection)
    packageConfigLibrary = Maybe
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         LibrarySection)
    library
        , packageConfigInternalLibraries :: Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection))
    packageConfigInternalLibraries = Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            LibrarySection))
    internalLibraries
        , packageConfigExecutable :: Maybe
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection)
    packageConfigExecutable = Maybe
      (WithCommonOptions
         (Maybe (List String))
         (Maybe (List String))
         (Maybe (List String))
         ExecutableSection)
    executable
        , packageConfigExecutables :: Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    packageConfigExecutables = Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    executables
        , packageConfigTests :: Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    packageConfigTests = Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    tests
        , packageConfigBenchmarks :: Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    packageConfigBenchmarks = Maybe
      (Map
         String
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            ExecutableSection))
    benchmarks
        }

    expandDefaults
      :: (FromValue a, Semigroup a, Monoid a)
      => ProgramName
      -> FilePath
      -> FilePath
      -> WithCommonOptionsWithDefaults a
      -> Warnings (Errors IO) (WithCommonOptions ParseCSources ParseCxxSources ParseJsSources a)
    expandDefaults :: ProgramName
    -> String
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expandDefaults programName :: ProgramName
    programName userDataDir :: String
    userDataDir = [String]
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    [String]
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expand []
      where
        expand :: (FromValue a, Semigroup a, Monoid a) =>
             [FilePath]
          -> FilePath
          -> WithCommonOptionsWithDefaults a
          -> Warnings (Errors IO) (WithCommonOptions ParseCSources ParseCxxSources ParseJsSources a)
        expand :: [String]
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expand seen :: [String]
    seen dir :: String
    dir (Product DefaultsConfig{..} c :: WithCommonOptions
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    c) = do
          WithCommonOptions
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    d <- [WithCommonOptions
       (Maybe (List String))
       (Maybe (List String))
       (Maybe (List String))
       a]
    -> WithCommonOptions
         (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    forall a. Monoid a => [a] -> a
    mconcat ([WithCommonOptions
        (Maybe (List String))
        (Maybe (List String))
        (Maybe (List String))
        a]
     -> WithCommonOptions
          (Maybe (List String))
          (Maybe (List String))
          (Maybe (List String))
          a)
    -> WriterT
         [String]
         (Errors IO)
         [WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a]
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Defaults
     -> Warnings
          (Errors IO)
          (WithCommonOptions
             (Maybe (List String))
             (Maybe (List String))
             (Maybe (List String))
             a))
    -> [Defaults]
    -> WriterT
         [String]
         (Errors IO)
         [WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM ([String]
    -> String
    -> Defaults
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    [String]
    -> String
    -> Defaults
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    get [String]
    seen String
    dir) (Maybe (List Defaults) -> [Defaults]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List Defaults)
    defaultsConfigDefaults)
          WithCommonOptions
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (WithCommonOptions
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    d WithCommonOptions
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    -> WithCommonOptions
         (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    -> WithCommonOptions
         (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    forall a. Semigroup a => a -> a -> a
    <> WithCommonOptions
      (Maybe (List String)) (Maybe (List String)) (Maybe (List String)) a
    c)

        get :: forall a. (FromValue a, Semigroup a, Monoid a) =>
             [FilePath]
          -> FilePath
          -> Defaults
          -> Warnings (Errors IO) (WithCommonOptions ParseCSources ParseCxxSources ParseJsSources a)
        get :: [String]
    -> String
    -> Defaults
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    get seen :: [String]
    seen dir :: String
    dir defaults :: Defaults
    defaults = do
          String
    file <- ExceptT String IO String -> WriterT [String] (Errors IO) String
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (ExceptT String IO String -> WriterT [String] (Errors IO) String)
    -> ExceptT String IO String -> WriterT [String] (Errors IO) String
    forall a b. (a -> b) -> a -> b
    $ IO (Either String String) -> ExceptT String IO String
    forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
    ExceptT (String -> String -> Defaults -> IO (Either String String)
    ensure String
    userDataDir String
    dir Defaults
    defaults)
          [String]
    seen_ <- ExceptT String IO [String] -> WriterT [String] (Errors IO) [String]
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift ([String] -> String -> ExceptT String IO [String]
    checkCycle [String]
    seen String
    file)
          let dir_ :: String
    dir_ = ShowS
    takeDirectory String
    file
          ProgramName
    -> String -> Warnings (Errors IO) (WithCommonOptionsWithDefaults a)
    forall a.
    FromValue a =>
    ProgramName -> String -> Warnings (Errors IO) a
    decodeYaml ProgramName
    programName String
    file Warnings (Errors IO) (WithCommonOptionsWithDefaults a)
    -> (WithCommonOptionsWithDefaults a
        -> Warnings
             (Errors IO)
             (WithCommonOptions
                (Maybe (List String))
                (Maybe (List String))
                (Maybe (List String))
                a))
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= [String]
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    forall a.
    (FromValue a, Semigroup a, Monoid a) =>
    [String]
    -> String
    -> WithCommonOptionsWithDefaults a
    -> Warnings
         (Errors IO)
         (WithCommonOptions
            (Maybe (List String))
            (Maybe (List String))
            (Maybe (List String))
            a)
    expand [String]
    seen_ String
    dir_

        checkCycle :: [FilePath] -> FilePath -> Errors IO [FilePath]
        checkCycle :: [String] -> String -> ExceptT String IO [String]
    checkCycle seen :: [String]
    seen file :: String
    file = do
          String
    canonic <- IO String -> ExceptT String IO String
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO String -> ExceptT String IO String)
    -> IO String -> ExceptT String IO String
    forall a b. (a -> b) -> a -> b
    $ String -> IO String
    canonicalizePath String
    file
          let seen_ :: [String]
    seen_ = String
    canonic String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : [String]
    seen
          Bool -> ExceptT String IO () -> ExceptT String IO ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (String
    canonic String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    seen) (ExceptT String IO () -> ExceptT String IO ())
    -> ExceptT String IO () -> ExceptT String IO ()
    forall a b. (a -> b) -> a -> b
    $ do
            String -> ExceptT String IO ()
    forall (m :: * -> *) e a. Monad m => e -> ExceptT e m a
    throwE ("cycle in defaults (" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate " -> " ([String] -> [String]
    forall a. [a] -> [a]
    reverse [String]
    seen_) String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ")")
          [String] -> ExceptT String IO [String]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [String]
    seen_

    toExecutableMap :: Monad m => String -> Maybe (Map String a) -> Maybe a -> Warnings m (Maybe (Map String a))
    toExecutableMap :: String
    -> Maybe (Map String a)
    -> Maybe a
    -> Warnings m (Maybe (Map String a))
    toExecutableMap name :: String
    name executables :: Maybe (Map String a)
    executables mExecutable :: Maybe a
    mExecutable = do
      case Maybe a
    mExecutable of
        Just executable :: a
    executable -> do
          Bool -> WriterT [String] m () -> WriterT [String] m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Maybe (Map String a) -> Bool
    forall a. Maybe a -> Bool
    isJust Maybe (Map String a)
    executables) (WriterT [String] m () -> WriterT [String] m ())
    -> WriterT [String] m () -> WriterT [String] m ()
    forall a b. (a -> b) -> a -> b
    $ do
            [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell ["Ignoring field \"executables\" in favor of \"executable\""]
          Maybe (Map String a) -> Warnings m (Maybe (Map String a))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Map String a) -> Warnings m (Maybe (Map String a)))
    -> Maybe (Map String a) -> Warnings m (Maybe (Map String a))
    forall a b. (a -> b) -> a -> b
    $ Map String a -> Maybe (Map String a)
    forall a. a -> Maybe a
    Just ([(String, a)] -> Map String a
    forall k a. Ord k => [(k, a)] -> Map k a
    Map.fromList [(String
    name, a
    executable)])
        Nothing -> Maybe (Map String a) -> Warnings m (Maybe (Map String a))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (Map String a)
    executables

    type GlobalOptions = CommonOptions CSources CxxSources JsSources Empty

    toPackage_ :: MonadIO m => FilePath -> Product GlobalOptions (PackageConfig CSources CxxSources JsSources) -> Warnings m (Package, String)
    toPackage_ :: String
    -> Config [Path] [Path] [Path] -> Warnings m (Package, String)
    toPackage_ dir :: String
    dir (Product g :: GlobalOptions
    g PackageConfig{..}) = do
      Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    executableMap <- String
    -> Maybe
         (Map
            String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> Maybe (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
    -> Warnings
         m
         (Maybe
            (Map
               String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)))
    forall (m :: * -> *) a.
    Monad m =>
    String
    -> Maybe (Map String a)
    -> Maybe a
    -> Warnings m (Maybe (Map String a))
    toExecutableMap String
    packageName_ Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    packageConfigExecutables Maybe (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
    packageConfigExecutable
      let
        globalVerbatim :: Maybe (List Verbatim)
    globalVerbatim = GlobalOptions -> Maybe (List Verbatim)
    forall cSources cxxSources jsSources a.
    CommonOptions cSources cxxSources jsSources a
    -> Maybe (List Verbatim)
    commonOptionsVerbatim GlobalOptions
    g
        globalOptions :: GlobalOptions
    globalOptions = GlobalOptions
    g {commonOptionsVerbatim :: Maybe (List Verbatim)
    commonOptionsVerbatim = Maybe (List Verbatim)
    forall a. Maybe a
    Nothing}

        executableNames :: [String]
    executableNames = [String]
    -> (Map
          String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
        -> [String])
    -> Maybe
         (Map
            String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [] Map
      String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
    -> [String]
    forall k a. Map k a -> [k]
    Map.keys Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    executableMap

        toSect :: (Monad m, Monoid a) => WithCommonOptions CSources CxxSources JsSources a -> Warnings m (Section a)
        toSect :: WithCommonOptions [Path] [Path] [Path] a -> Warnings m (Section a)
    toSect = String
    -> [String]
    -> WithCommonOptions [Path] [Path] [Path] a
    -> Warnings m (Section a)
    forall (m :: * -> *) a.
    Monad m =>
    String
    -> [String]
    -> WithCommonOptions [Path] [Path] [Path] a
    -> Warnings m (Section a)
    toSection String
    packageName_ [String]
    executableNames (WithCommonOptions [Path] [Path] [Path] a
     -> Warnings m (Section a))
    -> (WithCommonOptions [Path] [Path] [Path] a
        -> WithCommonOptions [Path] [Path] [Path] a)
    -> WithCommonOptions [Path] [Path] [Path] a
    -> Warnings m (Section a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (CommonOptions [Path] [Path] [Path] a
     -> CommonOptions [Path] [Path] [Path] a)
    -> WithCommonOptions [Path] [Path] [Path] a
    -> WithCommonOptions [Path] [Path] [Path] a
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first ((a
    forall a. Monoid a => a
    mempty a -> GlobalOptions -> CommonOptions [Path] [Path] [Path] a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ GlobalOptions
    globalOptions) CommonOptions [Path] [Path] [Path] a
    -> CommonOptions [Path] [Path] [Path] a
    -> CommonOptions [Path] [Path] [Path] a
    forall a. Semigroup a => a -> a -> a
    <>)

        toLib :: WithCommonOptions [Path] [Path] [Path] LibrarySection
    -> WriterT [String] m (Section Library)
    toLib = WithCommonOptions [Path] [Path] [Path] LibrarySection
    -> Warnings m (Section LibrarySection)
    forall (m :: * -> *) a.
    (Monad m, Monoid a) =>
    WithCommonOptions [Path] [Path] [Path] a -> Warnings m (Section a)
    toSect (WithCommonOptions [Path] [Path] [Path] LibrarySection
     -> Warnings m (Section LibrarySection))
    -> (Section LibrarySection -> WriterT [String] m (Section Library))
    -> WithCommonOptions [Path] [Path] [Path] LibrarySection
    -> WriterT [String] m (Section Library)
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> IO (Section Library) -> WriterT [String] m (Section Library)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Section Library) -> WriterT [String] m (Section Library))
    -> (Section LibrarySection -> IO (Section Library))
    -> Section LibrarySection
    -> WriterT [String] m (Section Library)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> String -> Section LibrarySection -> IO (Section Library)
    toLibrary String
    dir String
    packageName_
        toExecutables :: Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> WriterT [String] m (Map String (Section Executable))
    toExecutables = WriterT [String] m (Map String (Section Executable))
    -> (Map
          String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
        -> WriterT [String] m (Map String (Section Executable)))
    -> Maybe
         (Map
            String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> WriterT [String] m (Map String (Section Executable))
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Map String (Section Executable)
    -> WriterT [String] m (Map String (Section Executable))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Map String (Section Executable)
    forall a. Monoid a => a
    mempty) ((WithCommonOptions [Path] [Path] [Path] ExecutableSection
     -> WriterT [String] m (Section Executable))
    -> Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
    -> WriterT [String] m (Map String (Section Executable))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((WithCommonOptions [Path] [Path] [Path] ExecutableSection
      -> WriterT [String] m (Section Executable))
     -> Map
          String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
     -> WriterT [String] m (Map String (Section Executable)))
    -> (WithCommonOptions [Path] [Path] [Path] ExecutableSection
        -> WriterT [String] m (Section Executable))
    -> Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection)
    -> WriterT [String] m (Map String (Section Executable))
    forall a b. (a -> b) -> a -> b
    $ WithCommonOptions [Path] [Path] [Path] ExecutableSection
    -> Warnings m (Section ExecutableSection)
    forall (m :: * -> *) a.
    (Monad m, Monoid a) =>
    WithCommonOptions [Path] [Path] [Path] a -> Warnings m (Section a)
    toSect (WithCommonOptions [Path] [Path] [Path] ExecutableSection
     -> Warnings m (Section ExecutableSection))
    -> (Section ExecutableSection
        -> WriterT [String] m (Section Executable))
    -> WithCommonOptions [Path] [Path] [Path] ExecutableSection
    -> WriterT [String] m (Section Executable)
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> IO (Section Executable) -> WriterT [String] m (Section Executable)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Section Executable)
     -> WriterT [String] m (Section Executable))
    -> (Section ExecutableSection -> IO (Section Executable))
    -> Section ExecutableSection
    -> WriterT [String] m (Section Executable)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String
    -> String -> Section ExecutableSection -> IO (Section Executable)
    toExecutable String
    dir String
    packageName_)

      Maybe (Section Library)
    mLibrary <- (WithCommonOptions [Path] [Path] [Path] LibrarySection
     -> WriterT [String] m (Section Library))
    -> Maybe (WithCommonOptions [Path] [Path] [Path] LibrarySection)
    -> WriterT [String] m (Maybe (Section Library))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse WithCommonOptions [Path] [Path] [Path] LibrarySection
    -> WriterT [String] m (Section Library)
    toLib Maybe (WithCommonOptions [Path] [Path] [Path] LibrarySection)
    packageConfigLibrary
      Map String (Section Library)
    internalLibraries <- WriterT [String] m (Map String (Section Library))
    -> (Map
          String (WithCommonOptions [Path] [Path] [Path] LibrarySection)
        -> WriterT [String] m (Map String (Section Library)))
    -> Maybe
         (Map
            String (WithCommonOptions [Path] [Path] [Path] LibrarySection))
    -> WriterT [String] m (Map String (Section Library))
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Map String (Section Library)
    -> WriterT [String] m (Map String (Section Library))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Map String (Section Library)
    forall a. Monoid a => a
    mempty) ((WithCommonOptions [Path] [Path] [Path] LibrarySection
     -> WriterT [String] m (Section Library))
    -> Map
         String (WithCommonOptions [Path] [Path] [Path] LibrarySection)
    -> WriterT [String] m (Map String (Section Library))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse WithCommonOptions [Path] [Path] [Path] LibrarySection
    -> WriterT [String] m (Section Library)
    toLib) Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] LibrarySection))
    packageConfigInternalLibraries

      Map String (Section Executable)
    executables <- Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> WriterT [String] m (Map String (Section Executable))
    toExecutables Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    executableMap
      Map String (Section Executable)
    tests <- Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> WriterT [String] m (Map String (Section Executable))
    toExecutables Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    packageConfigTests
      Map String (Section Executable)
    benchmarks <- Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    -> WriterT [String] m (Map String (Section Executable))
    toExecutables Maybe
      (Map
         String (WithCommonOptions [Path] [Path] [Path] ExecutableSection))
    packageConfigBenchmarks

      Bool
    licenseFileExists <- IO Bool -> WriterT [String] m Bool
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> WriterT [String] m Bool)
    -> IO Bool -> WriterT [String] m Bool
    forall a b. (a -> b) -> a -> b
    $ String -> IO Bool
    doesFileExist (String
    dir String -> ShowS
    </> "LICENSE")

      [String]
    missingSourceDirs <- IO [String] -> WriterT [String] m [String]
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO [String] -> WriterT [String] m [String])
    -> IO [String] -> WriterT [String] m [String]
    forall a b. (a -> b) -> a -> b
    $ [String] -> [String]
    forall a. Eq a => [a] -> [a]
    nub ([String] -> [String])
    -> ([String] -> [String]) -> [String] -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [String] -> [String]
    sort ([String] -> [String]) -> IO [String] -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (String -> IO Bool) -> [String] -> IO [String]
    forall (m :: * -> *) a.
    Applicative m =>
    (a -> m Bool) -> [a] -> m [a]
    filterM ((Bool -> Bool) -> IO Bool -> IO Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Bool -> Bool
    not (IO Bool -> IO Bool) -> (String -> IO Bool) -> String -> IO Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> IO Bool
    doesDirectoryExist (String -> IO Bool) -> ShowS -> String -> IO Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String
    dir String -> ShowS
    </>)) (
           [String]
    -> (Section Library -> [String])
    -> Maybe (Section Library)
    -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [] Section Library -> [String]
    forall a. Section a -> [String]
    sectionSourceDirs Maybe (Section Library)
    mLibrary
        [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ (Section Library -> [String])
    -> Map String (Section Library) -> [String]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Library -> [String]
    forall a. Section a -> [String]
    sectionSourceDirs Map String (Section Library)
    internalLibraries
        [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ (Section Executable -> [String])
    -> Map String (Section Executable) -> [String]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Executable -> [String]
    forall a. Section a -> [String]
    sectionSourceDirs Map String (Section Executable)
    executables
        [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ (Section Executable -> [String])
    -> Map String (Section Executable) -> [String]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Executable -> [String]
    forall a. Section a -> [String]
    sectionSourceDirs Map String (Section Executable)
    tests
        [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ (Section Executable -> [String])
    -> Map String (Section Executable) -> [String]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Section Executable -> [String]
    forall a. Section a -> [String]
    sectionSourceDirs Map String (Section Executable)
    benchmarks
        )

      [Path]
    extraSourceFiles <- String -> String -> [String] -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> String -> [String] -> Warnings m [Path]
    expandGlobs "extra-source-files" String
    dir (Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    packageConfigExtraSourceFiles)
      [Path]
    extraDocFiles <- String -> String -> [String] -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> String -> [String] -> Warnings m [Path]
    expandGlobs "extra-doc-files" String
    dir (Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    packageConfigExtraDocFiles)

      let dataBaseDir :: String
    dataBaseDir = String -> ShowS -> Maybe String -> String
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe String
    dir (String
    dir String -> ShowS
    </>) Maybe String
    packageConfigDataDir

      [Path]
    dataFiles <- String -> String -> [String] -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> String -> [String] -> Warnings m [Path]
    expandGlobs "data-files" String
    dataBaseDir (Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    packageConfigDataFiles)

      let
        licenseFiles :: [String]
        licenseFiles :: [String]
    licenseFiles = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String) -> [String])
    -> Maybe (List String) -> [String]
    forall a b. (a -> b) -> a -> b
    $ Maybe (List String)
    packageConfigLicenseFile Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> do
          Bool -> Maybe ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard Bool
    licenseFileExists
          List String -> Maybe (List String)
    forall a. a -> Maybe a
    Just ([String] -> List String
    forall a. [a] -> List a
    List ["LICENSE"])

      Maybe (License License)
    inferredLicense <- case (Maybe (Maybe String)
    packageConfigLicense, [String]
    licenseFiles) of
        (Nothing, [file :: String
    file]) -> do
          Maybe String
    input <- IO (Maybe String) -> WriterT [String] m (Maybe String)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (String -> IO (Maybe String)
    tryReadFile (String
    dir String -> ShowS
    </> String
    file))
          case Maybe String
    input Maybe String
    -> (String -> Maybe (License License)) -> Maybe (License License)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= String -> Maybe (License License)
    inferLicense of
            Nothing -> do
              [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell ["Inferring license from file " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    file String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " failed!"]
              Maybe (License License)
    -> WriterT [String] m (Maybe (License License))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (License License)
    forall a. Maybe a
    Nothing
            license :: Maybe (License License)
    license -> Maybe (License License)
    -> WriterT [String] m (Maybe (License License))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (License License)
    license
        _ -> Maybe (License License)
    -> WriterT [String] m (Maybe (License License))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (License License)
    forall a. Maybe a
    Nothing

      let defaultBuildType :: BuildType
          defaultBuildType :: BuildType
    defaultBuildType = BuildType
    -> (CustomSetup -> BuildType) -> Maybe CustomSetup -> BuildType
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe BuildType
    Simple (BuildType -> CustomSetup -> BuildType
    forall a b. a -> b -> a
    const BuildType
    Custom) Maybe CustomSetup
    mCustomSetup

          pkg :: Package
    pkg = Package :: String
    -> String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> [String]
    -> [String]
    -> [String]
    -> BuildType
    -> Maybe String
    -> [String]
    -> Maybe String
    -> [Flag]
    -> [Path]
    -> [Path]
    -> [Path]
    -> Maybe String
    -> Maybe SourceRepository
    -> Maybe CustomSetup
    -> Maybe (Section Library)
    -> Map String (Section Library)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    -> Map String (Section Executable)
    -> [Verbatim]
    -> Package
    Package {
            packageName :: String
    packageName = String
    packageName_
          , packageVersion :: String
    packageVersion = String
    -> (PackageVersion -> String) -> Maybe PackageVersion -> String
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe "0.0.0" PackageVersion -> String
    unPackageVersion Maybe PackageVersion
    packageConfigVersion
          , packageSynopsis :: Maybe String
    packageSynopsis = Maybe String
    packageConfigSynopsis
          , packageDescription :: Maybe String
    packageDescription = Maybe String
    packageConfigDescription
          , packageHomepage :: Maybe String
    packageHomepage = Maybe String
    homepage
          , packageBugReports :: Maybe String
    packageBugReports = Maybe String
    bugReports
          , packageCategory :: Maybe String
    packageCategory = Maybe String
    packageConfigCategory
          , packageStability :: Maybe String
    packageStability = Maybe String
    packageConfigStability
          , packageAuthor :: [String]
    packageAuthor = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    packageConfigAuthor
          , packageMaintainer :: [String]
    packageMaintainer = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    maintainer
          , packageCopyright :: [String]
    packageCopyright = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    packageConfigCopyright
          , packageBuildType :: BuildType
    packageBuildType = BuildType -> Maybe BuildType -> BuildType
    forall a. a -> Maybe a -> a
    fromMaybe BuildType
    defaultBuildType Maybe BuildType
    packageConfigBuildType
          , packageLicense :: Maybe String
    packageLicense = Maybe (Maybe String) -> Maybe String
    forall (m :: * -> *) a. Monad m => m (m a) -> m a
    join Maybe (Maybe String)
    packageConfigLicense
          , packageLicenseFile :: [String]
    packageLicenseFile = [String]
    licenseFiles
          , packageTestedWith :: Maybe String
    packageTestedWith = Maybe String
    packageConfigTestedWith
          , packageFlags :: [Flag]
    packageFlags = [Flag]
    flags
          , packageExtraSourceFiles :: [Path]
    packageExtraSourceFiles = [Path]
    extraSourceFiles
          , packageExtraDocFiles :: [Path]
    packageExtraDocFiles = [Path]
    extraDocFiles
          , packageDataFiles :: [Path]
    packageDataFiles = [Path]
    dataFiles
          , packageDataDir :: Maybe String
    packageDataDir = Maybe String
    packageConfigDataDir
          , packageSourceRepository :: Maybe SourceRepository
    packageSourceRepository = Maybe SourceRepository
    sourceRepository
          , packageCustomSetup :: Maybe CustomSetup
    packageCustomSetup = Maybe CustomSetup
    mCustomSetup
          , packageLibrary :: Maybe (Section Library)
    packageLibrary = Maybe (Section Library)
    mLibrary
          , packageInternalLibraries :: Map String (Section Library)
    packageInternalLibraries = Map String (Section Library)
    internalLibraries
          , packageExecutables :: Map String (Section Executable)
    packageExecutables = Map String (Section Executable)
    executables
          , packageTests :: Map String (Section Executable)
    packageTests = Map String (Section Executable)
    tests
          , packageBenchmarks :: Map String (Section Executable)
    packageBenchmarks = Map String (Section Executable)
    benchmarks
          , packageVerbatim :: [Verbatim]
    packageVerbatim = Maybe (List Verbatim) -> [Verbatim]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List Verbatim)
    globalVerbatim
          }

      [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell [String]
    nameWarnings
      [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell ([String] -> [String]
    formatMissingSourceDirs [String]
    missingSourceDirs)
      (Package, String) -> Warnings m (Package, String)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (License License) -> Package -> (Package, String)
    determineCabalVersion Maybe (License License)
    inferredLicense Package
    pkg)
      where
        nameWarnings :: [String]
        packageName_ :: String
        (nameWarnings :: [String]
    nameWarnings, packageName_ :: String
    packageName_) = case Maybe String
    packageConfigName of
          Nothing -> let inferredName :: String
    inferredName = ShowS
    takeBaseName String
    dir in
            (["Package name not specified, inferred " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ShowS
    forall a. Show a => a -> String
    show String
    inferredName], String
    inferredName)
          Just n :: String
    n -> ([], String
    n)

        mCustomSetup :: Maybe CustomSetup
        mCustomSetup :: Maybe CustomSetup
    mCustomSetup = CustomSetupSection -> CustomSetup
    toCustomSetup (CustomSetupSection -> CustomSetup)
    -> Maybe CustomSetupSection -> Maybe CustomSetup
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe CustomSetupSection
    packageConfigCustomSetup

        flags :: [Flag]
    flags = ((String, FlagSection) -> Flag)
    -> [(String, FlagSection)] -> [Flag]
    forall a b. (a -> b) -> [a] -> [b]
    map (String, FlagSection) -> Flag
    toFlag ([(String, FlagSection)] -> [Flag])
    -> [(String, FlagSection)] -> [Flag]
    forall a b. (a -> b) -> a -> b
    $ Maybe (Map String FlagSection) -> [(String, FlagSection)]
    forall a. Maybe (Map String a) -> [(String, a)]
    toList Maybe (Map String FlagSection)
    packageConfigFlags

        toList :: Maybe (Map String a) -> [(String, a)]
        toList :: Maybe (Map String a) -> [(String, a)]
    toList = Map String a -> [(String, a)]
    forall k a. Map k a -> [(k, a)]
    Map.toList (Map String a -> [(String, a)])
    -> (Maybe (Map String a) -> Map String a)
    -> Maybe (Map String a)
    -> [(String, a)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map String a -> Maybe (Map String a) -> Map String a
    forall a. a -> Maybe a -> a
    fromMaybe Map String a
    forall a. Monoid a => a
    mempty

        formatMissingSourceDirs :: [String] -> [String]
    formatMissingSourceDirs = ShowS -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map ShowS
    forall a. Show a => a -> String
    f
          where
            f :: a -> String
    f name :: a
    name = "Specified source-dir " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    name String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " does not exist"

        sourceRepository :: Maybe SourceRepository
        sourceRepository :: Maybe SourceRepository
    sourceRepository = Maybe SourceRepository
    github Maybe SourceRepository
    -> Maybe SourceRepository -> Maybe SourceRepository
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> (String -> Maybe String -> SourceRepository
    `SourceRepository` Maybe String
    forall a. Maybe a
    Nothing) (String -> SourceRepository)
    -> Maybe String -> Maybe SourceRepository
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe String
    packageConfigGit

        github :: Maybe SourceRepository
        github :: Maybe SourceRepository
    github = GitHub -> SourceRepository
    toSourceRepository (GitHub -> SourceRepository)
    -> Maybe GitHub -> Maybe SourceRepository
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe GitHub
    packageConfigGithub
          where
            toSourceRepository :: GitHub -> SourceRepository
            toSourceRepository :: GitHub -> SourceRepository
    toSourceRepository (GitHub owner :: String
    owner repo :: String
    repo subdir :: Maybe String
    subdir) = String -> Maybe String -> SourceRepository
    SourceRepository (String
    githubBaseUrl String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    owner String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "/" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    repo) Maybe String
    subdir

        homepage :: Maybe String
        homepage :: Maybe String
    homepage = case Maybe (Maybe String)
    packageConfigHomepage of
          Just Nothing -> Maybe String
    forall a. Maybe a
    Nothing
          _ -> Maybe (Maybe String) -> Maybe String
    forall (m :: * -> *) a. Monad m => m (m a) -> m a
    join Maybe (Maybe String)
    packageConfigHomepage Maybe String -> Maybe String -> Maybe String
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Maybe String
    fromGithub
          where
            fromGithub :: Maybe String
    fromGithub = (String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "#readme") ShowS -> (SourceRepository -> String) -> SourceRepository -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SourceRepository -> String
    sourceRepositoryUrl (SourceRepository -> String)
    -> Maybe SourceRepository -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe SourceRepository
    github

        bugReports :: Maybe String
        bugReports :: Maybe String
    bugReports = case Maybe (Maybe String)
    packageConfigBugReports of
          Just Nothing -> Maybe String
    forall a. Maybe a
    Nothing
          _ -> Maybe (Maybe String) -> Maybe String
    forall (m :: * -> *) a. Monad m => m (m a) -> m a
    join Maybe (Maybe String)
    packageConfigBugReports Maybe String -> Maybe String -> Maybe String
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Maybe String
    fromGithub
          where
            fromGithub :: Maybe String
    fromGithub = (String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "/issues") ShowS -> (SourceRepository -> String) -> SourceRepository -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SourceRepository -> String
    sourceRepositoryUrl (SourceRepository -> String)
    -> Maybe SourceRepository -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe SourceRepository
    github

        maintainer :: Maybe (List String)
        maintainer :: Maybe (List String)
    maintainer = case (Maybe (List String)
    packageConfigAuthor, Maybe (Maybe (List String))
    packageConfigMaintainer) of
          (Just _, Nothing) -> Maybe (List String)
    packageConfigAuthor
          (_, Just m :: Maybe (List String)
    m) -> Maybe (List String)
    m
          _            -> Maybe (List String)
    forall a. Maybe a
    Nothing

    expandForeignSources
      :: MonadIO m
      => FilePath
      -> Traverse (Warnings m) ParseCSources CSources ParseCxxSources CxxSources ParseJsSources JsSources
    expandForeignSources :: String
    -> Traverse
         (Warnings m)
         (Maybe (List String))
         [Path]
         (Maybe (List String))
         [Path]
         (Maybe (List String))
         [Path]
    expandForeignSources dir :: String
    dir = Traverse :: forall (m :: * -> *) cSources cSources_ cxxSources cxxSources_
           jsSources jsSources_.
    (cSources -> m cSources_)
    -> (cxxSources -> m cxxSources_)
    -> (jsSources -> m jsSources_)
    -> Traverse
         m cSources cSources_ cxxSources cxxSources_ jsSources jsSources_
    Traverse {
        traverseCSources :: Maybe (List String) -> Warnings m [Path]
    traverseCSources = String -> Maybe (List String) -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> Maybe (List String) -> Warnings m [Path]
    expand "c-sources"
      , traverseCxxSources :: Maybe (List String) -> Warnings m [Path]
    traverseCxxSources = String -> Maybe (List String) -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> Maybe (List String) -> Warnings m [Path]
    expand "cxx-sources"
      , traverseJsSources :: Maybe (List String) -> Warnings m [Path]
    traverseJsSources = String -> Maybe (List String) -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> Maybe (List String) -> Warnings m [Path]
    expand "js-sources"
      }
      where
        expand :: String -> Maybe (List String) -> Warnings m [Path]
    expand fieldName :: String
    fieldName xs :: Maybe (List String)
    xs = do
          String -> String -> [String] -> Warnings m [Path]
    forall (m :: * -> *).
    MonadIO m =>
    String -> String -> [String] -> Warnings m [Path]
    expandGlobs String
    fieldName String
    dir (Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    xs)

    newtype Path = Path { Path -> String
    unPath :: FilePath }
      deriving (Path -> Path -> Bool
    (Path -> Path -> Bool) -> (Path -> Path -> Bool) -> Eq Path
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Path -> Path -> Bool
    $c/= :: Path -> Path -> Bool
    == :: Path -> Path -> Bool
    $c== :: Path -> Path -> Bool
    Eq, Int -> Path -> ShowS
    [Path] -> ShowS
    Path -> String
    (Int -> Path -> ShowS)
    -> (Path -> String) -> ([Path] -> ShowS) -> Show Path
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Path] -> ShowS
    $cshowList :: [Path] -> ShowS
    show :: Path -> String
    $cshow :: Path -> String
    showsPrec :: Int -> Path -> ShowS
    $cshowsPrec :: Int -> Path -> ShowS
    Show, Eq Path
    Eq Path =>
    (Path -> Path -> Ordering)
    -> (Path -> Path -> Bool)
    -> (Path -> Path -> Bool)
    -> (Path -> Path -> Bool)
    -> (Path -> Path -> Bool)
    -> (Path -> Path -> Path)
    -> (Path -> Path -> Path)
    -> Ord Path
    Path -> Path -> Bool
    Path -> Path -> Ordering
    Path -> Path -> Path
    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
    min :: Path -> Path -> Path
    $cmin :: Path -> Path -> Path
    max :: Path -> Path -> Path
    $cmax :: Path -> Path -> Path
    >= :: Path -> Path -> Bool
    $c>= :: Path -> Path -> Bool
    > :: Path -> Path -> Bool
    $c> :: Path -> Path -> Bool
    <= :: Path -> Path -> Bool
    $c<= :: Path -> Path -> Bool
    < :: Path -> Path -> Bool
    $c< :: Path -> Path -> Bool
    compare :: Path -> Path -> Ordering
    $ccompare :: Path -> Path -> Ordering
    $cp1Ord :: Eq Path
    Ord)

    instance IsString Path where
      fromString :: String -> Path
    fromString = String -> Path
    Path

    expandGlobs :: MonadIO m => String -> FilePath -> [String] -> Warnings m [Path]
    expandGlobs :: String -> String -> [String] -> Warnings m [Path]
    expandGlobs name :: String
    name dir :: String
    dir patterns :: [String]
    patterns = (String -> Path) -> [String] -> [Path]
    forall a b. (a -> b) -> [a] -> [b]
    map String -> Path
    Path ([String] -> [Path])
    -> WriterT [String] m [String] -> Warnings m [Path]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> do
      (warnings :: [String]
    warnings, files :: [String]
    files) <- IO ([String], [String]) -> WriterT [String] m ([String], [String])
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO ([String], [String])
     -> WriterT [String] m ([String], [String]))
    -> IO ([String], [String])
    -> WriterT [String] m ([String], [String])
    forall a b. (a -> b) -> a -> b
    $ String -> String -> [String] -> IO ([String], [String])
    Util.expandGlobs String
    name String
    dir [String]
    patterns
      [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell [String]
    warnings
      [String] -> WriterT [String] m [String]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [String]
    files

    toCustomSetup :: CustomSetupSection -> CustomSetup
    toCustomSetup :: CustomSetupSection -> CustomSetup
    toCustomSetup CustomSetupSection{..} = CustomSetup :: Dependencies -> CustomSetup
    CustomSetup
      { customSetupDependencies :: Dependencies
    customSetupDependencies = Dependencies -> Maybe Dependencies -> Dependencies
    forall a. a -> Maybe a -> a
    fromMaybe Dependencies
    forall a. Monoid a => a
    mempty Maybe Dependencies
    customSetupSectionDependencies }

    traverseSectionAndConditionals :: Monad m
      => (acc -> Section a -> m (acc, b))
      -> (acc -> Section a -> m (acc, b))
      -> acc
      -> Section a
      -> m (Section b)
    traverseSectionAndConditionals :: (acc -> Section a -> m (acc, b))
    -> (acc -> Section a -> m (acc, b))
    -> acc
    -> Section a
    -> m (Section b)
    traverseSectionAndConditionals fData :: acc -> Section a -> m (acc, b)
    fData fConditionals :: acc -> Section a -> m (acc, b)
    fConditionals acc0 :: acc
    acc0 sect :: Section a
    sect@Section{..} = do
      (acc1 :: acc
    acc1, x :: b
    x) <- acc -> Section a -> m (acc, b)
    fData acc
    acc0 Section a
    sect
      [Conditional (Section b)]
    xs <- acc -> [Conditional (Section a)] -> m [Conditional (Section b)]
    traverseConditionals acc
    acc1 [Conditional (Section a)]
    sectionConditionals
      Section b -> m (Section b)
    forall (m :: * -> *) a. Monad m => a -> m a
    return Section a
    sect{sectionData :: b
    sectionData = b
    x, sectionConditionals :: [Conditional (Section b)]
    sectionConditionals = [Conditional (Section b)]
    xs}
      where
        traverseConditionals :: acc -> [Conditional (Section a)] -> m [Conditional (Section b)]
    traverseConditionals = (Conditional (Section a) -> m (Conditional (Section b)))
    -> [Conditional (Section a)] -> m [Conditional (Section b)]
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((Conditional (Section a) -> m (Conditional (Section b)))
     -> [Conditional (Section a)] -> m [Conditional (Section b)])
    -> (acc -> Conditional (Section a) -> m (Conditional (Section b)))
    -> acc
    -> [Conditional (Section a)]
    -> m [Conditional (Section b)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Section a -> m (Section b))
    -> Conditional (Section a) -> m (Conditional (Section b))
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    traverse ((Section a -> m (Section b))
     -> Conditional (Section a) -> m (Conditional (Section b)))
    -> (acc -> Section a -> m (Section b))
    -> acc
    -> Conditional (Section a)
    -> m (Conditional (Section b))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (acc -> Section a -> m (acc, b))
    -> (acc -> Section a -> m (acc, b))
    -> acc
    -> Section a
    -> m (Section b)
    forall (m :: * -> *) acc a b.
    Monad m =>
    (acc -> Section a -> m (acc, b))
    -> (acc -> Section a -> m (acc, b))
    -> acc
    -> Section a
    -> m (Section b)
    traverseSectionAndConditionals acc -> Section a -> m (acc, b)
    fConditionals acc -> Section a -> m (acc, b)
    fConditionals

    getMentionedLibraryModules :: LibrarySection -> [String]
    getMentionedLibraryModules :: LibrarySection -> [String]
    getMentionedLibraryModules (LibrarySection _ _ exposedModules :: Maybe (List String)
    exposedModules generatedExposedModules :: Maybe (List String)
    generatedExposedModules otherModules :: Maybe (List String)
    otherModules generatedOtherModules :: Maybe (List String)
    generatedOtherModules _ _)
      = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String)
    exposedModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    generatedExposedModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    otherModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    generatedOtherModules)

    listModules :: FilePath -> Section a -> IO [String]
    listModules :: String -> Section a -> IO [String]
    listModules dir :: String
    dir Section{..} = [[String]] -> [String]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat ([[String]] -> [String]) -> IO [[String]] -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (String -> IO [String]) -> [String] -> IO [[String]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (String -> String -> IO [String]
    getModules String
    dir) [String]
    sectionSourceDirs

    inferModules ::
         FilePath
      -> String
      -> (a -> [String])
      -> (b -> [String])
      -> ([String] -> [String] -> a -> b)
      -> ([String] -> a -> b)
      -> Section a
      -> IO (Section b)
    inferModules :: String
    -> String
    -> (a -> [String])
    -> (b -> [String])
    -> ([String] -> [String] -> a -> b)
    -> ([String] -> a -> b)
    -> Section a
    -> IO (Section b)
    inferModules dir :: String
    dir packageName_ :: String
    packageName_ getMentionedModules :: a -> [String]
    getMentionedModules getInferredModules :: b -> [String]
    getInferredModules fromData :: [String] -> [String] -> a -> b
    fromData fromConditionals :: [String] -> a -> b
    fromConditionals = ([String] -> Section a -> IO ([String], b))
    -> ([String] -> Section a -> IO ([String], b))
    -> [String]
    -> Section a
    -> IO (Section b)
    forall (m :: * -> *) acc a b.
    Monad m =>
    (acc -> Section a -> m (acc, b))
    -> (acc -> Section a -> m (acc, b))
    -> acc
    -> Section a
    -> m (Section b)
    traverseSectionAndConditionals
      (([String] -> [String] -> a -> b)
    -> [String] -> [String] -> Section a -> IO ([String], b)
    fromConfigSection [String] -> [String] -> a -> b
    fromData [ShowS
    pathsModuleFromPackageName String
    packageName_])
      (([String] -> [String] -> a -> b)
    -> [String] -> [String] -> Section a -> IO ([String], b)
    fromConfigSection (\ [] -> [String] -> a -> b
    fromConditionals) [])
      []
      where
        fromConfigSection :: ([String] -> [String] -> a -> b)
    -> [String] -> [String] -> Section a -> IO ([String], b)
    fromConfigSection fromConfig :: [String] -> [String] -> a -> b
    fromConfig pathsModule_ :: [String]
    pathsModule_ outerModules :: [String]
    outerModules sect :: Section a
    sect@Section{sectionData :: forall a. Section a -> a
    sectionData = a
    conf} = do
          [String]
    modules <- String -> Section a -> IO [String]
    forall a. String -> Section a -> IO [String]
    listModules String
    dir Section a
    sect
          let
            mentionedModules :: [String]
    mentionedModules = (a -> [String]) -> Section a -> [String]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap a -> [String]
    getMentionedModules Section a
    sect
            inferableModules :: [String]
    inferableModules = ([String]
    modules [String] -> [String] -> [String]
    forall a. Eq a => [a] -> [a] -> [a]
    \\ [String]
    outerModules) [String] -> [String] -> [String]
    forall a. Eq a => [a] -> [a] -> [a]
    \\ [String]
    mentionedModules
            pathsModule :: [String]
    pathsModule = ([String]
    pathsModule_ [String] -> [String] -> [String]
    forall a. Eq a => [a] -> [a] -> [a]
    \\ [String]
    outerModules) [String] -> [String] -> [String]
    forall a. Eq a => [a] -> [a] -> [a]
    \\ [String]
    mentionedModules
            r :: b
    r = [String] -> [String] -> a -> b
    fromConfig [String]
    pathsModule [String]
    inferableModules a
    conf
          ([String], b) -> IO ([String], b)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([String]
    outerModules [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ b -> [String]
    getInferredModules b
    r, b
    r)

    toLibrary :: FilePath -> String -> Section LibrarySection -> IO (Section Library)
    toLibrary :: String -> String -> Section LibrarySection -> IO (Section Library)
    toLibrary dir :: String
    dir name :: String
    name =
        String
    -> String
    -> (LibrarySection -> [String])
    -> (Library -> [String])
    -> ([String] -> [String] -> LibrarySection -> Library)
    -> ([String] -> LibrarySection -> Library)
    -> Section LibrarySection
    -> IO (Section Library)
    forall a b.
    String
    -> String
    -> (a -> [String])
    -> (b -> [String])
    -> ([String] -> [String] -> a -> b)
    -> ([String] -> a -> b)
    -> Section a
    -> IO (Section b)
    inferModules String
    dir String
    name LibrarySection -> [String]
    getMentionedLibraryModules Library -> [String]
    getLibraryModules [String] -> [String] -> LibrarySection -> Library
    fromLibrarySectionTopLevel [String] -> LibrarySection -> Library
    fromLibrarySectionInConditional
      where
        getLibraryModules :: Library -> [String]
        getLibraryModules :: Library -> [String]
    getLibraryModules Library{..} = [String]
    libraryExposedModules [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String]
    libraryOtherModules

        fromLibrarySectionTopLevel :: [String] -> [String] -> LibrarySection -> Library
    fromLibrarySectionTopLevel pathsModule :: [String]
    pathsModule inferableModules :: [String]
    inferableModules LibrarySection{..} =
          Maybe Bool
    -> Maybe String
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> Library
    Library Maybe Bool
    librarySectionExposed Maybe String
    librarySectionVisibility [String]
    exposedModules [String]
    otherModules [String]
    generatedModules [String]
    reexportedModules [String]
    signatures
          where
            (exposedModules :: [String]
    exposedModules, otherModules :: [String]
    otherModules, generatedModules :: [String]
    generatedModules) =
              [String]
    -> [String]
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> ([String], [String], [String])
    determineModules [String]
    pathsModule [String]
    inferableModules Maybe (List String)
    librarySectionExposedModules Maybe (List String)
    librarySectionGeneratedExposedModules Maybe (List String)
    librarySectionOtherModules Maybe (List String)
    librarySectionGeneratedOtherModules
            reexportedModules :: [String]
    reexportedModules = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    librarySectionReexportedModules
            signatures :: [String]
    signatures = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    librarySectionSignatures

    determineModules :: [String] -> [String] -> Maybe (List String) -> Maybe (List String) -> Maybe (List String) -> Maybe (List String) -> ([String], [String], [String])
    determineModules :: [String]
    -> [String]
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> Maybe (List String)
    -> ([String], [String], [String])
    determineModules pathsModule :: [String]
    pathsModule inferable :: [String]
    inferable mExposed :: Maybe (List String)
    mExposed mGeneratedExposed :: Maybe (List String)
    mGeneratedExposed mOther :: Maybe (List String)
    mOther mGeneratedOther :: Maybe (List String)
    mGeneratedOther =
      ([String]
    exposed, [String]
    others, [String]
    generated)
      where
        generated :: [String]
    generated = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String)
    mGeneratedExposed Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    mGeneratedOther)
        exposed :: [String]
    exposed = [String]
    -> (List String -> [String]) -> Maybe (List String) -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [String]
    inferable List String -> [String]
    forall a. List a -> [a]
    fromList Maybe (List String)
    mExposed [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    mGeneratedExposed
        others :: [String]
    others = [String]
    -> (List String -> [String]) -> Maybe (List String) -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (([String]
    inferable [String] -> [String] -> [String]
    forall a. Eq a => [a] -> [a] -> [a]
    \\ [String]
    exposed) [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String]
    pathsModule) List String -> [String]
    forall a. List a -> [a]
    fromList Maybe (List String)
    mOther [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    mGeneratedOther

    fromLibrarySectionInConditional :: [String] -> LibrarySection -> Library
    fromLibrarySectionInConditional :: [String] -> LibrarySection -> Library
    fromLibrarySectionInConditional inferableModules :: [String]
    inferableModules lib :: LibrarySection
    lib@(LibrarySection _ _ exposedModules :: Maybe (List String)
    exposedModules _ otherModules :: Maybe (List String)
    otherModules _ _ _) =
      case (Maybe (List String)
    exposedModules, Maybe (List String)
    otherModules) of
        (Nothing, Nothing) -> [String] -> Library -> Library
    addToOtherModules [String]
    inferableModules (LibrarySection -> Library
    fromLibrarySectionPlain LibrarySection
    lib)
        _ -> LibrarySection -> Library
    fromLibrarySectionPlain LibrarySection
    lib
      where
        addToOtherModules :: [String] -> Library -> Library
    addToOtherModules xs :: [String]
    xs r :: Library
    r = Library
    r {libraryOtherModules :: [String]
    libraryOtherModules = [String]
    xs [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ Library -> [String]
    libraryOtherModules Library
    r}

    fromLibrarySectionPlain :: LibrarySection -> Library
    fromLibrarySectionPlain :: LibrarySection -> Library
    fromLibrarySectionPlain LibrarySection{..} = Library :: Maybe Bool
    -> Maybe String
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> Library
    Library {
        libraryExposed :: Maybe Bool
    libraryExposed = Maybe Bool
    librarySectionExposed
      , libraryVisibility :: Maybe String
    libraryVisibility = Maybe String
    librarySectionVisibility
      , libraryExposedModules :: [String]
    libraryExposedModules = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String)
    librarySectionExposedModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    librarySectionGeneratedExposedModules)
      , libraryOtherModules :: [String]
    libraryOtherModules = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String)
    librarySectionOtherModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    librarySectionGeneratedOtherModules)
      , libraryGeneratedModules :: [String]
    libraryGeneratedModules = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String)
    librarySectionGeneratedOtherModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    librarySectionGeneratedExposedModules)
      , libraryReexportedModules :: [String]
    libraryReexportedModules = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    librarySectionReexportedModules
      , librarySignatures :: [String]
    librarySignatures = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    librarySectionSignatures
      }

    getMentionedExecutableModules :: ExecutableSection -> [String]
    getMentionedExecutableModules :: ExecutableSection -> [String]
    getMentionedExecutableModules (ExecutableSection main :: Maybe String
    main otherModules :: Maybe (List String)
    otherModules generatedModules :: Maybe (List String)
    generatedModules)=
      ([String] -> [String])
    -> (String -> [String] -> [String])
    -> Maybe String
    -> [String]
    -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [String] -> [String]
    forall a. a -> a
    id (:) (Maybe String
    main Maybe String -> (String -> Maybe String) -> Maybe String
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= [String] -> Maybe String
    toModule ([String] -> Maybe String)
    -> (String -> [String]) -> String -> Maybe String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> [String]
    splitDirectories) ([String] -> [String]) -> [String] -> [String]
    forall a b. (a -> b) -> a -> b
    $ Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList (Maybe (List String)
    otherModules Maybe (List String) -> Maybe (List String) -> Maybe (List String)
    forall a. Semigroup a => a -> a -> a
    <> Maybe (List String)
    generatedModules)

    toExecutable :: FilePath -> String -> Section ExecutableSection -> IO (Section Executable)
    toExecutable :: String
    -> String -> Section ExecutableSection -> IO (Section Executable)
    toExecutable dir :: String
    dir packageName_ :: String
    packageName_ =
        String
    -> String
    -> (ExecutableSection -> [String])
    -> (Executable -> [String])
    -> ([String] -> [String] -> ExecutableSection -> Executable)
    -> ([String] -> ExecutableSection -> Executable)
    -> Section ExecutableSection
    -> IO (Section Executable)
    forall a b.
    String
    -> String
    -> (a -> [String])
    -> (b -> [String])
    -> ([String] -> [String] -> a -> b)
    -> ([String] -> a -> b)
    -> Section a
    -> IO (Section b)
    inferModules String
    dir String
    packageName_ ExecutableSection -> [String]
    getMentionedExecutableModules Executable -> [String]
    executableOtherModules [String] -> [String] -> ExecutableSection -> Executable
    fromExecutableSection ([String] -> [String] -> ExecutableSection -> Executable
    fromExecutableSection [])
      (Section ExecutableSection -> IO (Section Executable))
    -> (Section ExecutableSection -> Section ExecutableSection)
    -> Section ExecutableSection
    -> IO (Section Executable)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section ExecutableSection -> Section ExecutableSection
    expandMain
      where
        fromExecutableSection :: [String] -> [String] -> ExecutableSection -> Executable
        fromExecutableSection :: [String] -> [String] -> ExecutableSection -> Executable
    fromExecutableSection pathsModule :: [String]
    pathsModule inferableModules :: [String]
    inferableModules ExecutableSection{..} =
          (Maybe String -> [String] -> [String] -> Executable
    Executable Maybe String
    executableSectionMain ([String]
    otherModules [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String]
    generatedModules) [String]
    generatedModules)
          where
            otherModules :: [String]
    otherModules = [String]
    -> (List String -> [String]) -> Maybe (List String) -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe ([String]
    inferableModules [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String]
    pathsModule) List String -> [String]
    forall a. List a -> [a]
    fromList Maybe (List String)
    executableSectionOtherModules
            generatedModules :: [String]
    generatedModules = [String]
    -> (List String -> [String]) -> Maybe (List String) -> [String]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [] List String -> [String]
    forall a. List a -> [a]
    fromList Maybe (List String)
    executableSectionGeneratedOtherModules

    expandMain :: Section ExecutableSection -> Section ExecutableSection
    expandMain :: Section ExecutableSection -> Section ExecutableSection
    expandMain = Section ([String], ExecutableSection) -> Section ExecutableSection
    flatten (Section ([String], ExecutableSection)
     -> Section ExecutableSection)
    -> (Section ExecutableSection
        -> Section ([String], ExecutableSection))
    -> Section ExecutableSection
    -> Section ExecutableSection
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Section ExecutableSection -> Section ([String], ExecutableSection)
    expand
      where
        expand :: Section ExecutableSection -> Section ([GhcOption], ExecutableSection)
        expand :: Section ExecutableSection -> Section ([String], ExecutableSection)
    expand = (ExecutableSection -> ([String], ExecutableSection))
    -> Section ExecutableSection
    -> Section ([String], ExecutableSection)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ExecutableSection -> ([String], ExecutableSection)
    go
          where
            go :: ExecutableSection -> ([String], ExecutableSection)
    go exec :: ExecutableSection
    exec@ExecutableSection{..} =
              let
                (mainSrcFile :: Maybe String
    mainSrcFile, ghcOptions :: [String]
    ghcOptions) = (Maybe String, [String])
    -> (String -> (Maybe String, [String]))
    -> Maybe String
    -> (Maybe String, [String])
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Maybe String
    forall a. Maybe a
    Nothing, []) ((String -> Maybe String)
    -> (String, [String]) -> (Maybe String, [String])
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first String -> Maybe String
    forall a. a -> Maybe a
    Just ((String, [String]) -> (Maybe String, [String]))
    -> (String -> (String, [String]))
    -> String
    -> (Maybe String, [String])
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> (String, [String])
    parseMain) Maybe String
    executableSectionMain
              in
                ([String]
    ghcOptions, ExecutableSection
    exec{executableSectionMain :: Maybe String
    executableSectionMain = Maybe String
    mainSrcFile})

        flatten :: Section ([GhcOption], ExecutableSection) -> Section ExecutableSection
        flatten :: Section ([String], ExecutableSection) -> Section ExecutableSection
    flatten sect :: Section ([String], ExecutableSection)
    sect@Section{sectionData :: forall a. Section a -> a
    sectionData = (ghcOptions :: [String]
    ghcOptions, exec :: ExecutableSection
    exec), ..} = Section ([String], ExecutableSection)
    sect{
            sectionData :: ExecutableSection
    sectionData = ExecutableSection
    exec
          , sectionGhcOptions :: [String]
    sectionGhcOptions = [String]
    sectionGhcOptions [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String]
    ghcOptions
          , sectionConditionals :: [Conditional (Section ExecutableSection)]
    sectionConditionals = (Conditional (Section ([String], ExecutableSection))
     -> Conditional (Section ExecutableSection))
    -> [Conditional (Section ([String], ExecutableSection))]
    -> [Conditional (Section ExecutableSection)]
    forall a b. (a -> b) -> [a] -> [b]
    map ((Section ([String], ExecutableSection)
     -> Section ExecutableSection)
    -> Conditional (Section ([String], ExecutableSection))
    -> Conditional (Section ExecutableSection)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Section ([String], ExecutableSection) -> Section ExecutableSection
    flatten) [Conditional (Section ([String], ExecutableSection))]
    sectionConditionals
          }

    toSection :: Monad m => String -> [String] -> WithCommonOptions CSources CxxSources JsSources a -> Warnings m (Section a)
    toSection :: String
    -> [String]
    -> WithCommonOptions [Path] [Path] [Path] a
    -> Warnings m (Section a)
    toSection packageName_ :: String
    packageName_ executableNames :: [String]
    executableNames = WithCommonOptions [Path] [Path] [Path] a -> Warnings m (Section a)
    forall (m :: * -> *) a.
    Monad m =>
    Product (CommonOptions [Path] [Path] [Path] a) a
    -> WriterT [String] m (Section a)
    go
      where
        go :: Product (CommonOptions [Path] [Path] [Path] a) a
    -> WriterT [String] m (Section a)
    go (Product CommonOptions{..} a :: a
    a) = do
          (systemBuildTools :: SystemBuildTools
    systemBuildTools, buildTools :: Map BuildTool DependencyVersion
    buildTools) <- WriterT
      [String] m (SystemBuildTools, Map BuildTool DependencyVersion)
    -> (BuildTools
        -> WriterT
             [String] m (SystemBuildTools, Map BuildTool DependencyVersion))
    -> Maybe BuildTools
    -> WriterT
         [String] m (SystemBuildTools, Map BuildTool DependencyVersion)
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe ((SystemBuildTools, Map BuildTool DependencyVersion)
    -> WriterT
         [String] m (SystemBuildTools, Map BuildTool DependencyVersion)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (SystemBuildTools, Map BuildTool DependencyVersion)
    forall a. Monoid a => a
    mempty) BuildTools
    -> WriterT
         [String] m (SystemBuildTools, Map BuildTool DependencyVersion)
    forall (m :: * -> *).
    Monad m =>
    BuildTools
    -> Warnings m (SystemBuildTools, Map BuildTool DependencyVersion)
    toBuildTools Maybe BuildTools
    commonOptionsBuildTools

          [Conditional (Section a)]
    conditionals <- (ConditionalSection [Path] [Path] [Path] a
     -> WriterT [String] m (Conditional (Section a)))
    -> [ConditionalSection [Path] [Path] [Path] a]
    -> WriterT [String] m [Conditional (Section a)]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM ConditionalSection [Path] [Path] [Path] a
    -> WriterT [String] m (Conditional (Section a))
    forall (m :: * -> *) a.
    Monad m =>
    ConditionalSection [Path] [Path] [Path] a
    -> Warnings m (Conditional (Section a))
    toConditional (Maybe (List (ConditionalSection [Path] [Path] [Path] a))
    -> [ConditionalSection [Path] [Path] [Path] a]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List (ConditionalSection [Path] [Path] [Path] a))
    commonOptionsWhen)
          Section a -> WriterT [String] m (Section a)
    forall (m :: * -> *) a. Monad m => a -> m a
    return Section :: forall a.
    a
    -> [String]
    -> Dependencies
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [Path]
    -> [String]
    -> [Path]
    -> [Path]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> Maybe Bool
    -> [Conditional (Section a)]
    -> Map BuildTool DependencyVersion
    -> SystemBuildTools
    -> [Verbatim]
    -> Section a
    Section {
            sectionData :: a
    sectionData = a
    a
          , sectionSourceDirs :: [String]
    sectionSourceDirs = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsSourceDirs
          , sectionDefaultExtensions :: [String]
    sectionDefaultExtensions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsDefaultExtensions
          , sectionOtherExtensions :: [String]
    sectionOtherExtensions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsOtherExtensions
          , sectionGhcOptions :: [String]
    sectionGhcOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsGhcOptions
          , sectionGhcProfOptions :: [String]
    sectionGhcProfOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsGhcProfOptions
          , sectionGhcjsOptions :: [String]
    sectionGhcjsOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsGhcjsOptions
          , sectionCppOptions :: [String]
    sectionCppOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsCppOptions
          , sectionCcOptions :: [String]
    sectionCcOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsCcOptions
          , sectionCSources :: [Path]
    sectionCSources = [Path]
    commonOptionsCSources
          , sectionCxxOptions :: [String]
    sectionCxxOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsCxxOptions
          , sectionCxxSources :: [Path]
    sectionCxxSources = [Path]
    commonOptionsCxxSources
          , sectionJsSources :: [Path]
    sectionJsSources = [Path]
    commonOptionsJsSources
          , sectionExtraLibDirs :: [String]
    sectionExtraLibDirs = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsExtraLibDirs
          , sectionExtraLibraries :: [String]
    sectionExtraLibraries = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsExtraLibraries
          , sectionExtraFrameworksDirs :: [String]
    sectionExtraFrameworksDirs = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsExtraFrameworksDirs
          , sectionFrameworks :: [String]
    sectionFrameworks = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsFrameworks
          , sectionIncludeDirs :: [String]
    sectionIncludeDirs = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsIncludeDirs
          , sectionInstallIncludes :: [String]
    sectionInstallIncludes = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsInstallIncludes
          , sectionLdOptions :: [String]
    sectionLdOptions = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsLdOptions
          , sectionBuildable :: Maybe Bool
    sectionBuildable = Maybe Bool
    commonOptionsBuildable
          , sectionDependencies :: Dependencies
    sectionDependencies = Dependencies -> Maybe Dependencies -> Dependencies
    forall a. a -> Maybe a -> a
    fromMaybe Dependencies
    forall a. Monoid a => a
    mempty Maybe Dependencies
    commonOptionsDependencies
          , sectionPkgConfigDependencies :: [String]
    sectionPkgConfigDependencies = Maybe (List String) -> [String]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List String)
    commonOptionsPkgConfigDependencies
          , sectionConditionals :: [Conditional (Section a)]
    sectionConditionals = [Conditional (Section a)]
    conditionals
          , sectionBuildTools :: Map BuildTool DependencyVersion
    sectionBuildTools = Map BuildTool DependencyVersion
    buildTools
          , sectionSystemBuildTools :: SystemBuildTools
    sectionSystemBuildTools = SystemBuildTools
    systemBuildTools SystemBuildTools -> SystemBuildTools -> SystemBuildTools
    forall a. Semigroup a => a -> a -> a
    <> SystemBuildTools -> Maybe SystemBuildTools -> SystemBuildTools
    forall a. a -> Maybe a -> a
    fromMaybe SystemBuildTools
    forall a. Monoid a => a
    mempty Maybe SystemBuildTools
    commonOptionsSystemBuildTools
          , sectionVerbatim :: [Verbatim]
    sectionVerbatim = Maybe (List Verbatim) -> [Verbatim]
    forall a. Maybe (List a) -> [a]
    fromMaybeList Maybe (List Verbatim)
    commonOptionsVerbatim
          }
        toBuildTools :: Monad m => BuildTools -> Warnings m (SystemBuildTools, Map BuildTool DependencyVersion)
        toBuildTools :: BuildTools
    -> Warnings m (SystemBuildTools, Map BuildTool DependencyVersion)
    toBuildTools = ([Either SystemBuildTool (BuildTool, DependencyVersion)]
     -> (SystemBuildTools, Map BuildTool DependencyVersion))
    -> WriterT
         [String] m [Either SystemBuildTool (BuildTool, DependencyVersion)]
    -> Warnings m (SystemBuildTools, Map BuildTool DependencyVersion)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ([Either SystemBuildTool (BuildTool, DependencyVersion)]
    -> SystemBuildTools
    forall b. [Either SystemBuildTool b] -> SystemBuildTools
    mkSystemBuildTools ([Either SystemBuildTool (BuildTool, DependencyVersion)]
     -> SystemBuildTools)
    -> ([Either SystemBuildTool (BuildTool, DependencyVersion)]
        -> Map BuildTool DependencyVersion)
    -> [Either SystemBuildTool (BuildTool, DependencyVersion)]
    -> (SystemBuildTools, Map BuildTool DependencyVersion)
    forall (a :: * -> * -> *) b c c'.
    Arrow a =>
    a b c -> a b c' -> a b (c, c')
    &&& [Either SystemBuildTool (BuildTool, DependencyVersion)]
    -> Map BuildTool DependencyVersion
    forall a a. [Either a (BuildTool, a)] -> Map BuildTool a
    mkBuildTools) (WriterT
       [String] m [Either SystemBuildTool (BuildTool, DependencyVersion)]
     -> Warnings m (SystemBuildTools, Map BuildTool DependencyVersion))
    -> (BuildTools
        -> WriterT
             [String] m [Either SystemBuildTool (BuildTool, DependencyVersion)])
    -> BuildTools
    -> Warnings m (SystemBuildTools, Map BuildTool DependencyVersion)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((ParseBuildTool, DependencyVersion)
     -> WriterT
          [String] m (Either SystemBuildTool (BuildTool, DependencyVersion)))
    -> [(ParseBuildTool, DependencyVersion)]
    -> WriterT
         [String] m [Either SystemBuildTool (BuildTool, DependencyVersion)]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (String
    -> [String]
    -> (ParseBuildTool, DependencyVersion)
    -> WriterT
         [String] m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall (m :: * -> *).
    Monad m =>
    String
    -> [String]
    -> (ParseBuildTool, DependencyVersion)
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    toBuildTool String
    packageName_ [String]
    executableNames)([(ParseBuildTool, DependencyVersion)]
     -> WriterT
          [String] m [Either SystemBuildTool (BuildTool, DependencyVersion)])
    -> (BuildTools -> [(ParseBuildTool, DependencyVersion)])
    -> BuildTools
    -> WriterT
         [String] m [Either SystemBuildTool (BuildTool, DependencyVersion)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . BuildTools -> [(ParseBuildTool, DependencyVersion)]
    unBuildTools
          where
            mkSystemBuildTools :: [Either (String, VersionConstraint) b] -> SystemBuildTools
            mkSystemBuildTools :: [Either SystemBuildTool b] -> SystemBuildTools
    mkSystemBuildTools = Map String VersionConstraint -> SystemBuildTools
    SystemBuildTools (Map String VersionConstraint -> SystemBuildTools)
    -> ([Either SystemBuildTool b] -> Map String VersionConstraint)
    -> [Either SystemBuildTool b]
    -> SystemBuildTools
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [SystemBuildTool] -> Map String VersionConstraint
    forall k a. Ord k => [(k, a)] -> Map k a
    Map.fromList ([SystemBuildTool] -> Map String VersionConstraint)
    -> ([Either SystemBuildTool b] -> [SystemBuildTool])
    -> [Either SystemBuildTool b]
    -> Map String VersionConstraint
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Either SystemBuildTool b] -> [SystemBuildTool]
    forall a b. [Either a b] -> [a]
    lefts

            mkBuildTools :: [Either a (BuildTool, a)] -> Map BuildTool a
    mkBuildTools = [(BuildTool, a)] -> Map BuildTool a
    forall k a. Ord k => [(k, a)] -> Map k a
    Map.fromList ([(BuildTool, a)] -> Map BuildTool a)
    -> ([Either a (BuildTool, a)] -> [(BuildTool, a)])
    -> [Either a (BuildTool, a)]
    -> Map BuildTool a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Either a (BuildTool, a)] -> [(BuildTool, a)]
    forall a b. [Either a b] -> [b]
    rights

        toConditional :: Monad m => ConditionalSection CSources CxxSources JsSources a -> Warnings m (Conditional (Section a))
        toConditional :: ConditionalSection [Path] [Path] [Path] a
    -> Warnings m (Conditional (Section a))
    toConditional x :: ConditionalSection [Path] [Path] [Path] a
    x = case ConditionalSection [Path] [Path] [Path] a
    x of
          ThenElseConditional (Product (ThenElse then_ :: WithCommonOptions [Path] [Path] [Path] a
    then_ else_ :: WithCommonOptions [Path] [Path] [Path] a
    else_) c :: Condition
    c) -> Condition
    -> Section a -> Maybe (Section a) -> Conditional (Section a)
    forall a. Condition -> a -> Maybe a -> Conditional a
    conditional Condition
    c (Section a -> Maybe (Section a) -> Conditional (Section a))
    -> WriterT [String] m (Section a)
    -> WriterT
         [String] m (Maybe (Section a) -> Conditional (Section a))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (WithCommonOptions [Path] [Path] [Path] a
    -> WriterT [String] m (Section a)
    forall (m :: * -> *) a.
    Monad m =>
    Product (CommonOptions [Path] [Path] [Path] a) a
    -> WriterT [String] m (Section a)
    go WithCommonOptions [Path] [Path] [Path] a
    then_) WriterT [String] m (Maybe (Section a) -> Conditional (Section a))
    -> WriterT [String] m (Maybe (Section a))
    -> Warnings m (Conditional (Section a))
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Section a -> Maybe (Section a)
    forall a. a -> Maybe a
    Just (Section a -> Maybe (Section a))
    -> WriterT [String] m (Section a)
    -> WriterT [String] m (Maybe (Section a))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> WithCommonOptions [Path] [Path] [Path] a
    -> WriterT [String] m (Section a)
    forall (m :: * -> *) a.
    Monad m =>
    Product (CommonOptions [Path] [Path] [Path] a) a
    -> WriterT [String] m (Section a)
    go WithCommonOptions [Path] [Path] [Path] a
    else_)
          FlatConditional (Product sect :: WithCommonOptions [Path] [Path] [Path] a
    sect c :: Condition
    c) -> Condition
    -> Section a -> Maybe (Section a) -> Conditional (Section a)
    forall a. Condition -> a -> Maybe a -> Conditional a
    conditional Condition
    c (Section a -> Maybe (Section a) -> Conditional (Section a))
    -> WriterT [String] m (Section a)
    -> WriterT
         [String] m (Maybe (Section a) -> Conditional (Section a))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (WithCommonOptions [Path] [Path] [Path] a
    -> WriterT [String] m (Section a)
    forall (m :: * -> *) a.
    Monad m =>
    Product (CommonOptions [Path] [Path] [Path] a) a
    -> WriterT [String] m (Section a)
    go WithCommonOptions [Path] [Path] [Path] a
    sect) WriterT [String] m (Maybe (Section a) -> Conditional (Section a))
    -> WriterT [String] m (Maybe (Section a))
    -> Warnings m (Conditional (Section a))
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe (Section a) -> WriterT [String] m (Maybe (Section a))
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Maybe (Section a)
    forall a. Maybe a
    Nothing
          where
            conditional :: Condition -> a -> Maybe a -> Conditional a
    conditional (Condition (Cond c :: String
    c)) = String -> a -> Maybe a -> Conditional a
    forall a. String -> a -> Maybe a -> Conditional a
    Conditional String
    c

    type SystemBuildTool = (String, VersionConstraint)

    toBuildTool :: Monad m => String -> [String] -> (ParseBuildTool, DependencyVersion)
      -> Warnings m (Either SystemBuildTool (BuildTool, DependencyVersion))
    toBuildTool :: String
    -> [String]
    -> (ParseBuildTool, DependencyVersion)
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    toBuildTool packageName_ :: String
    packageName_ executableNames :: [String]
    executableNames = \ case
      (QualifiedBuildTool pkg :: String
    pkg executable :: String
    executable, v :: DependencyVersion
    v)
        | String
    pkg String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    packageName_ Bool -> Bool -> Bool
    && String
    executable String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    executableNames -> String
    -> DependencyVersion
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall (m :: * -> *) b a.
    Monad m =>
    String -> b -> m (Either a (BuildTool, b))
    localBuildTool String
    executable DependencyVersion
    v
        | Bool
    otherwise -> String
    -> String
    -> DependencyVersion
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall (m :: * -> *) b a.
    Monad m =>
    String -> String -> b -> m (Either a (BuildTool, b))
    buildTool String
    pkg String
    executable DependencyVersion
    v
      (UnqualifiedBuildTool executable :: String
    executable, v :: DependencyVersion
    v)
        | String
    executable String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    executableNames -> String
    -> DependencyVersion
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall (m :: * -> *) b a.
    Monad m =>
    String -> b -> m (Either a (BuildTool, b))
    localBuildTool String
    executable DependencyVersion
    v
        | Just pkg :: String
    pkg <- String -> [(String, String)] -> Maybe String
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup String
    executable [(String, String)]
    legacyTools -> String
    -> String
    -> DependencyVersion
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall (m :: * -> *) b a.
    Monad m =>
    String
    -> String -> b -> WriterT [String] m (Either a (BuildTool, b))
    legacyBuildTool String
    pkg String
    executable DependencyVersion
    v
        | String
    executable String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    legacySystemTools, DependencyVersion Nothing c :: VersionConstraint
    c <- DependencyVersion
    v -> String
    -> VersionConstraint
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall a b b.
    Show a =>
    a -> b -> WriterT [String] m (Either (a, b) b)
    legacySystemBuildTool String
    executable VersionConstraint
    c
        | Bool
    otherwise -> String
    -> String
    -> DependencyVersion
    -> Warnings
         m (Either SystemBuildTool (BuildTool, DependencyVersion))
    forall (m :: * -> *) b a.
    Monad m =>
    String -> String -> b -> m (Either a (BuildTool, b))
    buildTool String
    executable String
    executable DependencyVersion
    v
      where
        buildTool :: String -> String -> b -> m (Either a (BuildTool, b))
    buildTool pkg :: String
    pkg executable :: String
    executable v :: b
    v = Either a (BuildTool, b) -> m (Either a (BuildTool, b))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Either a (BuildTool, b) -> m (Either a (BuildTool, b)))
    -> ((BuildTool, b) -> Either a (BuildTool, b))
    -> (BuildTool, b)
    -> m (Either a (BuildTool, b))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (BuildTool, b) -> Either a (BuildTool, b)
    forall a b. b -> Either a b
    Right ((BuildTool, b) -> m (Either a (BuildTool, b)))
    -> (BuildTool, b) -> m (Either a (BuildTool, b))
    forall a b. (a -> b) -> a -> b
    $ (String -> String -> BuildTool
    BuildTool String
    pkg String
    executable, b
    v)

        systemBuildTool :: a -> WriterT [String] m (Either a b)
    systemBuildTool = Either a b -> WriterT [String] m (Either a b)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Either a b -> WriterT [String] m (Either a b))
    -> (a -> Either a b) -> a -> WriterT [String] m (Either a b)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Either a b
    forall a b. a -> Either a b
    Left

        localBuildTool :: String -> b -> m (Either a (BuildTool, b))
    localBuildTool executable :: String
    executable v :: b
    v = Either a (BuildTool, b) -> m (Either a (BuildTool, b))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Either a (BuildTool, b) -> m (Either a (BuildTool, b)))
    -> ((BuildTool, b) -> Either a (BuildTool, b))
    -> (BuildTool, b)
    -> m (Either a (BuildTool, b))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (BuildTool, b) -> Either a (BuildTool, b)
    forall a b. b -> Either a b
    Right ((BuildTool, b) -> m (Either a (BuildTool, b)))
    -> (BuildTool, b) -> m (Either a (BuildTool, b))
    forall a b. (a -> b) -> a -> b
    $ (String -> BuildTool
    LocalBuildTool String
    executable, b
    v)
        legacyBuildTool :: String
    -> String -> b -> WriterT [String] m (Either a (BuildTool, b))
    legacyBuildTool pkg :: String
    pkg executable :: String
    executable v :: b
    v = String -> String -> WriterT [String] m ()
    forall (m :: * -> *).
    Monad m =>
    String -> String -> WriterT [String] m ()
    warnLegacyTool String
    pkg String
    executable WriterT [String] m ()
    -> WriterT [String] m (Either a (BuildTool, b))
    -> WriterT [String] m (Either a (BuildTool, b))
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String
    -> String -> b -> WriterT [String] m (Either a (BuildTool, b))
    forall (m :: * -> *) b a.
    Monad m =>
    String -> String -> b -> m (Either a (BuildTool, b))
    buildTool String
    pkg String
    executable b
    v
        legacySystemBuildTool :: a -> b -> WriterT [String] m (Either (a, b) b)
    legacySystemBuildTool executable :: a
    executable c :: b
    c = a -> WriterT [String] m ()
    forall (m :: * -> *) a.
    (Monad m, Show a) =>
    a -> WriterT [String] m ()
    warnLegacySystemTool a
    executable WriterT [String] m ()
    -> WriterT [String] m (Either (a, b) b)
    -> WriterT [String] m (Either (a, b) b)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> (a, b) -> WriterT [String] m (Either (a, b) b)
    forall a b. a -> WriterT [String] m (Either a b)
    systemBuildTool (a
    executable, b
    c)

        legacyTools :: [(String, String)]
    legacyTools = [
            ("gtk2hsTypeGen", "gtk2hs-buildtools")
          , ("gtk2hsHookGenerator", "gtk2hs-buildtools")
          , ("gtk2hsC2hs", "gtk2hs-buildtools")
          , ("cabal", "cabal-install")
          , ("grgen", "cgen")
          , ("cgen-hs", "cgen")
          ]
        legacySystemTools :: [String]
    legacySystemTools = [
            "ghc"
          , "git"
          , "llvm-config"
          , "gfortran"
          , "gcc"
          , "couchdb"
          , "mcc"
          , "nix-store"
          , "nix-instantiate"
          , "nix-hash"
          , "nix-env"
          , "nix-build"
          ]
        warnLegacyTool :: String -> String -> WriterT [String] m ()
    warnLegacyTool pkg :: String
    pkg name :: String
    name = [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell ["Usage of the unqualified build-tool name " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ShowS
    forall a. Show a => a -> String
    show String
    name String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " is deprecated! Please use the qualified name \"" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    pkg String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ":" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    name String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "\" instead!"]
        warnLegacySystemTool :: a -> WriterT [String] m ()
    warnLegacySystemTool name :: a
    name = [String] -> WriterT [String] m ()
    forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
    tell ["Listing " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    name String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ " under build-tools is deperecated! Please list system executables under system-build-tools instead!"]

    pathsModuleFromPackageName :: String -> String
    pathsModuleFromPackageName :: ShowS
    pathsModuleFromPackageName name :: String
    name = "Paths_" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ (Char -> Char) -> ShowS
    forall a b. (a -> b) -> [a] -> [b]
    map Char -> Char
    f String
    name
      where
        f :: Char -> Char
    f '-' = '_'
        f x :: Char
    x = Char
    x

    getModules :: FilePath -> FilePath -> IO [String]
    getModules :: String -> String -> IO [String]
    getModules dir :: String
    dir src_ :: String
    src_ = [String] -> [String]
    sort ([String] -> [String]) -> IO [String] -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> do
      Bool
    exists <- String -> IO Bool
    doesDirectoryExist (String
    dir String -> ShowS
    </> String
    src_)
      if Bool
    exists
        then do
          String
    src <- String -> IO String
    canonicalizePath (String
    dir String -> ShowS
    </> String
    src_)
          String -> [String] -> [String]
    removeSetup String
    src ([String] -> [String])
    -> ([[String]] -> [String]) -> [[String]] -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [[String]] -> [String]
    toModules ([[String]] -> [String]) -> IO [[String]] -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> IO [[String]]
    getModuleFilesRecursive String
    src
        else [String] -> IO [String]
    forall (m :: * -> *) a. Monad m => a -> m a
    return []
      where
        toModules :: [[FilePath]] -> [String]
        toModules :: [[String]] -> [String]
    toModules = [Maybe String] -> [String]
    forall a. [Maybe a] -> [a]
    catMaybes ([Maybe String] -> [String])
    -> ([[String]] -> [Maybe String]) -> [[String]] -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([String] -> Maybe String) -> [[String]] -> [Maybe String]
    forall a b. (a -> b) -> [a] -> [b]
    map [String] -> Maybe String
    toModule

        removeSetup :: FilePath -> [String] -> [String]
        removeSetup :: String -> [String] -> [String]
    removeSetup src :: String
    src
          | String
    src String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    dir = (String -> Bool) -> [String] -> [String]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "Setup")
          | Bool
    otherwise = [String] -> [String]
    forall a. a -> a
    id