-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
230 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 38 additions & 37 deletions
75
cabal-install/src/Distribution/Client/ProjectConfig/FieldGrammar.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,54 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
-- | 'ProjectConfig' Field descriptions | ||
module Distribution.Client.ProjectConfig.FieldGrammar ( | ||
projectConfigFieldGrammar | ||
module Distribution.Client.ProjectConfig.FieldGrammar | ||
( projectConfigFieldGrammar | ||
) where | ||
|
||
import Distribution.Compat.Prelude | ||
import qualified Distribution.Client.ProjectConfig.Lens as L | ||
import Distribution.Client.ProjectConfig.Types (ProjectConfig (..), ProjectConfigBuildOnly (..)) | ||
import Distribution.Client.Utils.Parsec | ||
import Distribution.Compat.Prelude | ||
import Distribution.FieldGrammar | ||
import Distribution.Simple.Flag | ||
import Distribution.Types.PackageVersionConstraint (PackageVersionConstraint (..)) | ||
import Distribution.Verbosity | ||
import Distribution.Client.Utils.Parsec | ||
|
||
|
||
projectConfigFieldGrammar :: ParsecFieldGrammar' ProjectConfig | ||
projectConfigFieldGrammar = ProjectConfig | ||
<$> monoidalFieldAla "packages" (alaList' FSep Token') L.projectPackages | ||
<*> monoidalFieldAla "optional-packages" (alaList' FSep Token') L.projectPackagesOptional | ||
<*> pure mempty -- source-repository-package stanza | ||
<*> monoidalFieldAla "extra-packages" formatPackagesNamedList L.projectPackagesNamed | ||
<*> blurFieldGrammar L.projectConfigBuildOnly projectConfigBuildOnlyFieldGrammar | ||
<*> pure mempty | ||
<*> pure mempty | ||
<*> pure mempty | ||
<*> pure mempty | ||
<*> pure mempty | ||
projectConfigFieldGrammar = | ||
ProjectConfig | ||
<$> monoidalFieldAla "packages" (alaList' FSep Token') L.projectPackages | ||
<*> monoidalFieldAla "optional-packages" (alaList' FSep Token') L.projectPackagesOptional | ||
<*> pure mempty -- source-repository-package stanza | ||
<*> monoidalFieldAla "extra-packages" formatPackagesNamedList L.projectPackagesNamed | ||
<*> blurFieldGrammar L.projectConfigBuildOnly projectConfigBuildOnlyFieldGrammar | ||
<*> pure mempty | ||
<*> pure mempty | ||
<*> pure mempty | ||
<*> pure mempty | ||
<*> pure mempty | ||
|
||
formatPackagesNamedList :: [PackageVersionConstraint] -> List CommaVCat (Identity PackageVersionConstraint) PackageVersionConstraint | ||
formatPackagesNamedList = alaList CommaVCat | ||
|
||
projectConfigBuildOnlyFieldGrammar :: ParsecFieldGrammar' ProjectConfigBuildOnly | ||
projectConfigBuildOnlyFieldGrammar = ProjectConfigBuildOnly | ||
<$> optionalFieldDef "verbose" L.projectConfigVerbosity (pure normal) | ||
<*> pure (toFlag False) -- cli flag: projectConfigDryRun | ||
<*> pure (toFlag False) -- cli flag: projectConfigOnlyDeps | ||
<*> pure (toFlag False) -- cli flag: projectConfigOnlyDownload | ||
<*> monoidalFieldAla "build-summary" (alaNubList VCat) L.projectConfigSummaryFile | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
|
||
projectConfigBuildOnlyFieldGrammar = | ||
ProjectConfigBuildOnly | ||
<$> optionalFieldDef "verbose" L.projectConfigVerbosity (pure normal) | ||
<*> pure (toFlag False) -- cli flag: projectConfigDryRun | ||
<*> pure (toFlag False) -- cli flag: projectConfigOnlyDeps | ||
<*> pure (toFlag False) -- cli flag: projectConfigOnlyDownload | ||
<*> monoidalFieldAla "build-summary" (alaNubList VCat) L.projectConfigSummaryFile | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined | ||
<*> undefined |
87 changes: 50 additions & 37 deletions
87
cabal-install/src/Distribution/Client/ProjectConfig/Lens.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,83 @@ | ||
module Distribution.Client.ProjectConfig.Lens where | ||
|
||
import Distribution.Compat.Prelude | ||
import Distribution.Client.ProjectConfig.Types (ProjectConfig (..), ProjectConfigBuildOnly (..), ProjectConfigShared, ProjectConfigProvenance, PackageConfig, MapMappend) | ||
import Distribution.Compat.Lens | ||
import Distribution.Client.Types.SourceRepo (SourceRepoList) | ||
import Distribution.Client.ProjectConfig.Types (MapMappend, PackageConfig, ProjectConfig (..), ProjectConfigBuildOnly (..), ProjectConfigProvenance, ProjectConfigShared) | ||
import qualified Distribution.Client.ProjectConfig.Types as T | ||
import Distribution.Client.Types.SourceRepo (SourceRepoList) | ||
import Distribution.Compat.Lens | ||
import Distribution.Compat.Prelude | ||
import Distribution.Package | ||
( PackageName, PackageId, UnitId ) | ||
( PackageId | ||
, PackageName | ||
, UnitId | ||
) | ||
import Distribution.Simple.InstallDirs | ||
( InstallDirs | ||
, PathTemplate | ||
) | ||
import Distribution.Simple.Setup | ||
( Flag, HaddockTarget(..), TestShowDetails(..), DumpBuildInfo (..) ) | ||
( DumpBuildInfo (..) | ||
, Flag | ||
, HaddockTarget (..) | ||
, TestShowDetails (..) | ||
) | ||
import Distribution.Types.PackageVersionConstraint | ||
( PackageVersionConstraint ) | ||
import Distribution.Verbosity | ||
import Distribution.Simple.InstallDirs | ||
( PathTemplate, InstallDirs ) | ||
( PackageVersionConstraint | ||
) | ||
import Distribution.Utils.NubList | ||
( NubList, toNubList, fromNubList ) | ||
( NubList | ||
, fromNubList | ||
, toNubList | ||
) | ||
import Distribution.Verbosity | ||
|
||
projectPackages :: Lens' ProjectConfig [String] | ||
projectPackages f s = fmap (\x -> s { T.projectPackages = x }) (f (T.projectPackages s)) | ||
{-# INLINABLE projectPackages #-} | ||
projectPackages f s = fmap (\x -> s{T.projectPackages = x}) (f (T.projectPackages s)) | ||
{-# INLINEABLE projectPackages #-} | ||
|
||
projectPackagesOptional :: Lens' ProjectConfig [String] | ||
projectPackagesOptional f s = fmap (\x -> s { T.projectPackagesOptional = x }) (f (T.projectPackagesOptional s)) | ||
{-# INLINABLE projectPackagesOptional #-} | ||
projectPackagesOptional f s = fmap (\x -> s{T.projectPackagesOptional = x}) (f (T.projectPackagesOptional s)) | ||
{-# INLINEABLE projectPackagesOptional #-} | ||
|
||
projectPackagesRepo :: Lens' ProjectConfig [SourceRepoList] | ||
projectPackagesRepo f s = fmap (\x -> s { T.projectPackagesRepo = x }) (f (T.projectPackagesRepo s)) | ||
{-# INLINABLE projectPackagesRepo #-} | ||
projectPackagesRepo f s = fmap (\x -> s{T.projectPackagesRepo = x}) (f (T.projectPackagesRepo s)) | ||
{-# INLINEABLE projectPackagesRepo #-} | ||
|
||
projectPackagesNamed :: Lens' ProjectConfig [PackageVersionConstraint] | ||
projectPackagesNamed f s = fmap (\x -> s { T.projectPackagesNamed = x }) (f (T.projectPackagesNamed s)) | ||
{-# INLINABLE projectPackagesNamed #-} | ||
projectPackagesNamed f s = fmap (\x -> s{T.projectPackagesNamed = x}) (f (T.projectPackagesNamed s)) | ||
{-# INLINEABLE projectPackagesNamed #-} | ||
|
||
projectConfigBuildOnly :: Lens' ProjectConfig ProjectConfigBuildOnly | ||
projectConfigBuildOnly f s = fmap (\x -> s { T.projectConfigBuildOnly = x }) (f (T.projectConfigBuildOnly s)) | ||
{-# INLINABLE projectConfigBuildOnly #-} | ||
projectConfigBuildOnly f s = fmap (\x -> s{T.projectConfigBuildOnly = x}) (f (T.projectConfigBuildOnly s)) | ||
{-# INLINEABLE projectConfigBuildOnly #-} | ||
|
||
projectConfigShared :: Lens' ProjectConfig ProjectConfigShared | ||
projectConfigShared f s = fmap (\x -> s { T.projectConfigShared = x }) (f (T.projectConfigShared s)) | ||
{-# INLINABLE projectConfigShared #-} | ||
projectConfigShared f s = fmap (\x -> s{T.projectConfigShared = x}) (f (T.projectConfigShared s)) | ||
{-# INLINEABLE projectConfigShared #-} | ||
|
||
projectConfigProvenance :: Lens' ProjectConfig (Set ProjectConfigProvenance) | ||
projectConfigProvenance f s = fmap (\x -> s { T.projectConfigProvenance = x }) (f (T.projectConfigProvenance s)) | ||
{-# INLINABLE projectConfigProvenance #-} | ||
projectConfigProvenance f s = fmap (\x -> s{T.projectConfigProvenance = x}) (f (T.projectConfigProvenance s)) | ||
{-# INLINEABLE projectConfigProvenance #-} | ||
|
||
projectConfigAllPackages :: Lens' ProjectConfig PackageConfig | ||
projectConfigAllPackages f s = fmap (\x -> s { T.projectConfigAllPackages = x }) (f (T.projectConfigAllPackages s)) | ||
{-# INLINABLE projectConfigAllPackages #-} | ||
projectConfigAllPackages f s = fmap (\x -> s{T.projectConfigAllPackages = x}) (f (T.projectConfigAllPackages s)) | ||
{-# INLINEABLE projectConfigAllPackages #-} | ||
|
||
projectConfigLocalPackages :: Lens' ProjectConfig PackageConfig | ||
projectConfigLocalPackages f s = fmap (\x -> s { T.projectConfigLocalPackages = x }) (f (T.projectConfigLocalPackages s)) | ||
{-# INLINABLE projectConfigLocalPackages #-} | ||
projectConfigLocalPackages f s = fmap (\x -> s{T.projectConfigLocalPackages = x}) (f (T.projectConfigLocalPackages s)) | ||
{-# INLINEABLE projectConfigLocalPackages #-} | ||
|
||
projectConfigSpecificPackage :: Lens' ProjectConfig (MapMappend PackageName PackageConfig) | ||
projectConfigSpecificPackage f s = fmap (\x -> s { T.projectConfigSpecificPackage = x }) (f (T.projectConfigSpecificPackage s)) | ||
{-# INLINABLE projectConfigSpecificPackage #-} | ||
projectConfigSpecificPackage f s = fmap (\x -> s{T.projectConfigSpecificPackage = x}) (f (T.projectConfigSpecificPackage s)) | ||
{-# INLINEABLE projectConfigSpecificPackage #-} | ||
|
||
projectConfigVerbosity :: Lens' ProjectConfigBuildOnly (Flag Verbosity) | ||
projectConfigVerbosity f s = fmap (\x -> s { T.projectConfigVerbosity = x }) (f (T.projectConfigVerbosity s)) | ||
{-# INLINABLE projectConfigVerbosity #-} | ||
projectConfigVerbosity f s = fmap (\x -> s{T.projectConfigVerbosity = x}) (f (T.projectConfigVerbosity s)) | ||
{-# INLINEABLE projectConfigVerbosity #-} | ||
|
||
projectConfigSummaryFile :: Lens' ProjectConfigBuildOnly (NubList PathTemplate) | ||
projectConfigSummaryFile f s = fmap (\x -> s { T.projectConfigSummaryFile = x }) (f (T.projectConfigSummaryFile s)) | ||
{-# INLINABLE projectConfigSummaryFile #-} | ||
projectConfigSummaryFile f s = fmap (\x -> s{T.projectConfigSummaryFile = x}) (f (T.projectConfigSummaryFile s)) | ||
{-# INLINEABLE projectConfigSummaryFile #-} | ||
|
||
projectConfigSummaryFile' :: Lens' ProjectConfigBuildOnly [PathTemplate] | ||
projectConfigSummaryFile' f s = fmap (\x -> s { T.projectConfigSummaryFile = toNubList x }) (f (fromNubList $ T.projectConfigSummaryFile s)) | ||
{-# INLINABLE projectConfigSummaryFile' #-} | ||
projectConfigSummaryFile' f s = fmap (\x -> s{T.projectConfigSummaryFile = toNubList x}) (f (fromNubList $ T.projectConfigSummaryFile s)) | ||
{-# INLINEABLE projectConfigSummaryFile' #-} |
Oops, something went wrong.