module Distribution.PackageDescription (
PackageDescription(..),
emptyPackageDescription,
specVersion,
descCabalVersion,
BuildType(..),
knownBuildTypes,
Component(..),
compSel,
Library(..),
emptyLibrary,
withLib,
hasLibs,
libModules,
Executable(..),
emptyExecutable,
withExe,
hasExes,
exeModules,
TestSuite(..),
TestSuiteInterface(..),
TestType(..),
testType,
knownTestTypes,
emptyTestSuite,
hasTests,
withTest,
testModules,
enabledTests,
BuildInfo(..),
emptyBuildInfo,
allBuildInfo,
allComponentsBy,
allLanguages,
allExtensions,
usedExtensions,
hcOptions,
HookedBuildInfo,
emptyHookedBuildInfo,
updatePackageDescription,
GenericPackageDescription(..),
Flag(..), FlagName(..), FlagAssignment,
CondTree(..), ConfVar(..), Condition(..),
SourceRepo(..),
RepoKind(..),
RepoType(..),
knownRepoTypes,
) where
import Data.List (nub, intersperse)
import Data.Maybe (maybeToList)
import Data.Monoid (Monoid(mempty, mappend))
import Control.Monad (MonadPlus(mplus))
import Text.PrettyPrint.HughesPJ as Disp
import qualified Distribution.Compat.ReadP as Parse
import qualified Data.Char as Char (isAlphaNum, isDigit, toLower)
import Distribution.Package
( PackageName(PackageName), PackageIdentifier(PackageIdentifier)
, Dependency, Package(..) )
import Distribution.ModuleName ( ModuleName )
import Distribution.Version
( Version(Version), VersionRange, anyVersion, orLaterVersion
, asVersionIntervals, LowerBound(..) )
import Distribution.License (License(AllRightsReserved))
import Distribution.Compiler (CompilerFlavor)
import Distribution.System (OS, Arch)
import Distribution.Text
( Text(..), display )
import Language.Haskell.Extension
( Language, Extension )
data testedWith :: [(CompilerFlavor, VersionRange)]PackageDescription
= PackageDescription {
package :: PackageIdentifier,
license :: License,
licenseFile :: FilePath,
copyright :: String,
maintainer :: String,
author :: String,
stability :: String,
testedWith :: [(CompilerFlavor,VersionRange)],
homepage :: String,
pkgUrl :: String,
bugReports :: String,
sourceRepos :: [SourceRepo],
synopsis :: String,
description :: String,
category :: String,
customFieldsPD :: [(String,String)],
buildDepends :: [Dependency],
specVersionRaw :: Either Version VersionRange,
buildType :: Maybe BuildType,
library :: Maybe Library,
executables :: [Executable],
testSuites :: [TestSuite],
dataFiles :: [FilePath],
dataDir :: FilePath,
extraSrcFiles :: [FilePath],
extraTmpFiles :: [FilePath]
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
instance D:Package :: (pkg -> PackageIdentifier) -> T:Package pkgPackage PackageDescription where
packageId = package :: PackageDescription -> PackageIdentifierpackage
specVersion :: PackageDescription -> Version
specVersion pkg = case specVersionRaw :: PackageDescription -> Either Version VersionRangespecVersionRaw pkg :: PackageDescriptionpkg of
Left version -> version :: Versionversion
Right versionRange -> case asVersionIntervals :: VersionRange -> [VersionInterval]asVersionIntervals versionRange :: VersionRangeversionRange of
[] -> Version :: [Int] -> [String] -> VersionVersion [0] [] :: [a][]
((LowerBound version _, _):_) -> version :: Versionversion
descCabalVersion :: PackageDescription -> VersionRange
descCabalVersion pkg = case specVersionRaw :: PackageDescription -> Either Version VersionRangespecVersionRaw pkg :: PackageDescriptionpkg of
Left version -> orLaterVersion :: Version -> VersionRangeorLaterVersion version :: Versionversion
Right versionRange -> versionRange :: VersionRangeversionRange
emptyPackageDescription :: PackageDescription
emptyPackageDescription
= PackageDescription {
package = PackageIdentifier :: PackageName -> Version -> PackageIdentifierPackageIdentifier (PackageName :: String -> PackageNamePackageName "")
(Version :: [Int] -> [String] -> VersionVersion [] :: [a][] [] :: [a][]),
license = AllRightsReserved :: LicenseAllRightsReserved,
licenseFile = "",
specVersionRaw = Right :: b -> Either a bRight anyVersion :: VersionRangeanyVersion,
buildType = Nothing :: Maybe aNothing,
copyright = "",
maintainer = "",
author = "",
stability = "",
testedWith = [] :: [a][],
buildDepends = [] :: [a][],
homepage = "",
pkgUrl = "",
bugReports = "",
sourceRepos = [] :: [a][],
synopsis = "",
description = "",
category = "",
customFieldsPD = [] :: [a][],
library = Nothing :: Maybe aNothing,
executables = [] :: [a][],
testSuites = [] :: [a][],
dataFiles = [] :: [a][],
dataDir = "",
extraSrcFiles = [] :: [a][],
extraTmpFiles = [] :: [a][]
}
data BuildType
= Simple
| Configure
| Make
| Custom
| UnknownBuildType String
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
knownBuildTypes :: [BuildType]
knownBuildTypes = [Simple :: BuildTypeSimple, Configure :: BuildTypeConfigure, Make :: BuildTypeMake, Custom :: BuildTypeCustom]
instance D:Text :: (a -> Doc) -> (forall r. ReadP r a) -> T:Text aText BuildType where
disp (UnknownBuildType other) = text :: String -> DocDisp.text other :: BuildTypeother
disp other = text :: String -> DocDisp.text (show :: Show a => a -> Stringshow other :: BuildTypeother)
parse = do
name <- munch1 :: (Char -> Bool) -> ReadP r StringParse.munch1 isAlphaNum :: Char -> BoolChar.isAlphaNum
return :: Monad m => forall a. a -> m areturn ($) :: (a -> b) -> a -> b$ case name :: Stringname of
"Simple" -> Simple :: BuildTypeSimple
"Configure" -> Configure :: BuildTypeConfigure
"Custom" -> Custom :: BuildTypeCustom
"Make" -> Make :: BuildTypeMake
_ -> UnknownBuildType :: String -> BuildTypeUnknownBuildType name :: Stringname
data exposedModules :: [ModuleName]Library = Library {
exposedModules :: [ModuleName],
libExposed :: Bool,
libBuildInfo :: BuildInfo
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead)
instance D:Monoid :: a -> (a -> a -> a) -> ([a] -> a) -> T:Monoid aMonoid Library where
mempty = Library {
exposedModules = mempty :: Monoid a => amempty,
libExposed = True :: BoolTrue,
libBuildInfo = mempty :: Monoid a => amempty
}
mappend a b = Library {
exposedModules = combine :: (Library -> a) -> acombine exposedModules :: Library -> [ModuleName]exposedModules,
libExposed = libExposed :: Library -> BoollibExposed a :: Librarya (&&) :: Bool -> Bool -> Bool&& libExposed :: Library -> BoollibExposed b :: Libraryb,
libBuildInfo = combine :: (Library -> a) -> acombine libBuildInfo :: Library -> BuildInfolibBuildInfo
}
where combine field = field :: Library -> afield a :: Librarya mappend :: Monoid a => a -> a -> a`mappend` field :: Library -> afield b :: Libraryb
emptyLibrary :: Library
emptyLibrary = mempty :: Monoid a => amempty
hasLibs :: PackageDescription -> Bool
hasLibs p = maybe :: b -> (a -> b) -> Maybe a -> bmaybe False :: BoolFalse (buildable :: BuildInfo -> Boolbuildable (.) :: (b -> c) -> (a -> b) -> a -> c. libBuildInfo :: Library -> BuildInfolibBuildInfo) (library :: PackageDescription -> Maybe Librarylibrary p :: PackageDescriptionp)
maybeHasLibs :: PackageDescription -> Maybe Library
maybeHasLibs p =
library :: PackageDescription -> Maybe Librarylibrary p :: PackageDescriptionp (>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b>>= \lib -> if buildable :: BuildInfo -> Boolbuildable (libBuildInfo :: Library -> BuildInfolibBuildInfo lib :: Librarylib)
then Just :: a -> Maybe aJust lib :: Librarylib
else Nothing :: Maybe aNothing
withLib :: PackageDescription -> (Library -> IO ()) -> IO ()
withLib pkg_descr f =
maybe :: b -> (a -> b) -> Maybe a -> bmaybe (return :: Monad m => forall a. a -> m areturn ()) f :: TestSuite -> [Char]f (maybeHasLibs :: PackageDescription -> Maybe LibrarymaybeHasLibs pkg_descr :: PackageDescriptionpkg_descr)
libModules :: Library -> [ModuleName]
libModules lib = exposedModules :: Library -> [ModuleName]exposedModules lib :: Librarylib
(++) :: [a] -> [a] -> [a]++ otherModules :: BuildInfo -> [ModuleName]otherModules (libBuildInfo :: Library -> BuildInfolibBuildInfo lib :: Librarylib)
data modulePath :: FilePathExecutable = Executable {
exeName :: String,
modulePath :: FilePath,
buildInfo :: BuildInfo
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
instance D:Monoid :: a -> (a -> a -> a) -> ([a] -> a) -> T:Monoid aMonoid Executable where
mempty = Executable {
exeName = mempty :: Monoid a => amempty,
modulePath = mempty :: Monoid a => amempty,
buildInfo = mempty :: Monoid a => amempty
}
mappend a b = Executable{
exeName = combine' :: (Executable -> [Char]) -> [Char]combine' exeName :: Executable -> StringexeName,
modulePath = combine :: (Library -> a) -> acombine modulePath :: Executable -> FilePathmodulePath,
buildInfo = combine :: (Library -> a) -> acombine buildInfo :: Executable -> BuildInfobuildInfo
}
where combine field = field :: Library -> afield a :: Librarya mappend :: Monoid a => a -> a -> a`mappend` field :: Library -> afield b :: Libraryb
combine' field = case (field :: Library -> afield a :: Librarya, field :: Library -> afield b :: Libraryb) of
("","") -> ""
("", x) -> x :: [Char]x
(x, "") -> x :: [Char]x
(x, y) -> error :: [Char] -> aerror ($) :: (a -> b) -> a -> b$ "Ambiguous values for executable field: '"
(++) :: [a] -> [a] -> [a]++ x :: [Char]x (++) :: [a] -> [a] -> [a]++ "' and '" (++) :: [a] -> [a] -> [a]++ y :: [Char]y (++) :: [a] -> [a] -> [a]++ "'"
emptyExecutable :: Executable
emptyExecutable = mempty :: Monoid a => amempty
hasExes :: PackageDescription -> Bool
hasExes p = any :: (a -> Bool) -> [a] -> Boolany (buildable :: BuildInfo -> Boolbuildable (.) :: (b -> c) -> (a -> b) -> a -> c. buildInfo :: Executable -> BuildInfobuildInfo) (executables :: PackageDescription -> [Executable]executables p :: PackageDescriptionp)
withExe :: PackageDescription -> (Executable -> IO ()) -> IO ()
withExe pkg_descr f =
sequence_ :: Monad m => [m a] -> m ()sequence_ [f :: TestSuite -> [Char]f exe :: Executableexe | exe <- executables :: PackageDescription -> [Executable]executables pkg_descr :: PackageDescriptionpkg_descr, buildable :: BuildInfo -> Boolbuildable (buildInfo :: Executable -> BuildInfobuildInfo exe :: Executableexe)]
exeModules :: Executable -> [ModuleName]
exeModules exe = otherModules :: BuildInfo -> [ModuleName]otherModules (buildInfo :: Executable -> BuildInfobuildInfo exe :: Executableexe)
data testInterface :: TestSuiteInterfaceTestSuite = TestSuite {
testName :: String,
testInterface :: TestSuiteInterface,
testBuildInfo :: BuildInfo,
testEnabled :: Bool
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
data TestSuiteInterface =
TestSuiteExeV10 Version FilePath
| TestSuiteLibV09 Version ModuleName
| TestSuiteUnsupported TestType
deriving (($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
instance D:Monoid :: a -> (a -> a -> a) -> ([a] -> a) -> T:Monoid aMonoid TestSuite where
mempty = TestSuite {
testName = mempty :: Monoid a => amempty,
testInterface = mempty :: Monoid a => amempty,
testBuildInfo = mempty :: Monoid a => amempty,
testEnabled = False :: BoolFalse
}
mappend a b = TestSuite {
testName = combine' :: (Executable -> [Char]) -> [Char]combine' testName :: TestSuite -> StringtestName,
testInterface = combine :: (Library -> a) -> acombine testInterface :: TestSuite -> TestSuiteInterfacetestInterface,
testBuildInfo = combine :: (Library -> a) -> acombine testBuildInfo :: TestSuite -> BuildInfotestBuildInfo,
testEnabled = if testEnabled :: TestSuite -> BooltestEnabled a :: Librarya then True :: BoolTrue else testEnabled :: TestSuite -> BooltestEnabled b :: Libraryb
}
where combine field = field :: Library -> afield a :: Librarya mappend :: Monoid a => a -> a -> a`mappend` field :: Library -> afield b :: Libraryb
combine' f = case (f :: TestSuite -> [Char]f a :: Librarya, f :: TestSuite -> [Char]f b :: Libraryb) of
("", x) -> x :: [Char]x
(x, "") -> x :: [Char]x
(x, y) -> error :: [Char] -> aerror "Ambiguous values for test field: '"
(++) :: [a] -> [a] -> [a]++ x :: [Char]x (++) :: [a] -> [a] -> [a]++ "' and '" (++) :: [a] -> [a] -> [a]++ y :: [Char]y (++) :: [a] -> [a] -> [a]++ "'"
instance D:Monoid :: a -> (a -> a -> a) -> ([a] -> a) -> T:Monoid aMonoid TestSuiteInterface where
mempty = TestSuiteUnsupported :: TestType -> TestSuiteInterfaceTestSuiteUnsupported (TestTypeUnknown :: String -> Version -> TestTypeTestTypeUnknown mempty :: Monoid a => amempty (Version :: [Int] -> [String] -> VersionVersion [] :: [a][] [] :: [a][]))
mappend a (TestSuiteUnsupported _) = a :: Librarya
mappend _ b = b :: Libraryb
emptyTestSuite :: TestSuite
emptyTestSuite = mempty :: Monoid a => amempty
hasTests :: PackageDescription -> Bool
hasTests = any :: (a -> Bool) -> [a] -> Boolany (buildable :: BuildInfo -> Boolbuildable (.) :: (b -> c) -> (a -> b) -> a -> c. testBuildInfo :: TestSuite -> BuildInfotestBuildInfo) (.) :: (b -> c) -> (a -> b) -> a -> c. testSuites :: PackageDescription -> [TestSuite]testSuites
enabledTests :: PackageDescription -> [TestSuite]
enabledTests = filter :: (a -> Bool) -> [a] -> [a]filter testEnabled :: TestSuite -> BooltestEnabled (.) :: (b -> c) -> (a -> b) -> a -> c. testSuites :: PackageDescription -> [TestSuite]testSuites
withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO ()
withTest pkg_descr f =
mapM_ :: Monad m => (a -> m b) -> [a] -> m ()mapM_ f :: TestSuite -> [Char]f ($) :: (a -> b) -> a -> b$ filter :: (a -> Bool) -> [a] -> [a]filter (buildable :: BuildInfo -> Boolbuildable (.) :: (b -> c) -> (a -> b) -> a -> c. testBuildInfo :: TestSuite -> BuildInfotestBuildInfo) ($) :: (a -> b) -> a -> b$ enabledTests :: PackageDescription -> [TestSuite]enabledTests pkg_descr :: PackageDescriptionpkg_descr
testModules :: TestSuite -> [ModuleName]
testModules test = (case testInterface :: TestSuite -> TestSuiteInterfacetestInterface test :: TestSuitetest of
TestSuiteLibV09 _ m -> [m :: ModuleNamem]
_ -> [] :: [a][])
(++) :: [a] -> [a] -> [a]++ otherModules :: BuildInfo -> [ModuleName]otherModules (testBuildInfo :: TestSuite -> BuildInfotestBuildInfo test :: TestSuitetest)
data TestType = TestTypeExe Version
| TestTypeLib Version
| TestTypeUnknown String Version
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
knownTestTypes :: [TestType]
knownTestTypes = [ TestTypeExe :: Version -> TestTypeTestTypeExe (Version :: [Int] -> [String] -> VersionVersion [1,0] [] :: [a][])
, TestTypeLib :: Version -> TestTypeTestTypeLib (Version :: [Int] -> [String] -> VersionVersion [0,9] [] :: [a][]) ]
instance D:Text :: (a -> Doc) -> (forall r. ReadP r a) -> T:Text aText TestType where
disp (TestTypeExe ver) = text :: String -> Doctext "exitcode-stdio-" (<>) :: Doc -> Doc -> Doc<> disp :: Text a => a -> Docdisp ver :: Versionver
disp (TestTypeLib ver) = text :: String -> Doctext "detailed-" (<>) :: Doc -> Doc -> Doc<> disp :: Text a => a -> Docdisp ver :: Versionver
disp (TestTypeUnknown name ver) = text :: String -> Doctext name :: Stringname (<>) :: Doc -> Doc -> Doc<> char :: Char -> Docchar '-' (<>) :: Doc -> Doc -> Doc<> disp :: Text a => a -> Docdisp ver :: Versionver
parse = do
cs <- sepBy1 :: ReadP r a -> ReadP r sep -> ReadP r [a]Parse.sepBy1 component :: Parser r Char Stringcomponent (char :: Char -> ReadP r CharParse.char '-')
_ <- char :: Char -> ReadP r CharParse.char '-'
ver <- parse :: Text a => forall r. ReadP r aparse
let name = concat :: [[a]] -> [a]concat (intersperse :: a -> [a] -> [a]intersperse "-" cs :: Stringcs)
return :: Monad m => forall a. a -> m areturn ($!) :: (a -> b) -> a -> b$! case lowercase :: String -> Stringlowercase name :: Stringname of
"exitcode-stdio" -> TestTypeExe :: Version -> TestTypeTestTypeExe ver :: Versionver
"detailed" -> TestTypeLib :: Version -> TestTypeTestTypeLib ver :: Versionver
_ -> TestTypeUnknown :: String -> Version -> TestTypeTestTypeUnknown name :: Stringname ver :: Versionver
where
component = do
cs <- munch1 :: (Char -> Bool) -> ReadP r StringParse.munch1 isAlphaNum :: Char -> BoolChar.isAlphaNum
if all :: (a -> Bool) -> [a] -> Boolall isDigit :: Char -> BoolChar.isDigit cs :: Stringcs then pfail :: ReadP r aParse.pfail else return :: Monad m => forall a. a -> m areturn cs :: Stringcs
testType :: TestSuite -> TestType
testType test = case testInterface :: TestSuite -> TestSuiteInterfacetestInterface test :: TestSuitetest of
TestSuiteExeV10 ver _ -> TestTypeExe :: Version -> TestTypeTestTypeExe ver :: Versionver
TestSuiteLibV09 ver _ -> TestTypeLib :: Version -> TestTypeTestTypeLib ver :: Versionver
TestSuiteUnsupported testtype -> testtype :: TestTypetesttype
data options :: [(CompilerFlavor, [String])]BuildInfo = BuildInfo {
buildable :: Bool,
buildTools :: [Dependency],
cppOptions :: [String],
ccOptions :: [String],
ldOptions :: [String],
pkgconfigDepends :: [Dependency],
frameworks :: [String],
cSources :: [FilePath],
hsSourceDirs :: [FilePath],
otherModules :: [ModuleName],
defaultLanguage :: Maybe Language,
otherLanguages :: [Language],
defaultExtensions :: [Extension],
otherExtensions :: [Extension],
oldExtensions :: [Extension],
extraLibs :: [String],
extraLibDirs :: [String],
includeDirs :: [FilePath],
includes :: [FilePath],
installIncludes :: [FilePath],
options :: [(CompilerFlavor,[String])],
ghcProfOptions :: [String],
ghcSharedOptions :: [String],
customFieldsBI :: [(String,String)],
targetBuildDepends :: [Dependency]
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow,D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead,($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
instance D:Monoid :: a -> (a -> a -> a) -> ([a] -> a) -> T:Monoid aMonoid BuildInfo where
mempty = BuildInfo {
buildable = True :: BoolTrue,
buildTools = [] :: [a][],
cppOptions = [] :: [a][],
ccOptions = [] :: [a][],
ldOptions = [] :: [a][],
pkgconfigDepends = [] :: [a][],
frameworks = [] :: [a][],
cSources = [] :: [a][],
hsSourceDirs = [] :: [a][],
otherModules = [] :: [a][],
defaultLanguage = Nothing :: Maybe aNothing,
otherLanguages = [] :: [a][],
defaultExtensions = [] :: [a][],
otherExtensions = [] :: [a][],
oldExtensions = [] :: [a][],
extraLibs = [] :: [a][],
extraLibDirs = [] :: [a][],
includeDirs = [] :: [a][],
includes = [] :: [a][],
installIncludes = [] :: [a][],
options = [] :: [a][],
ghcProfOptions = [] :: [a][],
ghcSharedOptions = [] :: [a][],
customFieldsBI = [] :: [a][],
targetBuildDepends = [] :: [a][]
}
mappend a b = BuildInfo {
buildable = buildable :: BuildInfo -> Boolbuildable a :: Librarya (&&) :: Bool -> Bool -> Bool&& buildable :: BuildInfo -> Boolbuildable b :: Libraryb,
buildTools = combine :: (Library -> a) -> acombine buildTools :: BuildInfo -> [Dependency]buildTools,
cppOptions = combine :: (Library -> a) -> acombine cppOptions :: BuildInfo -> [String]cppOptions,
ccOptions = combine :: (Library -> a) -> acombine ccOptions :: BuildInfo -> [String]ccOptions,
ldOptions = combine :: (Library -> a) -> acombine ldOptions :: BuildInfo -> [String]ldOptions,
pkgconfigDepends = combine :: (Library -> a) -> acombine pkgconfigDepends :: BuildInfo -> [Dependency]pkgconfigDepends,
frameworks = combineNub :: (BuildInfo -> [a]) -> [a]combineNub frameworks :: BuildInfo -> [String]frameworks,
cSources = combineNub :: (BuildInfo -> [a]) -> [a]combineNub cSources :: BuildInfo -> [FilePath]cSources,
hsSourceDirs = combineNub :: (BuildInfo -> [a]) -> [a]combineNub hsSourceDirs :: BuildInfo -> [FilePath]hsSourceDirs,
otherModules = combineNub :: (BuildInfo -> [a]) -> [a]combineNub otherModules :: BuildInfo -> [ModuleName]otherModules,
defaultLanguage = combineMby :: (BuildInfo -> m a) -> m acombineMby defaultLanguage :: BuildInfo -> Maybe LanguagedefaultLanguage,
otherLanguages = combineNub :: (BuildInfo -> [a]) -> [a]combineNub otherLanguages :: BuildInfo -> [Language]otherLanguages,
defaultExtensions = combineNub :: (BuildInfo -> [a]) -> [a]combineNub defaultExtensions :: BuildInfo -> [Extension]defaultExtensions,
otherExtensions = combineNub :: (BuildInfo -> [a]) -> [a]combineNub otherExtensions :: BuildInfo -> [Extension]otherExtensions,
oldExtensions = combineNub :: (BuildInfo -> [a]) -> [a]combineNub oldExtensions :: BuildInfo -> [Extension]oldExtensions,
extraLibs = combine :: (Library -> a) -> acombine extraLibs :: BuildInfo -> [String]extraLibs,
extraLibDirs = combineNub :: (BuildInfo -> [a]) -> [a]combineNub extraLibDirs :: BuildInfo -> [String]extraLibDirs,
includeDirs = combineNub :: (BuildInfo -> [a]) -> [a]combineNub includeDirs :: BuildInfo -> [FilePath]includeDirs,
includes = combineNub :: (BuildInfo -> [a]) -> [a]combineNub includes :: BuildInfo -> [FilePath]includes,
installIncludes = combineNub :: (BuildInfo -> [a]) -> [a]combineNub installIncludes :: BuildInfo -> [FilePath]installIncludes,
options = combine :: (Library -> a) -> acombine options :: BuildInfo -> [(CompilerFlavor, [String])]options,
ghcProfOptions = combine :: (Library -> a) -> acombine ghcProfOptions :: BuildInfo -> [String]ghcProfOptions,
ghcSharedOptions = combine :: (Library -> a) -> acombine ghcSharedOptions :: BuildInfo -> [String]ghcSharedOptions,
customFieldsBI = combine :: (Library -> a) -> acombine customFieldsBI :: BuildInfo -> [(String, String)]customFieldsBI,
targetBuildDepends = combineNub :: (BuildInfo -> [a]) -> [a]combineNub targetBuildDepends :: BuildInfo -> [Dependency]targetBuildDepends
}
where
combine field = field :: Library -> afield a :: Librarya mappend :: Monoid a => a -> a -> a`mappend` field :: Library -> afield b :: Libraryb
combineNub field = nub :: Eq a => [a] -> [a]nub (combine :: (Library -> a) -> acombine field :: Library -> afield)
combineMby field = field :: Library -> afield b :: Libraryb mplus :: MonadPlus m => forall a. m a -> m a -> m a`mplus` field :: Library -> afield a :: Librarya
emptyBuildInfo :: BuildInfo
emptyBuildInfo = mempty :: Monoid a => amempty
allBuildInfo :: PackageDescription -> [BuildInfo]
allBuildInfo = flip :: (a -> b -> c) -> b -> a -> cflip allComponentsBy :: PackageDescription -> (Component -> a) -> [a]allComponentsBy
($) :: (a -> b) -> a -> b$ compSel ::
(Library -> a)
-> (Executable -> a)
-> (TestSuite -> a)
-> Component
-> acompSel libBuildInfo :: Library -> BuildInfolibBuildInfo buildInfo :: Executable -> BuildInfobuildInfo testBuildInfo :: TestSuite -> BuildInfotestBuildInfo
data Component = CLib Library
| CExe Executable
| CTst TestSuite
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead)
compSel :: (Library -> a)
-> (Executable -> a)
-> (TestSuite -> a)
-> Component
-> a
compSel f _ _ (CLib l) = f :: TestSuite -> [Char]f l :: Libraryl
compSel _ f _ (CExe e) = f :: TestSuite -> [Char]f e :: Executablee
compSel _ _ f (CTst t) = f :: TestSuite -> [Char]f t :: TestSuitet
allComponentsBy :: PackageDescription
-> (Component -> a)
-> [a]
allComponentsBy pkg_descr f = [ f :: TestSuite -> [Char]f (CLib :: Library -> ComponentCLib l :: Libraryl) | Just l <- [library :: PackageDescription -> Maybe Librarylibrary pkg_descr :: PackageDescriptionpkg_descr]
, buildable :: BuildInfo -> Boolbuildable (libBuildInfo :: Library -> BuildInfolibBuildInfo l :: Libraryl)
]
(++) :: [a] -> [a] -> [a]++
[ f :: TestSuite -> [Char]f (CExe :: Executable -> ComponentCExe e :: Executablee) | e <- executables :: PackageDescription -> [Executable]executables pkg_descr :: PackageDescriptionpkg_descr
, buildable :: BuildInfo -> Boolbuildable (buildInfo :: Executable -> BuildInfobuildInfo e :: Executablee)
]
(++) :: [a] -> [a] -> [a]++
[ f :: TestSuite -> [Char]f (CTst :: TestSuite -> ComponentCTst t :: TestSuitet) | t <- testSuites :: PackageDescription -> [TestSuite]testSuites pkg_descr :: PackageDescriptionpkg_descr
, buildable :: BuildInfo -> Boolbuildable (testBuildInfo :: TestSuite -> BuildInfotestBuildInfo t :: TestSuitet)
, testEnabled :: TestSuite -> BooltestEnabled t :: TestSuitet
]
allLanguages :: BuildInfo -> [Language]
allLanguages bi = maybeToList :: Maybe a -> [a]maybeToList (defaultLanguage :: BuildInfo -> Maybe LanguagedefaultLanguage bi :: BuildInfobi)
(++) :: [a] -> [a] -> [a]++ otherLanguages :: BuildInfo -> [Language]otherLanguages bi :: BuildInfobi
allExtensions :: BuildInfo -> [Extension]
allExtensions bi = usedExtensions :: BuildInfo -> [Extension]usedExtensions bi :: BuildInfobi
(++) :: [a] -> [a] -> [a]++ otherExtensions :: BuildInfo -> [Extension]otherExtensions bi :: BuildInfobi
usedExtensions :: BuildInfo -> [Extension]
usedExtensions bi = oldExtensions :: BuildInfo -> [Extension]oldExtensions bi :: BuildInfobi
(++) :: [a] -> [a] -> [a]++ defaultExtensions :: BuildInfo -> [Extension]defaultExtensions bi :: BuildInfobi
type HookedBuildInfo = (Maybe BuildInfo, [(String, BuildInfo)])
emptyHookedBuildInfo :: HookedBuildInfo
emptyHookedBuildInfo = (Nothing :: Maybe aNothing, [] :: [a][])
hcOptions :: CompilerFlavor -> BuildInfo -> [String]
hcOptions hc bi = [ opt :: Stringopt | (hc',opts) <- options :: BuildInfo -> [(CompilerFlavor, [String])]options bi :: BuildInfobi
, hc' :: CompilerFlavorhc' (==) :: Eq a => a -> a -> Bool== hc :: CompilerFlavorhc
, opt <- opts :: [String]opts ]
data repoLocation :: Maybe StringSourceRepo = SourceRepo {
repoKind :: RepoKind,
repoType :: Maybe RepoType,
repoLocation :: Maybe String,
repoModule :: Maybe String,
repoBranch :: Maybe String,
repoTag :: Maybe String,
repoSubdir :: Maybe FilePath
}
deriving (($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
data RepoKind =
RepoHead
| RepoThis
| RepoKindUnknown String
deriving (($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Ord ::
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> T:Ord aOrd, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
data RepoType = Darcs | Git | SVN | CVS
| Mercurial | GnuArch | Bazaar | Monotone
| OtherRepoType String
deriving (($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Ord ::
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> T:Ord aOrd, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
knownRepoTypes :: [RepoType]
knownRepoTypes = [Darcs :: RepoTypeDarcs, Git :: RepoTypeGit, SVN :: RepoTypeSVN, CVS :: RepoTypeCVS
,Mercurial :: RepoTypeMercurial, GnuArch :: RepoTypeGnuArch, Bazaar :: RepoTypeBazaar, Monotone :: RepoTypeMonotone]
repoTypeAliases :: RepoType -> [String]
repoTypeAliases Bazaar = ["bzr"]
repoTypeAliases Mercurial = ["hg"]
repoTypeAliases GnuArch = ["arch"]
repoTypeAliases _ = [] :: [a][]
instance D:Text :: (a -> Doc) -> (forall r. ReadP r a) -> T:Text aText RepoKind where
disp RepoHead = text :: String -> DocDisp.text "head"
disp RepoThis = text :: String -> DocDisp.text "this"
disp (RepoKindUnknown other) = text :: String -> DocDisp.text other :: BuildTypeother
parse = do
name <- ident :: ReadP r Stringident
return :: Monad m => forall a. a -> m areturn ($) :: (a -> b) -> a -> b$ case lowercase :: String -> Stringlowercase name :: Stringname of
"head" -> RepoHead :: RepoKindRepoHead
"this" -> RepoThis :: RepoKindRepoThis
_ -> RepoKindUnknown :: String -> RepoKindRepoKindUnknown name :: Stringname
instance D:Text :: (a -> Doc) -> (forall r. ReadP r a) -> T:Text aText RepoType where
disp (OtherRepoType other) = text :: String -> DocDisp.text other :: BuildTypeother
disp other = text :: String -> DocDisp.text (lowercase :: String -> Stringlowercase (show :: Show a => a -> Stringshow other :: BuildTypeother))
parse = fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap classifyRepoType :: String -> RepoTypeclassifyRepoType ident :: ReadP r Stringident
classifyRepoType :: String -> RepoType
classifyRepoType s =
case lookup :: Eq a => a -> [(a, b)] -> Maybe blookup (lowercase :: String -> Stringlowercase s :: Strings) repoTypeMap :: [(String, RepoType)]repoTypeMap of
Just repoType' -> repoType' :: RepoTyperepoType'
Nothing -> OtherRepoType :: String -> RepoTypeOtherRepoType s :: Strings
where
repoTypeMap = [ (name :: Stringname, repoType' :: RepoTyperepoType')
| repoType' <- knownRepoTypes :: [RepoType]knownRepoTypes
, name <- display :: Text a => a -> Stringdisplay repoType' :: RepoTyperepoType' (:) :: a -> [a] -> [a]: repoTypeAliases :: RepoType -> [String]repoTypeAliases repoType' :: RepoTyperepoType' ]
ident :: Parse.ReadP r String
ident = munch1 :: (Char -> Bool) -> ReadP r StringParse.munch1 (\c -> isAlphaNum :: Char -> BoolChar.isAlphaNum c :: Charc (||) :: Bool -> Bool -> Bool|| c :: Charc (==) :: Eq a => a -> a -> Bool== '_' (||) :: Bool -> Bool -> Bool|| c :: Charc (==) :: Eq a => a -> a -> Bool== '-')
lowercase :: String -> String
lowercase = map :: (a -> b) -> [a] -> [b]map toLower :: Char -> CharChar.toLower
updatePackageDescription :: HookedBuildInfo -> PackageDescription -> PackageDescription
updatePackageDescription (mb_lib_bi, exe_bi) p
= p :: PackageDescriptionp{ executables = updateExecutables ::
[(String, BuildInfo)] -> [Executable] -> [Executable]updateExecutables exe_bi :: [(String, BuildInfo)]exe_bi (executables :: PackageDescription -> [Executable]executables p :: PackageDescriptionp)
, library = updateLibrary :: Maybe BuildInfo -> Maybe Library -> Maybe LibraryupdateLibrary mb_lib_bi :: Maybe BuildInfomb_lib_bi (library :: PackageDescription -> Maybe Librarylibrary p :: PackageDescriptionp)
}
where
updateLibrary :: Maybe BuildInfo -> Maybe Library -> Maybe Library
updateLibrary (Just bi) (Just lib) = Just :: a -> Maybe aJust (lib :: Librarylib{libBuildInfo = bi :: BuildInfobi mappend :: Monoid a => a -> a -> a`mappend` libBuildInfo :: Library -> BuildInfolibBuildInfo lib :: Librarylib})
updateLibrary Nothing mb_lib = mb_lib :: Maybe Librarymb_lib
updateLibrary (Just _) Nothing = Nothing :: Maybe aNothing
updateExecutables :: [(String, BuildInfo)]
-> [Executable]
-> [Executable]
updateExecutables exe_bi' executables' = foldr :: (a -> b -> b) -> b -> [a] -> bfoldr updateExecutable ::
(String, BuildInfo) -> [Executable] -> [Executable]updateExecutable executables' :: [Executable]executables' exe_bi' :: [(String, BuildInfo)]exe_bi'
updateExecutable :: (String, BuildInfo)
-> [Executable]
-> [Executable]
updateExecutable _ [] = [] :: [a][]
updateExecutable exe_bi'@(name,bi) (exe:exes)
| exeName :: Executable -> StringexeName exe :: Executableexe (==) :: Eq a => a -> a -> Bool== name :: Stringname = exe :: Executableexe{buildInfo = bi :: BuildInfobi mappend :: Monoid a => a -> a -> a`mappend` buildInfo :: Executable -> BuildInfobuildInfo exe :: Executableexe} (:) :: a -> [a] -> [a]: exes :: [Executable]exes
| otherwise :: Boolotherwise = exe :: Executableexe (:) :: a -> [a] -> [a]: updateExecutable ::
(String, BuildInfo) -> [Executable] -> [Executable]updateExecutable exe_bi' :: [(String, BuildInfo)]exe_bi' exes :: [Executable]exes
data condExecutables ::
[(String, CondTree ConfVar [Dependency] Executable)]GenericPackageDescription =
GenericPackageDescription {
packageDescription :: PackageDescription,
genPackageFlags :: [Flag],
condLibrary :: Maybe (CondTree ConfVar [Dependency] Library),
condExecutables :: [(String, CondTree ConfVar [Dependency] Executable)],
condTestSuites :: [(String, CondTree ConfVar [Dependency] TestSuite)]
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
instance D:Package :: (pkg -> PackageIdentifier) -> T:Package pkgPackage GenericPackageDescription where
packageId = packageId :: Package pkg => pkg -> PackageIdentifierpackageId (.) :: (b -> c) -> (a -> b) -> a -> c. packageDescription ::
GenericPackageDescription -> PackageDescriptionpackageDescription
data flagDescription :: StringFlag = MkFlag
{ flagName :: FlagName
, flagDescription :: String
, flagDefault :: Bool
, flagManual :: Bool
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
newtype FlagName = FlagName String
deriving (($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Ord ::
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> T:Ord aOrd, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead)
type FlagAssignment = [(FlagName, Bool)]
data ConfVar = OS OS
| Arch Arch
| Flag FlagName
| Impl CompilerFlavor VersionRange
deriving (($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
data Condition c = Var c
| Lit Bool
| CNot (Condition c)
| COr (Condition c) (Condition c)
| CAnd (Condition c) (Condition c)
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)
data condTreeComponents ::
[(Condition v, CondTree v c a, Maybe (CondTree v c a))]CondTree v c a = CondNode
{ condTreeData :: a
, condTreeConstraints :: c
, condTreeComponents :: [( Condition v
, CondTree v c a
, Maybe (CondTree v c a))]
}
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) ::
GenericPackageDescription -> GenericPackageDescription -> BoolEq)