{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Distribution.PackageDescription.Check
(
CheckExplanation (..)
, CheckExplanationID
, CheckExplanationIDString
, PackageCheck (..)
, checkPackage
, checkConfiguredPackage
, wrapParseWarning
, ppPackageCheck
, ppCheckExplanationId
, isHackageDistError
, filterPackageChecksById
, filterPackageChecksByIdString
, checkPackageFiles
, checkPackageFilesGPD
, checkPackageContent
, CheckPackageContentOps (..)
) where
import Distribution.Compat.Prelude
import Prelude ()
import Data.List (group)
import Distribution.CabalSpecVersion
import Distribution.Compat.Lens
import Distribution.Compiler
import Distribution.License
import Distribution.Package
import Distribution.PackageDescription
import Distribution.PackageDescription.Check.Common
import Distribution.PackageDescription.Check.Conditional
import Distribution.PackageDescription.Check.Monad
import Distribution.PackageDescription.Check.Paths
import Distribution.PackageDescription.Check.Target
import Distribution.PackageDescription.Check.Warning
import Distribution.Parsec.Warning (PWarning)
import Distribution.Pretty (prettyShow)
import Distribution.Simple.Glob
( Glob
, GlobResult (..)
, globMatches
, parseFileGlob
, runDirFileGlob
)
import Distribution.Simple.Utils hiding (findPackageDesc, notice)
import Distribution.Utils.Generic (isAscii)
import Distribution.Utils.Path
import Distribution.Verbosity
import Distribution.Version
import System.FilePath (splitExtension, takeFileName)
import qualified Data.ByteString.Lazy as BS
import qualified Distribution.SPDX as SPDX
import qualified System.Directory as System
import qualified System.Directory (getDirectoryContents)
import qualified System.FilePath.Windows as FilePath.Windows (isValid)
import qualified Data.Set as Set
import qualified Distribution.Utils.ShortText as ShortText
import qualified Distribution.Types.GenericPackageDescription.Lens as L
import Control.Monad
checkPackagePrim
:: Monad m
=> Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim :: forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
b Maybe (CheckPackageContentOps m)
mco Maybe (CheckPreDistributionOps m)
mpdo GenericPackageDescription
gpd = do
let cm :: CheckM m ()
cm = GenericPackageDescription -> CheckM m ()
forall (m :: * -> *).
Monad m =>
GenericPackageDescription -> CheckM m ()
checkGenericPackageDescription GenericPackageDescription
gpd
ci :: CheckInterface m
ci = Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> CheckInterface m
forall (m :: * -> *).
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> CheckInterface m
CheckInterface Bool
b Maybe (CheckPackageContentOps m)
mco Maybe (CheckPreDistributionOps m)
mpdo
ctx :: CheckCtx m
ctx = CheckInterface m -> GenericPackageDescription -> CheckCtx m
forall (m :: * -> *).
Monad m =>
CheckInterface m -> GenericPackageDescription -> CheckCtx m
pristineCheckCtx CheckInterface m
ci GenericPackageDescription
gpd
CheckM m () -> CheckCtx m -> m [PackageCheck]
forall (m :: * -> *).
Monad m =>
CheckM m () -> CheckCtx m -> m [PackageCheck]
execCheckM CheckM m ()
cm CheckCtx m
ctx
checkPackage :: GenericPackageDescription -> [PackageCheck]
checkPackage :: GenericPackageDescription -> [PackageCheck]
checkPackage GenericPackageDescription
gpd = Identity [PackageCheck] -> [PackageCheck]
forall a. Identity a -> a
runIdentity (Identity [PackageCheck] -> [PackageCheck])
-> Identity [PackageCheck] -> [PackageCheck]
forall a b. (a -> b) -> a -> b
$ Bool
-> Maybe (CheckPackageContentOps Identity)
-> Maybe (CheckPreDistributionOps Identity)
-> GenericPackageDescription
-> Identity [PackageCheck]
forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
True Maybe (CheckPackageContentOps Identity)
forall a. Maybe a
Nothing Maybe (CheckPreDistributionOps Identity)
forall a. Maybe a
Nothing GenericPackageDescription
gpd
checkConfiguredPackage :: PackageDescription -> [PackageCheck]
checkConfiguredPackage :: PackageDescription -> [PackageCheck]
checkConfiguredPackage PackageDescription
pd = GenericPackageDescription -> [PackageCheck]
checkPackage (PackageDescription -> GenericPackageDescription
pd2gpd PackageDescription
pd)
checkPackageContent
:: Monad m
=> CheckPackageContentOps m
-> GenericPackageDescription
-> m [PackageCheck]
checkPackageContent :: forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m
-> GenericPackageDescription -> m [PackageCheck]
checkPackageContent CheckPackageContentOps m
pops GenericPackageDescription
gpd = Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
False (CheckPackageContentOps m -> Maybe (CheckPackageContentOps m)
forall a. a -> Maybe a
Just CheckPackageContentOps m
pops) Maybe (CheckPreDistributionOps m)
forall a. Maybe a
Nothing GenericPackageDescription
gpd
checkPackageFilesGPD
:: Verbosity
-> GenericPackageDescription
-> FilePath
-> IO [PackageCheck]
checkPackageFilesGPD :: Verbosity
-> GenericPackageDescription -> String -> IO [PackageCheck]
checkPackageFilesGPD Verbosity
verbosity GenericPackageDescription
gpd String
root =
Bool
-> Maybe (CheckPackageContentOps IO)
-> Maybe (CheckPreDistributionOps IO)
-> GenericPackageDescription
-> IO [PackageCheck]
forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
False (CheckPackageContentOps IO -> Maybe (CheckPackageContentOps IO)
forall a. a -> Maybe a
Just CheckPackageContentOps IO
checkFilesIO) (CheckPreDistributionOps IO -> Maybe (CheckPreDistributionOps IO)
forall a. a -> Maybe a
Just CheckPreDistributionOps IO
checkPreIO) GenericPackageDescription
gpd
where
checkFilesIO :: CheckPackageContentOps IO
checkFilesIO =
CheckPackageContentOps
{ doesFileExist :: String -> IO Bool
doesFileExist = String -> IO Bool
System.doesFileExist (String -> IO Bool) -> (String -> String) -> String -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
, doesDirectoryExist :: String -> IO Bool
doesDirectoryExist = String -> IO Bool
System.doesDirectoryExist (String -> IO Bool) -> (String -> String) -> String -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
, getDirectoryContents :: String -> IO [String]
getDirectoryContents = String -> IO [String]
System.Directory.getDirectoryContents (String -> IO [String])
-> (String -> String) -> String -> IO [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
, getFileContents :: String -> IO ByteString
getFileContents = String -> IO ByteString
BS.readFile (String -> IO ByteString)
-> (String -> String) -> String -> IO ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
}
checkPreIO :: CheckPreDistributionOps IO
checkPreIO =
CheckPreDistributionOps
{ runDirFileGlobM :: String -> Glob -> IO [GlobResult String]
runDirFileGlobM = \String
fp Glob
g -> Verbosity
-> Maybe CabalSpecVersion
-> String
-> Glob
-> IO [GlobResult String]
runDirFileGlob Verbosity
verbosity (CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just (CabalSpecVersion -> Maybe CabalSpecVersion)
-> (PackageDescription -> CabalSpecVersion)
-> PackageDescription
-> Maybe CabalSpecVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageDescription -> CabalSpecVersion
specVersion (PackageDescription -> Maybe CabalSpecVersion)
-> PackageDescription -> Maybe CabalSpecVersion
forall a b. (a -> b) -> a -> b
$ GenericPackageDescription -> PackageDescription
packageDescription GenericPackageDescription
gpd) (String
root String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
fp) Glob
g
, getDirectoryContentsM :: String -> IO [String]
getDirectoryContentsM = String -> IO [String]
System.Directory.getDirectoryContents (String -> IO [String])
-> (String -> String) -> String -> IO [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
}
relative :: FilePath -> FilePath
relative :: String -> String
relative String
path = String
root String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
path
checkPackageFiles
:: Verbosity
-> PackageDescription
-> FilePath
-> IO [PackageCheck]
checkPackageFiles :: Verbosity -> PackageDescription -> String -> IO [PackageCheck]
checkPackageFiles Verbosity
verbosity PackageDescription
pd String
oot =
Verbosity
-> GenericPackageDescription -> String -> IO [PackageCheck]
checkPackageFilesGPD Verbosity
verbosity (PackageDescription -> GenericPackageDescription
pd2gpd PackageDescription
pd) String
oot
checkGenericPackageDescription
:: Monad m
=> GenericPackageDescription
-> CheckM m ()
checkGenericPackageDescription :: forall (m :: * -> *).
Monad m =>
GenericPackageDescription -> CheckM m ()
checkGenericPackageDescription
gpd :: GenericPackageDescription
gpd@( GenericPackageDescription
PackageDescription
packageDescription_
Maybe Version
_gpdScannedVersion_
[PackageFlag]
genPackageFlags_
Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
condForeignLibs_
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
condExecutables_
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites_
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
condBenchmarks_
) =
do
PackageDescription -> CheckM m ()
forall (m :: * -> *). Monad m => PackageDescription -> CheckM m ()
checkPackageDescription PackageDescription
packageDescription_
let condAllLibraries :: [CondTree ConfVar [Dependency] Library]
condAllLibraries =
Maybe (CondTree ConfVar [Dependency] Library)
-> [CondTree ConfVar [Dependency] Library]
forall a. Maybe a -> [a]
maybeToList Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_
[CondTree ConfVar [Dependency] Library]
-> [CondTree ConfVar [Dependency] Library]
-> [CondTree ConfVar [Dependency] Library]
forall a. [a] -> [a] -> [a]
++ (((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CondTree ConfVar [Dependency] Library)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> [CondTree ConfVar [Dependency] Library]
forall a b. (a -> b) -> [a] -> [b]
map (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CondTree ConfVar [Dependency] Library
forall a b. (a, b) -> b
snd [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and
[ [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
condExecutables_
, [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites_
, [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
condBenchmarks_
, [CondTree ConfVar [Dependency] Library] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [CondTree ConfVar [Dependency] Library]
condAllLibraries
, [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
condForeignLibs_
]
)
(CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoTarget)
(nsubs, nexes, ntests, nbenchs) <-
(CheckCtx m
-> ([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName]))
-> CheckM
m
([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName])
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM
( ( \PNames
n ->
( PNames -> [UnqualComponentName]
pnSubLibs PNames
n
, PNames -> [UnqualComponentName]
pnExecs PNames
n
, PNames -> [UnqualComponentName]
pnTests PNames
n
, PNames -> [UnqualComponentName]
pnBenchs PNames
n
)
)
(PNames
-> ([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName]))
-> (CheckCtx m -> PNames)
-> CheckCtx m
-> ([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CheckCtx m -> PNames
forall (m :: * -> *). CheckCtx m -> PNames
ccNames
)
let names = [[UnqualComponentName]] -> [UnqualComponentName]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[UnqualComponentName]
nsubs, [UnqualComponentName]
nexes, [UnqualComponentName]
ntests, [UnqualComponentName]
nbenchs]
dupes = [UnqualComponentName] -> [UnqualComponentName]
forall a. Ord a => [a] -> [a]
dups [UnqualComponentName]
names
checkP
(not . null $ dups names)
(PackageBuildImpossible $ DuplicateSections dupes)
checkPackageDescription packageDescription_
mapM_ checkFlagName genPackageFlags_
checkSpecVer
CabalSpecV2_0
(not . null $ condSubLibraries_)
(PackageDistInexcusable CVMultiLib)
checkSpecVer
CabalSpecV1_8
(not . null $ condTestSuites_)
(PackageDistInexcusable CVTestSuite)
pName <-
asksCM
( packageNameToUnqualComponentName
. pkgName
. pnPackageId
. ccNames
)
let ads =
[AssocDep]
-> (CondTree ConfVar [Dependency] Library -> [AssocDep])
-> Maybe (CondTree ConfVar [Dependency] Library)
-> [AssocDep]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((AssocDep -> [AssocDep] -> [AssocDep]
forall a. a -> [a] -> [a]
: []) (AssocDep -> [AssocDep])
-> (CondTree ConfVar [Dependency] Library -> AssocDep)
-> CondTree ConfVar [Dependency] Library
-> [AssocDep]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnqualComponentName
-> CondTree ConfVar [Dependency] Library -> AssocDep
extractAssocDeps UnqualComponentName
pName) Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_
[AssocDep] -> [AssocDep] -> [AssocDep]
forall a. [a] -> [a] -> [a]
++ ((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> AssocDep)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> [AssocDep]
forall a b. (a -> b) -> [a] -> [b]
map ((UnqualComponentName
-> CondTree ConfVar [Dependency] Library -> AssocDep)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> AssocDep
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry UnqualComponentName
-> CondTree ConfVar [Dependency] Library -> AssocDep
extractAssocDeps) [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_
case condLibrary_ of
Just CondTree ConfVar [Dependency] Library
cl ->
[PackageFlag]
-> (Library -> CheckM m ())
-> (UnqualComponentName -> Library -> Library)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
(Bool -> [AssocDep] -> Library -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> [AssocDep] -> Library -> CheckM m ()
checkLibrary Bool
False [AssocDep]
ads)
((Library -> Library) -> UnqualComponentName -> Library -> Library
forall a b. a -> b -> a
const Library -> Library
forall a. a -> a
id)
(UnqualComponentName
forall a. Monoid a => a
mempty, CondTree ConfVar [Dependency] Library
cl)
Maybe (CondTree ConfVar [Dependency] Library)
Nothing -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
mapM_
( checkCondTarget
genPackageFlags_
(checkLibrary False ads)
(\UnqualComponentName
u Library
l -> Library
l{libName = maybeToLibraryName (Just u)})
)
condSubLibraries_
mapM_
( checkCondTarget
genPackageFlags_
checkForeignLib
(const id)
)
condForeignLibs_
mapM_
( checkCondTarget
genPackageFlags_
(checkExecutable ads)
(const id)
)
condExecutables_
mapM_
( checkCondTarget
genPackageFlags_
(checkTestSuite ads)
(\UnqualComponentName
u TestSuite
l -> TestSuite
l{testName = u})
)
condTestSuites_
mapM_
( checkCondTarget
genPackageFlags_
(checkBenchmark ads)
(\UnqualComponentName
u Benchmark
l -> Benchmark
l{benchmarkName = u})
)
condBenchmarks_
checkP
(decFlags /= usedFlags)
(PackageDistSuspicious $ DeclaredUsedFlags decFlags usedFlags)
mapM_ tellP (checkDuplicateModules gpd)
where
checkFlagName :: Monad m => PackageFlag -> CheckM m ()
checkFlagName :: forall (m :: * -> *). Monad m => PackageFlag -> CheckM m ()
checkFlagName PackageFlag
pf =
let fn :: String
fn = FlagName -> String
unFlagName (FlagName -> String)
-> (PackageFlag -> FlagName) -> PackageFlag -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageFlag -> FlagName
flagName (PackageFlag -> String) -> PackageFlag -> String
forall a b. (a -> b) -> a -> b
$ PackageFlag
pf
invalidFlagName :: String -> Bool
invalidFlagName (Char
'-' : String
_) = Bool
True
invalidFlagName String
cs = (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
isAscii) String
cs
in Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(String -> Bool
invalidFlagName String
fn)
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [String] -> CheckExplanation
SuspiciousFlagName [String
fn])
decFlags :: Set.Set FlagName
decFlags :: Set FlagName
decFlags = Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[PackageFlag]
[PackageFlag]
Lens' GenericPackageDescription [PackageFlag]
L.genPackageFlags LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[PackageFlag]
[PackageFlag]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [PackageFlag] -> Const (Set FlagName) [PackageFlag])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PackageFlag -> Const (Set FlagName) PackageFlag)
-> [PackageFlag] -> Const (Set FlagName) [PackageFlag]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((PackageFlag -> Const (Set FlagName) PackageFlag)
-> [PackageFlag] -> Const (Set FlagName) [PackageFlag])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> PackageFlag -> Const (Set FlagName) PackageFlag)
-> (FlagName -> Const (Set FlagName) FlagName)
-> [PackageFlag]
-> Const (Set FlagName) [PackageFlag]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> PackageFlag -> Const (Set FlagName) PackageFlag
Lens' PackageFlag FlagName
L.flagName) GenericPackageDescription
gpd
usedFlags :: Set.Set FlagName
usedFlags :: Set FlagName
usedFlags =
[Set FlagName] -> Set FlagName
forall a. Monoid a => [a] -> a
mconcat
[ Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
(Maybe (CondTree ConfVar [Dependency] Library))
(Maybe (CondTree ConfVar [Dependency] Library))
Lens'
GenericPackageDescription
(Maybe (CondTree ConfVar [Dependency] Library))
L.condLibrary LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
(Maybe (CondTree ConfVar [Dependency] Library))
(Maybe (CondTree ConfVar [Dependency] Library))
-> ((FlagName -> Const (Set FlagName) FlagName)
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library)))
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse ((CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library)))
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> (FlagName -> Const (Set FlagName) FlagName)
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
L.condSubLibraries LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
L.condForeignLibs LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] ForeignLib
-> Const (Set FlagName) (CondTree ConfVar [Dependency] ForeignLib))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] ForeignLib
-> Const (Set FlagName) (CondTree ConfVar [Dependency] ForeignLib)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
L.condExecutables LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Executable
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Executable))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Executable
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Executable)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
L.condTestSuites LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] TestSuite
-> Const (Set FlagName) (CondTree ConfVar [Dependency] TestSuite))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] TestSuite
-> Const (Set FlagName) (CondTree ConfVar [Dependency] TestSuite)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
L.condBenchmarks LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Benchmark
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Benchmark))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Benchmark
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Benchmark)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
]
checkPackageDescription :: Monad m => PackageDescription -> CheckM m ()
checkPackageDescription :: forall (m :: * -> *). Monad m => PackageDescription -> CheckM m ()
checkPackageDescription
pkg :: PackageDescription
pkg@( PackageDescription
CabalSpecVersion
specVersion_
PackageIdentifier
package_
Either License License
licenseRaw_
[RelativePath Pkg 'File]
licenseFiles_
ShortText
_copyright_
ShortText
maintainer_
ShortText
_author_
ShortText
_stability_
[(CompilerFlavor, VersionRange)]
testedWith_
ShortText
_homepage_
ShortText
_pkgUrl_
ShortText
_bugReports_
[SourceRepo]
sourceRepos_
ShortText
synopsis_
ShortText
description_
ShortText
category_
[(String, String)]
customFieldsPD_
Maybe BuildType
buildTypeRaw_
Maybe SetupBuildInfo
setupBuildInfo_
Maybe Library
_library_
[Library]
_subLibraries_
[Executable]
_executables_
[ForeignLib]
_foreignLibs_
[TestSuite]
_testSuites_
[Benchmark]
_benchmarks_
[RelativePath DataDir 'File]
dataFiles_
SymbolicPath Pkg ('Dir DataDir)
dataDir_
[RelativePath Pkg 'File]
extraSrcFiles_
[RelativePath Pkg 'File]
extraTmpFiles_
[RelativePath Pkg 'File]
extraDocFiles_
[RelativePath Pkg 'File]
extraFiles_
) = do
PackageIdentifier -> CheckM m ()
forall (m :: * -> *). Monad m => PackageIdentifier -> CheckM m ()
checkPackageId PackageIdentifier
package_
let pn :: PackageName
pn = PackageIdentifier -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageIdentifier
package_
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (String -> Bool) -> (PackageName -> String) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> String
unPackageName (PackageName -> Bool) -> PackageName -> Bool
forall a b. (a -> b) -> a -> b
$ PackageName
pn)
(CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoNameField)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Version
nullVersion Version -> Version -> Bool
forall a. Eq a => a -> a -> Bool
== PackageIdentifier -> Version
forall pkg. Package pkg => pkg -> Version
packageVersion PackageIdentifier
package_)
(CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoVersionField)
nsubs <- (CheckCtx m -> [UnqualComponentName])
-> CheckM m [UnqualComponentName]
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM (PNames -> [UnqualComponentName]
pnSubLibs (PNames -> [UnqualComponentName])
-> (CheckCtx m -> PNames) -> CheckCtx m -> [UnqualComponentName]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CheckCtx m -> PNames
forall (m :: * -> *). CheckCtx m -> PNames
ccNames)
checkP
(any (== prettyShow pn) (prettyShow <$> nsubs))
(PackageBuildImpossible $ IllegalLibraryName pn)
checkNull
category_
(PackageDistSuspicious MissingFieldCategory)
checkNull
maintainer_
(PackageDistSuspicious MissingFieldMaintainer)
checkP
(ShortText.null synopsis_ && not (ShortText.null description_))
(PackageDistSuspicious MissingFieldSynopsis)
checkP
(ShortText.null description_ && not (ShortText.null synopsis_))
(PackageDistSuspicious MissingFieldDescription)
checkP
(all ShortText.null [synopsis_, description_])
(PackageDistInexcusable MissingFieldSynOrDesc)
checkP
(ShortText.length synopsis_ > 80)
(PackageDistSuspicious SynopsisTooLong)
checkP
( not (ShortText.null description_)
&& ShortText.length description_ <= ShortText.length synopsis_
)
(PackageDistSuspicious ShortDesc)
mapM_ (checkPath False "extra-source-files" PathKindGlob . getSymbolicPath) extraSrcFiles_
mapM_ (checkPath False "extra-tmp-files" PathKindFile . getSymbolicPath) extraTmpFiles_
mapM_ (checkPath False "extra-doc-files" PathKindGlob . getSymbolicPath) extraDocFiles_
mapM_ (checkPath False "extra-files" PathKindGlob . getSymbolicPath) extraFiles_
mapM_ (checkPath False "data-files" PathKindGlob . getSymbolicPath) dataFiles_
let rawDataDir = SymbolicPath Pkg ('Dir DataDir) -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath SymbolicPath Pkg ('Dir DataDir)
dataDir_
checkPath True "data-dir" PathKindDirectory rawDataDir
let licPaths = (RelativePath Pkg 'File -> String)
-> [RelativePath Pkg 'File] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath [RelativePath Pkg 'File]
licenseFiles_
mapM_ (checkPath False "license-file" PathKindFile) licPaths
mapM_ checkLicFileExist licenseFiles_
dataGlobs <- mapM (checkGlob "data-files" . getSymbolicPath) dataFiles_
extraSrcGlobs <- mapM (checkGlob "extra-source-files" . getSymbolicPath) extraSrcFiles_
docGlobs <- mapM (checkGlob "extra-doc-files" . getSymbolicPath) extraDocFiles_
extraGlobs <- mapM (checkGlob "extra-files" . getSymbolicPath) extraFiles_
checkMissingDocs
(catMaybes dataGlobs)
(catMaybes extraSrcGlobs)
(catMaybes docGlobs)
(catMaybes extraGlobs)
checkSetupBuildInfo setupBuildInfo_
mapM_ checkTestedWith testedWith_
either
checkNewLicense
(checkOldLicense $ null licenseFiles_)
licenseRaw_
checkSourceRepos sourceRepos_
mapM_ checkCustomField customFieldsPD_
checkSpecVer
CabalSpecV1_18
(not . null $ extraDocFiles_)
(PackageDistInexcusable CVExtraDocFiles)
checkSpecVer
CabalSpecV1_6
(not . null $ sourceRepos_)
(PackageDistInexcusable CVSourceRepository)
checkP
( specVersion_ >= CabalSpecV1_24
&& isNothing setupBuildInfo_
&& buildTypeRaw_ == Just Custom
)
(PackageBuildWarning CVCustomSetup)
checkSpecVer
CabalSpecV1_24
( isNothing setupBuildInfo_
&& buildTypeRaw_ == Just Custom
)
(PackageDistSuspiciousWarn CVExpliticDepsCustomSetup)
checkP
(isNothing buildTypeRaw_ && specVersion_ < CabalSpecV2_2)
(PackageBuildWarning NoBuildType)
checkP
(isJust setupBuildInfo_ && buildType pkg `notElem` [Custom, Hooks])
(PackageBuildWarning NoCustomSetup)
checkConfigureExists (buildType pkg)
checkSetupExists (buildType pkg)
checkCabalFile (packageName pkg)
mapM_ (checkGlobFile specVersion_ "." "extra-source-files" . getSymbolicPath) extraSrcFiles_
mapM_ (checkGlobFile specVersion_ "." "extra-doc-files" . getSymbolicPath) extraDocFiles_
mapM_ (checkGlobFile specVersion_ "." "extra-files" . getSymbolicPath) extraFiles_
mapM_ (checkGlobFile specVersion_ rawDataDir "data-files" . getSymbolicPath) dataFiles_
where
checkNull
:: Monad m
=> ShortText.ShortText
-> PackageCheck
-> CheckM m ()
checkNull :: forall (m :: * -> *).
Monad m =>
ShortText -> PackageCheck -> CheckM m ()
checkNull ShortText
st PackageCheck
c = Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP (ShortText -> Bool
ShortText.null ShortText
st) PackageCheck
c
checkTestedWith
:: Monad m
=> (CompilerFlavor, VersionRange)
-> CheckM m ()
checkTestedWith :: forall (m :: * -> *).
Monad m =>
(CompilerFlavor, VersionRange) -> CheckM m ()
checkTestedWith (OtherCompiler String
n, VersionRange
_) =
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (CheckExplanation -> PackageCheck
PackageBuildWarning (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [String] -> CheckExplanation
UnknownCompilers [String
n])
checkTestedWith (CompilerFlavor
compiler, VersionRange
versionRange) =
CompilerFlavor -> VersionRange -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CompilerFlavor -> VersionRange -> CheckM m ()
checkVersionRange CompilerFlavor
compiler VersionRange
versionRange
checkVersionRange
:: Monad m
=> CompilerFlavor
-> VersionRange
-> CheckM m ()
checkVersionRange :: forall (m :: * -> *).
Monad m =>
CompilerFlavor -> VersionRange -> CheckM m ()
checkVersionRange CompilerFlavor
cmp VersionRange
vr =
Bool -> CheckM m () -> CheckM m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when
(VersionRange -> Bool
isNoVersion VersionRange
vr)
( let dep :: [Dependency]
dep =
[ PackageName
-> VersionRange -> NonEmptySet LibraryName -> Dependency
Dependency
(String -> PackageName
mkPackageName (CompilerFlavor -> String
forall a. Pretty a => a -> String
prettyShow CompilerFlavor
cmp))
VersionRange
vr
NonEmptySet LibraryName
mainLibSet
]
in PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (CheckExplanation -> PackageCheck
PackageDistInexcusable ([Dependency] -> CheckExplanation
InvalidTestWith [Dependency]
dep))
)
checkSetupBuildInfo :: Monad m => Maybe SetupBuildInfo -> CheckM m ()
checkSetupBuildInfo :: forall (m :: * -> *).
Monad m =>
Maybe SetupBuildInfo -> CheckM m ()
checkSetupBuildInfo Maybe SetupBuildInfo
Nothing = () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkSetupBuildInfo (Just (SetupBuildInfo [Dependency]
ds Bool
_)) = do
let uqs :: [UnqualComponentName]
uqs = (String -> UnqualComponentName)
-> [String] -> [UnqualComponentName]
forall a b. (a -> b) -> [a] -> [b]
map String -> UnqualComponentName
mkUnqualComponentName [String
"base", String
"Cabal"]
(is, rs) <- [AssocDep]
-> [UnqualComponentName]
-> [Dependency]
-> CheckM m ([Dependency], [Dependency])
forall (m :: * -> *).
Monad m =>
[AssocDep]
-> [UnqualComponentName]
-> [Dependency]
-> CheckM m ([Dependency], [Dependency])
partitionDeps [] [UnqualComponentName]
uqs [Dependency]
ds
let ick = CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> (String -> CheckExplanation) -> String -> PackageCheck
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CheckExplanation
UpperBoundSetup
rck =
CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn
(CheckExplanation -> PackageCheck)
-> ([String] -> CheckExplanation) -> [String] -> PackageCheck
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CEType -> [String] -> CheckExplanation
MissingUpperBounds CEType
CETSetup
checkPVP ick is
checkPVPs rck rs
checkPackageId :: Monad m => PackageIdentifier -> CheckM m ()
checkPackageId :: forall (m :: * -> *). Monad m => PackageIdentifier -> CheckM m ()
checkPackageId (PackageIdentifier PackageName
pkgName_ Version
_pkgVersion_) = do
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Bool -> Bool
not (Bool -> Bool) -> (PackageName -> Bool) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Bool
FilePath.Windows.isValid (String -> Bool) -> (PackageName -> String) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageName -> Bool) -> PackageName -> Bool
forall a b. (a -> b) -> a -> b
$ PackageName
pkgName_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ PackageName -> CheckExplanation
InvalidNameWin PackageName
pkgName_)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP (String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf String
"z-" (String -> Bool) -> (PackageName -> String) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageName -> Bool) -> PackageName -> Bool
forall a b. (a -> b) -> a -> b
$ PackageName
pkgName_) (PackageCheck -> CheckM m ()) -> PackageCheck -> CheckM m ()
forall a b. (a -> b) -> a -> b
$
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
ZPrefix)
checkNewLicense :: Monad m => SPDX.License -> CheckM m ()
checkNewLicense :: forall (m :: * -> *). Monad m => License -> CheckM m ()
checkNewLicense License
lic = do
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
SPDX.NONE)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
NONELicense)
checkOldLicense
:: Monad m
=> Bool
-> License
-> CheckM m ()
checkOldLicense :: forall (m :: * -> *). Monad m => Bool -> License -> CheckM m ()
checkOldLicense Bool
nullLicFiles License
lic = do
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
UnspecifiedLicense)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
NoLicense)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
AllRightsReserved)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
AllRightsReservedLicense)
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV1_4
(License
lic License -> [License] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [License]
compatLicenses)
(CheckExplanation -> PackageCheck
PackageDistInexcusable (License -> CheckExplanation
LicenseMessParse License
lic))
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
BSD4)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
UncommonBSD4)
case License
lic of
UnknownLicense String
l ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (CheckExplanation -> PackageCheck
PackageBuildWarning (String -> CheckExplanation
UnrecognisedLicense String
l))
License
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( License
lic
License -> [License] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [ License
AllRightsReserved
, License
UnspecifiedLicense
, License
PublicDomain
]
Bool -> Bool -> Bool
&&
Bool
nullLicFiles
)
(PackageCheck -> CheckM m ()) -> PackageCheck -> CheckM m ()
forall a b. (a -> b) -> a -> b
$ (CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
NoLicenseFile)
case License -> Maybe [Version]
unknownLicenseVersion License
lic of
Just [Version]
knownVersions ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP
(CheckExplanation -> PackageCheck
PackageDistSuspicious (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ License -> [Version] -> CheckExplanation
UnknownLicenseVersion License
lic [Version]
knownVersions)
Maybe [Version]
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
where
compatLicenses :: [License]
compatLicenses =
[ Maybe Version -> License
GPL Maybe Version
forall a. Maybe a
Nothing
, Maybe Version -> License
LGPL Maybe Version
forall a. Maybe a
Nothing
, Maybe Version -> License
AGPL Maybe Version
forall a. Maybe a
Nothing
, License
BSD3
, License
BSD4
, License
PublicDomain
, License
AllRightsReserved
, License
UnspecifiedLicense
, License
OtherLicense
]
unknownLicenseVersion :: License -> Maybe [Version]
unknownLicenseVersion (GPL (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | GPL (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion (LGPL (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | LGPL (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion (AGPL (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | AGPL (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion (Apache (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | Apache (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion License
_ = Maybe [Version]
forall a. Maybe a
Nothing
checkSourceRepos :: Monad m => [SourceRepo] -> CheckM m ()
checkSourceRepos :: forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkSourceRepos [SourceRepo]
rs = do
(SourceRepo -> CheckM m ()) -> [SourceRepo] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SourceRepo -> CheckM m ()
forall (m :: * -> *). Monad m => SourceRepo -> CheckM m ()
repoCheck [SourceRepo]
rs
[SourceRepo] -> CheckM m ()
forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkMissingVcsInfo [SourceRepo]
rs
where
repoCheck :: Monad m => SourceRepo -> CheckM m ()
repoCheck :: forall (m :: * -> *). Monad m => SourceRepo -> CheckM m ()
repoCheck
( SourceRepo
RepoKind
repoKind_
Maybe RepoType
repoType_
Maybe String
repoLocation_
Maybe String
repoModule_
Maybe String
_repoBranch_
Maybe String
repoTag_
Maybe String
repoSubdir_
) = do
case RepoKind
repoKind_ of
RepoKindUnknown String
kind ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> CheckExplanation
UnrecognisedSourceRepo String
kind)
RepoKind
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Maybe RepoType -> Bool
forall a. Maybe a -> Bool
isNothing Maybe RepoType
repoType_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingType)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
repoLocation_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingLocation)
Maybe String -> CheckM m ()
forall (m :: * -> *). Monad m => Maybe String -> CheckM m ()
checkGitProtocol Maybe String
repoLocation_
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( Maybe RepoType
repoType_ Maybe RepoType -> Maybe RepoType -> Bool
forall a. Eq a => a -> a -> Bool
== RepoType -> Maybe RepoType
forall a. a -> Maybe a
Just (KnownRepoType -> RepoType
KnownRepoType KnownRepoType
CVS)
Bool -> Bool -> Bool
&& Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
repoModule_
)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingModule)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(RepoKind
repoKind_ RepoKind -> RepoKind -> Bool
forall a. Eq a => a -> a -> Bool
== RepoKind
RepoThis Bool -> Bool -> Bool
&& Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
repoTag_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingTag)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
((String -> Bool) -> Maybe String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any String -> Bool
isAbsoluteOnAnyPlatform Maybe String
repoSubdir_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
SubdirRelPath)
case Maybe (Maybe String) -> Maybe String
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Maybe (Maybe String) -> Maybe String)
-> (Maybe String -> Maybe (Maybe String))
-> Maybe String
-> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Maybe String) -> Maybe String -> Maybe (Maybe String)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Maybe String
isGoodRelativeDirectoryPath (Maybe String -> Maybe String) -> Maybe String -> Maybe String
forall a b. (a -> b) -> a -> b
$ Maybe String
repoSubdir_ of
Just String
err ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> CheckExplanation
SubdirGoodRelPath String
err)
Maybe String
Nothing -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkMissingVcsInfo :: Monad m => [SourceRepo] -> CheckM m ()
checkMissingVcsInfo :: forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkMissingVcsInfo [SourceRepo]
rs =
let rdirs :: [String]
rdirs = (KnownRepoType -> [String]) -> [KnownRepoType] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap KnownRepoType -> [String]
repoTypeDirname [KnownRepoType]
knownRepoTypes
in (CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
( \CheckPackageContentOps m
ops -> do
us <- [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
or ([Bool] -> Bool) -> m [Bool] -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (String -> m Bool) -> [String] -> m [Bool]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesDirectoryExist CheckPackageContentOps m
ops) [String]
rdirs
return (null rs && us)
)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
MissingSourceControl)
where
repoTypeDirname :: KnownRepoType -> [FilePath]
repoTypeDirname :: KnownRepoType -> [String]
repoTypeDirname KnownRepoType
Darcs = [String
"_darcs"]
repoTypeDirname KnownRepoType
Git = [String
".git"]
repoTypeDirname KnownRepoType
SVN = [String
".svn"]
repoTypeDirname KnownRepoType
CVS = [String
"CVS"]
repoTypeDirname KnownRepoType
Mercurial = [String
".hg"]
repoTypeDirname KnownRepoType
GnuArch = [String
".arch-params"]
repoTypeDirname KnownRepoType
Bazaar = [String
".bzr"]
repoTypeDirname KnownRepoType
Monotone = [String
"_MTN"]
repoTypeDirname KnownRepoType
Pijul = [String
".pijul"]
checkGitProtocol
:: Monad m
=> Maybe String
-> CheckM m ()
checkGitProtocol :: forall (m :: * -> *). Monad m => Maybe String -> CheckM m ()
checkGitProtocol Maybe String
mloc =
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
((String -> Bool) -> Maybe String -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf String
"git://") Maybe String
mloc Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True)
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
GitProtocol)
findPackageDesc :: Monad m => CheckPackageContentOps m -> m [FilePath]
findPackageDesc :: forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> m [String]
findPackageDesc CheckPackageContentOps m
ops = do
let dir :: String
dir = String
"."
files <- CheckPackageContentOps m -> String -> m [String]
forall (m :: * -> *).
CheckPackageContentOps m -> String -> m [String]
getDirectoryContents CheckPackageContentOps m
ops String
dir
cabalFiles <-
filterM
(doesFileExist ops)
[ dir </> file
| file <- files
, let (name, ext) = splitExtension file
, not (null name) && ext == ".cabal"
]
return cabalFiles
checkCabalFile :: Monad m => PackageName -> CheckM m ()
checkCabalFile :: forall (m :: * -> *). Monad m => PackageName -> CheckM m ()
checkCabalFile PackageName
pn = do
(CheckInterface m -> Maybe (CheckPackageContentOps m))
-> (CheckPackageContentOps m -> m [PackageCheck]) -> CheckM m ()
forall (m :: * -> *) (i :: (* -> *) -> *).
Monad m =>
(CheckInterface m -> Maybe (i m))
-> (i m -> m [PackageCheck]) -> CheckM m ()
liftInt
CheckInterface m -> Maybe (CheckPackageContentOps m)
forall (m :: * -> *).
CheckInterface m -> Maybe (CheckPackageContentOps m)
ciPackageOps
( \CheckPackageContentOps m
ops -> do
ds <- CheckPackageContentOps m -> m [String]
forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> m [String]
findPackageDesc CheckPackageContentOps m
ops
case ds of
[] -> [PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return [CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoDesc]
[String
d] -> do
bc <- CheckPackageContentOps m -> String -> m (Maybe PackageCheck)
forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> String -> m (Maybe PackageCheck)
bomf CheckPackageContentOps m
ops String
d
return (catMaybes [bc, noMatch d])
[String]
_ -> [PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return [CheckExplanation -> PackageCheck
PackageBuildImpossible (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [String] -> CheckExplanation
MultiDesc [String]
ds]
)
where
bomf
:: Monad m
=> CheckPackageContentOps m
-> FilePath
-> m (Maybe PackageCheck)
bomf :: forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> String -> m (Maybe PackageCheck)
bomf CheckPackageContentOps m
wops String
wfp = do
b <- ByteString -> ByteString -> Bool
BS.isPrefixOf ByteString
bomUtf8 (ByteString -> Bool) -> m ByteString -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CheckPackageContentOps m -> String -> m ByteString
forall (m :: * -> *).
CheckPackageContentOps m -> String -> m ByteString
getFileContents CheckPackageContentOps m
wops String
wfp
if b
then (return . Just) (PackageDistInexcusable $ BOMStart wfp)
else return Nothing
bomUtf8 :: BS.ByteString
bomUtf8 :: ByteString
bomUtf8 = [Word8] -> ByteString
BS.pack [Word8
0xef, Word8
0xbb, Word8
0xbf]
noMatch :: FilePath -> Maybe PackageCheck
noMatch :: String -> Maybe PackageCheck
noMatch String
wd =
let expd :: String
expd = PackageName -> String
unPackageName PackageName
pn String -> String -> String
forall p. FileLike p => p -> String -> p
<.> String
"cabal"
in if String -> String
takeFileName String
wd String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
expd
then PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just (CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> String -> CheckExplanation
NotPackageName String
wd String
expd)
else Maybe PackageCheck
forall a. Maybe a
Nothing
checkLicFileExist
:: Monad m
=> RelativePath Pkg File
-> CheckM m ()
checkLicFileExist :: forall (m :: * -> *).
Monad m =>
RelativePath Pkg 'File -> CheckM m ()
checkLicFileExist RelativePath Pkg 'File
sp = do
let fp :: String
fp = RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath RelativePath Pkg 'File
sp
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
(\CheckPackageContentOps m
ops -> Bool -> Bool
not (Bool -> Bool) -> m Bool -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
fp)
(CheckExplanation -> PackageCheck
PackageBuildWarning (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> RelativePath Pkg 'File -> CheckExplanation
UnknownFile String
"license-file" RelativePath Pkg 'File
sp)
checkConfigureExists :: Monad m => BuildType -> CheckM m ()
checkConfigureExists :: forall (m :: * -> *). Monad m => BuildType -> CheckM m ()
checkConfigureExists BuildType
Configure =
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
(\CheckPackageContentOps m
ops -> Bool -> Bool
not (Bool -> Bool) -> m Bool -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
"configure")
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
MissingConfigureScript)
checkConfigureExists BuildType
_ = () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkSetupExists :: Monad m => BuildType -> CheckM m ()
checkSetupExists :: forall (m :: * -> *). Monad m => BuildType -> CheckM m ()
checkSetupExists BuildType
Simple = () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkSetupExists BuildType
_ =
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
( \CheckPackageContentOps m
ops -> do
ba <- CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
"Setup.hs"
bb <- doesFileExist ops "Setup.lhs"
return (not $ ba || bb)
)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingSetupFile)
checkGlobFile
:: Monad m
=> CabalSpecVersion
-> FilePath
-> FilePath
-> CabalField
-> CheckM m ()
checkGlobFile :: forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> String -> String -> String -> CheckM m ()
checkGlobFile CabalSpecVersion
cv String
ddir String
title String
fp = do
let adjDdir :: String
adjDdir = if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
ddir then String
"." else String
ddir
dir :: String
dir
| String
title String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"data-files" = String
adjDdir
| Bool
otherwise = String
"."
case CabalSpecVersion -> String -> Either GlobSyntaxError Glob
parseFileGlob CabalSpecVersion
cv String
fp of
Left GlobSyntaxError
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Right Glob
parsedGlob -> do
(CheckInterface m -> Maybe (CheckPreDistributionOps m))
-> (CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ()
forall (m :: * -> *) (i :: (* -> *) -> *).
Monad m =>
(CheckInterface m -> Maybe (i m))
-> (i m -> m [PackageCheck]) -> CheckM m ()
liftInt CheckInterface m -> Maybe (CheckPreDistributionOps m)
forall (m :: * -> *).
CheckInterface m -> Maybe (CheckPreDistributionOps m)
ciPreDistOps ((CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ())
-> (CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ()
forall a b. (a -> b) -> a -> b
$ \CheckPreDistributionOps m
po -> do
rs <- CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
forall (m :: * -> *).
CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
runDirFileGlobM CheckPreDistributionOps m
po String
dir Glob
parsedGlob
return $ checkGlobResult title fp rs
checkGlobResult
:: CabalField
-> FilePath
-> [GlobResult FilePath]
-> [PackageCheck]
checkGlobResult :: String -> String -> [GlobResult String] -> [PackageCheck]
checkGlobResult String
title String
fp [GlobResult String]
rs = [PackageCheck]
dirCheck [PackageCheck] -> [PackageCheck] -> [PackageCheck]
forall a. [a] -> [a] -> [a]
++ [Maybe PackageCheck] -> [PackageCheck]
forall a. [Maybe a] -> [a]
catMaybes ((GlobResult String -> Maybe PackageCheck)
-> [GlobResult String] -> [Maybe PackageCheck]
forall a b. (a -> b) -> [a] -> [b]
map GlobResult String -> Maybe PackageCheck
getWarning [GlobResult String]
rs)
where
dirCheck :: [PackageCheck]
dirCheck
| (GlobResult String -> Bool) -> [GlobResult String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool
not (Bool -> Bool)
-> (GlobResult String -> Bool) -> GlobResult String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GlobResult String -> Bool
forall {a}. GlobResult a -> Bool
withoutNoMatchesWarning) [GlobResult String]
rs =
[CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> String -> CheckExplanation
GlobNoMatch String
title String
fp]
| Bool
otherwise = []
withoutNoMatchesWarning :: GlobResult a -> Bool
withoutNoMatchesWarning (GlobMatch a
_) = Bool
True
withoutNoMatchesWarning (GlobWarnMultiDot a
_) = Bool
False
withoutNoMatchesWarning (GlobMissingDirectory a
_) = Bool
True
withoutNoMatchesWarning (GlobMatchesDirectory a
_) = Bool
True
getWarning :: GlobResult FilePath -> Maybe PackageCheck
getWarning :: GlobResult String -> Maybe PackageCheck
getWarning (GlobMatch String
_) = Maybe PackageCheck
forall a. Maybe a
Nothing
getWarning (GlobWarnMultiDot String
file) =
PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just (PackageCheck -> Maybe PackageCheck)
-> PackageCheck -> Maybe PackageCheck
forall a b. (a -> b) -> a -> b
$ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (String -> String -> String -> CheckExplanation
GlobExactMatch String
title String
fp String
file)
getWarning (GlobMissingDirectory String
dir) =
PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just (PackageCheck -> Maybe PackageCheck)
-> PackageCheck -> Maybe PackageCheck
forall a b. (a -> b) -> a -> b
$ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (String -> String -> String -> CheckExplanation
GlobNoDir String
title String
fp String
dir)
getWarning (GlobMatchesDirectory String
_) = Maybe PackageCheck
forall a. Maybe a
Nothing
wrapParseWarning :: FilePath -> PWarning -> PackageCheck
wrapParseWarning :: String -> PWarning -> PackageCheck
wrapParseWarning String
fp PWarning
pw = CheckExplanation -> PackageCheck
PackageDistSuspicious (String -> PWarning -> CheckExplanation
ParseWarning String
fp PWarning
pw)
extractAssocDeps
:: UnqualComponentName
-> CondTree ConfVar [Dependency] Library
-> AssocDep
UnqualComponentName
n CondTree ConfVar [Dependency] Library
ct =
let a :: (Library, [Dependency])
a = CondTree ConfVar [Dependency] Library -> (Library, [Dependency])
forall a c v.
(Semigroup a, Semigroup c) =>
CondTree v c a -> (a, c)
ignoreConditions CondTree ConfVar [Dependency] Library
ct
in
(UnqualComponentName
n, (Library, [Dependency]) -> [Dependency]
forall a b. (a, b) -> b
snd (Library, [Dependency])
a)
pd2gpd :: PackageDescription -> GenericPackageDescription
pd2gpd :: PackageDescription -> GenericPackageDescription
pd2gpd PackageDescription
pd = GenericPackageDescription
gpd
where
gpd :: GenericPackageDescription
gpd :: GenericPackageDescription
gpd =
GenericPackageDescription
emptyGenericPackageDescription
{ packageDescription = pd
, condLibrary = fmap t2c (library pd)
, condSubLibraries = map (t2cName ln id) (subLibraries pd)
, condForeignLibs =
map
(t2cName foreignLibName id)
(foreignLibs pd)
, condExecutables =
map
(t2cName exeName id)
(executables pd)
, condTestSuites =
map
(t2cName testName remTest)
(testSuites pd)
, condBenchmarks =
map
(t2cName benchmarkName remBench)
(benchmarks pd)
}
t2c :: a -> CondTree ConfVar [Dependency] a
t2c :: forall a. a -> CondTree ConfVar [Dependency] a
t2c a
a = a
-> [Dependency]
-> [CondBranch ConfVar [Dependency] a]
-> CondTree ConfVar [Dependency] a
forall v c a. a -> c -> [CondBranch v c a] -> CondTree v c a
CondNode a
a [] []
t2cName
:: (a -> UnqualComponentName)
-> (a -> a)
-> a
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
t2cName :: forall a.
(a -> UnqualComponentName)
-> (a -> a)
-> a
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
t2cName a -> UnqualComponentName
nf a -> a
mf a
a = (a -> UnqualComponentName
nf a
a, a -> CondTree ConfVar [Dependency] a
forall a. a -> CondTree ConfVar [Dependency] a
t2c (a -> CondTree ConfVar [Dependency] a)
-> (a -> a) -> a -> CondTree ConfVar [Dependency] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
mf (a -> CondTree ConfVar [Dependency] a)
-> a -> CondTree ConfVar [Dependency] a
forall a b. (a -> b) -> a -> b
$ a
a)
ln :: Library -> UnqualComponentName
ln :: Library -> UnqualComponentName
ln Library
wl = case Library -> LibraryName
libName Library
wl of
(LSubLibName UnqualComponentName
u) -> UnqualComponentName
u
LibraryName
LMainLibName -> String -> UnqualComponentName
mkUnqualComponentName String
"main-library"
remTest :: TestSuite -> TestSuite
remTest :: TestSuite -> TestSuite
remTest TestSuite
t = TestSuite
t{testName = mempty}
remBench :: Benchmark -> Benchmark
remBench :: Benchmark -> Benchmark
remBench Benchmark
b = Benchmark
b{benchmarkName = mempty}
checkMissingDocs
:: Monad m
=> [Glob]
-> [Glob]
-> [Glob]
-> [Glob]
-> CheckM m ()
checkMissingDocs :: forall (m :: * -> *).
Monad m =>
[Glob] -> [Glob] -> [Glob] -> [Glob] -> CheckM m ()
checkMissingDocs [Glob]
dgs [Glob]
esgs [Glob]
edgs [Glob]
efgs = do
extraDocSupport <- (CabalSpecVersion -> CabalSpecVersion -> Bool
forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV1_18) (CabalSpecVersion -> Bool)
-> CheckM m CabalSpecVersion -> CheckM m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CheckCtx m -> CabalSpecVersion) -> CheckM m CabalSpecVersion
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM CheckCtx m -> CabalSpecVersion
forall (m :: * -> *). CheckCtx m -> CabalSpecVersion
ccSpecVersion
liftInt
ciPreDistOps
( \CheckPreDistributionOps m
ops -> do
rootContents <- CheckPreDistributionOps m -> String -> m [String]
forall (m :: * -> *).
CheckPreDistributionOps m -> String -> m [String]
getDirectoryContentsM CheckPreDistributionOps m
ops String
"."
let des = (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter String -> Bool
isDesirableExtraDocFile [String]
rootContents
let realGlob t Glob
t =
([GlobResult String] -> [String])
-> t [GlobResult String] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap [GlobResult String] -> [String]
forall a. [GlobResult a] -> [a]
globMatches
(t [GlobResult String] -> [String])
-> m (t [GlobResult String]) -> m [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Glob -> m [GlobResult String])
-> t Glob -> m (t [GlobResult String])
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)
mapM (CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
forall (m :: * -> *).
CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
runDirFileGlobM CheckPreDistributionOps m
ops String
"") t Glob
t
rgs <- realGlob dgs
res <- realGlob esgs
red <- realGlob edgs
ref <- realGlob efgs
let mcs = Bool -> [String] -> [String] -> [PackageCheck]
checkDoc Bool
extraDocSupport [String]
des ([String]
rgs [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
res [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
red [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
ref)
let pcsData = Bool -> String -> [String] -> [String] -> [PackageCheck]
checkDocMove Bool
extraDocSupport String
"data-files" [String]
des [String]
rgs
pcsSource =
if Bool
extraDocSupport
then
Bool -> String -> [String] -> [String] -> [PackageCheck]
checkDocMove
Bool
extraDocSupport
String
"extra-source-files"
[String]
des
[String]
res
else []
pcs = [PackageCheck]
pcsData [PackageCheck] -> [PackageCheck] -> [PackageCheck]
forall a. [a] -> [a] -> [a]
++ [PackageCheck]
pcsSource
return (mcs ++ pcs)
)
where
checkDoc
:: Bool
-> [FilePath]
-> [FilePath]
-> [PackageCheck]
checkDoc :: Bool -> [String] -> [String] -> [PackageCheck]
checkDoc Bool
b [String]
ds [String]
as =
let fds :: [String]
fds = (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
"." String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</>) ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool) -> [String] -> String -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
notElem [String]
as) [String]
ds
in if [String] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
fds
then []
else
[ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$
Bool -> [String] -> CheckExplanation
MissingExpectedDocFiles Bool
b [String]
fds
]
checkDocMove
:: Bool
-> CabalField
-> [FilePath]
-> [FilePath]
-> [PackageCheck]
checkDocMove :: Bool -> String -> [String] -> [String] -> [PackageCheck]
checkDocMove Bool
b String
field [String]
ds [String]
as =
let fds :: [String]
fds = (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool) -> [String] -> String -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> [String] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem [String]
as) [String]
ds
in if [String] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
fds
then []
else
[ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$
Bool -> String -> [String] -> CheckExplanation
WrongFieldForExpectedDocFiles Bool
b String
field [String]
fds
]
isDesirableExtraDocFile :: FilePath -> Bool
String
path =
String
basename String -> [String] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
desirableChangeLog
Bool -> Bool -> Bool
&& String
ext String -> [String] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
desirableChangeLogExtensions
where
(String
basename, String
ext) = String -> (String, String)
splitExtension ((Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
path)
desirableChangeLog :: [String]
desirableChangeLog = [String
"news", String
"changelog", String
"change_log", String
"changes"]
desirableChangeLogExtensions :: [String]
desirableChangeLogExtensions = [String
"", String
".txt", String
".md", String
".markdown", String
".rst"]
dups :: Ord a => [a] -> [a]
dups :: forall a. Ord a => [a] -> [a]
dups [a]
xs = [a
x | (a
x : a
_ : [a]
_) <- [a] -> [[a]]
forall a. Eq a => [a] -> [[a]]
group ([a] -> [a]
forall a. Ord a => [a] -> [a]
sort [a]
xs)]