Skip to content

Commit

Permalink
Apply formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jgotoh committed Jun 2, 2023
1 parent afe419d commit 92c3e02
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 208 deletions.
5 changes: 1 addition & 4 deletions Cabal/src/Distribution/Simple/InstallDirs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ import Distribution.Compat.Prelude
import Prelude ()

import Distribution.Compat.Environment (lookupEnv)
import Distribution.Pretty
import Distribution.Package
import Distribution.Parsec
import Distribution.System
import Distribution.Compiler
import Distribution.Package
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Simple.InstallDirs.Internal
import Distribution.System
Expand Down
49 changes: 28 additions & 21 deletions cabal-install/src/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -747,32 +747,39 @@ readProjectFileSkeleton
extensionDescription = do
exists <- liftIO $ doesFileExist extensionFile
if exists
then do monitorFiles [monitorFileHashed extensionFile]
pcs <- liftIO $ readExtensionFile verbosity extensionFile
monitorFiles $ map monitorFileHashed (projectSkeletonImports pcs)
pure pcs
else do monitorFiles [monitorNonExistentFile extensionFile]
return mempty
where
extensionFile = distProjectFile extensionName
readExtensionFile = readAndParseFile Parsec.parseProjectSkeleton
then do
monitorFiles [monitorFileHashed extensionFile]
pcs <- liftIO $ readExtensionFile verbosity extensionFile
monitorFiles $ map monitorFileHashed (projectSkeletonImports pcs)
pure pcs
else do
monitorFiles [monitorNonExistentFile extensionFile]
return mempty
where
extensionFile = distProjectFile extensionName
readExtensionFile = readAndParseFile Parsec.parseProjectSkeleton

-- | Reads a named extended (with imports and conditionals) config file in the given project root dir, or returns empty.
--
readProjectFileSkeletonLegacy :: Verbosity -> HttpTransport -> DistDirLayout -> String -> String -> Rebuild ProjectConfigSkeleton
readProjectFileSkeletonLegacy verbosity httpTransport DistDirLayout{distProjectFile, distDownloadSrcDirectory}
extensionName extensionDescription = do
readProjectFileSkeletonLegacy
verbosity
httpTransport
DistDirLayout{distProjectFile, distDownloadSrcDirectory}
extensionName
extensionDescription = do
exists <- liftIO $ doesFileExist extensionFile
if exists
then do monitorFiles [monitorFileHashed extensionFile]
pcs <- liftIO readExtensionFile
monitorFiles $ map monitorFileHashed (projectSkeletonImports pcs)
pure pcs
else do monitorFiles [monitorNonExistentFile extensionFile]
return mempty
where
extensionFile = distProjectFile extensionName
readExtensionFile =
then do
monitorFiles [monitorFileHashed extensionFile]
pcs <- liftIO readExtensionFile
monitorFiles $ map monitorFileHashed (projectSkeletonImports pcs)
pure pcs
else do
monitorFiles [monitorNonExistentFile extensionFile]
return mempty
where
extensionFile = distProjectFile extensionName
readExtensionFile =
reportParseResult verbosity extensionDescription extensionFile
=<< parseProjectSkeleton distDownloadSrcDirectory httpTransport verbosity [] extensionFile
=<< BS.readFile extensionFile
Expand Down
75 changes: 38 additions & 37 deletions cabal-install/src/Distribution/Client/ProjectConfig/FieldGrammar.hs
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 cabal-install/src/Distribution/Client/ProjectConfig/Lens.hs
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' #-}
Loading

0 comments on commit 92c3e02

Please sign in to comment.