summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsolpeth <>2020-02-02 02:18:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-02-02 02:18:00 (GMT)
commit6842df796135e3dd90d6e067900b83df824f7323 (patch)
tree0a65977f71943fc2bbe1bcbcf6b35938c59fff3b
parent863ffa9d23dd152a9489f5b958c47fc5dcbf6f10 (diff)
version 0.6.40.6.4
-rw-r--r--Cabal2Ebuild.hs42
-rw-r--r--Main.hs21
-rw-r--r--Merge.hs45
-rw-r--r--Merge/Dependencies.hs10
-rw-r--r--Portage/Cabal.hs14
-rw-r--r--Portage/Dependency/Print.hs18
-rw-r--r--Portage/GHCCore.hs11
-rw-r--r--Portage/Overlay.hs8
-rw-r--r--Portage/PackageId.hs173
-rw-r--r--Portage/Resolve.hs6
-rw-r--r--Portage/Use.hs28
-rw-r--r--Portage/Version.hs79
-rw-r--r--Status.hs13
-rw-r--r--cabal/.mailmap9
-rw-r--r--cabal/.travis.yml21
-rw-r--r--cabal/AUTHORS12
-rw-r--r--cabal/CONTRIBUTING.md254
-rw-r--r--cabal/Cabal/Cabal.cabal165
-rw-r--r--cabal/Cabal/ChangeLog.md59
-rw-r--r--cabal/Cabal/Distribution/Backpack.hs48
-rw-r--r--cabal/Cabal/Distribution/Backpack/ComponentsGraph.hs18
-rw-r--r--cabal/Cabal/Distribution/Backpack/Configure.hs21
-rw-r--r--cabal/Cabal/Distribution/Backpack/ConfiguredComponent.hs63
-rw-r--r--cabal/Cabal/Distribution/Backpack/DescribeUnitId.hs18
-rw-r--r--cabal/Cabal/Distribution/Backpack/Id.hs20
-rw-r--r--cabal/Cabal/Distribution/Backpack/LinkedComponent.hs23
-rw-r--r--cabal/Cabal/Distribution/Backpack/MixLink.hs30
-rw-r--r--cabal/Cabal/Distribution/Backpack/ModuleScope.hs17
-rw-r--r--cabal/Cabal/Distribution/Backpack/PreExistingComponent.hs2
-rw-r--r--cabal/Cabal/Distribution/Backpack/ReadyComponent.hs31
-rw-r--r--cabal/Cabal/Distribution/Backpack/UnifyM.hs22
-rw-r--r--cabal/Cabal/Distribution/CabalSpecVersion.hs101
-rw-r--r--cabal/Cabal/Distribution/Compat/CharParsing.hs8
-rw-r--r--cabal/Cabal/Distribution/Compat/CopyFile.hs115
-rw-r--r--cabal/Cabal/Distribution/Compat/Directory.hs7
-rw-r--r--cabal/Cabal/Distribution/Compat/MonadFail.hs35
-rw-r--r--cabal/Cabal/Distribution/Compat/Newtype.hs69
-rw-r--r--cabal/Cabal/Distribution/Compat/Parsing.hs17
-rw-r--r--cabal/Cabal/Distribution/Compat/Prelude.hs47
-rwxr-xr-xcabal/Cabal/Distribution/Compat/ResponseFile.hs68
-rw-r--r--cabal/Cabal/Distribution/Compat/Semigroup.hs115
-rw-r--r--cabal/Cabal/Distribution/Compiler.hs95
-rw-r--r--cabal/Cabal/Distribution/FieldGrammar.hs3
-rw-r--r--cabal/Cabal/Distribution/FieldGrammar/Class.hs62
-rw-r--r--cabal/Cabal/Distribution/FieldGrammar/FieldDescrs.hs49
-rw-r--r--cabal/Cabal/Distribution/FieldGrammar/Parsec.hs177
-rw-r--r--cabal/Cabal/Distribution/FieldGrammar/Pretty.hs73
-rw-r--r--cabal/Cabal/Distribution/Fields.hs42
-rw-r--r--cabal/Cabal/Distribution/Fields/ConfVar.hs (renamed from cabal/Cabal/Distribution/Parsec/ConfVar.hs)22
-rw-r--r--cabal/Cabal/Distribution/Fields/Field.hs (renamed from cabal/Cabal/Distribution/Parsec/Field.hs)22
-rw-r--r--cabal/Cabal/Distribution/Fields/Lexer.hs488
-rw-r--r--cabal/Cabal/Distribution/Fields/LexerMonad.hs (renamed from cabal/Cabal/Distribution/Parsec/LexerMonad.hs)9
-rw-r--r--cabal/Cabal/Distribution/Fields/ParseResult.hs (renamed from cabal/Cabal/Distribution/Parsec/ParseResult.hs)31
-rw-r--r--cabal/Cabal/Distribution/Fields/Parser.hs (renamed from cabal/Cabal/Distribution/Parsec/Parser.hs)50
-rw-r--r--cabal/Cabal/Distribution/Fields/Pretty.hs163
-rw-r--r--cabal/Cabal/Distribution/InstalledPackageInfo.hs57
-rw-r--r--cabal/Cabal/Distribution/License.hs29
-rw-r--r--cabal/Cabal/Distribution/Make.hs13
-rw-r--r--cabal/Cabal/Distribution/ModuleName.hs20
-rw-r--r--cabal/Cabal/Distribution/Package.hs6
-rw-r--r--cabal/Cabal/Distribution/PackageDescription.hs6
-rw-r--r--cabal/Cabal/Distribution/PackageDescription/Check.hs327
-rw-r--r--cabal/Cabal/Distribution/PackageDescription/Configuration.hs82
-rw-r--r--cabal/Cabal/Distribution/PackageDescription/FieldGrammar.hs139
-rw-r--r--cabal/Cabal/Distribution/PackageDescription/Parsec.hs252
-rw-r--r--cabal/Cabal/Distribution/PackageDescription/PrettyPrint.hs207
-rw-r--r--cabal/Cabal/Distribution/PackageDescription/Quirks.hs89
-rw-r--r--cabal/Cabal/Distribution/Parsec.hs (renamed from cabal/Cabal/Distribution/Parsec/Class.hs)92
-rw-r--r--cabal/Cabal/Distribution/Parsec/Error.hs21
-rw-r--r--cabal/Cabal/Distribution/Parsec/FieldLineStream.hs21
-rw-r--r--cabal/Cabal/Distribution/Parsec/Lexer.hs422
-rw-r--r--cabal/Cabal/Distribution/Parsec/Newtypes.hs82
-rw-r--r--cabal/Cabal/Distribution/Parsec/Position.hs44
-rw-r--r--cabal/Cabal/Distribution/Parsec/Warning.hs (renamed from cabal/Cabal/Distribution/Parsec/Common.hs)56
-rw-r--r--cabal/Cabal/Distribution/Pretty.hs24
-rw-r--r--cabal/Cabal/Distribution/PrettyUtils.hs23
-rw-r--r--cabal/Cabal/Distribution/ReadE.hs19
-rw-r--r--cabal/Cabal/Distribution/SPDX/License.hs2
-rw-r--r--cabal/Cabal/Distribution/SPDX/LicenseExceptionId.hs58
-rw-r--r--cabal/Cabal/Distribution/SPDX/LicenseExpression.hs2
-rw-r--r--cabal/Cabal/Distribution/SPDX/LicenseId.hs187
-rw-r--r--cabal/Cabal/Distribution/SPDX/LicenseListVersion.hs2
-rw-r--r--cabal/Cabal/Distribution/SPDX/LicenseReference.hs2
-rw-r--r--cabal/Cabal/Distribution/Simple.hs216
-rw-r--r--cabal/Cabal/Distribution/Simple/Bench.hs4
-rw-r--r--cabal/Cabal/Distribution/Simple/Build.hs106
-rw-r--r--cabal/Cabal/Distribution/Simple/Build/Macros.hs28
-rw-r--r--cabal/Cabal/Distribution/Simple/Build/PathsModule.hs15
-rw-r--r--cabal/Cabal/Distribution/Simple/BuildPaths.hs63
-rw-r--r--cabal/Cabal/Distribution/Simple/BuildTarget.hs96
-rw-r--r--cabal/Cabal/Distribution/Simple/Command.hs75
-rw-r--r--cabal/Cabal/Distribution/Simple/Compiler.hs6
-rw-r--r--cabal/Cabal/Distribution/Simple/Configure.hs414
-rw-r--r--cabal/Cabal/Distribution/Simple/Doctest.hs2
-rw-r--r--cabal/Cabal/Distribution/Simple/GHC.hs202
-rw-r--r--cabal/Cabal/Distribution/Simple/GHC/Internal.hs20
-rw-r--r--cabal/Cabal/Distribution/Simple/GHCJS.hs1753
-rw-r--r--cabal/Cabal/Distribution/Simple/Glob.hs23
-rw-r--r--cabal/Cabal/Distribution/Simple/Haddock.hs52
-rw-r--r--cabal/Cabal/Distribution/Simple/HaskellSuite.hs33
-rw-r--r--cabal/Cabal/Distribution/Simple/Install.hs48
-rw-r--r--cabal/Cabal/Distribution/Simple/InstallDirs.hs141
-rw-r--r--cabal/Cabal/Distribution/Simple/InstallDirs/Internal.hs124
-rw-r--r--cabal/Cabal/Distribution/Simple/LocalBuildInfo.hs97
-rw-r--r--cabal/Cabal/Distribution/Simple/PackageIndex.hs65
-rw-r--r--cabal/Cabal/Distribution/Simple/PreProcess.hs31
-rw-r--r--cabal/Cabal/Distribution/Simple/PreProcess/Unlit.hs3
-rw-r--r--cabal/Cabal/Distribution/Simple/Program.hs58
-rw-r--r--cabal/Cabal/Distribution/Simple/Program/Db.hs6
-rw-r--r--cabal/Cabal/Distribution/Simple/Program/Find.hs11
-rw-r--r--cabal/Cabal/Distribution/Simple/Program/GHC.hs48
-rw-r--r--cabal/Cabal/Distribution/Simple/Program/HcPkg.hs34
-rw-r--r--cabal/Cabal/Distribution/Simple/Program/Hpc.hs8
-rw-r--r--cabal/Cabal/Distribution/Simple/Program/Ld.hs1
-rw-r--r--cabal/Cabal/Distribution/Simple/Register.hs23
-rw-r--r--cabal/Cabal/Distribution/Simple/Setup.hs325
-rw-r--r--cabal/Cabal/Distribution/Simple/ShowBuildInfo.hs158
-rw-r--r--cabal/Cabal/Distribution/Simple/SrcDist.hs53
-rw-r--r--cabal/Cabal/Distribution/Simple/Test.hs6
-rw-r--r--cabal/Cabal/Distribution/Simple/Test/ExeV10.hs11
-rw-r--r--cabal/Cabal/Distribution/Simple/Test/LibV09.hs22
-rw-r--r--cabal/Cabal/Distribution/Simple/Test/Log.hs8
-rw-r--r--cabal/Cabal/Distribution/Simple/UHC.hs21
-rw-r--r--cabal/Cabal/Distribution/Simple/UserHooks.hs18
-rw-r--r--cabal/Cabal/Distribution/Simple/Utils.hs187
-rw-r--r--cabal/Cabal/Distribution/Simple/Utils/Json.hs46
-rw-r--r--cabal/Cabal/Distribution/System.hs58
-rw-r--r--cabal/Cabal/Distribution/Text.hs108
-rw-r--r--cabal/Cabal/Distribution/Types/AbiDependency.hs14
-rw-r--r--cabal/Cabal/Distribution/Types/AbiHash.hs7
-rw-r--r--cabal/Cabal/Distribution/Types/BenchmarkType.hs10
-rw-r--r--cabal/Cabal/Distribution/Types/BuildInfo.hs40
-rw-r--r--cabal/Cabal/Distribution/Types/BuildInfo/Lens.hs24
-rw-r--r--cabal/Cabal/Distribution/Types/BuildType.hs17
-rw-r--r--cabal/Cabal/Distribution/Types/Component.hs2
-rw-r--r--cabal/Cabal/Distribution/Types/ComponentId.hs10
-rw-r--r--cabal/Cabal/Distribution/Types/ComponentName.hs74
-rw-r--r--cabal/Cabal/Distribution/Types/ComponentRequestedSpec.hs5
-rw-r--r--cabal/Cabal/Distribution/Types/CondTree.hs8
-rw-r--r--cabal/Cabal/Distribution/Types/Dependency.hs85
-rw-r--r--cabal/Cabal/Distribution/Types/DependencyMap.hs18
-rw-r--r--cabal/Cabal/Distribution/Types/ExeDependency.hs14
-rw-r--r--cabal/Cabal/Distribution/Types/ExecutableScope.hs10
-rw-r--r--cabal/Cabal/Distribution/Types/ExposedModule.hs17
-rw-r--r--cabal/Cabal/Distribution/Types/ForeignLib.hs16
-rw-r--r--cabal/Cabal/Distribution/Types/ForeignLibOption.hs9
-rw-r--r--cabal/Cabal/Distribution/Types/ForeignLibType.hs10
-rw-r--r--cabal/Cabal/Distribution/Types/GenericPackageDescription.hs32
-rw-r--r--cabal/Cabal/Distribution/Types/GenericPackageDescription/Lens.hs46
-rw-r--r--cabal/Cabal/Distribution/Types/GivenComponent.hs28
-rw-r--r--cabal/Cabal/Distribution/Types/IncludeRenaming.hs11
-rw-r--r--cabal/Cabal/Distribution/Types/InstalledPackageInfo.hs22
-rw-r--r--cabal/Cabal/Distribution/Types/InstalledPackageInfo/FieldGrammar.hs144
-rw-r--r--cabal/Cabal/Distribution/Types/InstalledPackageInfo/Lens.hs9
-rw-r--r--cabal/Cabal/Distribution/Types/LegacyExeDependency.hs21
-rw-r--r--cabal/Cabal/Distribution/Types/Library.hs81
-rw-r--r--cabal/Cabal/Distribution/Types/Library/Lens.hs21
-rw-r--r--cabal/Cabal/Distribution/Types/LibraryName.hs72
-rw-r--r--cabal/Cabal/Distribution/Types/LibraryVisibility.hs49
-rw-r--r--cabal/Cabal/Distribution/Types/LocalBuildInfo.hs50
-rw-r--r--cabal/Cabal/Distribution/Types/Mixin.hs11
-rw-r--r--cabal/Cabal/Distribution/Types/Module.hs11
-rw-r--r--cabal/Cabal/Distribution/Types/ModuleReexport.hs18
-rw-r--r--cabal/Cabal/Distribution/Types/ModuleRenaming.hs106
-rw-r--r--cabal/Cabal/Distribution/Types/MungedPackageId.hs75
-rw-r--r--cabal/Cabal/Distribution/Types/MungedPackageName.hs139
-rw-r--r--cabal/Cabal/Distribution/Types/PackageDescription.hs18
-rw-r--r--cabal/Cabal/Distribution/Types/PackageDescription/Lens.hs66
-rw-r--r--cabal/Cabal/Distribution/Types/PackageId.hs62
-rw-r--r--cabal/Cabal/Distribution/Types/PackageName.hs7
-rw-r--r--cabal/Cabal/Distribution/Types/PackageName/Magic.hs20
-rw-r--r--cabal/Cabal/Distribution/Types/PackageVersionConstraint.hs39
-rw-r--r--cabal/Cabal/Distribution/Types/PkgconfigDependency.hs19
-rw-r--r--cabal/Cabal/Distribution/Types/PkgconfigName.hs8
-rw-r--r--cabal/Cabal/Distribution/Types/PkgconfigVersion.hs105
-rw-r--r--cabal/Cabal/Distribution/Types/PkgconfigVersionRange.hs142
-rw-r--r--cabal/Cabal/Distribution/Types/SourceRepo.hs15
-rw-r--r--cabal/Cabal/Distribution/Types/TestType.hs9
-rw-r--r--cabal/Cabal/Distribution/Types/UnitId.hs17
-rw-r--r--cabal/Cabal/Distribution/Types/UnqualComponentName.hs11
-rw-r--r--cabal/Cabal/Distribution/Types/Version.hs54
-rw-r--r--cabal/Cabal/Distribution/Types/VersionInterval.hs5
-rw-r--r--cabal/Cabal/Distribution/Types/VersionRange.hs428
-rw-r--r--cabal/Cabal/Distribution/Types/VersionRange/Internal.hs433
-rw-r--r--cabal/Cabal/Distribution/Utils/NubList.hs3
-rw-r--r--cabal/Cabal/Distribution/Verbosity.hs97
-rw-r--r--cabal/Cabal/Distribution/Verbosity/Internal.hs23
-rw-r--r--cabal/Cabal/Distribution/Version.hs71
-rw-r--r--cabal/Cabal/Language/Haskell/Extension.hs41
-rw-r--r--cabal/Cabal/Makefile20
-rw-r--r--cabal/Cabal/doc/cabaldomain.py37
-rw-r--r--cabal/Cabal/doc/conf.py8
-rw-r--r--cabal/Cabal/doc/developing-packages.rst393
-rw-r--r--cabal/Cabal/doc/file-format-changelog.rst88
-rw-r--r--cabal/Cabal/doc/hcar/Cabal-201604.tex118
-rw-r--r--cabal/Cabal/doc/hcar/Cabal-201611.tex140
-rw-r--r--cabal/Cabal/doc/hcar/Cabal-201811.tex121
-rw-r--r--cabal/Cabal/doc/hcar/hcar.sty186
-rw-r--r--cabal/Cabal/doc/hcar/main.tex11
-rw-r--r--cabal/Cabal/doc/installing-packages.rst37
-rw-r--r--cabal/Cabal/doc/nix-local-build-overview.rst8
-rw-r--r--cabal/Cabal/doc/nix-local-build.rst356
-rw-r--r--cabal/Cabal/doc/references.inc2
-rw-r--r--cabal/Makefile72
-rw-r--r--cabal/README.md253
-rw-r--r--cabal/appveyor.yml31
-rw-r--r--cabal/boot/Lexer.x8
-rw-r--r--cabal/boot/SPDX.LicenseExceptionId.template.hs20
-rw-r--r--cabal/boot/SPDX.LicenseId.template.hs22
-rw-r--r--cabal/cabal-dev-scripts/cabal-dev-scripts.cabal8
-rw-r--r--cabal/cabal-dev-scripts/src/GenSPDX.hs47
-rw-r--r--cabal/cabal-dev-scripts/src/GenSPDXExc.hs47
-rw-r--r--cabal/cabal-dev-scripts/src/GenUtils.hs25
-rw-r--r--cabal/cabal-install/Distribution/Client/BuildReports/Anonymous.hs6
-rw-r--r--cabal/cabal-install/Distribution/Client/BuildReports/Types.hs4
-rw-r--r--cabal/cabal-install/Distribution/Client/BuildReports/Upload.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/Check.hs8
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdBench.hs28
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdBuild.hs55
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdClean.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdConfigure.hs34
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdErrorMessages.hs10
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdExec.hs24
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdFreeze.hs32
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdHaddock.hs22
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdInstall.hs567
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdInstall/ClientInstallFlags.hs105
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdLegacy.hs80
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdRepl.hs131
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdRun.hs205
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdSdist.hs120
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdTest.hs75
-rw-r--r--cabal/cabal-install/Distribution/Client/CmdUpdate.hs48
-rw-r--r--cabal/cabal-install/Distribution/Client/Compat/Prelude.hs5
-rw-r--r--cabal/cabal-install/Distribution/Client/Config.hs234
-rw-r--r--cabal/cabal-install/Distribution/Client/Configure.hs24
-rw-r--r--cabal/cabal-install/Distribution/Client/Dependency.hs61
-rw-r--r--cabal/cabal-install/Distribution/Client/Dependency/Types.hs4
-rw-r--r--cabal/cabal-install/Distribution/Client/DistDirLayout.hs19
-rw-r--r--cabal/cabal-install/Distribution/Client/Fetch.hs8
-rw-r--r--cabal/cabal-install/Distribution/Client/FetchUtils.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/Freeze.hs8
-rw-r--r--cabal/cabal-install/Distribution/Client/GenBounds.hs10
-rw-r--r--cabal/cabal-install/Distribution/Client/Get.hs19
-rw-r--r--cabal/cabal-install/Distribution/Client/Glob.hs6
-rw-r--r--cabal/cabal-install/Distribution/Client/HttpUtils.hs10
-rw-r--r--cabal/cabal-install/Distribution/Client/IndexUtils.hs10
-rw-r--r--cabal/cabal-install/Distribution/Client/IndexUtils/Timestamp.hs6
-rw-r--r--cabal/cabal-install/Distribution/Client/Init.hs320
-rw-r--r--cabal/cabal-install/Distribution/Client/Init/Heuristics.hs8
-rw-r--r--cabal/cabal-install/Distribution/Client/Init/Types.hs20
-rw-r--r--cabal/cabal-install/Distribution/Client/Install.hs140
-rw-r--r--cabal/cabal-install/Distribution/Client/InstallPlan.hs4
-rw-r--r--cabal/cabal-install/Distribution/Client/InstallSymlink.hs20
-rw-r--r--cabal/cabal-install/Distribution/Client/List.hs6
-rw-r--r--cabal/cabal-install/Distribution/Client/Outdated.hs33
-rw-r--r--cabal/cabal-install/Distribution/Client/PackageHash.hs11
-rw-r--r--cabal/cabal-install/Distribution/Client/PackageUtils.hs18
-rw-r--r--cabal/cabal-install/Distribution/Client/ParseUtils.hs145
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectBuilding.hs173
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectConfig.hs130
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs256
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectConfig/Types.hs33
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectOrchestration.hs168
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectPlanOutput.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectPlanning.hs174
-rw-r--r--cabal/cabal-install/Distribution/Client/ProjectPlanning/Types.hs55
-rw-r--r--cabal/cabal-install/Distribution/Client/Run.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/Sandbox.hs5
-rw-r--r--cabal/cabal-install/Distribution/Client/Sandbox/PackageEnvironment.hs8
-rw-r--r--cabal/cabal-install/Distribution/Client/Sandbox/Timestamp.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/Security/HTTP.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/Setup.hs607
-rw-r--r--cabal/cabal-install/Distribution/Client/SetupWrapper.hs21
-rw-r--r--cabal/cabal-install/Distribution/Client/SolverInstallPlan.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/SourceRepoParse.hs9
-rw-r--r--cabal/cabal-install/Distribution/Client/SrcDist.hs54
-rw-r--r--cabal/cabal-install/Distribution/Client/Store.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/TargetSelector.hs33
-rw-r--r--cabal/cabal-install/Distribution/Client/Targets.hs26
-rw-r--r--cabal/cabal-install/Distribution/Client/Types.hs18
-rw-r--r--cabal/cabal-install/Distribution/Client/Update.hs2
-rw-r--r--cabal/cabal-install/Distribution/Client/Upload.hs74
-rw-r--r--cabal/cabal-install/Distribution/Client/Utils/Parsec.hs102
-rw-r--r--cabal/cabal-install/Distribution/Client/World.hs8
-rw-r--r--cabal/cabal-install/Distribution/Deprecated/ParseUtils.hs (renamed from cabal/Cabal/Distribution/ParseUtils.hs)177
-rw-r--r--cabal/cabal-install/Distribution/Deprecated/ReadP.hs (renamed from cabal/Cabal/Distribution/Compat/ReadP.hs)70
-rw-r--r--cabal/cabal-install/Distribution/Deprecated/Text.hs410
-rw-r--r--cabal/cabal-install/Distribution/Deprecated/ViewAsFieldDescr.hs85
-rw-r--r--cabal/cabal-install/Distribution/Solver/Compat/Prelude.hs2
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular.hs246
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Builder.hs8
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/ConflictSet.hs14
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Dependency.hs3
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Explore.hs77
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/IndexConversion.hs8
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Log.hs43
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Message.hs18
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Package.hs2
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Preference.hs10
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Solver.hs16
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Tree.hs5
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Validate.hs5
-rw-r--r--cabal/cabal-install/Distribution/Solver/Modular/Version.hs2
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/ComponentDeps.hs28
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/InstSolverPackage.hs3
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/PackageConstraint.hs6
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/PackageIndex.hs19
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/PackagePath.hs2
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/PkgConfigDb.hs49
-rw-r--r--cabal/cabal-install/Distribution/Solver/Types/Settings.hs30
-rw-r--r--cabal/cabal-install/README.md2
-rw-r--r--cabal/cabal-install/bash-completion/cabal216
-rwxr-xr-xcabal/cabal-install/bootstrap.sh39
-rw-r--r--cabal/cabal-install/cabal-install.cabal26
-rw-r--r--cabal/cabal-install/cabal-install.cabal.pp36
-rw-r--r--cabal/cabal-install/changelog48
-rw-r--r--cabal/cabal-install/main/Main.hs75
-rw-r--r--cabal/cabal-install/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs19
-rw-r--r--cabal/cabal-install/tests/IntegrationTests2.hs65
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs26
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/FileMonitor.hs3
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/GenericInstances.hs10
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/Glob.hs4
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/IndexUtils/Timestamp.hs2
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/InstallPlan.hs4
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs188
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/Targets.hs7
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Client/TreeDiffInstances.hs106
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL/TestCaseUtils.hs19
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Solver/Modular/QuickCheck.hs5
-rw-r--r--cabal/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs121
-rw-r--r--cabal/cabal-testsuite/PackageTests/AllowNewer/cabal.test.hs32
-rw-r--r--cabal/cabal-testsuite/PackageTests/AllowOlder/cabal.test.hs32
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external-target.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external-target.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal-target.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal-target.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-external.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-external.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-internal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-internal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Reexport2/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/Reexport2/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/Go.hs5
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/T5634.cabal22
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/Unused.hsig1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/impl/Impl.hs1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/setup.cabal.out17
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/setup.out16
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/setup.test.hs5
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/sig-with-th/Sig.hsig1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/T5634/sig-with-th/THFuns.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/Main.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/bkpcabal01.cabal36
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/cabal.out34
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/cabal.project1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/cabal.test.hs5
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/impl/H.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/impl/I.hs1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/p/H.hsig2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/p/P.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/q/I.hsig1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Backpack/bkpcabal01/q/Q.hs3
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildDeps/DepCycle/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildDeps/DepCycle/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary1/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary1/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTargets/UseLocalPackage/use-local-version-of-package.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTargets/UseLocalPackage/use-local-version-of-package.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTargets/UseLocalPackageForSetup/use-local-package-as-setup-dep.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTargets/UseLocalPackageForSetup/use-local-package-as-setup-dep.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildToolDepends/setup.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildToolDepends/setup.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTools/External/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTools/External/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTools/Internal/cabal.out3
-rw-r--r--cabal/cabal-testsuite/PackageTests/BuildTools/Internal/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CaretOperator/setup.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Check/DifferentGhcOptions/cabal.out8
-rw-r--r--cabal/cabal-testsuite/PackageTests/Check/DifferentGhcOptions/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Check/DifferentGhcOptions/pkg.cabal15
-rw-r--r--cabal/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomDep/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomPlain/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomSegfault/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomSegfault/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomWithoutCabal/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomWithoutCabal/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomWithoutCabalDefaultMain/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/CustomWithoutCabalDefaultMain/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/Exec/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Exec/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.test.hs5
-rw-r--r--cabal/cabal-testsuite/PackageTests/ExecModern/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/ExecModern/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalLibraries/Executable/setup-static.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalLibraries/cabal-per-package.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalLibraries/cabal-per-package.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalLibraries/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalLibraries/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/setup.cabal.out13
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/setup.out13
-rw-r--r--cabal/cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/setup.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/MultipleLibraries/cabal.out12
-rw-r--r--cabal/cabal-testsuite/PackageTests/MultipleLibraries/cabal.project4
-rw-r--r--cabal/cabal-testsuite/PackageTests/MultipleLibraries/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/MultipleLibraries/d/d.cabal12
-rw-r--r--cabal/cabal-testsuite/PackageTests/MultipleLibraries/p/p.cabal8
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdBench/MultipleBenchmarks/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdBench/MultipleBenchmarks/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdExec/GhcInvocation/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdExec/GhcInvocation/cabal.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdExec/RunExe/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdExec/RunExe/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Datafiles/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Datafiles/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ExeAndLib/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ExeAndLib/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ExitCodePropagation/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ExitCodePropagation/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/MultipleExes/cabal.out10
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/MultipleExes/cabal.test.hs10
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/MultiplePackages/cabal.out16
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/MultiplePackages/cabal.test.hs16
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Script/cabal.out8
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Script/cabal.project1
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Script/cabal.test.hs5
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Script/script.cabal4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Script/script.hs11
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ScriptLiterate/cabal.out8
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ScriptLiterate/cabal.project1
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ScriptLiterate/cabal.test.hs5
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ScriptLiterate/script.cabal4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/ScriptLiterate/script.lhs18
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Single/cabal.out12
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CmdRun/Single/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CustomSetup/LocalPackageWithCustomSetup/build-local-package-with-custom-setup.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/MonitorCabalFiles/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/MonitorCabalFiles/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T3460/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T3827/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T3978/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T3978/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4017/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4017/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4375/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4375/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4405/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4405/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4450/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4477/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T4477/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewBuild/T5164/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewConfigure/LocalConfigOverwrite/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewConfigure/LocalConfigOverwrite/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewFreeze/BuildTools/new_freeze.out6
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewFreeze/BuildTools/new_freeze.test.hs8
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewFreeze/Flags/new_freeze.out6
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewFreeze/Flags/new_freeze.test.hs8
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewFreeze/FreezeFile/new_freeze.out12
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewFreeze/FreezeFile/new_freeze.test.hs20
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewHaddock/Fails/Example.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out15
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.project1
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewHaddock/Fails/example.cabal9
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/DeterministicTrivial/deterministic.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/DeterministicTrivial/deterministic.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/Globbing/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/Globbing/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/ManyDataFiles/many-data-files.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/ManyDataFiles/many-data-files.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.outbin42 -> 41 bytes
-rw-r--r--cabal/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Outdated/outdated-project-file.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Outdated/outdated-project-file.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/Outdated/outdated_freeze.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T3436/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T3932/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4202/cabal.out6
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4202/cabal.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4291/dependee/Dependee.hs1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4291/dependee/dependee.cabal11
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4291/depender/depender.cabal10
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4291/setup.cabal.out20
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4291/setup.out18
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4291/setup.test.hs17
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4720/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4720/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4986/cabal.out2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T4986/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T5309/cabal.out9
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T5309/cabal.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T5386/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T5409/use-different-versions-of-dependency-for-library-and-build-tool.test.hs4
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T5677/cabal.out3
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T5677/cabal.test.hs3
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T6125/Main.hs1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T6125/data/foo/bar.html1
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T6125/myprog.cabal9
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T6125/setup.cabal.out9
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T6125/setup.out8
-rw-r--r--cabal/cabal-testsuite/PackageTests/Regression/T6125/setup.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/FlagInProject/a.cabal7
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/FlagInProject/cabal.project3
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/FlagInProject/cabal.test.hs6
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/MultiPkg/a/a.cabal8
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/MultiPkg/b/b.cabal10
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/MultiPkg/cabal.project6
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/MultiPkg/cabal.test.hs16
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/repo/other-lib-1.0/other-lib.cabal7
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/repo/some-exe-1.0/some-exe.cabal6
-rw-r--r--cabal/cabal-testsuite/PackageTests/RequireExplicit/repo/some-lib-1.0/some-lib.cabal7
-rw-r--r--cabal/cabal-testsuite/PackageTests/SPDX/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/SimpleDefault/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal-with-hpc.multitest.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.out4
-rw-r--r--cabal/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.test.hs2
-rw-r--r--cabal/cabal-testsuite/PackageTests/UserConfig/cabal.out6
-rw-r--r--cabal/cabal-testsuite/PackageTests/UserConfig/cabal.test.hs4
-rw-r--r--cabal/cabal-testsuite/Setup.hs84
-rw-r--r--cabal/cabal-testsuite/Setup.simple.hs6
-rw-r--r--cabal/cabal-testsuite/Test/Cabal/Monad.hs18
-rw-r--r--cabal/cabal-testsuite/Test/Cabal/Plan.hs13
-rw-r--r--cabal/cabal-testsuite/Test/Cabal/Prelude.hs21
-rw-r--r--cabal/cabal-testsuite/Test/Cabal/Script.hs37
-rw-r--r--cabal/cabal-testsuite/Test/Cabal/Server.hs6
-rw-r--r--cabal/cabal-testsuite/cabal-testsuite.cabal105
-rw-r--r--cabal/cabal-testsuite/main/cabal-tests.hs39
-rw-r--r--cabal/cabal.project10
-rw-r--r--cabal/cabal.project.local.travis12
-rw-r--r--cabal/cabal.project.travis20
-rw-r--r--cabal/cabal.project.travis.libonly1
-rw-r--r--cabal/cabal.project.validate2
-rw-r--r--cabal/cabal.project.validate.libonly8
-rw-r--r--cabal/license-list-data/exceptions-3.6.json408
-rw-r--r--cabal/license-list-data/licenses-3.6.json4974
-rw-r--r--cabal/pretty-show-1.6.16/CHANGELOG41
-rw-r--r--cabal/pretty-show-1.6.16/LICENSE19
-rw-r--r--cabal/pretty-show-1.6.16/Setup.lhs8
-rw-r--r--cabal/pretty-show-1.6.16/Text/Show/Html.hs211
-rw-r--r--cabal/pretty-show-1.6.16/Text/Show/Parser.y130
-rw-r--r--cabal/pretty-show-1.6.16/Text/Show/Pretty.hs186
-rw-r--r--cabal/pretty-show-1.6.16/Text/Show/PrettyVal.hs130
-rw-r--r--cabal/pretty-show-1.6.16/Text/Show/Value.hs41
-rw-r--r--cabal/pretty-show-1.6.16/bin/ppsh.hs44
-rw-r--r--cabal/pretty-show-1.6.16/pretty-show.cabal73
-rw-r--r--cabal/pretty-show-1.6.16/style/jquery-src.js10337
-rw-r--r--cabal/pretty-show-1.6.16/style/jquery.js4
-rw-r--r--cabal/pretty-show-1.6.16/style/pretty-show.css32
-rw-r--r--cabal/pretty-show-1.6.16/style/pretty-show.js23
-rw-r--r--cabal/solver-benchmarks/solver-benchmarks.cabal2
-rwxr-xr-xcabal/travis-bootstrap.sh15
-rw-r--r--cabal/travis-common.sh4
-rwxr-xr-xcabal/travis-deploy.sh2
-rwxr-xr-xcabal/travis-install.sh9
-rwxr-xr-xcabal/validate.sh313
-rw-r--r--hackport.cabal24
587 files changed, 21147 insertions, 19764 deletions
diff --git a/Cabal2Ebuild.hs b/Cabal2Ebuild.hs
index 15cffa1..e5bb8a3 100644
--- a/Cabal2Ebuild.hs
+++ b/Cabal2Ebuild.hs
@@ -25,8 +25,10 @@ import qualified Distribution.PackageDescription as Cabal
(PackageDescription(..), license)
import qualified Distribution.Package as Cabal (PackageIdentifier(..)
, Dependency(..))
-import qualified Distribution.Version as Cabal (VersionRange, foldVersionRange')
-import Distribution.Text (display)
+import qualified Distribution.Version as Cabal (VersionRange, cataVersionRange, normaliseVersionRange
+ , wildcardUpperBound, majorUpperBound)
+import Distribution.Version (VersionRangeF(..))
+import Distribution.Pretty (prettyShow)
import Data.Char (isUpper)
import Data.Maybe
@@ -44,9 +46,9 @@ import Portage.Version
cabal2ebuild :: Portage.Category -> Cabal.PackageDescription -> Portage.EBuild
cabal2ebuild cat pkg = Portage.ebuildTemplate {
E.name = Portage.cabal_pn_to_PN cabal_pn,
- E.category = display cat,
+ E.category = prettyShow cat,
E.hackage_name= cabalPkgName,
- E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
+ E.version = prettyShow (Cabal.pkgVersion (Cabal.package pkg)),
E.description = if null (Cabal.synopsis pkg) then Cabal.description pkg
else Cabal.synopsis pkg,
E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
@@ -69,7 +71,7 @@ cabal2ebuild cat pkg = Portage.ebuildTemplate {
else [])
} where
cabal_pn = Cabal.pkgName $ Cabal.package pkg
- cabalPkgName = display cabal_pn
+ cabalPkgName = prettyShow cabal_pn
hasLibs = isJust (Cabal.library pkg)
hasTests = (not . null) (Cabal.testSuites pkg)
thisHomepage = if (null $ Cabal.homepage pkg)
@@ -80,7 +82,7 @@ convertDependencies :: O.Overlay -> Portage.Category -> [Cabal.Dependency] -> [D
convertDependencies overlay category = map (convertDependency overlay category)
convertDependency :: O.Overlay -> Portage.Category -> Cabal.Dependency -> Dependency
-convertDependency overlay category (Cabal.Dependency pname versionRange)
+convertDependency overlay category (Cabal.Dependency pname versionRange _lib)
= convert versionRange
where
pn = case Portage.resolveFullPortageName overlay pname of
@@ -91,16 +93,18 @@ convertDependency overlay category (Cabal.Dependency pname versionRange)
p_v v = fromCabalVersion v
convert :: Cabal.VersionRange -> Dependency
- convert = Cabal.foldVersionRange'
- ( mk_p (DRange ZeroB InfinityB) -- ^ @\"-any\"@ version
- )(\v -> mk_p (DExact (p_v v)) -- ^ @\"== v\"@
- )(\v -> mk_p (DRange (StrictLB (p_v v)) InfinityB) -- ^ @\"> v\"@
- )(\v -> mk_p (DRange ZeroB (StrictUB (p_v v))) -- ^ @\"< v\"@
- )(\v -> mk_p (DRange (NonstrictLB (p_v v)) InfinityB) -- ^ @\">= v\"@
- )(\v -> mk_p (DRange ZeroB (NonstrictUB (p_v v))) -- ^ @\"<= v\"@
- )(\v1 v2 -> mk_p (DRange (NonstrictLB (p_v v1)) (StrictUB (p_v v2))) -- ^ @\"== v.*\"@ wildcard. (incl lower, excl upper)
- )(\v1 v2 -> mk_p (DRange (NonstrictLB (p_v v1)) (StrictUB (p_v v2))) -- ^ @\"^>= v\"@ major upper bound
- )(\g1 g2 -> DependAnyOf [g1, g2] -- ^ @\"_ || _\"@ union
- )(\r1 r2 -> DependAllOf [r1, r2] -- ^ @\"_ && _\"@ intersection
- )(\dp -> dp -- ^ @\"(_)\"@ parentheses
- )
+ convert = Cabal.cataVersionRange alg . Cabal.normaliseVersionRange
+ where
+ alg AnyVersionF = mk_p $ DRange ZeroB InfinityB
+ alg (ThisVersionF v) = mk_p $ DExact $ p_v v
+ alg (LaterVersionF v) = mk_p $ DRange (StrictLB $ p_v v) InfinityB
+ alg (EarlierVersionF v) = mk_p $ DRange ZeroB $ StrictUB $ p_v v
+ alg (OrLaterVersionF v) = mk_p $ DRange (NonstrictLB $ p_v v) InfinityB
+ alg (OrEarlierVersionF v) = mk_p $ DRange ZeroB $ NonstrictUB $ p_v v
+ alg (WildcardVersionF v) = mk_p $ DRange (NonstrictLB $ p_v v)
+ $ StrictUB $ p_v $ Cabal.wildcardUpperBound v
+ alg (MajorBoundVersionF v) = mk_p $ DRange (NonstrictLB $ p_v v)
+ $ StrictUB $ p_v $ Cabal.majorUpperBound v
+ alg (UnionVersionRangesF v1 v2) = DependAnyOf [v1, v2]
+ alg (IntersectVersionRangesF v1 v2) = DependAllOf [v1, v2]
+ alg (VersionRangeParensF v) = v
diff --git a/Main.hs b/Main.hs
index 1fcb6f8..1ec09c4 100644
--- a/Main.hs
+++ b/Main.hs
@@ -18,11 +18,14 @@ import Distribution.Simple.Setup
)
import Distribution.Simple.Command -- commandsRun
-import Distribution.Simple.Utils ( die, cabalVersion, warn )
+import Distribution.Simple.Utils ( dieNoVerbosity, cabalVersion, warn )
import qualified Distribution.PackageDescription.Parsec as Cabal
import qualified Distribution.Package as Cabal
import Distribution.Verbosity (Verbosity, normal)
-import Distribution.Text (display, simpleParse)
+
+import Data.Version (showVersion)
+import Distribution.Pretty (prettyShow)
+import Distribution.Parsec (simpleParsec)
import qualified Distribution.Client.Setup as CabalInstall
import qualified Distribution.Client.Types as CabalInstall
@@ -122,7 +125,7 @@ listAction flags extraArgs globalFlags = do
pretty (isInOverlay, pkgId) =
let dec | isInOverlay = " * "
| otherwise = " "
- in dec ++ display pkgId
+ in dec ++ prettyShow pkgId
-----------------------------------------------------------------------
@@ -167,7 +170,7 @@ makeEbuildAction flags args globalFlags = do
(catstr,cabals) <- case args of
(category:cabal1:cabaln) -> return (category, cabal1:cabaln)
_ -> throwEx (ArgumentError "make-ebuild needs at least two arguments. <category> <cabal-1> <cabal-n>")
- cat <- case simpleParse catstr of
+ cat <- case simpleParsec catstr of
Just c -> return c
Nothing -> throwEx (ArgumentError ("could not parse category: " ++ catstr))
let verbosity = fromFlag (makeEbuildVerbosity flags)
@@ -254,7 +257,7 @@ updateCommand = CommandUI {
updateAction :: UpdateFlags -> [String] -> H.GlobalFlags -> IO ()
updateAction flags extraArgs globalFlags = do
unless (null extraArgs) $
- die $ "'update' doesn't take any extra arguments: " ++ unwords extraArgs
+ dieNoVerbosity $ "'update' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag (updateVerbosity flags)
H.withHackPortContext verbosity globalFlags $ \repoContext ->
@@ -475,13 +478,13 @@ mainWorker args =
printErrors errs = do
putStr (concat (intersperse "\n" errs))
exitFailure
- printNumericVersion = putStrLn $ display Paths_hackport.version
+ printNumericVersion = putStrLn $ showVersion Paths_hackport.version
printVersion = putStrLn $ "hackport version "
- ++ display Paths_hackport.version
+ ++ showVersion Paths_hackport.version
++ "\nusing cabal-install "
- ++ display Paths_cabal_install.version
+ ++ showVersion Paths_cabal_install.version
++ " and the Cabal library version "
- ++ display cabalVersion
+ ++ prettyShow cabalVersion
errorHandler :: HackPortError -> IO ()
errorHandler e = do
putStrLn (hackPortShowError e)
diff --git a/Merge.hs b/Merge.hs
index 6458173..b6dc097 100644
--- a/Merge.hs
+++ b/Merge.hs
@@ -21,7 +21,7 @@ import qualified Distribution.PackageDescription.PrettyPrint as Cabal (showPacka
import qualified Distribution.Solver.Types.SourcePackage as CabalInstall
import qualified Distribution.Solver.Types.PackageIndex as CabalInstall
-import Distribution.Text (display)
+import Distribution.Pretty (prettyShow)
import Distribution.Verbosity
import Distribution.Simple.Utils
@@ -39,7 +39,8 @@ import System.Directory ( getCurrentDirectory
, listDirectory
)
import System.Process (system)
-import System.FilePath ((</>), isExtensionOf)
+import System.FilePath ((</>))
+import qualified System.FilePath as SF
import System.Exit
import qualified Cabal2Ebuild as C2E
@@ -80,12 +81,13 @@ readPackageString args = do
[pkg] -> return pkg
_ -> Left (ArgumentError ("Too many arguments: " ++ unwords args))
case Portage.parseFriendlyPackage packageString of
- Just v@(_,_,Nothing) -> return v
+ Right v@(_,_,Nothing) -> return v
-- we only allow versions we can convert into cabal versions
- Just v@(_,_,Just (Portage.Version _ Nothing [] 0)) -> return v
- _ -> Left (ArgumentError ("Could not parse [category/]package[-version]: " ++ packageString))
-
-
+ Right v@(_,_,Just (Portage.Version _ Nothing [] 0)) -> return v
+ Left e -> Left $ ArgumentError $ "Could not parse [category/]package[-version]: "
+ ++ packageString ++ "\nParsec error: " ++ e
+ _ -> Left $ ArgumentError $ "Could not parse [category/]package[-version]: "
+ ++ packageString
-- | Given a list of available packages, and maybe a preferred version,
-- return the available package with that version. Latest version is chosen
@@ -129,7 +131,7 @@ merge verbosity repoContext args overlayPath users_cabal_flags = do
notice verbosity $ "Ambiguous names: " ++ L.intercalate ", " names
forM_ pkgs $ \ps ->
do let p_name = (cabal_pkg_to_pn . L.head) ps
- notice verbosity $ p_name ++ ": " ++ (L.intercalate ", " $ map (display . Cabal.pkgVersion . CabalInstall.packageInfoId) ps)
+ notice verbosity $ p_name ++ ": " ++ (L.intercalate ", " $ map (prettyShow . Cabal.pkgVersion . CabalInstall.packageInfoId) ps)
return $ concat pkgs
-- select a single package taking into account the user specified version
@@ -138,7 +140,7 @@ merge verbosity repoContext args overlayPath users_cabal_flags = do
Nothing -> do
putStrLn "No such version for that package, available versions:"
forM_ availablePkgs $ \ avail ->
- putStrLn (display . CabalInstall.packageInfoId $ avail)
+ putStrLn (prettyShow . CabalInstall.packageInfoId $ avail)
throwEx (ArgumentError "no such version for that package")
Just avail -> return avail
@@ -147,7 +149,7 @@ merge verbosity repoContext args overlayPath users_cabal_flags = do
forM_ availablePkgs $ \ avail -> do
let match_text | CabalInstall.packageInfoId avail == CabalInstall.packageInfoId selectedPkg = "* "
| otherwise = "- "
- info verbosity $ match_text ++ (display . CabalInstall.packageInfoId $ avail)
+ info verbosity $ match_text ++ (prettyShow . CabalInstall.packageInfoId $ avail)
let cabal_pkgId = CabalInstall.packageInfoId selectedPkg
norm_pkgName = Cabal.packageName (Portage.normalizeCabalPackageId cabal_pkgId)
@@ -171,10 +173,7 @@ diffEbuilds fp a b = do _ <- system $ "diff -u --color=auto "
exitSuccess
-- | Maybe return a PackageId of the next highest version for a given
--- package, relative to the provided PackageId of the new version.
--- We achieve this by mapping Portage.filePathToPackageId over the
--- provided package directory, whose contents are filtered for files
--- with the '.ebuild' file extension
+-- package, relative to the provided PackageId.
getPreviousPackageId :: [FilePath] -- ^ list of ebuilds for given package
-> Portage.PackageId -- ^ new PackageId
-> Maybe Portage.PackageId -- ^ maybe PackageId of previous version
@@ -182,8 +181,8 @@ getPreviousPackageId pkgDir newPkgId = do
let pkgIds = reverse
. L.sortOn (Portage.pkgVersion)
. filter (<newPkgId)
- $ Portage.filePathToPackageId newPkgId
- <$> filter (\fp -> ".ebuild" `isExtensionOf` fp) pkgDir
+ $ mapMaybe (Portage.filePathToPackageId (Portage.category . Portage.packageId $ newPkgId))
+ $ SF.dropExtension <$> filter (\fp -> SF.takeExtension fp == ".ebuild") pkgDir
case pkgIds of
x:_ -> Just x
_ -> Nothing
@@ -253,8 +252,8 @@ mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch us
debug verbosity "searching for minimal suitable ghc version"
(compiler_info, ghc_packages, pkgDesc0, _flags, pix) <- case GHCCore.minimumGHCVersionToBuildPackage pkgGenericDesc (Cabal.mkFlagAssignment user_specified_fas) of
Just v -> return v
- Nothing -> let pn = display merged_cabal_pkg_name
- cn = display cat
+ Nothing -> let pn = prettyShow merged_cabal_pkg_name
+ cn = prettyShow cat
in error $ unlines [ "mergeGenericPackageDescription: failed to find suitable GHC for " ++ pn
, " You can try to merge the package manually:"
, " $ cabal unpack " ++ pn
@@ -384,11 +383,11 @@ mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch us
cabal_to_emerge_dep cabal_pkg = Merge.resolveDependencies overlay cabal_pkg compiler_info ghc_packages merged_cabal_pkg_name
debug verbosity $ "buildDepends pkgDesc0 raw: " ++ Cabal.showPackageDescription pkgDesc0
- debug verbosity $ "buildDepends pkgDesc0: " ++ show (map display (Merge.exeAndLibDeps pkgDesc0))
- debug verbosity $ "buildDepends pkgDesc: " ++ show (map display (Merge.buildDepends pkgDesc))
+ debug verbosity $ "buildDepends pkgDesc0: " ++ show (map prettyShow (Merge.exeAndLibDeps pkgDesc0))
+ debug verbosity $ "buildDepends pkgDesc: " ++ show (map prettyShow (Merge.buildDepends pkgDesc))
- notice verbosity $ "Accepted depends: " ++ show (map display accepted_deps)
- notice verbosity $ "Skipped depends: " ++ show (map display skipped_deps)
+ notice verbosity $ "Accepted depends: " ++ show (map prettyShow accepted_deps)
+ notice verbosity $ "Skipped depends: " ++ show (map prettyShow skipped_deps)
notice verbosity $ "Dead flags: " ++ show (map pp_fa irresolvable_flag_assignments)
notice verbosity $ "Dropped flags: " ++ show (map (Cabal.unFlagName.fst) common_fa)
notice verbosity $ "Active flags: " ++ show (map Cabal.unFlagName active_flags)
@@ -442,7 +441,7 @@ mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch us
when fetch $ do
let cabal_pkgId = Cabal.packageId (Merge.packageDescription pkgDesc)
norm_pkgName = Cabal.packageName (Portage.normalizeCabalPackageId cabal_pkgId)
- fetchDigestAndCheck verbosity (overlayPath </> display cat </> display norm_pkgName)
+ fetchDigestAndCheck verbosity (overlayPath </> prettyShow cat </> prettyShow norm_pkgName)
fetchDigestAndCheck :: Verbosity
-> FilePath -- ^ directory of ebuild
diff --git a/Merge/Dependencies.hs b/Merge/Dependencies.hs
index 340ada7..9eb015f 100644
--- a/Merge/Dependencies.hs
+++ b/Merge/Dependencies.hs
@@ -18,7 +18,7 @@ import qualified Data.Set as S
import qualified Distribution.Package as Cabal
import qualified Distribution.PackageDescription as Cabal
import qualified Distribution.Version as Cabal
-import qualified Distribution.Text as Cabal
+import qualified Distribution.Pretty as Cabal
import qualified Distribution.Types.ExeDependency as Cabal
import qualified Distribution.Types.LegacyExeDependency as Cabal
import qualified Distribution.Types.PkgconfigDependency as Cabal
@@ -219,7 +219,7 @@ cabalDependency overlay pkg ~(Cabal.CompilerInfo {
C2E.convertDependency overlay
(Portage.Category "dev-haskell")
(Cabal.Dependency (Cabal.mkPackageName "Cabal")
- finalCabalDep)
+ finalCabalDep (S.singleton Cabal.defaultLibName))
where
versionNumbers = Cabal.versionNumbers cabal_version
userCabalVersion = Cabal.orLaterVersion (Cabal.specVersion pkg)
@@ -389,7 +389,7 @@ legacyBuildToolsDependencies :: Cabal.PackageDescription -> [Portage.Dependency]
legacyBuildToolsDependencies (Cabal.PackageDescription { Cabal.library = lib, Cabal.executables = exes }) = L.nub $
[ case pkg of
Just p -> p
- Nothing -> trace ("WARNING: Unknown build tool '" ++ Cabal.display exe ++ "'. Check the generated ebuild.")
+ Nothing -> trace ("WARNING: Unknown build tool '" ++ Cabal.prettyShow exe ++ "'. Check the generated ebuild.")
(any_c_p "unknown-build-tool" pn)
| exe@(Cabal.LegacyExeDependency pn _range) <- cabalDeps
, pkg <- return (lookup pn buildToolsTable)
@@ -429,7 +429,7 @@ buildToolsProvided = ["hsc2hs"]
hackageBuildToolsDependencies :: Portage.Overlay -> Cabal.PackageDescription -> [Portage.Dependency]
hackageBuildToolsDependencies overlay (Cabal.PackageDescription { Cabal.library = lib, Cabal.executables = exes }) =
haskellDependencies overlay $ L.nub $
- [ Cabal.Dependency pn versionRange
+ [ Cabal.Dependency pn versionRange $ S.singleton Cabal.defaultLibName
| Cabal.ExeDependency pn _component versionRange <- cabalDeps
]
where
@@ -452,7 +452,7 @@ resolvePkgConfigs :: Portage.Overlay -> [Cabal.PkgconfigDependency] -> [Portage.
resolvePkgConfigs overlay cdeps =
[ case resolvePkgConfig overlay pkg of
Just d -> d
- Nothing -> trace ("WARNING: Could not resolve pkg-config: " ++ Cabal.display pkg ++ ". Check generated ebuild.")
+ Nothing -> trace ("WARNING: Could not resolve pkg-config: " ++ Cabal.prettyShow pkg ++ ". Check generated ebuild.")
(any_c_p "unknown-pkg-config" pn)
| pkg@(Cabal.PkgconfigDependency cabal_pn _range) <- cdeps
, let pn = Cabal.unPkgconfigName cabal_pn
diff --git a/Portage/Cabal.hs b/Portage/Cabal.hs
index 25b4ff7..be97b4f 100644
--- a/Portage/Cabal.hs
+++ b/Portage/Cabal.hs
@@ -8,24 +8,24 @@ import qualified Data.List as L
import qualified Distribution.License as Cabal
import qualified Distribution.SPDX.License as SPDX
import qualified Distribution.Package as Cabal
-import qualified Distribution.Text as Cabal
+import qualified Distribution.Pretty as Cabal
-- map the cabal license type to the gentoo license string format
convertLicense :: SPDX.License -> Either String String
convertLicense l =
case Cabal.licenseFromSPDX l of
-- good ones
- Cabal.AGPL mv -> Right $ "AGPL-" ++ (maybe "3" Cabal.display mv) -- almost certainly version 3
- Cabal.GPL mv -> Right $ "GPL-" ++ (maybe "2" Cabal.display mv) -- almost certainly version 2
- Cabal.LGPL mv -> Right $ "LGPL-" ++ (maybe "2.1" Cabal.display mv) -- probably version 2.1
+ Cabal.AGPL mv -> Right $ "AGPL-" ++ (maybe "3" Cabal.prettyShow mv) -- almost certainly version 3
+ Cabal.GPL mv -> Right $ "GPL-" ++ (maybe "2" Cabal.prettyShow mv) -- almost certainly version 2
+ Cabal.LGPL mv -> Right $ "LGPL-" ++ (maybe "2.1" Cabal.prettyShow mv) -- probably version 2.1
Cabal.BSD2 -> Right "BSD-2"
Cabal.BSD3 -> Right "BSD"
Cabal.BSD4 -> Right "BSD-4"
Cabal.PublicDomain -> Right "public-domain"
Cabal.MIT -> Right "MIT"
- Cabal.Apache mv -> Right $ "Apache-" ++ (maybe "1.1" Cabal.display mv) -- probably version 1.1
+ Cabal.Apache mv -> Right $ "Apache-" ++ (maybe "1.1" Cabal.prettyShow mv) -- probably version 1.1
Cabal.ISC -> Right "ISC"
- Cabal.MPL v -> Right $ "MPL-" ++ Cabal.display v -- probably version 1.0
+ Cabal.MPL v -> Right $ "MPL-" ++ Cabal.prettyShow v -- probably version 1.0
-- bad ones
Cabal.AllRightsReserved -> Left "EULA-style licence. Please pick it manually."
Cabal.UnknownLicense _ -> Left "license unknown to cabal. Please pick it manually."
@@ -34,6 +34,6 @@ convertLicense l =
partition_depends :: [Cabal.PackageName] -> Cabal.PackageName -> [Cabal.Dependency] -> ([Cabal.Dependency], [Cabal.Dependency])
partition_depends ghc_package_names merged_cabal_pkg_name = L.partition (not . is_internal_depend)
- where is_internal_depend (Cabal.Dependency pn _vr) = is_itself || is_ghc_package
+ where is_internal_depend (Cabal.Dependency pn _vr _lib) = is_itself || is_ghc_package
where is_itself = pn == merged_cabal_pkg_name
is_ghc_package = pn `elem` ghc_package_names
diff --git a/Portage/Dependency/Print.hs b/Portage/Dependency/Print.hs
index 2c941aa..0b1d667 100644
--- a/Portage/Dependency/Print.hs
+++ b/Portage/Dependency/Print.hs
@@ -11,7 +11,7 @@ import Portage.Use
import Portage.PackageId
-import qualified Distribution.Text as DT
+import qualified Distribution.Pretty as DP (Pretty(..))
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ( vcat, nest, render )
import Text.PrettyPrint as PP ((<>))
@@ -24,13 +24,13 @@ dispSlot AnyBuildTimeSlot = Disp.text ":="
dispSlot (GivenSlot slot) = Disp.text (':' : slot)
dispLBound :: PackageName -> LBound -> Disp.Doc
-dispLBound pn (StrictLB v) = Disp.char '>' PP.<> DT.disp pn <-> DT.disp v
-dispLBound pn (NonstrictLB v) = Disp.text ">=" PP.<> DT.disp pn <-> DT.disp v
+dispLBound pn (StrictLB v) = Disp.char '>' PP.<> DP.pretty pn <-> DP.pretty v
+dispLBound pn (NonstrictLB v) = Disp.text ">=" PP.<> DP.pretty pn <-> DP.pretty v
dispLBound _pn ZeroB = error "unhandled 'dispLBound ZeroB'"
dispUBound :: PackageName -> UBound -> Disp.Doc
-dispUBound pn (StrictUB v) = Disp.char '<' PP.<> DT.disp pn <-> DT.disp v
-dispUBound pn (NonstrictUB v) = Disp.text "<=" PP.<> DT.disp pn <-> DT.disp v
+dispUBound pn (StrictUB v) = Disp.char '<' PP.<> DP.pretty pn <-> DP.pretty v
+dispUBound pn (NonstrictUB v) = Disp.text "<=" PP.<> DP.pretty pn <-> DP.pretty v
dispUBound _pn InfinityB = error "unhandled 'dispUBound Infinity'"
dispDAttr :: DAttr -> Disp.Doc
@@ -58,7 +58,7 @@ showDepend :: Dependency -> Disp.Doc
showDepend (DependAtom (Atom pn range dattr))
= case range of
-- any version
- DRange ZeroB InfinityB -> DT.disp pn PP.<> dispDAttr dattr
+ DRange ZeroB InfinityB -> DP.pretty pn PP.<> dispDAttr dattr
DRange ZeroB ub -> dispUBound pn ub PP.<> dispDAttr dattr
DRange lb InfinityB -> dispLBound pn lb PP.<> dispDAttr dattr
-- TODO: handle >=foo-0 special case
@@ -66,15 +66,15 @@ showDepend (DependAtom (Atom pn range dattr))
DRange lb ub -> showDepend (DependAtom (Atom pn (DRange lb InfinityB) dattr))
PP.<> Disp.char ' '
PP.<> showDepend (DependAtom (Atom pn (DRange ZeroB ub) dattr))
- DExact v -> Disp.char '~' PP.<> DT.disp pn <-> DT.disp v { versionRevision = 0 } PP.<> dispDAttr dattr
+ DExact v -> Disp.char '~' PP.<> DP.pretty pn <-> DP.pretty v { versionRevision = 0 } PP.<> dispDAttr dattr
showDepend (DependIfUse u td fd) = valign $ vcat [td_doc, fd_doc]
where td_doc
| is_empty_dependency td = Disp.empty
- | otherwise = DT.disp u PP.<> Disp.char '?' PP.<> sp PP.<> sparens (showDepend td)
+ | otherwise = DP.pretty u PP.<> Disp.char '?' PP.<> sp PP.<> sparens (showDepend td)
fd_doc
| is_empty_dependency fd = Disp.empty
- | otherwise = Disp.char '!' PP.<> DT.disp u PP.<> Disp.char '?' PP.<> sp PP.<> sparens (showDepend fd)
+ | otherwise = Disp.char '!' PP.<> DP.pretty u PP.<> Disp.char '?' PP.<> sp PP.<> sparens (showDepend fd)
showDepend (DependAnyOf deps) = Disp.text "||" PP.<> sp PP.<> sparens (vcat $ map showDependInAnyOf deps)
showDepend (DependAllOf deps) = valign $ vcat $ map showDepend deps
diff --git a/Portage/GHCCore.hs b/Portage/GHCCore.hs
index e8e0f2c..e026705 100644
--- a/Portage/GHCCore.hs
+++ b/Portage/GHCCore.hs
@@ -21,8 +21,9 @@ import Distribution.PackageDescription.Configuration
import Distribution.Compiler (CompilerId(..), CompilerFlavor(GHC))
import Distribution.System
import Distribution.Types.ComponentRequestedSpec (defaultComponentRequestedSpec)
+import Distribution.Types.Dependency (depPkgName, depVerRange)
-import Distribution.Text
+import Distribution.Pretty (prettyShow)
import Data.Maybe
import Data.List ( nub )
@@ -66,9 +67,9 @@ packageIsCoreInAnyGHC pn = any (flip packageIsCore pn) (map snd ghcs)
-- Packages that are not core will always be accepted, packages that are
-- core in any ghc must be satisfied by the 'PackageIndex'.
dependencySatisfiable :: InstalledPackageIndex -> Cabal.Dependency -> Bool
-dependencySatisfiable pindex dep@(Cabal.Dependency pn _rang)
+dependencySatisfiable pindex dep@(Cabal.Dependency pn _rang _lib)
| Cabal.unPackageName pn == "Win32" = False -- only exists on windows, not in linux
- | not . null $ lookupDependency pindex dep = True -- the package index satisfies the dep
+ | not . null $ lookupDependency pindex (depPkgName dep) (depVerRange dep) = True -- the package index satisfies the dep
| packageIsCoreInAnyGHC pn = False -- some other ghcs support the dependency
| otherwise = True -- the dep is not related with core packages, accept the dep
@@ -88,8 +89,8 @@ packageBuildableWithGHCVersion pkg user_specified_fas (compiler_info, pkgIndex)
_ -> trace (unwords ["accepting dep:" , show_compiler compiler_info
]
) v
- show_deps = show . map display
- show_compiler (DC.CompilerInfo { DC.compilerInfoId = CompilerId GHC v }) = "ghc-" ++ display v
+ show_deps = show . map prettyShow
+ show_compiler (DC.CompilerInfo { DC.compilerInfoId = CompilerId GHC v }) = "ghc-" ++ prettyShow v
show_compiler c = show c
-- | Given a 'GenericPackageDescription' it returns the miminum GHC version
diff --git a/Portage/Overlay.hs b/Portage/Overlay.hs
index 8200e88..c3aabf5 100644
--- a/Portage/Overlay.hs
+++ b/Portage/Overlay.hs
@@ -16,7 +16,7 @@ import qualified Portage.Metadata as Portage
import qualified Distribution.Package as Cabal
-import Distribution.Text (simpleParse)
+import Distribution.Parsec (simpleParsec)
import Distribution.Simple.Utils ( comparing, equating )
import Data.List as List
@@ -135,14 +135,14 @@ readOverlayByPackage tree =
categories entries =
[ (category, entries')
| Directory dir entries' <- entries
- , Just category <- [simpleParse dir] ]
+ , Just category <- [simpleParsec dir] ]
packages :: Portage.Category -> DirectoryTree
-> [(Portage.PackageName, DirectoryTree)]
packages category entries =
[ (Portage.PackageName category name, entries')
| Directory dir entries' <- entries
- , Just name <- [simpleParse dir] ]
+ , Just name <- [simpleParsec dir] ]
versions :: Portage.PackageName -> DirectoryTree -> [Portage.Version]
versions name@(Portage.PackageName (Portage.Category category) _) entries =
@@ -151,7 +151,7 @@ readOverlayByPackage tree =
, let (baseName, ext) = splitExtension fileName
, ext == ".ebuild"
, let fullName = category ++ '/' : baseName
- , Just (Portage.PackageId name' version) <- [simpleParse fullName]
+ , Just (Portage.PackageId name' version) <- [simpleParsec fullName]
, name == name' ]
readOverlay :: DirectoryTree -> [Portage.PackageId]
diff --git a/Portage/PackageId.hs b/Portage/PackageId.hs
index ffaa324..9496ee5 100644
--- a/Portage/PackageId.hs
+++ b/Portage/PackageId.hs
@@ -18,21 +18,19 @@ module Portage.PackageId (
cabal_pn_to_PN
) where
-import Data.Char
-
import qualified Distribution.Package as Cabal
-import Distribution.Text (Text(..))
-import qualified Distribution.Compat.ReadP as Parse
+import Distribution.Parsec (CabalParsing(..), Parsec(..), explicitEitherParsec)
+import qualified Distribution.Compat.CharParsing as P
import qualified Portage.Version as Portage
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
-import qualified Data.Char as Char (isAlphaNum, isSpace, toLower)
+import qualified Data.Char as Char (isAlphaNum, toLower)
-import Distribution.Text(display)
-import System.FilePath ((</>), dropExtension)
+import Distribution.Pretty (Pretty(..), prettyShow)
+import System.FilePath ((</>))
#if MIN_VERSION_base(4,11,0)
import Prelude hiding ((<>))
@@ -47,47 +45,61 @@ data PackageName = PackageName { category :: Category, cabalPkgName :: Cabal.Pac
data PackageId = PackageId { packageId :: PackageName, pkgVersion :: Portage.Version }
deriving (Eq, Ord, Show, Read)
-{-
-instance Text PN where
- disp (PN n) = Disp.text n
- parse = do
- ns <- Parse.sepBy1 component (Parse.char '-')
- return (PN (concat (intersperse "-" ns)))
+instance Pretty Category where
+ pretty (Category c) = Disp.text c
+
+instance Parsec Category where
+ parsec = Category <$> P.munch1 categoryChar
where
- component = do
- cs <- Parse.munch1 Char.isAlphaNum
- if all Char.isDigit cs then Parse.pfail else return cs
- -- each component must contain an alphabetic character, to avoid
- -- ambiguity in identifiers like foo-1 (the 1 is the version number).
--}
+ categoryChar c = Char.isAlphaNum c || c == '-'
+
+instance Pretty PackageName where
+ pretty (PackageName category name) =
+ pretty category <> Disp.char '/' <> pretty name
+
+instance Parsec PackageName where
+ parsec = do
+ category <- parsec
+ _ <- P.char '/'
+ name <- parsec
+ return $ PackageName category name
+
+instance Pretty PackageId where
+ pretty (PackageId name version) =
+ pretty name <> Disp.char '-' <> pretty version
+
+instance Parsec PackageId where
+ parsec = do
+ name <- parsec
+ _ <- P.char '-'
+ version <- parsec
+ return $ PackageId name version
packageIdToFilePath :: PackageId -> FilePath
packageIdToFilePath (PackageId (PackageName cat pn) version) =
- display cat </> display pn </> display pn <-> display version <.> "ebuild"
+ prettyShow cat </> prettyShow pn </> prettyShow pn <-> prettyShow version <.> "ebuild"
where
a <-> b = a ++ '-':b
a <.> b = a ++ '.':b
--- | Attempt to generate a PackageId from a FilePath. If not, return
--- the provided PackageId as-is.
-filePathToPackageId :: PackageId -> FilePath -> PackageId
-filePathToPackageId pkgId fp = do
- -- take package name from provided FilePath
- let pn = take (length
- $ Cabal.unPackageName . cabalPkgName . packageId
- $ pkgId) fp
- -- drop .ebuild file extension
- p = dropExtension fp
- -- drop package name and the following dash
- v = drop ((length pn) +1) p
- c = unCategory . category . packageId $ pkgId
- -- parse and extract version
- parsed_v = case parseVersion v of
- Just (Just my_v) -> my_v
- _ -> pkgVersion pkgId
- -- Construct PackageId
- PackageId (mkPackageName c pn) parsed_v
-
+-- TODO: fix the parser such that it can tolerate malformed package strings,
+-- strings with ".ebuild" extensions and strings which are not in fact package
+-- strings at all (e.g. metadata.xml). Then we can eliminate the string manipulation
+-- present in Merge.getPreviousPackageId, which ensures this function is only fed
+-- well-formed package strings, i.e <name>-<version>.
+-- | Maybe generate a PackageId from a FilePath.
+filePathToPackageId :: Category -> FilePath -> Maybe PackageId
+filePathToPackageId cat fp =
+ case explicitEitherParsec parser fp of
+ Right x -> Just x
+ _ -> Nothing
+ where
+ parser = do
+ pn <- parseCabalPackageName
+ _ <- P.char '-'
+ v <- parsec
+ return $ PackageId (PackageName cat pn) v
+
mkPackageName :: String -> String -> PackageName
mkPackageName cat package = PackageName (Category cat) (Cabal.mkPackageName package)
@@ -109,64 +121,33 @@ toCabalPackageId (PackageId (PackageName _cat name) version) =
fmap (Cabal.PackageIdentifier name)
(Portage.toCabalVersion version)
-instance Text Category where
- disp (Category c) = Disp.text c
- parse = fmap Category (Parse.munch1 categoryChar)
- where
- categoryChar c = Char.isAlphaNum c || c == '-'
-
-instance Text PackageName where
- disp (PackageName category name) =
- disp category <> Disp.char '/' <> disp name
-
- parse = do
- category <- parse
- _ <- Parse.char '/'
- name <- parse
- return (PackageName category name)
-
-instance Text PackageId where
- disp (PackageId name version) =
- disp name <> Disp.char '-' <> disp version
-
- parse = do
- name <- parse
- _ <- Parse.char '-'
- version <- parse
- return (PackageId name version)
-
-parseFriendlyPackage :: String -> Maybe (Maybe Category, Cabal.PackageName, Maybe Portage.Version)
-parseFriendlyPackage str =
- case [ p | (p,s) <- Parse.readP_to_S parser str
- , all Char.isSpace s ] of
- [] -> Nothing
- (x:_) -> Just x
+parseFriendlyPackage :: String -> Either String (Maybe Category, Cabal.PackageName, Maybe Portage.Version)
+parseFriendlyPackage str = explicitEitherParsec parser str
where
parser = do
- mc <- Parse.option Nothing $ do
- c <- parse
- _ <- Parse.char '/'
- return (Just c)
- p <- parse
- mv <- Parse.option Nothing $ do
- _ <- Parse.char '-'
- v <- parse
- return (Just v)
+ mc <- P.optional . P.try $ do
+ c <- parsec
+ _ <- P.char '/'
+ return c
+ p <- parseCabalPackageName
+ mv <- P.optional $ do
+ _ <- P.char '-'
+ v <- parsec
+ return v
return (mc, p, mv)
--- | Parse a String in the form of a Portage version
-parseVersion :: FilePath -> Maybe (Maybe Portage.Version)
-parseVersion str =
- case [ p | (p,s) <- Parse.readP_to_S parser str
- , all Char.isSpace s ] of
- [] -> Nothing
- (x:_) -> Just x
- where
- parser = do
- mv <- Parse.option Nothing $ do
- v <- parse
- return (Just v)
- return mv
-
+-- | Parse a Cabal PackageName. Note that we cannot use the @parsec@
+-- method as defined in the @Parsec PackageName@ instance, since it
+-- fails the entire PackageName parse if it tries to parse a version
+-- number.
+parseCabalPackageName :: CabalParsing m => m Cabal.PackageName
+parseCabalPackageName = do
+ pn <- P.some . P.try $
+ P.choice
+ [ P.alphaNum
+ , P.char '-' <* P.notFollowedBy (P.some P.digit <* P.notFollowedBy P.letter)
+ ]
+ return $ Cabal.mkPackageName pn
+
cabal_pn_to_PN :: Cabal.PackageName -> String
-cabal_pn_to_PN = map toLower . display
+cabal_pn_to_PN = map Char.toLower . prettyShow
diff --git a/Portage/Resolve.hs b/Portage/Resolve.hs
index 0696d41..d06b23a 100644
--- a/Portage/Resolve.hs
+++ b/Portage/Resolve.hs
@@ -10,7 +10,7 @@ import qualified Portage.Overlay as Overlay
import qualified Portage.PackageId as Portage
import Distribution.Verbosity
-import Distribution.Text (display)
+import Distribution.Pretty (prettyShow)
import qualified Distribution.Package as Cabal
import Distribution.Simple.Utils
@@ -31,10 +31,10 @@ resolveCategory verbosity overlay pn = do
return devhaskell
[cat] -> do
info verbosity $ "Exact match of already existing package, using category: "
- ++ display cat
+ ++ prettyShow cat
return cat
cats -> do
- warn verbosity $ "Multiple matches of categories: " ++ unwords (map display cats)
+ warn verbosity $ "Multiple matches of categories: " ++ unwords (map prettyShow cats)
if devhaskell `elem` cats
then do notice verbosity "Defaulting to dev-haskell"
return devhaskell
diff --git a/Portage/Use.hs b/Portage/Use.hs
index 0f29f08..51a5505 100644
--- a/Portage/Use.hs
+++ b/Portage/Use.hs
@@ -13,7 +13,7 @@ module Portage.Use (
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
-import qualified Distribution.Text as DT
+import Distribution.Pretty (Pretty(..))
#if MIN_VERSION_base(4,11,0)
import Prelude hiding ((<>))
@@ -27,6 +27,9 @@ data UseFlag = UseFlag Use -- ^ no modificator
| N UseFlag -- ^ - modificator
deriving (Eq,Show,Ord,Read)
+instance Pretty UseFlag where
+ pretty = showModificator
+
mkUse :: Use -> UseFlag
mkUse = UseFlag
@@ -36,31 +39,26 @@ mkNotUse = N . UseFlag
mkQUse :: Use -> UseFlag
mkQUse = Q . UseFlag
-instance DT.Text UseFlag where
- disp = showModificator
- parse = error "instance DT.Text UseFlag: not implemented"
-
showModificator :: UseFlag -> Disp.Doc
-showModificator (UseFlag u) = DT.disp u
-showModificator (X u) = Disp.char '!' <> DT.disp u
-showModificator (Q u) = DT.disp u <> Disp.char '?'
-showModificator (E u) = DT.disp u <> Disp.char '='
-showModificator (N u) = Disp.char '-' <> DT.disp u
+showModificator (UseFlag u) = pretty u
+showModificator (X u) = Disp.char '!' <> pretty u
+showModificator (Q u) = pretty u <> Disp.char '?'
+showModificator (E u) = pretty u <> Disp.char '='
+showModificator (N u) = Disp.char '-' <> pretty u
dispUses :: [UseFlag] -> Disp.Doc
dispUses [] = Disp.empty
-dispUses us = Disp.brackets $ Disp.hcat $ (Disp.punctuate (Disp.text ", ")) $ map DT.disp us
+dispUses us = Disp.brackets $ Disp.hcat $ (Disp.punctuate (Disp.text ", ")) $ map pretty us
newtype Use = Use String
deriving (Eq, Read, Show)
+instance Pretty Use where
+ pretty (Use u) = Disp.text u
+
instance Ord Use where
compare (Use a) (Use b) = case (a,b) of
("test", "test") -> EQ
("test", _) -> LT
(_, "test") -> GT
(_, _) -> a `compare` b
-
-instance DT.Text Use where
- disp (Use u) = Disp.text u
- parse = error "instance DT.Text Use: not implemented"
diff --git a/Portage/Version.hs b/Portage/Version.hs
index d87e9a6..076d324 100644
--- a/Portage/Version.hs
+++ b/Portage/Version.hs
@@ -21,9 +21,10 @@ module Portage.Version (
import qualified Distribution.Version as Cabal
-import Distribution.Text (Text(..))
+import Distribution.Pretty (Pretty(..))
-import qualified Distribution.Compat.ReadP as Parse
+import Distribution.Parsec (Parsec(..))
+import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import qualified Data.Char as Char (isAlpha, isDigit)
@@ -39,6 +40,24 @@ data Version = Version { versionNumber :: [Int] -- [1,42,3] ~= 1.42.3
}
deriving (Eq, Ord, Show, Read)
+instance Pretty Version where
+ pretty (Version ver c suf rev) =
+ dispVer ver <> dispC c <> dispSuf suf <> dispRev rev
+ where
+ dispVer = Disp.hcat . Disp.punctuate (Disp.char '.') . map Disp.int
+ dispC = maybe Disp.empty Disp.char
+ dispSuf = Disp.hcat . map pretty
+ dispRev 0 = Disp.empty
+ dispRev n = Disp.text "-r" <> Disp.int n
+
+instance Parsec Version where
+ parsec = do
+ ver <- P.sepBy1 digits (P.char '.')
+ c <- P.optional $ P.satisfy Char.isAlpha
+ suf <- P.many parsec
+ rev <- P.option 0 $ P.string "-r" *> digits
+ return $ Version ver c suf rev
+
-- foo-9999* is treated as live ebuild
-- Cabal-1.17.9999* as well
is_live :: Version -> Bool
@@ -55,32 +74,8 @@ is_live v =
data Suffix = Alpha Int | Beta Int | Pre Int | RC Int | P Int
deriving (Eq, Ord, Show, Read)
-fromCabalVersion :: Cabal.Version -> Version
-fromCabalVersion cabal_version = Version (Cabal.versionNumbers cabal_version) Nothing [] 0
-
-toCabalVersion :: Version -> Maybe Cabal.Version
-toCabalVersion (Version nums Nothing [] _) = Just (Cabal.mkVersion nums)
-toCabalVersion _ = Nothing
-
-instance Text Version where
- disp (Version ver c suf rev) =
- dispVer ver <> dispC c <> dispSuf suf <> dispRev rev
- where
- dispVer = Disp.hcat . Disp.punctuate (Disp.char '.') . map Disp.int
- dispC = maybe Disp.empty Disp.char
- dispSuf = Disp.hcat . map disp
- dispRev 0 = Disp.empty
- dispRev n = Disp.text "-r" <> Disp.int n
-
- parse = do
- ver <- Parse.sepBy1 digits (Parse.char '.')
- c <- Parse.option Nothing (fmap Just (Parse.satisfy Char.isAlpha))
- suf <- Parse.many parse
- rev <- Parse.option 0 (Parse.string "-r" >> digits)
- return (Version ver c suf rev)
-
-instance Text Suffix where
- disp suf = case suf of
+instance Pretty Suffix where
+ pretty suf = case suf of
Alpha n -> Disp.text "_alpha" <> dispPos n
Beta n -> Disp.text "_beta" <> dispPos n
Pre n -> Disp.text "_pre" <> dispPos n
@@ -92,16 +87,24 @@ instance Text Suffix where
dispPos 0 = Disp.empty
dispPos n = Disp.int n
- parse = Parse.char '_'
- >> Parse.choice
- [ Parse.string "alpha" >> fmap Alpha maybeDigits
- , Parse.string "beta" >> fmap Beta maybeDigits
- , Parse.string "pre" >> fmap Pre maybeDigits
- , Parse.string "rc" >> fmap RC maybeDigits
- , Parse.string "p" >> fmap P maybeDigits
+instance Parsec Suffix where
+ parsec = P.char '_'
+ >> P.choice
+ [ P.string "alpha" >> fmap Alpha maybeDigits
+ , P.string "beta" >> fmap Beta maybeDigits
+ , P.string "pre" >> fmap Pre maybeDigits
+ , P.string "rc" >> fmap RC maybeDigits
+ , P.string "p" >> fmap P maybeDigits
]
where
- maybeDigits = Parse.option 0 digits
+ maybeDigits = P.option 0 digits
+
+fromCabalVersion :: Cabal.Version -> Version
+fromCabalVersion cabal_version = Version (Cabal.versionNumbers cabal_version) Nothing [] 0
+
+toCabalVersion :: Version -> Maybe Cabal.Version
+toCabalVersion (Version nums Nothing [] _) = Just (Cabal.mkVersion nums)
+toCabalVersion _ = Nothing
-digits :: Parse.ReadP r Int
-digits = fmap read (Parse.munch1 Char.isDigit)
+digits :: P.CharParsing m => m Int
+digits = read <$> P.munch1 Char.isDigit
diff --git a/Status.hs b/Status.hs
index 3fa5478..82ac9a8 100644
--- a/Status.hs
+++ b/Status.hs
@@ -30,8 +30,9 @@ import Control.Monad
-- cabal
import qualified Distribution.Verbosity as Cabal
import qualified Distribution.Package as Cabal (pkgName)
-import qualified Distribution.Simple.Utils as Cabal (comparing, die, equating)
-import qualified Distribution.Text as Cabal ( display, simpleParse )
+import qualified Distribution.Simple.Utils as Cabal (comparing, die', equating)
+import Distribution.Pretty (prettyShow)
+import Distribution.Parsec (simpleParsec)
import qualified Distribution.Client.GlobalFlags as CabalInstall
import qualified Distribution.Client.IndexUtils as CabalInstall
@@ -145,8 +146,8 @@ runStatus verbosity portdir overlaydir direction pkgs repoContext = do
PortagePlusOverlay -> id
HackageToOverlay -> fromHackageFilter
pkgs' <- forM pkgs $ \p ->
- case Cabal.simpleParse p of
- Nothing -> Cabal.die ("Could not parse package name: " ++ p ++ ". Format cat/pkg")
+ case simpleParsec p of
+ Nothing -> Cabal.die' verbosity ("Could not parse package name: " ++ p ++ ". Format cat/pkg")
Just pn -> return pn
tree0 <- status verbosity portdir overlaydir repoContext
let tree = pkgFilter tree0
@@ -204,10 +205,10 @@ statusPrinter packages = do
let (PackageName c p) = pkg
putStr (bold (show ix))
putStr " "
- putStr $ Cabal.display c ++ '/' : bold (Cabal.display p)
+ putStr $ prettyShow c ++ '/' : bold (prettyShow p)
putStr " "
forM_ ebuilds $ \e -> do
- putStr $ toColor (fmap (Cabal.display . pkgVersion . ebuildId) e)
+ putStr $ toColor (fmap (prettyShow . pkgVersion . ebuildId) e)
putChar ' '
putStrLn ""
diff --git a/cabal/.mailmap b/cabal/.mailmap
index ef0cbb9..27a2a38 100644
--- a/cabal/.mailmap
+++ b/cabal/.mailmap
@@ -6,12 +6,14 @@
Adam Langley <agl@imperialviolet.org>
Alex Biehl <alexbiehl@gmail.com>
+Alex Biehl <alexbiehl@gmail.com> <alex.biehl@target.com>
Alex Biehl <alexbiehl@gmail.com> Alexander Biehl <abiehl@novomind.com>
Alex Biehl <alexbiehl@gmail.com> alexbiehl <alex.biehl@gmail.com>
Alex Washburn <github@recursion.ninja>
Alex Washburn <github@recursion.ninja> recursion-ninja <github@recursion.ninja>
Alistair Bailey <alistair@abayley.org> alistair <alistair@abayley.org>
Alson Kemp <alson@alsonkemp.com> alson <alson@alsonkemp.com>
+Andreas Klebinger <klebinger.andreas@gmx.at> klebinger.andreas@gmx.at <klebinger.andreas@gmx.at>
Andres Löh <andres.loeh@gmail.com>
Andres Löh <andres.loeh@gmail.com> <andres@cs.uu.nl>
Andres Löh <andres.loeh@gmail.com> <andres@well-typed.com>
@@ -43,6 +45,7 @@ David Luposchainsky <dluposchainsky@gmail.com> <quchen@users
David Waern <davve@dtek.chalmers.se> David Waern <unknown>
Dennis Gosnell <cdep.illabout@gmail.com>
Dmitry Kovanikov <kovanikov@gmail.com> ChShersh <dmitrii@holmusk.com>
+Domen Kožar <domen@dev.si> <domen@enlambda.com>
Don Stewart <dons00@gmail.com> <dons@galois.com>
Duncan Coutts <duncan@community.haskell.org>
Duncan Coutts <duncan@community.haskell.org> <Duncan Coutts duncan@community.haskell.org>
@@ -56,7 +59,8 @@ Edward Z. Yang <ezyang@cs.stanford.edu> <ezyang@mit.e
Einar Karttunen <ekarttun@cs.helsinki.fi>
Federico Mastellone <fmaste@users.noreply.github.com>
Felix Yan <felixonmars@archlinux.org> Felix Yan <felixonmars@gmail.com>
-Francesco Gazzetta <francygazz@gmail.com> <fgaz@users.noreply.github.com>
+Francesco Gazzetta <fgaz@fgaz.me> <fgaz@users.noreply.github.com>
+Francesco Gazzetta <fgaz@fgaz.me> <francygazz@gmail.com>
Ganesh Sittampalam <ganesh.sittampalam@credit-suisse.com> <ganesh@earth.li>
Geoff Nixon <geoff-codes@users.noreply.github.com> <geoff.nixon@aol.com>
Gershom Bazerman <gershomb@gmail.com>
@@ -120,6 +124,8 @@ Nathan Conroy <nathanconroydev@gmail.com>
Neil Mitchell <ndmitchell@gmail.com> Neil Mitchell <unknown>
Niklas Broberg <niklas.broberg@gmail.com> <d00nibro@chalmers.se>
Niklas Broberg <niklas.broberg@gmail.com> <git@nand.wakku.to>
+Nikolai Obedin <dev@nkly.me> <github@nkly.me>
+Nikolai Obedin <dev@nkly.me> <no@idagio.com> # 3c1502bb633b61ae4d24d40898fca66d7f169679
Peter Higley <phigley@gmail.com>
Peter Simons <simons@cryp.to>
Peter Trško <peter.trsko@gmail.com> Peter Trsko <peter.trsko@ixperta.com>
@@ -154,3 +160,4 @@ capsjac <capsjac@gmail.com> # G
ghthrowaway7 <41365123+ghthrowaway7@users.noreply.github.com> # Goes by that name online
quasicomputational <quasicomputational@gmail.com> # Goes by that name online
vedksah <31156362+vedksah@users.noreply.github.com> # Goes by that name online
+!
diff --git a/cabal/.travis.yml b/cabal/.travis.yml
index 051641d..1fbec4b 100644
--- a/cabal/.travis.yml
+++ b/cabal/.travis.yml
@@ -13,6 +13,7 @@ sudo: true
branches:
only:
- master
+ - "3.0"
- "2.4"
- "2.2"
- "2.0"
@@ -58,9 +59,12 @@ matrix:
- env: GHCVER=8.4.4 SCRIPT=script USE_GOLD=YES DEPLOY_DOCS=YES
os: linux
sudo: required
- - env: GHCVER=8.6.2 SCRIPT=script USE_GOLD=YES
+ - env: GHCVER=8.6.4 SCRIPT=script USE_GOLD=YES
os: linux
sudo: required
+ #- env: GHCVER=8.8.1 SCRIPT=script USE_GOLD=YES
+ # os: linux
+ # sudo: required
- env: GHCVER=8.4.4 SCRIPT=solver-debug-flags USE_GOLD=YES
sudo: required
@@ -92,13 +96,17 @@ matrix:
- env: GHCVER=8.0.2 SCRIPT=bootstrap
os: osx
- - env: GHCVER=via-stack SCRIPT=stack STACK_CONFIG=stack.yaml
- os: linux
-
+ # It's been long known that CI with
+ # Stack does not work so it's disabled until further notice
+ # to reduce latency and avoid wasting CI slots for no reason.
+ #
+ #- env: GHCVER=via-stack SCRIPT=stack STACK_CONFIG=stack.yaml
+ # os: linux
+ #
# See https://github.com/haskell/cabal/pull/4667#issuecomment-321036564
# for why failures are allowed.
- allow_failures:
- - env: GHCVER=via-stack SCRIPT=stack STACK_CONFIG=stack.yaml
+ # allow_failures:
+ # - env: GHCVER=via-stack SCRIPT=stack STACK_CONFIG=stack.yaml
# TODO add PARSEC_BUNDLED=YES when it's so
# It seems pointless to run head if we're going to ignore the results.
@@ -112,7 +120,6 @@ before_install:
- export PATH=$HOME/.cabal/bin:$PATH
- export PATH=$HOME/.local/bin:$PATH
- export PATH=/opt/cabal/2.4/bin:$PATH
- - export PATH=/opt/alex/3.1.7/bin:$PATH
- if [ "$USE_GOLD" = "YES" ]; then sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20; fi
- if [ "$USE_GOLD" = "YES" ]; then sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10; fi
- ld -v
diff --git a/cabal/AUTHORS b/cabal/AUTHORS
index a887424..b7cd9ea 100644
--- a/cabal/AUTHORS
+++ b/cabal/AUTHORS
@@ -20,6 +20,7 @@ Alson Kemp <alson@alsonkemp.com>
Amir Mohammad Saied <amirsaied@gmail.com>
Anders Kaseorg <andersk@mit.edu>
Andrea Vezzosi <sanzhiyan@gmail.com>
+Andreas Klebinger <klebinger.andreas@gmx.at>
Andres Löh <andres.loeh@gmail.com>
Andrzej Rybczak <electricityispower@gmail.com>
Andrés Sicard-Ramírez <andres.sicard.ramirez@gmail.com>
@@ -55,6 +56,7 @@ Brian Smith <brianlsmith@gmail.com>
Bryan O'Sullivan <bos@serpentine.com>
Bryan Richter <bryan.richter@gmail.com>
Carter Tazio Schonwald <carter.schonwald@gmail.com>
+Chaitanya Koparkar <ckoparkar@gmail.com>
Chang Yang Jiao <jiaochangyang@gmail.com>
Chris Allen <cma@bitemyapp.com>
Chris Wong <lambda.fairy@gmail.com>
@@ -85,6 +87,7 @@ Dennis Gosnell <cdep.illabout@gmail.com>
Dino Morelli <dino@ui3.info>
Dmitry Astapov <dastapov@gmail.com>
Dmitry Kovanikov <kovanikov@gmail.com>
+Domen Kožar <domen@dev.si>
Dominic Steinitz <dominic@steinitz.org>
Don Stewart <dons00@gmail.com>
Doug Beardsley <mightybyte@gmail.com>
@@ -107,7 +110,7 @@ Federico Mastellone <fmaste@users.noreply.github.com>
Felix Yan <felixonmars@archlinux.org>
Florian Hartwig <florian.j.hartwig@gmail.com>
Francesco Ariis <fa-ml@ariis.it>
-Francesco Gazzetta <francygazz@gmail.com>
+Francesco Gazzetta <fgaz@fgaz.me>
Franz Thoma <franz.thoma@tngtech.com>
Fujimura Daisuke <me@fujimuradaisuke.com>
Gabor Greif <ggreif@gmail.com>
@@ -142,6 +145,7 @@ JP Moresmau <jp@moresmau.fr>
Jacco Krijnen <jaccokrijnen@gmail.com>
Jack Henahan <jhenahan@uvm.edu>
Jake Wheat <jakewheatmail@gmail.com>
+Jan Path <jan@jpath.de>
Jason Dagit <dagitj@gmail.com>
Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>
Jens Petersen <juhpetersen@gmail.com>
@@ -163,6 +167,7 @@ Jonathan Daugherty <jtd@galois.com>
Jookia <166291@gmail.com>
Josef Svenningsson <josef.svenningsson@gmail.com>
Josh Hoyt <josh.hoyt@galois.com>
+Josh Kalderimis <josh.kalderimis@gmail.com>
Judah Jacobson <judah.jacobson@gmail.com>
Jürgen Nicklisch-Franken <jnf@arcor.de>
Karel Gardas <karel.gardas@centrum.cz>
@@ -176,6 +181,7 @@ Kristen Kozak <grayjay@wordroute.com>
Lennart Kolmodin <kolmodin@gmail.com>
Lennart Spitzner <hexagoxel@hexagoxel.de>
Leon Isenberg <ljli@users.noreply.github.com>
+Leon Schoorl <l.m.schoorl@student.utwente.nl>
Leonid Onokhov <sopvop@gmail.com>
Li-yao Xia <lysxia@gmail.com>
Liyang HU <git@liyang.hu>
@@ -193,6 +199,7 @@ Martin Sjögren <msjogren@gmail.com>
Martin Vlk <martin@vlkk.cz>
Masahiro Yamauchi <sgt.yamauchi@gmail.com>
Mathieu Boespflug <mboes@tweag.net>
+Matt Renaud <matt@m-renaud.com>
Matthew William Cox <matt@mattcox.ca>
Matthias Fischmann <mf@zerobuzz.net>
Matthias Kilian <kili@outback.escape.de>
@@ -223,6 +230,7 @@ Nick Smallbone <nick.smallbone@gmail.com>
Nikita Karetnikov <nikita@karetnikov.org>
Niklas Broberg <niklas.broberg@gmail.com>
Niklas Hambüchen <mail@nh2.me>
+Nikolai Obedin <dev@nkly.me>
Oleg Grenrus <oleg.grenrus@iki.fi>
Oleksandr Manzyuk <manzyuk@gmail.com>
Omar Mefire <omefire@gmail.com>
@@ -299,6 +307,7 @@ Tim McGilchrist <timmcgil@gmail.com>
Tomas Vestelind <tomas.vestelind@gmail.com>
Toshio Ito <debug.ito@gmail.com>
Travis Cardwell <travis.cardwell@extellisys.com>
+Travis Whitaker <pi.boy.travis@gmail.com>
Tuncer Ayaz <tuncer.ayaz@gmail.com>
Vaibhav Sagar <vaibhavsagar@gmail.com>
Veronika Romashkina <vrom911@gmail.com>
@@ -309,6 +318,7 @@ Wojciech Danilo <wojtek.danilo@gmail.com>
Yitzchak Gale <gale@sefer.org>
Yuras Shumovich <shumovichy@gmail.com>
Yuriy Syrovetskiy <cblp@cblp.su>
+Zejun Wu <watashi@watashi.ws>
capsjac <capsjac@gmail.com>
ghthrowaway7 <41365123+ghthrowaway7@users.noreply.github.com>
quasicomputational <quasicomputational@gmail.com>
diff --git a/cabal/CONTRIBUTING.md b/cabal/CONTRIBUTING.md
new file mode 100644
index 0000000..4cb1c86
--- /dev/null
+++ b/cabal/CONTRIBUTING.md
@@ -0,0 +1,254 @@
+# Contributing to Cabal
+
+Building Cabal for hacking
+--------------------------
+
+The current recommended way of developing Cabal is to use the
+`new-build` feature which [shipped in cabal-install-1.24](http://blog.ezyang.com/2016/05/announcing-cabal-new-build-nix-style-local-builds/). Assuming
+that you have a sufficiently recent cabal-install (see above),
+it is sufficient to run:
+
+~~~~
+cabal new-build cabal
+~~~~
+
+To build a local, development copy of cabal-install. The location
+of your build products will vary depending on which version of
+cabal-install you use to build; see the documentation section
+[Where are my build products?](http://cabal.readthedocs.io/en/latest/nix-local-build.html#where-are-my-build-products)
+to find the binary (or just run `find -type f -executable -name cabal`).
+
+Here are some other useful variations on the commands:
+
+~~~~
+cabal new-build Cabal # build library only
+cabal new-build Cabal:unit-tests # build Cabal's unit test suite
+cabal new-build cabal-tests # etc...
+~~~~
+
+**Dogfooding HEAD.**
+Many of the core developers of Cabal dogfood `cabal-install` HEAD
+when doing development on Cabal. This helps us identify bugs
+which were missed by the test suite and easily experiment with new
+features.
+
+The recommended workflow in this case is slightly different: you will
+maintain two Cabal source trees: your production tree (built with a
+released version of Cabal) which always tracks `master` and which you
+update only when you want to move to a new version of Cabal to dogfood,
+and your development tree (built with your production Cabal) that you
+actually do development on.
+
+In more detail, suppose you have checkouts of Cabal at `~/cabal-prod`
+and `~/cabal-dev`, and you have a release copy of cabal installed at
+`/opt/cabal/2.4/bin/cabal`. First, build your production tree:
+
+~~~~
+cd ~/cabal-prod
+/opt/cabal/2.4/bin/cabal new-build cabal
+~~~~
+
+This will produce a cabal binary (see also: [Where are my build products?](http://cabal.readthedocs.io/en/latest/nix-local-build.html#where-are-my-build-products)
+). Add this binary to your PATH,
+and then use it to build your development copy:
+
+~~~~
+cd ~/cabal-dev
+cabal new-build cabal
+~~~~
+
+Running tests
+-------------
+
+**Using Travis and AppVeyor.**
+If you are not in a hurry, the most convenient way to run tests on Cabal
+is to make a branch on GitHub and then open a pull request; our
+continuous integration service on Travis and AppVeyor will build and
+test your code. Title your PR with WIP so we know that it does not need
+code review.
+
+Some tips for using Travis effectively:
+
+* Travis builds take a long time. Use them when you are pretty
+ sure everything is OK; otherwise, try to run relevant tests locally
+ first.
+
+* Watch over your jobs on the [Travis website](http://travis-ci.org).
+ If you know a build of yours is going to fail (because one job has
+ already failed), be nice to others and cancel the rest of the jobs,
+ so that other commits on the build queue can be processed.
+
+* If you want realtime notification when builds of your PRs finish, we have a [Slack team](https://haskell-cabal.slack.com/). To get issued an invite, fill in your email at [this sign up page](https://haskell-cabal.herokuapp.com).
+
+**How to debug a failing CI test.**
+One of the annoying things about running tests on CI is when they
+fail, there is often no easy way to further troubleshoot the broken
+build. Here are some guidelines for debugging continuous integration
+failures:
+
+1. Can you tell what the problem is by looking at the logs? The
+ `cabal-testsuite` tests run with `-v` logging by default, which
+ is dumped to the log upon failure; you may be able to figure out
+ what the problem is directly this way.
+
+2. Can you reproduce the problem by running the test locally?
+ See the next section for how to run the various test suites
+ on your local machine.
+
+3. Is the test failing only for a specific version of GHC, or
+ a specific operating system? If so, try reproducing the
+ problem on the specific configuration.
+
+4. Is the test failing on a Travis per-GHC build
+ ([for example](https://travis-ci.org/haskell-pushbot/cabal-binaries/builds/208128401))?
+ In this case, if you click on "Branch", you can get access to
+ the precise binaries that were built by Travis that are being
+ tested. If you have an Ubuntu system, you can download
+ the binaries and run them directly.
+
+5. Is the test failing on AppVeyor? Consider logging in via
+ Remote Desktop to the build VM:
+ https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
+
+If none of these let you reproduce, there might be some race condition
+or continuous integration breakage; please file a bug.
+
+**Running tests locally.**
+To run tests locally with `new-build`, you will need to know the
+name of the test suite you want. Cabal and cabal-install have
+several. Also, you'll want to read [Where are my build products?](http://cabal.readthedocs.io/en/latest/nix-local-build.html#where-are-my-build-products)
+
+The most important test suite is `cabal-testsuite`: most user-visible
+changes to Cabal should come with a test in this framework. See
+[cabal-testsuite/README.md](cabal-testsuite/README.md) for more
+information about how to run tests and write new ones. Quick
+start: use `cabal-tests` to run `Cabal` tests, and `cabal-tests
+--with-cabal=/path/to/cabal` to run `cabal-install` tests
+(don't forget `--with-cabal`! Your cabal-install tests won't
+run without it).
+
+There are also other test suites:
+
+* `Cabal:unit-tests` are small, quick-running unit tests
+ on small pieces of functionality in Cabal. If you are working
+ on some utility functions in the Cabal library you should run this
+ test suite.
+
+* `cabal-install:unit-tests` are small, quick-running unit tests on
+ small pieces of functionality in cabal-install. If you are working
+ on some utility functions in cabal-install you should run this test
+ suite.
+
+* `cabal-install:solver-quickcheck` are QuickCheck tests on
+ cabal-install's dependency solver. If you are working
+ on the solver you should run this test suite.
+
+* `cabal-install:integration-tests2` are integration tests on some
+ top-level API functions inside the `cabal-install` source code.
+
+For these test executables, `-p` which applies a regex filter to the test
+names.
+
+Conventions
+-----------
+
+* Spaces, not tabs.
+
+* Try to follow style conventions of a file you are modifying, and
+ avoid gratuitous reformatting (it makes merges harder!)
+
+* Format your commit messages [in the standard way](https://chris.beams.io/posts/git-commit/#seven-rules).
+
+* A lot of Cabal does not have top-level comments. We are trying to
+ fix this. If you add new top-level definitions, please Haddock them;
+ and if you spend some time understanding what a function does, help
+ us out and add a comment. We'll try to remind you during code review.
+
+* If you do something tricky or non-obvious, add a comment.
+
+* If your commit only touches comments, you can use `[ci skip]`
+ anywhere in the body of the commit message to avoid needlessly
+ triggering the build bots.
+
+* For local imports (Cabal module importing Cabal module), import lists
+ are NOT required (although you may use them at your discretion.) For
+ third-party and standard library imports, please use either qualified imports
+ or explicit import lists.
+
+* You can use basically any GHC extension supported by a GHC in our
+ support window, except Template Haskell, which would cause
+ bootstrapping problems in the GHC compilation process.
+
+* Our GHC support window is five years for the Cabal library and three
+ years for cabal-install: that is, the Cabal library must be
+ buildable out-of-the-box with the dependencies that shipped with GHC
+ for at least five years. The Travis CI checks this, so most
+ developers submit a PR to see if their code works on all these
+ versions of GHC. `cabal-install` must also be buildable on all
+ supported GHCs, although it does not have to be buildable
+ out-of-the-box. Instead, the `cabal-install/bootstrap.sh` script
+ must be able to download and install all of the dependencies (this
+ is also checked by CI). Also, self-upgrade to the latest version
+ (i.e. `cabal install cabal-install`) must work with all versions of
+ `cabal-install` released during the last three years.
+
+* `Cabal` has its own Prelude, in `Distribution.Compat.Prelude`,
+ that provides a compatibility layer and exports some commonly
+ used additional functions. Use it in all new modules.
+
+* As far as possible, please do not use CPP. If you must use it,
+ try to put it in a `Compat` module, and minimize the amount of code
+ that is enclosed by CPP. For example, prefer:
+ ```
+ f :: Int -> Int
+ #ifdef mingw32_HOST_OS
+ f = (+1)
+ #else
+ f = (+2)
+ #endif
+ ```
+
+ over:
+ ```
+ #ifdef mingw32_HOST_OS
+ f :: Int -> Int
+ f = (+1)
+ #else
+ f :: Int -> Int
+ f = (+2)
+ #endif
+ ```
+
+We like [this style guide][guide].
+
+[guide]: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
+
+Communicating
+-------------
+
+There are a few main venues of communication:
+
+* Most developers subscribe to receive messages from [all issues](https://github.com/haskell/cabal/issues); issues can be used to [open discussion](https://github.com/haskell/cabal/issues?q=is%3Aissue+is%3Aopen+custom+label%3A%22type%3A+discussion%22). If you know someone who should hear about a message, CC them explicitly using the @username GitHub syntax.
+
+* For more organizational concerns, the [mailing
+ list](http://www.haskell.org/mailman/listinfo/cabal-devel) is used.
+
+* Many developers idle on `#hackage` on `irc.freenode.net` ([archives](http://ircbrowse.net/browse/hackage)). `#ghc` ([archives](http://ircbrowse.net/browse/ghc)) is also a decently good bet.
+
+Releases
+--------
+
+Notes for how to make a release are at the
+wiki page ["Making a release"](https://github.com/haskell/cabal/wiki/Making-a-release).
+Currently, @23Skidoo, @rthomas, @tibbe and @dcoutts have access to
+`haskell.org/cabal`, and @davean is the point of contact for getting
+permissions.
+
+API Documentation
+-----------------
+
+Auto-generated API documentation for the `master` branch of Cabal is automatically uploaded here: http://haskell.github.io/cabal-website/doc/html/Cabal/.
+
+## Issue triage [![Open Source Helpers](https://www.codetriage.com/haskell/cabal/badges/users.svg)](https://www.codetriage.com/haskell/cabal)
+
+You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to cabal on CodeTriage](https://www.codetriage.com/haskell/cabal).
diff --git a/cabal/Cabal/Cabal.cabal b/cabal/Cabal/Cabal.cabal
index b97d346..b538a22 100644
--- a/cabal/Cabal/Cabal.cabal
+++ b/cabal/Cabal/Cabal.cabal
@@ -1,6 +1,7 @@
+cabal-version: >=1.10
name: Cabal
-version: 2.4.1.0
-copyright: 2003-2018, Cabal Development Team (see AUTHORS file)
+version: 3.1.0.0
+copyright: 2003-2019, Cabal Development Team (see AUTHORS file)
license: BSD3
license-file: LICENSE
author: Cabal Development Team <cabal-devel@haskell.org>
@@ -16,7 +17,6 @@ description:
The Haskell Cabal is part of a larger infrastructure for distributing,
organizing, and cataloging Haskell libraries and tools.
category: Distribution
-cabal-version: >=1.10
build-type: Simple
-- If we use a new Cabal feature, this needs to be changed to Custom so
-- we can bootstrap.
@@ -33,6 +33,8 @@ extra-source-files:
-- Generated with 'make gen-extra-source-files'
-- Do NOT edit this section manually; instead, run the script.
-- BEGIN gen-extra-source-files
+ tests/ParserTests/errors/MiniAgda.cabal
+ tests/ParserTests/errors/MiniAgda.errors
tests/ParserTests/errors/common1.cabal
tests/ParserTests/errors/common1.errors
tests/ParserTests/errors/common2.cabal
@@ -49,20 +51,48 @@ extra-source-files:
tests/ParserTests/errors/issue-5055-2.errors
tests/ParserTests/errors/issue-5055.cabal
tests/ParserTests/errors/issue-5055.errors
+ tests/ParserTests/errors/leading-comma-2.cabal
+ tests/ParserTests/errors/leading-comma-2.errors
+ tests/ParserTests/errors/leading-comma-2b.cabal
+ tests/ParserTests/errors/leading-comma-2b.errors
+ tests/ParserTests/errors/leading-comma-2c.cabal
+ tests/ParserTests/errors/leading-comma-2c.errors
tests/ParserTests/errors/leading-comma.cabal
tests/ParserTests/errors/leading-comma.errors
+ tests/ParserTests/errors/libpq1.cabal
+ tests/ParserTests/errors/libpq1.errors
+ tests/ParserTests/errors/libpq2.cabal
+ tests/ParserTests/errors/libpq2.errors
+ tests/ParserTests/errors/mixin-1.cabal
+ tests/ParserTests/errors/mixin-1.errors
+ tests/ParserTests/errors/mixin-2.cabal
+ tests/ParserTests/errors/mixin-2.errors
+ tests/ParserTests/errors/multiple-libs.cabal
+ tests/ParserTests/errors/multiple-libs.errors
tests/ParserTests/errors/noVersion.cabal
tests/ParserTests/errors/noVersion.errors
tests/ParserTests/errors/noVersion2.cabal
tests/ParserTests/errors/noVersion2.errors
tests/ParserTests/errors/range-ge-wild.cabal
tests/ParserTests/errors/range-ge-wild.errors
+ tests/ParserTests/errors/removed-fields.cabal
+ tests/ParserTests/errors/removed-fields.errors
tests/ParserTests/errors/spdx-1.cabal
tests/ParserTests/errors/spdx-1.errors
tests/ParserTests/errors/spdx-2.cabal
tests/ParserTests/errors/spdx-2.errors
tests/ParserTests/errors/spdx-3.cabal
tests/ParserTests/errors/spdx-3.errors
+ tests/ParserTests/errors/undefined-flag.cabal
+ tests/ParserTests/errors/undefined-flag.errors
+ tests/ParserTests/errors/version-sets-1.cabal
+ tests/ParserTests/errors/version-sets-1.errors
+ tests/ParserTests/errors/version-sets-2.cabal
+ tests/ParserTests/errors/version-sets-2.errors
+ tests/ParserTests/errors/version-sets-3.cabal
+ tests/ParserTests/errors/version-sets-3.errors
+ tests/ParserTests/errors/version-sets-4.cabal
+ tests/ParserTests/errors/version-sets-4.errors
tests/ParserTests/ipi/Includes2.cabal
tests/ParserTests/ipi/Includes2.expr
tests/ParserTests/ipi/Includes2.format
@@ -75,8 +105,6 @@ extra-source-files:
tests/ParserTests/ipi/transformers.cabal
tests/ParserTests/ipi/transformers.expr
tests/ParserTests/ipi/transformers.format
- tests/ParserTests/regressions/MiniAgda.cabal
- tests/ParserTests/regressions/MiniAgda.check
tests/ParserTests/regressions/Octree-0.5.cabal
tests/ParserTests/regressions/Octree-0.5.expr
tests/ParserTests/regressions/Octree-0.5.format
@@ -84,12 +112,18 @@ extra-source-files:
tests/ParserTests/regressions/bad-glob-syntax.check
tests/ParserTests/regressions/cc-options-with-optimization.cabal
tests/ParserTests/regressions/cc-options-with-optimization.check
+ tests/ParserTests/regressions/common-conditional.cabal
+ tests/ParserTests/regressions/common-conditional.expr
+ tests/ParserTests/regressions/common-conditional.format
tests/ParserTests/regressions/common.cabal
tests/ParserTests/regressions/common.expr
tests/ParserTests/regressions/common.format
tests/ParserTests/regressions/common2.cabal
tests/ParserTests/regressions/common2.expr
tests/ParserTests/regressions/common2.format
+ tests/ParserTests/regressions/common3.cabal
+ tests/ParserTests/regressions/common3.expr
+ tests/ParserTests/regressions/common3.format
tests/ParserTests/regressions/cxx-options-with-optimization.cabal
tests/ParserTests/regressions/cxx-options-with-optimization.check
tests/ParserTests/regressions/elif.cabal
@@ -110,6 +144,18 @@ extra-source-files:
tests/ParserTests/regressions/ghc-option-j.check
tests/ParserTests/regressions/haddock-api-2.18.1-check.cabal
tests/ParserTests/regressions/haddock-api-2.18.1-check.check
+ tests/ParserTests/regressions/hidden-main-lib.cabal
+ tests/ParserTests/regressions/hidden-main-lib.expr
+ tests/ParserTests/regressions/hidden-main-lib.format
+ tests/ParserTests/regressions/indentation.cabal
+ tests/ParserTests/regressions/indentation.expr
+ tests/ParserTests/regressions/indentation.format
+ tests/ParserTests/regressions/indentation2.cabal
+ tests/ParserTests/regressions/indentation2.expr
+ tests/ParserTests/regressions/indentation2.format
+ tests/ParserTests/regressions/indentation3.cabal
+ tests/ParserTests/regressions/indentation3.expr
+ tests/ParserTests/regressions/indentation3.format
tests/ParserTests/regressions/issue-5055.cabal
tests/ParserTests/regressions/issue-5055.expr
tests/ParserTests/regressions/issue-5055.format
@@ -117,9 +163,34 @@ extra-source-files:
tests/ParserTests/regressions/issue-774.check
tests/ParserTests/regressions/issue-774.expr
tests/ParserTests/regressions/issue-774.format
+ tests/ParserTests/regressions/jaeger-flamegraph.cabal
+ tests/ParserTests/regressions/jaeger-flamegraph.expr
+ tests/ParserTests/regressions/jaeger-flamegraph.format
+ tests/ParserTests/regressions/leading-comma-2.cabal
+ tests/ParserTests/regressions/leading-comma-2.expr
+ tests/ParserTests/regressions/leading-comma-2.format
tests/ParserTests/regressions/leading-comma.cabal
tests/ParserTests/regressions/leading-comma.expr
tests/ParserTests/regressions/leading-comma.format
+ tests/ParserTests/regressions/libpq1.cabal
+ tests/ParserTests/regressions/libpq1.expr
+ tests/ParserTests/regressions/libpq1.format
+ tests/ParserTests/regressions/libpq2.cabal
+ tests/ParserTests/regressions/libpq2.expr
+ tests/ParserTests/regressions/libpq2.format
+ tests/ParserTests/regressions/mixin-1.cabal
+ tests/ParserTests/regressions/mixin-1.expr
+ tests/ParserTests/regressions/mixin-1.format
+ tests/ParserTests/regressions/mixin-2.cabal
+ tests/ParserTests/regressions/mixin-2.expr
+ tests/ParserTests/regressions/mixin-2.format
+ tests/ParserTests/regressions/mixin-3.cabal
+ tests/ParserTests/regressions/mixin-3.expr
+ tests/ParserTests/regressions/mixin-3.format
+ tests/ParserTests/regressions/multiple-libs-2.cabal
+ tests/ParserTests/regressions/multiple-libs-2.check
+ tests/ParserTests/regressions/multiple-libs-2.expr
+ tests/ParserTests/regressions/multiple-libs-2.format
tests/ParserTests/regressions/noVersion.cabal
tests/ParserTests/regressions/noVersion.expr
tests/ParserTests/regressions/noVersion.format
@@ -146,6 +217,9 @@ extra-source-files:
tests/ParserTests/regressions/th-lift-instances.cabal
tests/ParserTests/regressions/th-lift-instances.expr
tests/ParserTests/regressions/th-lift-instances.format
+ tests/ParserTests/regressions/version-sets.cabal
+ tests/ParserTests/regressions/version-sets.expr
+ tests/ParserTests/regressions/version-sets.format
tests/ParserTests/regressions/wl-pprint-indef.cabal
tests/ParserTests/regressions/wl-pprint-indef.expr
tests/ParserTests/regressions/wl-pprint-indef.format
@@ -166,6 +240,7 @@ extra-source-files:
tests/ParserTests/warnings/unknownsection.cabal
tests/ParserTests/warnings/utf8.cabal
tests/ParserTests/warnings/versiontag.cabal
+ tests/cbits/rpmvercmp.c
tests/hackage/check.sh
tests/hackage/download.sh
tests/hackage/unpack.sh
@@ -208,6 +283,11 @@ library
ghc-options: -Wcompat -Wnoncanonical-monad-instances
-Wnoncanonical-monadfail-instances
+ if !impl(ghc >= 8.0)
+ -- at least one of lib:Cabal's dependency (i.e. `parsec`)
+ -- already depends on `fail` and `semigroups` transitively
+ build-depends: fail == 4.9.*, semigroups >= 0.18.3 && < 0.20
+
exposed-modules:
Distribution.Backpack
Distribution.Backpack.Configure
@@ -230,8 +310,8 @@ library
Distribution.Compat.Graph
Distribution.Compat.Internal.TempFile
Distribution.Compat.Newtype
+ Distribution.Compat.ResponseFile
Distribution.Compat.Prelude.Internal
- Distribution.Compat.ReadP
Distribution.Compat.Semigroup
Distribution.Compat.Stack
Distribution.Compat.Time
@@ -251,8 +331,6 @@ library
Distribution.PackageDescription.Configuration
Distribution.PackageDescription.PrettyPrint
Distribution.PackageDescription.Utils
- Distribution.ParseUtils
- Distribution.PrettyUtils
Distribution.ReadE
Distribution.Simple
Distribution.Simple.Bench
@@ -276,6 +354,7 @@ library
Distribution.Simple.Hpc
Distribution.Simple.Install
Distribution.Simple.InstallDirs
+ Distribution.Simple.InstallDirs.Internal
Distribution.Simple.LocalBuildInfo
Distribution.Simple.PackageIndex
Distribution.Simple.PreProcess
@@ -297,6 +376,7 @@ library
Distribution.Simple.Program.Types
Distribution.Simple.Register
Distribution.Simple.Setup
+ Distribution.Simple.ShowBuildInfo
Distribution.Simple.SrcDist
Distribution.Simple.Test
Distribution.Simple.Test.ExeV10
@@ -336,6 +416,7 @@ library
Distribution.Types.Executable
Distribution.Types.ExecutableScope
Distribution.Types.Library
+ Distribution.Types.LibraryVisibility
Distribution.Types.ForeignLib
Distribution.Types.ForeignLibType
Distribution.Types.ForeignLibOption
@@ -343,9 +424,13 @@ library
Distribution.Types.ModuleReexport
Distribution.Types.ModuleRenaming
Distribution.Types.ComponentName
+ Distribution.Types.LibraryName
Distribution.Types.MungedPackageName
Distribution.Types.PackageName
+ Distribution.Types.PackageName.Magic
Distribution.Types.PkgconfigName
+ Distribution.Types.PkgconfigVersion
+ Distribution.Types.PkgconfigVersionRange
Distribution.Types.UnqualComponentName
Distribution.Types.IncludeRenaming
Distribution.Types.Mixin
@@ -366,12 +451,16 @@ library
Distribution.Types.TargetInfo
Distribution.Types.Version
Distribution.Types.VersionRange
+ Distribution.Types.VersionRange.Internal
Distribution.Types.VersionInterval
+ Distribution.Types.GivenComponent
+ Distribution.Types.PackageVersionConstraint
Distribution.Utils.Generic
Distribution.Utils.NubList
Distribution.Utils.ShortText
Distribution.Utils.Progress
Distribution.Verbosity
+ Distribution.Verbosity.Internal
Distribution.Version
Language.Haskell.Extension
Distribution.Compat.Binary
@@ -395,16 +484,20 @@ library
Distribution.PackageDescription.FieldGrammar
Distribution.PackageDescription.Parsec
Distribution.PackageDescription.Quirks
- Distribution.Parsec.Class
- Distribution.Parsec.Common
- Distribution.Parsec.ConfVar
- Distribution.Parsec.Field
- Distribution.Parsec.FieldLineStream
- Distribution.Parsec.Lexer
- Distribution.Parsec.LexerMonad
+ Distribution.Parsec
+ Distribution.Parsec.Error
Distribution.Parsec.Newtypes
- Distribution.Parsec.ParseResult
- Distribution.Parsec.Parser
+ Distribution.Parsec.Position
+ Distribution.Parsec.Warning
+ Distribution.Parsec.FieldLineStream
+ Distribution.Fields
+ Distribution.Fields.ConfVar
+ Distribution.Fields.Field
+ Distribution.Fields.Lexer
+ Distribution.Fields.LexerMonad
+ Distribution.Fields.ParseResult
+ Distribution.Fields.Parser
+ Distribution.Fields.Pretty
-- Lens functionality
exposed-modules:
@@ -443,6 +536,7 @@ library
Distribution.Simple.GHC.EnvironmentParser
Distribution.Simple.GHC.Internal
Distribution.Simple.GHC.ImplInfo
+ Distribution.Simple.Utils.Json
Paths_Cabal
if flag(bundled-binary-generic)
@@ -489,7 +583,6 @@ test-suite unit-tests
Test.Laws
Test.QuickCheck.Utils
UnitTests.Distribution.Compat.CreatePipe
- UnitTests.Distribution.Compat.ReadP
UnitTests.Distribution.Compat.Time
UnitTests.Distribution.Compat.Graph
UnitTests.Distribution.Simple.Glob
@@ -502,10 +595,12 @@ test-suite unit-tests
UnitTests.Distribution.Utils.NubList
UnitTests.Distribution.Utils.ShortText
UnitTests.Distribution.Version
+ UnitTests.Distribution.PkgconfigVersion
main-is: UnitTests.hs
build-depends:
array,
base,
+ binary,
bytestring,
containers,
directory,
@@ -531,6 +626,7 @@ test-suite parser-tests
base,
base-compat >=0.10.4 && <0.11,
bytestring,
+ directory,
filepath,
tasty >= 1.1.0.3 && < 1.2,
tasty-hunit,
@@ -541,9 +637,12 @@ test-suite parser-tests
ghc-options: -Wall
default-language: Haskell2010
+ if !impl(ghc >= 8.0)
+ build-depends: semigroups
+
if impl(ghc >= 7.8)
build-depends:
- tree-diff >= 0.0.1 && <0.1
+ tree-diff >= 0.0.2 && <0.1
other-modules:
Instances.TreeDiff
Instances.TreeDiff.Language
@@ -557,6 +656,7 @@ test-suite check-tests
build-depends:
base,
bytestring,
+ directory,
filepath,
tasty >= 1.1.0.3 && < 1.2,
tasty-golden >=2.3.1.1 && <2.4,
@@ -564,6 +664,8 @@ test-suite check-tests
Cabal
ghc-options: -Wall
default-language: Haskell2010
+ if !impl(ghc >= 8.0)
+ build-depends: semigroups
test-suite custom-setup-tests
type: exitcode-stdio-1.0
@@ -603,11 +705,12 @@ test-suite hackage-tests
base-compat >=0.10.4 && <0.11,
base-orphans >=0.6 && <0.9,
optparse-applicative >=0.13.2.0 && <0.15,
+ stm >=2.4.5.0 && <2.6,
tar >=0.5.0.3 && <0.6
if impl(ghc >= 7.8)
build-depends:
- tree-diff >= 0.0.1 && <0.1
+ tree-diff >= 0.0.2 && <0.1
other-modules:
Instances.TreeDiff
Instances.TreeDiff.Language
@@ -617,3 +720,25 @@ test-suite hackage-tests
ghc-options: -Wall -rtsopts -threaded
default-extensions: CPP
default-language: Haskell2010
+
+test-suite rpmvercmp
+ type: exitcode-stdio-1.0
+ main-is: RPMVerCmp.hs
+
+ hs-source-dirs: tests
+ build-depends:
+ base,
+ Cabal,
+ bytestring
+
+ build-depends:
+ tasty >= 1.1.0.3 && < 1.2,
+ tasty-hunit,
+ tasty-quickcheck,
+ QuickCheck
+
+ c-sources: tests/cbits/rpmvercmp.c
+ cc-options: -Wall
+
+ ghc-options: -Wall
+ default-language: Haskell2010
diff --git a/cabal/Cabal/ChangeLog.md b/cabal/Cabal/ChangeLog.md
index 99105ee..81cb7f3 100644
--- a/cabal/Cabal/ChangeLog.md
+++ b/cabal/Cabal/ChangeLog.md
@@ -1,9 +1,60 @@
+# 3.1.0.0 (current development version)
+
+# 3.0.0.0 TBD
+ * TODO
+ * Introduce set notation for `^>=` and `==` operators
+ ([#5906](https://github.com/haskell/cabal/pull/5906)).
+ * 'check' reports warnings for various ghc-\*-options fields separately
+ ([#5342](https://github.com/haskell/cabal/issues/5432)).
+ * `KnownExtension`: added new extensions `DerivingVia` and
+ `EmptyDataDeriving`.
+ * Add `extra-dynamic-library-flavours`, to specify extra dynamic library
+ flavours to build and install from a .cabal file.
+ * `autoconfUserHooks` now passes `--host=$HOST` when cross-compiling
+ * Introduce multiple public libraries feature
+ ([#5526](https://github.com/haskell/cabal/pull/5526)).
+ * New build-depends syntax
+ * Add a set of library components to the `Dependency` datatype
+ * New `visibility` field in the `library` stanza
+ * New `LibraryVisibility` field in `InstalledPackageInfo`
+ * New syntax for the `--dependency` Cabal flag
+ * Static linking
+ * Add `--enable-executable-static` flag for building fully
+ static executables (GHC's normal "statish" linking links
+ Haskell libraries statically, but libc and system dependencies
+ dynamically). This new flag links everything statically.
+ * Note you likely want to link against `musl` or another libc that
+ supports fully static linking;
+ [`glibc` has some issues](https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F)
+ with fully static linking.
+ * Fix corrupted config file header for non-ASCII package names
+ ([2557](https://github.com/haskell/cabal/issues/2557)).
+ * Extend `Distribution.Simple.Utils.rewriteFileEx` from ASCII to UTF-8 encoding.
+ * Change the arguments of `Newtype` class to better suit @DeriveAnyClass@ usage,
+ add default implementation in terms of `coerce` / `unsafeCoerce`.
+ * Implement support for response file arguments to defaultMain* and cabal-install.
+ * Uniformly provide 'Semigroup' instances for `base < 4.9` via `semigroups` package
+ * Setting `debug-info` now implies `library-stripping: False` and
+ `executable-stripping: False) ([#2702](https://github.com/haskell/cabal/issues/2702))
+ * `Setup.hs copy` and `install` now work in the presence of
+ `data-files` that use `**` syntax
+ ([#6125](https://github.com/haskell/cabal/issues/6125)).
+
+----
+
+### 2.4.1.1 [Mikhail Glushenkov](mailto:mikhail.glushenkov@gmail.com) December 2018
+
+ * Fix `--with-compiler` failing to locate compiler on Windows
+ ([#5753](https://github.com/haskell/cabal/pull/5753)).
+ * Cabal can once again be built with GHC 7.8 and 7.6
+ ([#5730](https://github.com/haskell/cabal/pull/5730)).
+
### 2.4.1.0 [Mikhail Glushenkov](mailto:mikhail.glushenkov@gmail.com) November 2018
* Warnings in autogenerated files are now silenced
- ([#5678](https://github.com/haskell/cabal/pulls/5678)).
+ ([#5678](https://github.com/haskell/cabal/pull/5678)).
* Improved recompilation avoidance, especially when using GHC 8.6
- ([#5589](https://github.com/haskell/cabal/pulls/5589)).
+ ([#5589](https://github.com/haskell/cabal/pull/5589)).
* Do not error on empty packagedbs in `getInstalledPackages`
([#5516](https://github.com/haskell/cabal/issues/5516)).
@@ -26,6 +77,8 @@
`non`) and an optics to access the modules in a component
of a `PackageDescription` by the `ComponentName`:
`componentBuildInfo` and `componentModules`
+ * Linker `ld-options` are now passed to GHC as `-optl` options
+ ([#4925](https://github.com/haskell/cabal/pull/4925)).
* Add `readGhcEnvironmentFile` to parse GHC environment files.
* Drop support for GHC 7.4, since it is out of our support window
(and has been for over a year!)
@@ -414,7 +467,7 @@
* Experimental support for emitting DWARF debug info.
* Preliminary support for relocatable packages.
* Allow cabal to be used inside cabal exec enviroments.
- * hpc: support mutliple "ways" (e.g. profiling and vanilla).
+ * hpc: support multiple "ways" (e.g. profiling and vanilla).
* Support GHCJS.
* Improved command line documentation.
* Add `-none` constraint syntax for version ranges (#2093).
diff --git a/cabal/Cabal/Distribution/Backpack.hs b/cabal/Cabal/Distribution/Backpack.hs
index 604579d..d354bd2 100644
--- a/cabal/Cabal/Distribution/Backpack.hs
+++ b/cabal/Cabal/Distribution/Backpack.hs
@@ -29,8 +29,6 @@ module Distribution.Backpack (
OpenModuleSubst,
dispOpenModuleSubst,
dispOpenModuleSubstEntry,
- parseOpenModuleSubst,
- parseOpenModuleSubstEntry,
parsecOpenModuleSubst,
parsecOpenModuleSubstEntry,
openModuleSubstFreeHoles,
@@ -41,18 +39,15 @@ module Distribution.Backpack (
) where
import Distribution.Compat.Prelude hiding (mod)
-import Distribution.Compat.ReadP ((<++))
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Pretty
import Prelude ()
import Text.PrettyPrint (hcat)
import qualified Distribution.Compat.CharParsing as P
-import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
import Distribution.ModuleName
-import Distribution.Text
import Distribution.Types.ComponentId
import Distribution.Types.Module
import Distribution.Types.UnitId
@@ -134,15 +129,6 @@ instance Parsec OpenUnitId where
parsecOpenModuleSubst
return (IndefFullUnitId cid insts)
-instance Text OpenUnitId where
- parse = parseOpenUnitId <++ fmap DefiniteUnitId parse
- where
- parseOpenUnitId = do
- cid <- parse
- insts <- Parse.between (Parse.char '[') (Parse.char ']')
- parseOpenModuleSubst
- return (IndefFullUnitId cid insts)
-
-- | Get the set of holes ('ModuleVar') embedded in a 'UnitId'.
openUnitIdFreeHoles :: OpenUnitId -> Set ModuleName
openUnitIdFreeHoles (IndefFullUnitId _ insts) = openModuleSubstFreeHoles insts
@@ -211,20 +197,6 @@ instance Parsec OpenModule where
_ <- P.char '>'
return (OpenModuleVar mod_name)
-instance Text OpenModule where
- parse = parseModuleVar <++ parseOpenModule
- where
- parseOpenModule = do
- uid <- parse
- _ <- Parse.char ':'
- mod_name <- parse
- return (OpenModule uid mod_name)
- parseModuleVar = do
- _ <- Parse.char '<'
- mod_name <- parse
- _ <- Parse.char '>'
- return (OpenModuleVar mod_name)
-
-- | Get the set of holes ('ModuleVar') embedded in a 'Module'.
openModuleFreeHoles :: OpenModule -> Set ModuleName
openModuleFreeHoles (OpenModuleVar mod_name) = Set.singleton mod_name
@@ -249,21 +221,7 @@ dispOpenModuleSubst subst
-- | Pretty-print a single entry of a module substitution.
dispOpenModuleSubstEntry :: (ModuleName, OpenModule) -> Disp.Doc
-dispOpenModuleSubstEntry (k, v) = disp k <<>> Disp.char '=' <<>> disp v
-
--- | Inverse to 'dispModSubst'.
-parseOpenModuleSubst :: Parse.ReadP r OpenModuleSubst
-parseOpenModuleSubst = fmap Map.fromList
- . flip Parse.sepBy (Parse.char ',')
- $ parseOpenModuleSubstEntry
-
--- | Inverse to 'dispModSubstEntry'.
-parseOpenModuleSubstEntry :: Parse.ReadP r (ModuleName, OpenModule)
-parseOpenModuleSubstEntry =
- do k <- parse
- _ <- Parse.char '='
- v <- parse
- return (k, v)
+dispOpenModuleSubstEntry (k, v) = pretty k <<>> Disp.char '=' <<>> pretty v
-- | Inverse to 'dispModSubst'.
--
@@ -307,5 +265,5 @@ hashModuleSubst subst
| Map.null subst = Nothing
| otherwise =
Just . hashToBase62 $
- concat [ display mod_name ++ "=" ++ display m ++ "\n"
+ concat [ prettyShow mod_name ++ "=" ++ prettyShow m ++ "\n"
| (mod_name, m) <- Map.toList subst]
diff --git a/cabal/Cabal/Distribution/Backpack/ComponentsGraph.hs b/cabal/Cabal/Distribution/Backpack/ComponentsGraph.hs
index 9b03638..8a19180 100644
--- a/cabal/Cabal/Distribution/Backpack/ComponentsGraph.hs
+++ b/cabal/Cabal/Distribution/Backpack/ComponentsGraph.hs
@@ -20,8 +20,7 @@ import Distribution.Types.UnqualComponentName
import Distribution.Compat.Graph (Graph, Node(..))
import qualified Distribution.Compat.Graph as Graph
-import Distribution.Text
- ( Text(disp) )
+import Distribution.Pretty (pretty)
import Text.PrettyPrint
------------------------------------------------------------------------------
@@ -42,8 +41,8 @@ type ComponentsWithDeps = [(Component, [ComponentName])]
--
dispComponentsWithDeps :: ComponentsWithDeps -> Doc
dispComponentsWithDeps graph =
- vcat [ hang (text "component" <+> disp (componentName c)) 4
- (vcat [ text "dependency" <+> disp cdep | cdep <- cdeps ])
+ vcat [ hang (text "component" <+> pretty (componentName c)) 4
+ (vcat [ text "dependency" <+> pretty cdep | cdep <- cdeps ])
| (c, cdeps) <- graph ]
-- | Create a 'Graph' of 'Component', or report a cycle if there is a
@@ -66,16 +65,17 @@ mkComponentsGraph enabled pkg_descr =
(CExeName <$> getAllInternalToolDependencies pkg_descr bi)
++ [ if pkgname == packageName pkg_descr
- then CLibName
- else CSubLibName toolname
- | Dependency pkgname _ <- targetBuildDepends bi
+ then CLibName LMainLibName
+ else CLibName (LSubLibName toolname)
+ | Dependency pkgname _ _ <- targetBuildDepends bi
, let toolname = packageNameToUnqualComponentName pkgname
, toolname `elem` internalPkgDeps ]
where
bi = componentBuildInfo component
internalPkgDeps = map (conv . libName) (allLibraries pkg_descr)
- conv Nothing = packageNameToUnqualComponentName $ packageName pkg_descr
- conv (Just s) = s
+
+ conv LMainLibName = packageNameToUnqualComponentName $ packageName pkg_descr
+ conv (LSubLibName s) = s
-- | Given the package description and a 'PackageDescription' (used
-- to determine if a package name is internal or not), sort the
diff --git a/cabal/Cabal/Distribution/Backpack/Configure.hs b/cabal/Cabal/Distribution/Backpack/Configure.hs
index 597bf82..927570f 100644
--- a/cabal/Cabal/Distribution/Backpack/Configure.hs
+++ b/cabal/Cabal/Distribution/Backpack/Configure.hs
@@ -41,6 +41,7 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Types.AnnotatedId
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ComponentInclude
+import Distribution.Types.MungedPackageName
import Distribution.Verbosity
import qualified Distribution.Compat.Graph as Graph
import Distribution.Compat.Graph (Graph, IsNode(..))
@@ -50,7 +51,7 @@ import Data.Either
( lefts )
import qualified Data.Set as Set
import qualified Data.Map as Map
-import Distribution.Text
+import Distribution.Pretty
import Text.PrettyPrint
------------------------------------------------------------------------------
@@ -105,7 +106,7 @@ configureComponentLocalBuildInfos
| Just pkg <- PackageIndex.lookupUnitId installedPackageSet uid
= FullUnitId (Installed.installedComponentId pkg)
(Map.fromList (Installed.instantiatedWith pkg))
- | otherwise = error ("uid_lookup: " ++ display uid)
+ | otherwise = error ("uid_lookup: " ++ prettyShow uid)
where uid = unDefUnitId def_uid
graph2 <- toLinkedComponents verbosity uid_lookup
(package pkg_descr) shape_pkg_map graph1
@@ -186,14 +187,14 @@ toComponentLocalBuildInfos
++ "packages must be rebuilt before they can be used.\n"
-- TODO: Undupe.
++ unlines [ "installed package "
- ++ display (packageId pkg)
+ ++ prettyShow (packageId pkg)
++ " is broken due to missing package "
- ++ intercalate ", " (map display deps)
+ ++ intercalate ", " (map prettyShow deps)
| (Left pkg, deps) <- broken ]
++ unlines [ "planned package "
- ++ display (packageId pkg)
+ ++ prettyShow (packageId pkg)
++ " is broken due to missing package "
- ++ intercalate ", " (map display deps)
+ ++ intercalate ", " (map prettyShow deps)
| (Right pkg, deps) <- broken ]
-- In this section, we'd like to look at the 'packageDependsIndex'
@@ -224,9 +225,9 @@ toComponentLocalBuildInfos
warnProgress $
hang (text "This package indirectly depends on multiple versions of the same" <+>
text "package. This is very likely to cause a compile failure.") 2
- (vcat [ text "package" <+> disp (packageName user) <+>
- parens (disp (installedUnitId user)) <+> text "requires" <+>
- disp inst
+ (vcat [ text "package" <+> pretty (packageName user) <+>
+ parens (pretty (installedUnitId user)) <+> text "requires" <+>
+ pretty inst
| (_dep_key, insts) <- inconsistencies
, (inst, users) <- insts
, user <- users ])
@@ -277,7 +278,7 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
Right instc -> [ (m, OpenModule (DefiniteUnitId uid') m')
| (m, Module uid' m') <- instc_insts instc ]
- compat_name = computeCompatPackageName (packageName rc) (libName lib)
+ compat_name = MungedPackageName (packageName rc) (libName lib)
compat_key = computeCompatPackageKey comp compat_name (packageVersion rc) this_uid
in LibComponentLocalBuildInfo {
diff --git a/cabal/Cabal/Distribution/Backpack/ConfiguredComponent.hs b/cabal/Cabal/Distribution/Backpack/ConfiguredComponent.hs
index dab4066..79a678b 100644
--- a/cabal/Cabal/Distribution/Backpack/ConfiguredComponent.hs
+++ b/cabal/Cabal/Distribution/Backpack/ConfiguredComponent.hs
@@ -30,6 +30,7 @@ import Distribution.Types.PackageId
import Distribution.Types.PackageName
import Distribution.Types.Mixin
import Distribution.Types.ComponentName
+import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
import Distribution.Types.ComponentInclude
import Distribution.Package
@@ -45,7 +46,7 @@ import Distribution.Utils.Generic
import Control.Monad
import qualified Data.Set as Set
import qualified Data.Map as Map
-import Distribution.Text
+import Distribution.Pretty
import Text.PrettyPrint
-- | A configured component, we know exactly what its 'ComponentId' is,
@@ -91,8 +92,9 @@ cc_name = ann_cname . cc_ann_id
-- | Pretty-print a 'ConfiguredComponent'.
dispConfiguredComponent :: ConfiguredComponent -> Doc
dispConfiguredComponent cc =
- hang (text "component" <+> disp (cc_cid cc)) 4
- (vcat [ hsep $ [ text "include", disp (ci_id incl), disp (ci_renaming incl) ]
+ hang (text "component" <+> pretty (cc_cid cc)) 4
+ (vcat [ hsep $ [ text "include"
+ , pretty (ci_id incl), pretty (ci_renaming incl) ]
| incl <- cc_includes cc
])
@@ -114,9 +116,9 @@ mkConfiguredComponent pkg_descr this_cid lib_deps exe_deps component = do
aid <- case Map.lookup keys deps_map of
Nothing ->
dieProgress $
- text "Mix-in refers to non-existent package" <+>
- quotes (disp name) $$
- text "(did you forget to add the package to build-depends?)"
+ text "Mix-in refers to non-existent package" <+>
+ quotes (pretty name) $$
+ text "(did you forget to add the package to build-depends?)"
Just r -> return r
return ComponentInclude {
ci_ann_id = aid,
@@ -150,7 +152,7 @@ mkConfiguredComponent pkg_descr this_cid lib_deps exe_deps component = do
bi = componentBuildInfo component
deps_map = Map.fromList [ ((packageName dep, ann_cname dep), dep)
| dep <- lib_deps ]
- is_public = componentName component == CLibName
+ is_public = componentName component == CLibName LMainLibName
type ConfiguredComponentMap =
Map PackageName (Map ComponentName (AnnotatedId ComponentId))
@@ -165,16 +167,30 @@ toConfiguredComponent
toConfiguredComponent pkg_descr this_cid lib_dep_map exe_dep_map component = do
lib_deps <-
if newPackageDepsBehaviour pkg_descr
- then forM (targetBuildDepends bi) $ \(Dependency name _) -> do
- let (pn, cn) = fixFakePkgName pkg_descr name
- value <- case Map.lookup cn =<< Map.lookup pn lib_dep_map of
+ then fmap concat $ forM (targetBuildDepends bi) $
+ \(Dependency name _ sublibs) -> do
+ -- The package name still needs fixing in case of legacy
+ -- sublibrary dependency syntax
+ let (pn, _) = fixFakePkgName pkg_descr name
+ pkg <- case Map.lookup pn lib_dep_map of
Nothing ->
dieProgress $
- text "Dependency on unbuildable (i.e. 'buildable: False')" <+>
- text (showComponentName cn) <+>
- text "from" <+> disp pn
- Just v -> return v
- return value
+ text "Dependency on unbuildable" <+>
+ text "package" <+> pretty pn
+ Just p -> return p
+ -- Return all library components
+ forM (Set.toList sublibs) $ \lib ->
+ let comp = CLibName lib in
+ case Map.lookup (CLibName $ LSubLibName $
+ packageNameToUnqualComponentName name) pkg
+ <|> Map.lookup comp pkg
+ of
+ Nothing ->
+ dieProgress $
+ text "Dependency on unbuildable" <+>
+ text (showLibraryName lib) <+>
+ text "from" <+> pretty pn
+ Just v -> return v
else return old_style_lib_deps
mkConfiguredComponent
pkg_descr this_cid
@@ -192,7 +208,7 @@ toConfiguredComponent pkg_descr this_cid lib_dep_map exe_dep_map component = do
| (pn, comp_map) <- Map.toList lib_dep_map
, pn /= packageName pkg_descr
, (cn, e) <- Map.toList comp_map
- , cn == CLibName ]
+ , cn == CLibName LMainLibName ]
-- We have to nub here, because 'getAllToolDependencies' may return
-- duplicates (see #4986). (NB: This is not needed for lib_deps,
-- since those elaborate into includes, for which there explicitly
@@ -231,8 +247,8 @@ toConfiguredComponent' use_external_internal_deps flags
else cc
where
-- TODO: pass component names to it too!
- this_cid = computeComponentId deterministic ipid_flag cid_flag (package pkg_descr)
- (componentName component) (Just (deps, flags))
+ this_cid = computeComponentId deterministic ipid_flag cid_flag
+ (package pkg_descr) (componentName component) (Just (deps, flags))
deps = [ ann_id aid | m <- Map.elems dep_map
, aid <- Map.elems m ]
@@ -293,11 +309,14 @@ newPackageDepsBehaviour pkg =
-- and internal libraries are specified the same. For now, we assume internal
-- libraries shadow, and this function disambiguates accordingly, but soon the
-- underlying ambiguity will be addressed.
+-- Multiple public libraries (cabal 3.0) added an unambiguous way of specifying
+-- sublibraries, but we still have to support the old syntax for bc reasons.
fixFakePkgName :: PackageDescription -> PackageName -> (PackageName, ComponentName)
fixFakePkgName pkg_descr pn =
if subLibName `elem` internalLibraries
- then (packageName pkg_descr, CSubLibName subLibName)
- else (pn, CLibName)
+ then (packageName pkg_descr, CLibName (LSubLibName subLibName))
+ else (pn, CLibName LMainLibName )
where
- subLibName = packageNameToUnqualComponentName pn
- internalLibraries = mapMaybe libName (allLibraries pkg_descr)
+ subLibName = packageNameToUnqualComponentName pn
+ internalLibraries = mapMaybe (libraryNameString . libName)
+ (allLibraries pkg_descr)
diff --git a/cabal/Cabal/Distribution/Backpack/DescribeUnitId.hs b/cabal/Cabal/Distribution/Backpack/DescribeUnitId.hs
index 8deb42a..3dc063b 100644
--- a/cabal/Cabal/Distribution/Backpack/DescribeUnitId.hs
+++ b/cabal/Cabal/Distribution/Backpack/DescribeUnitId.hs
@@ -1,17 +1,17 @@
-{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE Rank2Types #-}
module Distribution.Backpack.DescribeUnitId where
-import Prelude ()
import Distribution.Compat.Prelude
+import Prelude ()
-import Distribution.Types.PackageId
-import Distribution.Types.ComponentName
import Distribution.Compat.Stack
-import Distribution.Verbosity
import Distribution.ModuleName
-import Distribution.Text
+import Distribution.Pretty
import Distribution.Simple.Utils
+import Distribution.Types.ComponentName
+import Distribution.Types.PackageId
+import Distribution.Verbosity
import Text.PrettyPrint
@@ -37,7 +37,7 @@ import Text.PrettyPrint
-- for (2) which component (with enough details to uniquely identify
-- the build in question.)
--
-setupMessage' :: Text a => Verbosity
+setupMessage' :: Pretty a => Verbosity
-> String -- ^ Operation being done (capitalized), on:
-> PackageIdentifier -- ^ Package
-> ComponentName -- ^ Component name
@@ -50,7 +50,7 @@ setupMessage' verbosity msg pkgid cname mb_insts = withFrozenCallStack $ do
case mb_insts of
Just insts | not (null insts) ->
hang (msg_doc <+> text "instantiated with") 2
- (vcat [ disp k <+> text "=" <+> disp v
+ (vcat [ pretty k <+> text "=" <+> pretty v
| (k,v) <- insts ]) $$
for_doc
_ ->
@@ -58,4 +58,4 @@ setupMessage' verbosity msg pkgid cname mb_insts = withFrozenCallStack $ do
where
msg_doc = text msg <+> text (showComponentName cname)
- for_doc = text "for" <+> disp pkgid <<>> text ".."
+ for_doc = text "for" <+> pretty pkgid <<>> text ".."
diff --git a/cabal/Cabal/Distribution/Backpack/Id.hs b/cabal/Cabal/Distribution/Backpack/Id.hs
index afe9756..b5e14a6 100644
--- a/cabal/Cabal/Distribution/Backpack/Id.hs
+++ b/cabal/Cabal/Distribution/Backpack/Id.hs
@@ -5,7 +5,6 @@
module Distribution.Backpack.Id(
computeComponentId,
computeCompatPackageKey,
- computeCompatPackageName,
) where
import Prelude ()
@@ -24,8 +23,9 @@ import Distribution.Types.MungedPackageName
import Distribution.Utils.Base62
import Distribution.Version
-import Distribution.Text
- ( display, simpleParse )
+import Distribution.Pretty
+ ( prettyShow )
+import Distribution.Parsec ( simpleParsec )
-- | This method computes a default, "good enough" 'ComponentId'
-- for a package. The intent is that cabal-install (or the user) will
@@ -50,11 +50,11 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
-- For safety, include the package + version here
-- for GHC 7.10, where just the hash is used as
-- the package key
- ( display pid
+ ( prettyShow pid
++ show dep_ipids
++ show flags )
| otherwise = ""
- generated_base = display pid ++ hash_suffix
+ generated_base = prettyShow pid ++ hash_suffix
explicit_base cid0 = fromPathTemplate (InstallDirs.substPathTemplate env
(toPathTemplate cid0))
-- Hack to reuse install dirs machinery
@@ -62,7 +62,7 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
where env = packageTemplateEnv pid (mkUnitId "")
actual_base = case mb_ipid of
Flag ipid0 -> explicit_base ipid0
- NoFlag | deterministic -> display pid
+ NoFlag | deterministic -> prettyShow pid
| otherwise -> generated_base
in case mb_cid of
Flag cid -> cid
@@ -126,15 +126,15 @@ computeCompatPackageKey
-> String
computeCompatPackageKey comp pkg_name pkg_version uid
| not (packageKeySupported comp) =
- display pkg_name ++ "-" ++ display pkg_version
+ prettyShow pkg_name ++ "-" ++ prettyShow pkg_version
| not (unifiedIPIDRequired comp) =
let str = unUnitId uid -- assume no Backpack support
mb_verbatim_key
- = case simpleParse str :: Maybe PackageId of
+ = case simpleParsec str :: Maybe PackageId of
-- Something like 'foo-0.1', use it verbatim.
-- (NB: hash tags look like tags, so they are parsed,
-- so the extra equality check tests if a tag was dropped.)
- Just pid0 | display pid0 == str -> Just str
+ Just pid0 | prettyShow pid0 == str -> Just str
_ -> Nothing
mb_truncated_key
= let cand = reverse (takeWhile isAlphaNum (reverse str))
@@ -143,4 +143,4 @@ computeCompatPackageKey comp pkg_name pkg_version uid
else Nothing
rehashed_key = hashToBase62 str
in fromMaybe rehashed_key (mb_verbatim_key `mplus` mb_truncated_key)
- | otherwise = display uid
+ | otherwise = prettyShow uid
diff --git a/cabal/Cabal/Distribution/Backpack/LinkedComponent.hs b/cabal/Cabal/Distribution/Backpack/LinkedComponent.hs
index 29a0a92..1ead8f0 100644
--- a/cabal/Cabal/Distribution/Backpack/LinkedComponent.hs
+++ b/cabal/Cabal/Distribution/Backpack/LinkedComponent.hs
@@ -45,8 +45,7 @@ import qualified Data.Set as Set
import qualified Data.Map as Map
import Data.Traversable
( mapM )
-import Distribution.Text
- ( Text(disp) )
+import Distribution.Pretty (pretty)
import Text.PrettyPrint
import Data.Either
@@ -104,11 +103,11 @@ lc_insts lc = [ (req, OpenModuleVar req)
dispLinkedComponent :: LinkedComponent -> Doc
dispLinkedComponent lc =
- hang (text "unit" <+> disp (lc_uid lc)) 4 $
- vcat [ text "include" <+> disp (ci_id incl) <+> disp (ci_renaming incl)
+ hang (text "unit" <+> pretty (lc_uid lc)) 4 $
+ vcat [ text "include" <+> pretty (ci_id incl) <+> pretty (ci_renaming incl)
| incl <- lc_includes lc ]
$+$
- vcat [ text "signature include" <+> disp (ci_id incl)
+ vcat [ text "signature include" <+> pretty (ci_id incl)
| incl <- lc_sig_includes lc ]
$+$ dispOpenModuleSubst (modShapeProvides (lc_shape lc))
@@ -230,7 +229,7 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
when (not (Set.null reqs) && isNotLib component) $
dieProgress $
hang (text "Non-library component has unfilled requirements:")
- 4 (vcat [disp req | req <- Set.toList reqs])
+ 4 (vcat [pretty req | req <- Set.toList reqs])
-- NB: do NOT include hidden modules here: GHC 7.10's ghc-pkg
-- won't allow it (since someone could directly synthesize
@@ -285,7 +284,7 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
let build_reexports m (k, v)
| Map.member k m =
dieProgress $ hsep
- [ text "Module name ", disp k, text " is exported multiple times." ]
+ [ text "Module name ", pretty k, text " is exported multiple times." ]
| otherwise = return (Map.insert k v m)
provs <- foldM build_reexports Map.empty $
-- TODO: doublecheck we have checked for
@@ -364,17 +363,17 @@ extendLinkedComponentMap lc m =
brokenReexportMsg :: ModuleReexport -> Doc
brokenReexportMsg (ModuleReexport (Just pn) from _to) =
- vcat [ text "The package" <+> quotes (disp pn)
- , text "does not export a module" <+> quotes (disp from) ]
+ vcat [ text "The package" <+> quotes (pretty pn)
+ , text "does not export a module" <+> quotes (pretty from) ]
brokenReexportMsg (ModuleReexport Nothing from _to) =
- vcat [ text "The module" <+> quotes (disp from)
+ vcat [ text "The module" <+> quotes (pretty from)
, text "is not exported by any suitable package."
, text "It occurs in neither the 'exposed-modules' of this package,"
, text "nor any of its 'build-depends' dependencies." ]
ambiguousReexportMsg :: ModuleReexport -> ModuleWithSource -> [ModuleWithSource] -> Doc
ambiguousReexportMsg (ModuleReexport mb_pn from _to) y1 ys =
- vcat [ text "Ambiguous reexport" <+> quotes (disp from)
+ vcat [ text "Ambiguous reexport" <+> quotes (pretty from)
, hang (text "It could refer to either:") 2
(vcat (msg : msgs))
, help_msg mb_pn ]
@@ -393,7 +392,7 @@ ambiguousReexportMsg (ModuleReexport mb_pn from _to) y1 ys =
, text "mixins field to rename one of the module"
, text "names differently." ]
displayModuleWithSource y
- = vcat [ quotes (disp (unWithSource y))
+ = vcat [ quotes (pretty (unWithSource y))
, text "brought into scope by" <+>
dispModuleSource (getSource y)
]
diff --git a/cabal/Cabal/Distribution/Backpack/MixLink.hs b/cabal/Cabal/Distribution/Backpack/MixLink.hs
index 6d560f3..8b44e74 100644
--- a/cabal/Cabal/Distribution/Backpack/MixLink.hs
+++ b/cabal/Cabal/Distribution/Backpack/MixLink.hs
@@ -14,7 +14,7 @@ import Distribution.Backpack.ModuleScope
import qualified Distribution.Utils.UnionFind as UnionFind
import Distribution.ModuleName
-import Distribution.Text
+import Distribution.Pretty
import Distribution.Types.ComponentId
import Text.PrettyPrint
@@ -56,10 +56,10 @@ linkProvision mod_name ret@(prov:provs) (req:reqs) = do
Just () -> return ()
Nothing -> do
addErr $
- text "Ambiguous module" <+> quotes (disp mod_name) $$
+ text "Ambiguous module" <+> quotes (pretty mod_name) $$
text "It could refer to" <+>
- ( text " " <+> (quotes (disp mod) $$ in_scope_by (getSource prov)) $$
- text "or" <+> (quotes (disp mod') $$ in_scope_by (getSource prov')) ) $$
+ ( text " " <+> (quotes (pretty mod) $$ in_scope_by (getSource prov)) $$
+ text "or" <+> (quotes (pretty mod') $$ in_scope_by (getSource prov')) ) $$
link_doc
mod <- convertModuleU (unWithSource prov)
req_mod <- convertModuleU (unWithSource req)
@@ -67,7 +67,7 @@ linkProvision mod_name ret@(prov:provs) (req:reqs) = do
case mod of
OpenModule (IndefFullUnitId cid _) _
| cid == self_cid -> addErr $
- text "Cannot instantiate requirement" <+> quotes (disp mod_name) <+>
+ text "Cannot instantiate requirement" <+> quotes (pretty mod_name) <+>
in_scope_by (getSource req) $$
text "with locally defined module" <+> in_scope_by (getSource prov) $$
text "as this would create a cyclic dependency, which GHC does not support." $$
@@ -79,9 +79,9 @@ linkProvision mod_name ret@(prov:provs) (req:reqs) = do
Just () -> return ()
Nothing -> do
-- TODO: Record and report WHERE the bad constraint came from
- addErr $ text "Could not instantiate requirement" <+> quotes (disp mod_name) $$
- nest 4 (text "Expected:" <+> disp mod $$
- text "Actual: " <+> disp req_mod) $$
+ addErr $ text "Could not instantiate requirement" <+> quotes (pretty mod_name) $$
+ nest 4 (text "Expected:" <+> pretty mod $$
+ text "Actual: " <+> pretty req_mod) $$
parens (text "This can occur if an exposed module of" <+>
text "a libraries shares a name with another module.") $$
link_doc
@@ -90,7 +90,7 @@ linkProvision mod_name ret@(prov:provs) (req:reqs) = do
unify s1 s2 = tryM $ addErrContext short_link_doc
$ unifyModule (unWithSource s1) (unWithSource s2)
in_scope_by s = text "brought into scope by" <+> dispModuleSource s
- short_link_doc = text "While filling requirement" <+> quotes (disp mod_name)
+ short_link_doc = text "While filling requirement" <+> quotes (pretty mod_name)
link_doc = text "While filling requirements of" <+> reqs_doc
reqs_doc
| null reqs = dispModuleSource (getSource req)
@@ -117,8 +117,8 @@ unifyUnitId uid1_u uid2_u
| u1 == u2 -> return ()
| otherwise ->
failWith $ hang (text "Couldn't match unit IDs:") 4
- (text " " <+> disp u1 $$
- text "and" <+> disp u2)
+ (text " " <+> pretty u1 $$
+ text "and" <+> pretty u2)
(UnitIdThunkU uid1, UnitIdU _ cid2 insts2)
-> unifyThunkWith cid2 insts2 uid2_u uid1 uid1_u
(UnitIdU _ cid1 insts1, UnitIdThunkU uid2)
@@ -151,8 +151,8 @@ unifyInner cid1 insts1 uid1_u cid2 insts2 uid2_u = do
-- easier to understand error message.
failWith $
hang (text "Couldn't match component IDs:") 4
- (text " " <+> disp cid1 $$
- text "and" <+> disp cid2)
+ (text " " <+> pretty cid1 $$
+ text "and" <+> pretty cid2)
-- The KEY STEP which makes this a Huet-style unification
-- algorithm. (Also a payoff of using union-find.)
-- We can build infinite unit IDs this way, which is necessary
@@ -176,8 +176,8 @@ unifyModule mod1_u mod2_u
when (mod_name1 /= mod_name2) $
failWith $
hang (text "Cannot match module names") 4 $
- text " " <+> disp mod_name1 $$
- text "and" <+> disp mod_name2
+ text " " <+> pretty mod_name1 $$
+ text "and" <+> pretty mod_name2
-- NB: this is not actually necessary (because we'll
-- detect loops eventually in 'unifyUnitId'), but it
-- seems harmless enough
diff --git a/cabal/Cabal/Distribution/Backpack/ModuleScope.hs b/cabal/Cabal/Distribution/Backpack/ModuleScope.hs
index 8926a61..a6736d5 100644
--- a/cabal/Cabal/Distribution/Backpack/ModuleScope.hs
+++ b/cabal/Cabal/Distribution/Backpack/ModuleScope.hs
@@ -23,10 +23,11 @@ import Distribution.ModuleName
import Distribution.Types.IncludeRenaming
import Distribution.Types.PackageName
import Distribution.Types.ComponentName
+import Distribution.Types.LibraryName
+import Distribution.Pretty
import Distribution.Backpack
import Distribution.Backpack.ModSubst
-import Distribution.Text
import qualified Data.Map as Map
import Text.PrettyPrint
@@ -96,15 +97,15 @@ data ModuleSource
-- TODO: Deduplicate this with Distribution.Backpack.UnifyM.ci_msg
dispModuleSource :: ModuleSource -> Doc
dispModuleSource (FromMixins pn cn incls)
- = text "mixins:" <+> dispComponent pn cn <+> disp incls
+ = text "mixins:" <+> dispComponent pn cn <+> pretty incls
dispModuleSource (FromBuildDepends pn cn)
= text "build-depends:" <+> dispComponent pn cn
dispModuleSource (FromExposedModules m)
- = text "exposed-modules:" <+> disp m
+ = text "exposed-modules:" <+> pretty m
dispModuleSource (FromOtherModules m)
- = text "other-modules:" <+> disp m
+ = text "other-modules:" <+> pretty m
dispModuleSource (FromSignatures m)
- = text "signatures:" <+> disp m
+ = text "signatures:" <+> pretty m
-- Dependency
dispComponent :: PackageName -> ComponentName -> Doc
@@ -113,10 +114,10 @@ dispComponent pn cn =
-- should be clear enough. To do source syntax, we'd
-- need to know what the package we're linking is.
case cn of
- CLibName -> disp pn
- CSubLibName ucn -> disp pn <<>> colon <<>> disp ucn
+ CLibName LMainLibName -> pretty pn
+ CLibName (LSubLibName ucn) -> pretty pn <<>> colon <<>> pretty ucn
-- Case below shouldn't happen
- _ -> disp pn <+> parens (disp cn)
+ _ -> pretty pn <+> parens (pretty cn)
-- | An 'OpenModule', annotated with where it came from in a Cabal file.
data WithSource a = WithSource ModuleSource a
diff --git a/cabal/Cabal/Distribution/Backpack/PreExistingComponent.hs b/cabal/Cabal/Distribution/Backpack/PreExistingComponent.hs
index b1ed962..2fcfdf1 100644
--- a/cabal/Cabal/Distribution/Backpack/PreExistingComponent.hs
+++ b/cabal/Cabal/Distribution/Backpack/PreExistingComponent.hs
@@ -46,7 +46,7 @@ ipiToPreExistingComponent :: InstalledPackageInfo -> PreExistingComponent
ipiToPreExistingComponent ipi =
PreExistingComponent {
pc_pkgname = packageName ipi,
- pc_compname = libraryComponentName $ Installed.sourceLibName ipi,
+ pc_compname = CLibName $ Installed.sourceLibName ipi,
pc_munged_id = mungedId ipi,
pc_uid = Installed.installedUnitId ipi,
pc_cid = Installed.installedComponentId ipi,
diff --git a/cabal/Cabal/Distribution/Backpack/ReadyComponent.hs b/cabal/Cabal/Distribution/Backpack/ReadyComponent.hs
index db09121..950a643 100644
--- a/cabal/Cabal/Distribution/Backpack/ReadyComponent.hs
+++ b/cabal/Cabal/Distribution/Backpack/ReadyComponent.hs
@@ -26,12 +26,14 @@ import Distribution.Types.ComponentInclude
import Distribution.Types.ComponentId
import Distribution.Types.ComponentName
import Distribution.Types.PackageId
+import Distribution.Types.PackageName.Magic
import Distribution.Types.UnitId
import Distribution.Compat.Graph (IsNode(..))
import Distribution.Types.Module
import Distribution.Types.MungedPackageId
import Distribution.Types.MungedPackageName
import Distribution.Types.Library
+import Distribution.Types.LibraryName
import Distribution.ModuleName
import Distribution.Package
@@ -43,9 +45,10 @@ import qualified Data.Traversable as T
import Control.Monad
import Text.PrettyPrint
import qualified Data.Map as Map
+import qualified Data.Set as Set
import Distribution.Version
-import Distribution.Text
+import Distribution.Pretty
-- | A 'ReadyComponent' is one that we can actually generate build
-- products for. We have a ready component for the typecheck-only
@@ -134,15 +137,14 @@ rc_depends rc = ordNub $
(instc_includes instc)
++ instc_insts_deps instc
where
- toMungedPackageId :: Text id => ComponentInclude id rn -> MungedPackageId
+ toMungedPackageId :: Pretty id => ComponentInclude id rn -> MungedPackageId
toMungedPackageId ci =
computeCompatPackageId
(ci_pkgid ci)
(case ci_cname ci of
- CLibName -> Nothing
- CSubLibName uqn -> Just uqn
- _ -> error $ display (rc_cid rc) ++
- " depends on non-library " ++ display (ci_id ci))
+ CLibName name -> name
+ _ -> error $ prettyShow (rc_cid rc) ++
+ " depends on non-library " ++ prettyShow (ci_id ci))
-- | Get the 'MungedPackageId' of a 'ReadyComponent' IF it is
-- a library.
@@ -178,9 +180,9 @@ dispReadyComponent rc =
hang (text (case rc_i rc of
Left _ -> "indefinite"
Right _ -> "definite")
- <+> disp (nodeKey rc)
+ <+> pretty (nodeKey rc)
{- <+> dispModSubst (Map.fromList (lc_insts lc)) -} ) 4 $
- vcat [ text "depends" <+> disp uid
+ vcat [ text "depends" <+> pretty uid
| uid <- nodeNeighbors rc ]
-- | The state of 'InstM'; a mapping from 'UnitId's to their
@@ -274,7 +276,7 @@ toReadyComponents pid_map subst0 comps
fmap rc_munged_id (join (Map.lookup dep_uid s)))]
where
err_pid = MungedPackageId
- (mkMungedPackageName "nonexistent-package-this-is-a-cabal-bug")
+ (MungedPackageName nonExistentPackageThisIsCabalBug LMainLibName)
(mkVersion [0])
instc = InstantiatedComponent {
instc_insts = Map.toList insts,
@@ -336,11 +338,19 @@ toReadyComponents pid_map subst0 comps
indefiniteComponent :: UnitId -> ComponentId -> InstM (Maybe ReadyComponent)
indefiniteComponent uid cid
| Just lc <- Map.lookup cid cmap = do
+ -- We're going to process includes, in case some of them
+ -- are fully definite even without any substitution. We
+ -- want to build those too; see #5634.
+ inst_includes <- forM (lc_includes lc) $ \ci ->
+ if Set.null (openUnitIdFreeHoles (ci_id ci))
+ then do uid' <- substUnitId Map.empty (ci_id ci)
+ return $ ci { ci_ann_id = fmap (const (DefiniteUnitId uid')) (ci_ann_id ci) }
+ else return ci
exe_deps <- mapM (substExeDep Map.empty) (lc_exe_deps lc)
let indefc = IndefiniteComponent {
indefc_requires = map fst (lc_insts lc),
indefc_provides = modShapeProvides (lc_shape lc),
- indefc_includes = lc_includes lc ++ lc_sig_includes lc
+ indefc_includes = inst_includes ++ lc_sig_includes lc
}
return $ Just ReadyComponent {
rc_ann_id = (lc_ann_id lc) { ann_id = uid },
@@ -357,6 +367,7 @@ toReadyComponents pid_map subst0 comps
ready_map = snd $ runInstM work Map.empty
work
+ -- Top-level instantiation per subst0
| not (Map.null subst0)
, [lc] <- filter lc_public (Map.elems cmap)
= do _ <- instantiateUnitId (lc_cid lc) subst0
diff --git a/cabal/Cabal/Distribution/Backpack/UnifyM.hs b/cabal/Cabal/Distribution/Backpack/UnifyM.hs
index 97fc391..2d2e559 100644
--- a/cabal/Cabal/Distribution/Backpack/UnifyM.hs
+++ b/cabal/Cabal/Distribution/Backpack/UnifyM.hs
@@ -56,7 +56,7 @@ import qualified Distribution.Utils.UnionFind as UnionFind
import Distribution.ModuleName
import Distribution.Package
import Distribution.PackageDescription
-import Distribution.Text
+import Distribution.Pretty
import Distribution.Types.IncludeRenaming
import Distribution.Types.ComponentInclude
import Distribution.Types.AnnotatedId
@@ -436,15 +436,15 @@ type ModuleWithSourceU s = WithSource (ModuleU s)
ci_msg :: ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming -> Doc
ci_msg ci
| ci_implicit ci = text "build-depends:" <+> pp_pn
- | otherwise = text "mixins:" <+> pp_pn <+> disp (ci_renaming ci)
+ | otherwise = text "mixins:" <+> pp_pn <+> pretty (ci_renaming ci)
where
pn = pkgName (ci_pkgid ci)
pp_pn =
case ci_cname ci of
- CLibName -> disp pn
- CSubLibName cn -> disp pn <<>> colon <<>> disp cn
+ CLibName LMainLibName -> pretty pn
+ CLibName (LSubLibName cn) -> pretty pn <<>> colon <<>> pretty cn
-- Shouldn't happen
- cn -> disp pn <+> parens (disp cn)
+ cn -> pretty pn <+> parens (pretty cn)
-- | Convert a 'ModuleShape' into a 'ModuleScopeU', so we can do
-- unification on it.
@@ -505,8 +505,8 @@ convertInclude ci@(ComponentInclude {
[] -> error "req_rename"
[v] -> return v
v:vs -> do addErr $
- text "Conflicting renamings of requirement" <+> quotes (disp k) $$
- text "Renamed to: " <+> vcat (map disp (v:vs))
+ text "Conflicting renamings of requirement" <+> quotes (pretty k) $$
+ text "Renamed to: " <+> vcat (map pretty (v:vs))
return v
let req_rename_fn k = case Map.lookup k req_rename of
@@ -536,9 +536,9 @@ convertInclude ci@(ComponentInclude {
unless (Set.null leftover) $
addErr $
hang (text "The" <+> text (showComponentName compname) <+>
- text "from package" <+> quotes (disp pid)
+ text "from package" <+> quotes (pretty pid)
<+> text "does not require:") 4
- (vcat (map disp (Set.toList leftover)))
+ (vcat (map pretty (Set.toList leftover)))
-- Provision computation is more complex.
-- For example, if we have:
@@ -576,8 +576,8 @@ convertInclude ci@(ComponentInclude {
[ case Map.lookup from provs of
Just m -> return (to, m)
Nothing -> failWith $
- text "Package" <+> quotes (disp pid) <+>
- text "does not expose the module" <+> quotes (disp from)
+ text "Package" <+> quotes (pretty pid) <+>
+ text "does not expose the module" <+> quotes (pretty from)
| (from, to) <- rns ]
return (r, prov_rns)
let prov_scope = modSubst req_subst
diff --git a/cabal/Cabal/Distribution/CabalSpecVersion.hs b/cabal/Cabal/Distribution/CabalSpecVersion.hs
index afdebf8..f53d999 100644
--- a/cabal/Cabal/Distribution/CabalSpecVersion.hs
+++ b/cabal/Cabal/Distribution/CabalSpecVersion.hs
@@ -4,73 +4,88 @@ module Distribution.CabalSpecVersion where
import Prelude ()
import Distribution.Compat.Prelude
-import qualified Data.Set as Set
-- | Different Cabal-the-spec versions.
--
-- We branch based on this at least in the parser.
--
data CabalSpecVersion
- = CabalSpecOld
+ = CabalSpecV1_0 -- ^ this is older than 'CabalSpecV1_2'
+ | CabalSpecV1_2 -- ^ new syntax (sections)
+ | CabalSpecV1_4
+ | CabalSpecV1_6
+ | CabalSpecV1_8
+ | CabalSpecV1_10
+ | CabalSpecV1_12
+ -- 1.16 -- 1.14: no changes
+ | CabalSpecV1_18
+ | CabalSpecV1_20
| CabalSpecV1_22
| CabalSpecV1_24
| CabalSpecV2_0
| CabalSpecV2_2
| CabalSpecV2_4
+ | CabalSpecV3_0
deriving (Eq, Ord, Show, Read, Enum, Bounded, Typeable, Data, Generic)
-cabalSpecLatest :: CabalSpecVersion
-cabalSpecLatest = CabalSpecV2_4
+-- | Show cabal spec version, but not the way in the .cabal files
+--
+-- @since 3.0.0.0
+showCabalSpecVersion :: CabalSpecVersion -> String
+showCabalSpecVersion CabalSpecV3_0 = "3.0"
+showCabalSpecVersion CabalSpecV2_4 = "2.4"
+showCabalSpecVersion CabalSpecV2_2 = "2.2"
+showCabalSpecVersion CabalSpecV2_0 = "2.0"
+showCabalSpecVersion CabalSpecV1_24 = "1.24"
+showCabalSpecVersion CabalSpecV1_22 = "1.22"
+showCabalSpecVersion CabalSpecV1_20 = "1.20"
+showCabalSpecVersion CabalSpecV1_18 = "1.18"
+showCabalSpecVersion CabalSpecV1_12 = "1.12"
+showCabalSpecVersion CabalSpecV1_10 = "1.10"
+showCabalSpecVersion CabalSpecV1_8 = "1.8"
+showCabalSpecVersion CabalSpecV1_6 = "1.6"
+showCabalSpecVersion CabalSpecV1_4 = "1.4"
+showCabalSpecVersion CabalSpecV1_2 = "1.2"
+showCabalSpecVersion CabalSpecV1_0 = "1.0"
-cabalSpecFeatures :: CabalSpecVersion -> Set.Set CabalFeature
-cabalSpecFeatures CabalSpecOld = Set.empty
-cabalSpecFeatures CabalSpecV1_22 = Set.empty
-cabalSpecFeatures CabalSpecV1_24 = Set.empty
-cabalSpecFeatures CabalSpecV2_0 = Set.empty
-cabalSpecFeatures CabalSpecV2_2 = Set.fromList
- [ Elif
- , CommonStanzas
- ]
-cabalSpecFeatures CabalSpecV2_4 = Set.fromList
- [ Elif
- , CommonStanzas
- , Globstar
- ]
+cabalSpecLatest :: CabalSpecVersion
+cabalSpecLatest = CabalSpecV3_0
-cabalSpecSupports :: CabalSpecVersion -> [Int] -> Bool
-cabalSpecSupports CabalSpecOld v = v < [1,21]
-cabalSpecSupports CabalSpecV1_22 v = v < [1,23]
-cabalSpecSupports CabalSpecV1_24 v = v < [1,25]
-cabalSpecSupports CabalSpecV2_0 v = v < [2,1]
-cabalSpecSupports CabalSpecV2_2 v = v < [2,3]
-cabalSpecSupports CabalSpecV2_4 _ = True
+cabalSpecFromVersionDigits :: [Int] -> CabalSpecVersion
+cabalSpecFromVersionDigits v
+ | v >= [2,5] = CabalSpecV3_0
+ | v >= [2,3] = CabalSpecV2_4
+ | v >= [2,1] = CabalSpecV2_2
+ | v >= [1,25] = CabalSpecV2_0
+ | v >= [1,23] = CabalSpecV1_24
+ | v >= [1,21] = CabalSpecV1_22
+ | v >= [1,19] = CabalSpecV1_20
+ | v >= [1,17] = CabalSpecV1_18
+ | v >= [1,11] = CabalSpecV1_12
+ | v >= [1,9] = CabalSpecV1_10
+ | v >= [1,7] = CabalSpecV1_8
+ | v >= [1,5] = CabalSpecV1_6
+ | v >= [1,3] = CabalSpecV1_4
+ | v >= [1,1] = CabalSpecV1_2
+ | otherwise = CabalSpecV1_0
specHasCommonStanzas :: CabalSpecVersion -> HasCommonStanzas
-specHasCommonStanzas CabalSpecV2_2 = HasCommonStanzas
-specHasCommonStanzas CabalSpecV2_4 = HasCommonStanzas
-specHasCommonStanzas _ = NoCommonStanzas
+specHasCommonStanzas v =
+ if v >= CabalSpecV2_2
+ then HasCommonStanzas
+ else NoCommonStanzas
specHasElif :: CabalSpecVersion -> HasElif
-specHasElif CabalSpecV2_2 = HasElif
-specHasElif CabalSpecV2_4 = HasElif
-specHasElif _ = NoElif
-
--------------------------------------------------------------------------------
--- Features
--------------------------------------------------------------------------------
-
-data CabalFeature
- = Elif
- | CommonStanzas
- | Globstar
- -- ^ Implemented in #5284. Not actually a change to the parser,
- -- as filename patterns are opaque to it currently.
- deriving (Eq, Ord, Show, Read, Enum, Bounded, Typeable, Data, Generic)
+specHasElif v =
+ if v >= CabalSpecV2_2
+ then HasElif
+ else NoElif
-------------------------------------------------------------------------------
-- Booleans
-------------------------------------------------------------------------------
+-- IDEA: make some kind of tagged booleans?
data HasElif = HasElif | NoElif
deriving (Eq, Show)
diff --git a/cabal/Cabal/Distribution/Compat/CharParsing.hs b/cabal/Cabal/Distribution/Compat/CharParsing.hs
index 74126c5..a6460f2 100644
--- a/cabal/Cabal/Distribution/Compat/CharParsing.hs
+++ b/cabal/Cabal/Distribution/Compat/CharParsing.hs
@@ -60,7 +60,6 @@ import Data.Char
import Data.Text (Text, unpack)
import qualified Text.Parsec as Parsec
-import qualified Distribution.Compat.ReadP as ReadP
import Distribution.Compat.Parsing
@@ -310,13 +309,6 @@ instance Parsec.Stream s m Char => CharParsing (Parsec.ParsecT s u m) where
anyChar = Parsec.anyChar
string = Parsec.string
-instance t ~ Char => CharParsing (ReadP.Parser r t) where
- satisfy = ReadP.satisfy
- char = ReadP.char
- notChar c = ReadP.satisfy (/= c)
- anyChar = ReadP.get
- string = ReadP.string
-
-------------------------------------------------------------------------------
-- Our additions
-------------------------------------------------------------------------------
diff --git a/cabal/Cabal/Distribution/Compat/CopyFile.hs b/cabal/Cabal/Distribution/Compat/CopyFile.hs
index 826be7f..341975c 100644
--- a/cabal/Cabal/Distribution/Compat/CopyFile.hs
+++ b/cabal/Cabal/Distribution/Compat/CopyFile.hs
@@ -51,7 +51,17 @@ import System.IO.Error
import System.Directory
( doesFileExist )
import System.FilePath
- ( isRelative, normalise )
+ ( addTrailingPathSeparator
+ , hasTrailingPathSeparator
+ , isPathSeparator
+ , isRelative
+ , joinDrive
+ , joinPath
+ , pathSeparator
+ , pathSeparators
+ , splitDirectories
+ , splitDrive
+ )
import System.IO
( IOMode(ReadMode), hFileSize
, withBinaryFile )
@@ -113,16 +123,107 @@ copyFile fromFPath toFPath =
-- | Add the @"\\\\?\\"@ prefix if necessary or possible. The path remains
-- unchanged if the prefix is not added. This function can sometimes be used
-- to bypass the @MAX_PATH@ length restriction in Windows API calls.
+--
+-- See Note [Path normalization].
toExtendedLengthPath :: FilePath -> FilePath
toExtendedLengthPath path
| isRelative path = path
| otherwise =
- case normalise path of
- '\\' : '?' : '?' : '\\' : _ -> path
- '\\' : '\\' : '?' : '\\' : _ -> path
- '\\' : '\\' : '.' : '\\' : _ -> path
- '\\' : subpath@('\\' : _) -> "\\\\?\\UNC" <> subpath
- normalisedPath -> "\\\\?\\" <> normalisedPath
+ case normalisedPath of
+ '\\' : '?' : '?' : '\\' : _ -> normalisedPath
+ '\\' : '\\' : '?' : '\\' : _ -> normalisedPath
+ '\\' : '\\' : '.' : '\\' : _ -> normalisedPath
+ '\\' : subpath@('\\' : _) -> "\\\\?\\UNC" <> subpath
+ _ -> "\\\\?\\" <> normalisedPath
+ where normalisedPath = simplifyWindows path
+
+-- | Similar to 'normalise' but:
+--
+-- * empty paths stay empty,
+-- * parent dirs (@..@) are expanded, and
+-- * paths starting with @\\\\?\\@ are preserved.
+--
+-- The goal is to preserve the meaning of paths better than 'normalise'.
+--
+-- Note [Path normalization]
+-- 'normalise' doesn't simplify path names but will convert / into \\
+-- this would normally not be a problem as once the path hits the RTS we would
+-- have simplified the path then. However since we're calling the WIn32 API
+-- directly we have to do the simplification before the call. Without this the
+-- path Z:// would become Z:\\\\ and when converted to a device path the path
+-- becomes \\?\Z:\\\\ which is an invalid path.
+--
+-- This is not a bug in normalise as it explicitly states that it won't simplify
+-- a FilePath.
+simplifyWindows :: FilePath -> FilePath
+simplifyWindows "" = ""
+simplifyWindows path =
+ case drive' of
+ "\\\\?\\" -> drive' <> subpath
+ _ -> simplifiedPath
+ where
+ simplifiedPath = joinDrive drive' subpath'
+ (drive, subpath) = splitDrive path
+ drive' = upperDrive (normaliseTrailingSep (normalisePathSeps drive))
+ subpath' = appendSep . avoidEmpty . prependSep . joinPath .
+ stripPardirs . expandDots . skipSeps .
+ splitDirectories $ subpath
+
+ upperDrive d = case d of
+ c : ':' : s | isAlpha c && all isPathSeparator s -> toUpper c : ':' : s
+ _ -> d
+ skipSeps = filter (not . (`elem` (pure <$> pathSeparators)))
+ stripPardirs | pathIsAbsolute || subpathIsAbsolute = dropWhile (== "..")
+ | otherwise = id
+ prependSep | subpathIsAbsolute = (pathSeparator :)
+ | otherwise = id
+ avoidEmpty | not pathIsAbsolute
+ && (null drive || hasTrailingPathSep) -- prefer "C:" over "C:."
+ = emptyToCurDir
+ | otherwise = id
+ appendSep p | hasTrailingPathSep
+ && not (pathIsAbsolute && null p)
+ = addTrailingPathSeparator p
+ | otherwise = p
+ pathIsAbsolute = not (isRelative path)
+ subpathIsAbsolute = any isPathSeparator (take 1 subpath)
+ hasTrailingPathSep = hasTrailingPathSeparator subpath
+
+-- | Given a list of path segments, expand @.@ and @..@. The path segments
+-- must not contain path separators.
+expandDots :: [FilePath] -> [FilePath]
+expandDots = reverse . go []
+ where
+ go ys' xs' =
+ case xs' of
+ [] -> ys'
+ x : xs ->
+ case x of
+ "." -> go ys' xs
+ ".." ->
+ case ys' of
+ [] -> go (x : ys') xs
+ ".." : _ -> go (x : ys') xs
+ _ : ys -> go ys xs
+ _ -> go (x : ys') xs
+
+-- | Convert to the right kind of slashes.
+normalisePathSeps :: FilePath -> FilePath
+normalisePathSeps p = (\ c -> if isPathSeparator c then pathSeparator else c) <$> p
+
+-- | Remove redundant trailing slashes and pick the right kind of slash.
+normaliseTrailingSep :: FilePath -> FilePath
+normaliseTrailingSep path = do
+ let path' = reverse path
+ let (sep, path'') = span isPathSeparator path'
+ let addSep = if null sep then id else (pathSeparator :)
+ reverse (addSep path'')
+
+-- | Convert empty paths to the current directory, otherwise leave it
+-- unchanged.
+emptyToCurDir :: FilePath -> FilePath
+emptyToCurDir "" = "."
+emptyToCurDir path = path
#endif /* mingw32_HOST_OS */
-- | Like `copyFile`, but does not touch the target if source and destination
diff --git a/cabal/Cabal/Distribution/Compat/Directory.hs b/cabal/Cabal/Distribution/Compat/Directory.hs
index 6bc4b07..0733095 100644
--- a/cabal/Cabal/Distribution/Compat/Directory.hs
+++ b/cabal/Cabal/Distribution/Compat/Directory.hs
@@ -38,7 +38,12 @@ makeAbsolute p | Path.isAbsolute p = return p
#if !MIN_VERSION_directory(1,2,7)
doesPathExist :: FilePath -> IO Bool
-doesPathExist path = (||) <$> doesDirectoryExist path <*> doesFileExist path
+doesPathExist path = do
+ -- not using Applicative, as this way we can do less IO
+ e <- doesDirectoryExist path
+ if e
+ then return True
+ else doesFileExist path
#endif
diff --git a/cabal/Cabal/Distribution/Compat/MonadFail.hs b/cabal/Cabal/Distribution/Compat/MonadFail.hs
index f535ccf..f4da211 100644
--- a/cabal/Cabal/Distribution/Compat/MonadFail.hs
+++ b/cabal/Cabal/Distribution/Compat/MonadFail.hs
@@ -1,36 +1,5 @@
{-# LANGUAGE CPP #-}
-- | Compatibility layer for "Control.Monad.Fail"
-module Distribution.Compat.MonadFail ( MonadFail(fail) ) where
-#if __GLASGOW_HASKELL__ >= 800
--- provided by base-4.9.0.0 and later
-import Control.Monad.Fail (MonadFail(fail))
-#else
--- the following code corresponds to
--- http://hackage.haskell.org/package/fail-4.9.0.0
-import qualified Prelude as P
-import Distribution.Compat.Prelude hiding (fail)
-
-import Text.ParserCombinators.ReadP
-import Text.ParserCombinators.ReadPrec
-
-class Monad m => MonadFail m where
- fail :: String -> m a
-
--- instances provided by base-4.9
-
-instance MonadFail Maybe where
- fail _ = Nothing
-
-instance MonadFail [] where
- fail _ = []
-
-instance MonadFail P.IO where
- fail = P.fail
-
-instance MonadFail ReadPrec where
- fail = P.fail -- = P (\_ -> fail s)
-
-instance MonadFail ReadP where
- fail = P.fail
-#endif
+module Distribution.Compat.MonadFail ( Control.Monad.Fail.MonadFail(fail) ) where
+import Control.Monad.Fail
diff --git a/cabal/Cabal/Distribution/Compat/Newtype.hs b/cabal/Cabal/Distribution/Compat/Newtype.hs
index e45e97c..3e6d1c3 100644
--- a/cabal/Cabal/Distribution/Compat/Newtype.hs
+++ b/cabal/Cabal/Distribution/Compat/Newtype.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
-- | Per Conor McBride, the 'Newtype' typeclass represents the packing and
@@ -14,31 +16,50 @@ module Distribution.Compat.Newtype (
import Data.Functor.Identity (Identity (..))
import Data.Monoid (Sum (..), Product (..), Endo (..))
+#if MIN_VERSION_base(4,7,0)
+import Data.Coerce (coerce, Coercible)
+#else
+import Unsafe.Coerce (unsafeCoerce)
+#endif
+
-- | The @FunctionalDependencies@ version of 'Newtype' type-class.
--
--- /Note:/ for actual newtypes the implementation can be
--- @pack = coerce; unpack = coerce@. We don't have default implementation,
--- because @Cabal@ have to support older than @base >= 4.7@ compilers.
--- Also, 'Newtype' could witness a non-structural isomorphism.
-class Newtype n o | n -> o where
+-- Since Cabal-3.0 class arguments are in a different order than in @newtype@ package.
+-- This change is to allow usage with @DeriveAnyClass@ (and @DerivingStrategies@, in GHC-8.2).
+-- Unfortunately one have to repeat inner type.
+--
+-- @
+-- newtype New = New Old
+-- deriving anyclass (Newtype Old)
+-- @
+--
+-- Another approach would be to use @TypeFamilies@ (and possibly
+-- compute inner type using "GHC.Generics"), but we think @FunctionalDependencies@
+-- version gives cleaner type signatures.
+--
+class Newtype o n | n -> o where
pack :: o -> n
- unpack :: n -> o
-
-instance Newtype (Identity a) a where
- pack = Identity
- unpack = runIdentity
+#if MIN_VERSION_base(4,7,0)
+ default pack :: Coercible o n => o -> n
+ pack = coerce
+#else
+ default pack :: o -> n
+ pack = unsafeCoerce
+#endif
-instance Newtype (Sum a) a where
- pack = Sum
- unpack = getSum
-
-instance Newtype (Product a) a where
- pack = Product
- unpack = getProduct
+ unpack :: n -> o
+#if MIN_VERSION_base(4,7,0)
+ default unpack :: Coercible n o => n -> o
+ unpack = coerce
+#else
+ default unpack :: n -> o
+ unpack = unsafeCoerce
+#endif
-instance Newtype (Endo a) (a -> a) where
- pack = Endo
- unpack = appEndo
+instance Newtype a (Identity a)
+instance Newtype a (Sum a)
+instance Newtype a (Product a)
+instance Newtype (a -> a) (Endo a)
-- |
--
@@ -49,7 +70,7 @@ instance Newtype (Endo a) (a -> a) where
--
-- >>> ala (Sum . (+1)) foldMap [1, 2, 3, 4 :: Int]
-- 10
-ala :: (Newtype n o, Newtype n' o') => (o -> n) -> ((o -> n) -> b -> n') -> (b -> o')
+ala :: (Newtype o n, Newtype o' n') => (o -> n) -> ((o -> n) -> b -> n') -> (b -> o')
ala pa hof = alaf pa hof id
-- |
@@ -58,13 +79,13 @@ ala pa hof = alaf pa hof id
-- 12
--
-- /Note:/ as with 'ala', the user supplied function for the newtype is /ignored/.
-alaf :: (Newtype n o, Newtype n' o') => (o -> n) -> ((a -> n) -> b -> n') -> (a -> o) -> (b -> o')
+alaf :: (Newtype o n, Newtype o' n') => (o -> n) -> ((a -> n) -> b -> n') -> (a -> o) -> (b -> o')
alaf _ hof f = unpack . hof (pack . f)
-- | Variant of 'pack', which takes a phantom type.
-pack' :: Newtype n o => (o -> n) -> o -> n
+pack' :: Newtype o n => (o -> n) -> o -> n
pack' _ = pack
-- | Variant of 'pack', which takes a phantom type.
-unpack' :: Newtype n o => (o -> n) -> n -> o
+unpack' :: Newtype o n => (o -> n) -> n -> o
unpack' _ = unpack
diff --git a/cabal/Cabal/Distribution/Compat/Parsing.hs b/cabal/Cabal/Distribution/Compat/Parsing.hs
index bd5c39e..afc995f 100644
--- a/cabal/Cabal/Distribution/Compat/Parsing.hs
+++ b/cabal/Cabal/Distribution/Compat/Parsing.hs
@@ -26,7 +26,7 @@ module Distribution.Compat.Parsing
, many -- from Control.Applicative
, sepBy
, sepBy1
- -- , sepByNonEmpty
+ , sepByNonEmpty
, sepEndBy1
-- , sepEndByNonEmpty
, sepEndBy
@@ -59,7 +59,6 @@ import Control.Monad.Trans.Identity (IdentityT (..))
import Data.Foldable (asum)
import qualified Text.Parsec as Parsec
-import qualified Distribution.Compat.ReadP as ReadP
-- | @choice ps@ tries to apply the parsers in the list @ps@ in order,
-- until one of them succeeds. Returns the value of the succeeding
@@ -107,13 +106,11 @@ sepBy1 p sep = (:) <$> p <*> many (sep *> p)
-- toList <$> sepByNonEmpty p sep
{-# INLINE sepBy1 #-}
-{-
-- | @sepByNonEmpty p sep@ parses /one/ or more occurrences of @p@, separated
-- by @sep@. Returns a non-empty list of values returned by @p@.
sepByNonEmpty :: Alternative m => m a -> m sep -> m (NonEmpty a)
sepByNonEmpty p sep = (:|) <$> p <*> many (sep *> p)
{-# INLINE sepByNonEmpty #-}
--}
-- | @sepEndBy1 p sep@ parses /one/ or more occurrences of @p@,
-- separated and optionally ended by @sep@. Returns a list of values
@@ -389,15 +386,3 @@ instance (Parsec.Stream s m t, Show t) => Parsing (Parsec.ParsecT s u m) where
unexpected = Parsec.unexpected
eof = Parsec.eof
notFollowedBy = Parsec.notFollowedBy
-
-instance t ~ Char => Parsing (ReadP.Parser r t) where
- try = id
- (<?>) = const
- skipMany = ReadP.skipMany
- skipSome = ReadP.skipMany1
- unexpected = const ReadP.pfail
- eof = ReadP.eof
-
- -- TODO: we would like to have <++ here
- notFollowedBy p = ((Just <$> p) ReadP.+++ pure Nothing)
- >>= maybe (pure ()) (unexpected . show)
diff --git a/cabal/Cabal/Distribution/Compat/Prelude.hs b/cabal/Cabal/Distribution/Compat/Prelude.hs
index d032825..c3bc040 100644
--- a/cabal/Cabal/Distribution/Compat/Prelude.hs
+++ b/cabal/Cabal/Distribution/Compat/Prelude.hs
@@ -4,16 +4,18 @@
{-# LANGUAGE FlexibleContexts #-}
#ifdef MIN_VERSION_base
+#define MINVER_base_411 MIN_VERSION_base(4,11,0)
#define MINVER_base_48 MIN_VERSION_base(4,8,0)
#define MINVER_base_47 MIN_VERSION_base(4,7,0)
#else
+#define MINVER_base_411 (__GLASGOW_HASKELL__ >= 804)
#define MINVER_base_48 (__GLASGOW_HASKELL__ >= 710)
#define MINVER_base_47 (__GLASGOW_HASKELL__ >= 708)
#endif
-- | This module does two things:
--
--- * Acts as a compatiblity layer, like @base-compat@.
+-- * Acts as a compatibility layer, like @base-compat@.
--
-- * Provides commonly used imports.
module Distribution.Compat.Prelude (
@@ -57,6 +59,9 @@ module Distribution.Compat.Prelude (
sort, sortBy,
nub, nubBy,
+ -- * Data.List.NonEmpty
+ NonEmpty((:|)), foldl1, foldr1,
+
-- * Data.Foldable
Foldable, foldMap, foldr,
null, length,
@@ -89,11 +94,21 @@ module Distribution.Compat.Prelude (
-- * Text.PrettyPrint
(<<>>),
- ) where
+ -- * Text.Read
+ readMaybe,
+ ) where
-- We also could hide few partial function
import Prelude as BasePrelude hiding
( IO, mapM, mapM_, sequence, null, length, foldr, any, all
+ -- partial functions
+ , read
+ , foldr1, foldl1
+#if MINVER_base_411
+ -- As of base 4.11.0.0 Prelude exports part of Semigroup(..).
+ -- Hide this so we instead rely on Distribution.Compat.Semigroup.
+ , Semigroup(..)
+#endif
#if MINVER_base_48
, Word
-- We hide them, as we import only some members
@@ -111,6 +126,7 @@ import Data.Foldable (length, null)
import Data.Foldable (Foldable (foldMap, foldr), find, foldl', for_, traverse_, any, all)
import Data.Traversable (Traversable (traverse, sequenceA), for)
+import qualified Data.Foldable
import Control.Applicative (Alternative (..))
import Control.DeepSeq (NFData (..))
@@ -130,10 +146,12 @@ import Data.Char
import Data.List (intercalate, intersperse, isPrefixOf,
isSuffixOf, nub, nubBy, sort, sortBy,
unfoldr)
+import Data.List.NonEmpty (NonEmpty((:|)))
import Data.Maybe
import Data.String (IsString (..))
import Data.Int
import Data.Word
+import Text.Read (readMaybe)
import qualified Text.PrettyPrint as Disp
@@ -202,3 +220,28 @@ instance (GNFData a, GNFData b) => GNFData (a :+: b) where
grnf (L1 x) = grnf x
grnf (R1 x) = grnf x
{-# INLINEABLE grnf #-}
+
+
+-- TODO: if we want foldr1/foldl1 to work on more than NonEmpty, we
+-- can define a local typeclass 'Foldable1', e.g.
+--
+-- @
+-- class Foldable f => Foldable1 f
+--
+-- instance Foldable1 NonEmpty
+--
+-- foldr1 :: Foldable1 t => (a -> a -> a) -> t a -> a
+-- foldr1 = Data.Foldable.foldr1
+--
+-- foldl1 :: Foldable1 t => (a -> a -> a) -> t a -> a
+-- foldl1 = Data.Foldable.foldl1
+-- @
+--
+
+{-# INLINE foldr1 #-}
+foldr1 :: (a -> a -> a) -> NonEmpty a -> a
+foldr1 = Data.Foldable.foldr1
+
+{-# INLINE foldl1 #-}
+foldl1 :: (a -> a -> a) -> NonEmpty a -> a
+foldl1 = Data.Foldable.foldl1
diff --git a/cabal/Cabal/Distribution/Compat/ResponseFile.hs b/cabal/Cabal/Distribution/Compat/ResponseFile.hs
new file mode 100755
index 0000000..5ddfe57
--- /dev/null
+++ b/cabal/Cabal/Distribution/Compat/ResponseFile.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE CPP, RankNTypes, FlexibleContexts #-}
+
+-- Compatibility layer for GHC.ResponseFile
+-- Implementation from base 4.12.0 is used.
+-- http://hackage.haskell.org/package/base-4.12.0.0/src/LICENSE
+module Distribution.Compat.ResponseFile (expandResponse) where
+
+import Prelude (mapM)
+import Distribution.Compat.Prelude
+
+import System.Exit
+import System.FilePath
+import System.IO (hPutStrLn, stderr)
+import System.IO.Error
+
+#if MIN_VERSION_base(4,12,0)
+import GHC.ResponseFile (unescapeArgs)
+#else
+
+unescapeArgs :: String -> [String]
+unescapeArgs = filter (not . null) . unescape
+
+data Quoting = NoneQ | SngQ | DblQ
+
+unescape :: String -> [String]
+unescape args = reverse . map reverse $ go args NoneQ False [] []
+ where
+ -- n.b., the order of these cases matters; these are cribbed from gcc
+ -- case 1: end of input
+ go [] _q _bs a as = a:as
+ -- case 2: back-slash escape in progress
+ go (c:cs) q True a as = go cs q False (c:a) as
+ -- case 3: no back-slash escape in progress, but got a back-slash
+ go (c:cs) q False a as
+ | '\\' == c = go cs q True a as
+ -- case 4: single-quote escaping in progress
+ go (c:cs) SngQ False a as
+ | '\'' == c = go cs NoneQ False a as
+ | otherwise = go cs SngQ False (c:a) as
+ -- case 5: double-quote escaping in progress
+ go (c:cs) DblQ False a as
+ | '"' == c = go cs NoneQ False a as
+ | otherwise = go cs DblQ False (c:a) as
+ -- case 6: no escaping is in progress
+ go (c:cs) NoneQ False a as
+ | isSpace c = go cs NoneQ False [] (a:as)
+ | '\'' == c = go cs SngQ False a as
+ | '"' == c = go cs DblQ False a as
+ | otherwise = go cs NoneQ False (c:a) as
+
+#endif
+
+expandResponse :: [String] -> IO [String]
+expandResponse = go recursionLimit "."
+ where
+ recursionLimit = 100
+
+ go :: Int -> FilePath -> [String] -> IO [String]
+ go n dir
+ | n >= 0 = fmap concat . mapM (expand n dir)
+ | otherwise = const $ hPutStrLn stderr "Error: response file recursion limit exceeded." >> exitFailure
+
+ expand :: Int -> FilePath -> String -> IO [String]
+ expand n dir arg@('@':f) = readRecursively n (dir </> f) `catchIOError` (const $ print "?" >> return [arg])
+ expand _n _dir x = return [x]
+
+ readRecursively :: Int -> FilePath -> IO [String]
+ readRecursively n f = go (n - 1) (takeDirectory f) =<< unescapeArgs <$> readFile f
diff --git a/cabal/Cabal/Distribution/Compat/Semigroup.hs b/cabal/Cabal/Distribution/Compat/Semigroup.hs
index d50a93c..f8ffa95 100644
--- a/cabal/Cabal/Distribution/Compat/Semigroup.hs
+++ b/cabal/Cabal/Distribution/Compat/Semigroup.hs
@@ -11,113 +11,54 @@ module Distribution.Compat.Semigroup
, All(..)
, Any(..)
+ , First'(..)
, Last'(..)
+ , Option'(..)
+
, gmappend
, gmempty
) where
import Distribution.Compat.Binary (Binary)
-import Control.Applicative as App
import GHC.Generics
-#if __GLASGOW_HASKELL__ >= 711
--- Data.Semigroup is available since GHC 8.0/base-4.9
+-- Data.Semigroup is available since GHC 8.0/base-4.9 in `base`
+-- for older GHC/base, it's provided by `semigroups`
import Data.Semigroup
import qualified Data.Monoid as Mon
-#else
--- provide internal simplified non-exposed class for older GHCs
-import Data.Monoid as Mon (Monoid(..), All(..), Any(..), Dual(..))
--- containers
-import Data.Set (Set)
-import Data.IntSet (IntSet)
-import Data.Map (Map)
-import Data.IntMap (IntMap)
-
-
-class Semigroup a where
- (<>) :: a -> a -> a
-
--- several primitive instances
-instance Semigroup () where
- _ <> _ = ()
-
-instance Semigroup [a] where
- (<>) = (++)
-
-instance Semigroup a => Semigroup (Dual a) where
- Dual a <> Dual b = Dual (b <> a)
-
-instance Semigroup a => Semigroup (Maybe a) where
- Nothing <> b = b
- a <> Nothing = a
- Just a <> Just b = Just (a <> b)
-
-instance Semigroup (Either a b) where
- Left _ <> b = b
- a <> _ = a
-
-instance Semigroup Ordering where
- LT <> _ = LT
- EQ <> y = y
- GT <> _ = GT
-instance Semigroup b => Semigroup (a -> b) where
- f <> g = \a -> f a <> g a
-instance Semigroup All where
- All a <> All b = All (a && b)
+-- | A copy of 'Data.Semigroup.First'.
+newtype First' a = First' { getFirst' :: a }
+ deriving (Eq, Ord, Show)
-instance Semigroup Any where
- Any a <> Any b = Any (a || b)
+instance Semigroup (First' a) where
+ a <> _ = a
-instance (Semigroup a, Semigroup b) => Semigroup (a, b) where
- (a,b) <> (a',b') = (a<>a',b<>b')
+-- | A copy of 'Data.Semigroup.Last'.
+newtype Last' a = Last' { getLast' :: a }
+ deriving (Eq, Ord, Read, Show, Binary)
-instance (Semigroup a, Semigroup b, Semigroup c)
- => Semigroup (a, b, c) where
- (a,b,c) <> (a',b',c') = (a<>a',b<>b',c<>c')
-
-instance (Semigroup a, Semigroup b, Semigroup c, Semigroup d)
- => Semigroup (a, b, c, d) where
- (a,b,c,d) <> (a',b',c',d') = (a<>a',b<>b',c<>c',d<>d')
-
-instance (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e)
- => Semigroup (a, b, c, d, e) where
- (a,b,c,d,e) <> (a',b',c',d',e') = (a<>a',b<>b',c<>c',d<>d',e<>e')
-
--- containers instances
-instance Semigroup IntSet where
- (<>) = mappend
-
-instance Ord a => Semigroup (Set a) where
- (<>) = mappend
-
-instance Semigroup (IntMap v) where
- (<>) = mappend
+instance Semigroup (Last' a) where
+ _ <> b = b
-instance Ord k => Semigroup (Map k v) where
- (<>) = mappend
-#endif
+instance Functor Last' where
+ fmap f (Last' x) = Last' (f x)
--- | Cabal's own 'Data.Monoid.Last' copy to avoid requiring an orphan
--- 'Binary' instance.
---
--- Once the oldest `binary` version we support provides a 'Binary'
--- instance for 'Data.Monoid.Last' we can remove this one here.
---
--- NB: 'Data.Semigroup.Last' is defined differently and not a 'Monoid'
-newtype Last' a = Last' { getLast' :: Maybe a }
- deriving (Eq, Ord, Read, Show, Binary,
- Functor, App.Applicative, Generic)
+-- | A wrapper around 'Maybe', providing the 'Semigroup' and 'Monoid' instances
+-- implemented for 'Maybe' since @base-4.11@.
+newtype Option' a = Option' { getOption' :: Maybe a }
+ deriving (Eq, Ord, Read, Show, Binary, Functor)
-instance Semigroup (Last' a) where
- x <> Last' Nothing = x
- _ <> x = x
+instance Semigroup a => Semigroup (Option' a) where
+ Option' (Just a) <> Option' (Just b) = Option' (Just (a <> b))
+ Option' Nothing <> b = b
+ a <> Option' Nothing = a
-instance Monoid (Last' a) where
- mempty = Last' Nothing
- mappend = (<>)
+instance Semigroup a => Monoid (Option' a) where
+ mempty = Option' Nothing
+ mappend = (<>)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
diff --git a/cabal/Cabal/Distribution/Compiler.hs b/cabal/Cabal/Distribution/Compiler.hs
index 92018ea..1195df8 100644
--- a/cabal/Cabal/Distribution/Compiler.hs
+++ b/cabal/Cabal/Distribution/Compiler.hs
@@ -30,10 +30,13 @@ module Distribution.Compiler (
buildCompilerId,
buildCompilerFlavor,
defaultCompilerFlavor,
- parseCompilerFlavorCompat,
classifyCompilerFlavor,
knownCompilerFlavors,
+ -- * Per compiler flavor
+ PerCompilerFlavor (..),
+ perCompilerFlavorToList,
+
-- * Compiler id
CompilerId(..),
@@ -51,10 +54,8 @@ import Language.Haskell.Extension
import Distribution.Version (Version, mkVersion', nullVersion)
import qualified System.Info (compilerName, compilerVersion)
-import Distribution.Parsec.Class (Parsec (..))
-import Distribution.Pretty (Pretty (..))
-import Distribution.Text (Text(..), display)
-import qualified Distribution.Compat.ReadP as Parse
+import Distribution.Parsec (Parsec (..))
+import Distribution.Pretty (Pretty (..), prettyShow)
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
@@ -85,44 +86,13 @@ instance Parsec CompilerFlavor where
cs <- P.munch1 isAlphaNum
if all isDigit cs then fail "all digits compiler name" else return cs
-instance Text CompilerFlavor where
- parse = do
- comp <- Parse.munch1 isAlphaNum
- when (all isDigit comp) Parse.pfail
- return (classifyCompilerFlavor comp)
-
classifyCompilerFlavor :: String -> CompilerFlavor
classifyCompilerFlavor s =
fromMaybe (OtherCompiler s) $ lookup (lowercase s) compilerMap
where
- compilerMap = [ (lowercase (display compiler), compiler)
+ compilerMap = [ (lowercase (prettyShow compiler), compiler)
| compiler <- knownCompilerFlavors ]
-
---TODO: In some future release, remove 'parseCompilerFlavorCompat' and use
--- ordinary 'parse'. Also add ("nhc", NHC) to the above 'compilerMap'.
-
--- | Like 'classifyCompilerFlavor' but compatible with the old ReadS parser.
---
--- It is compatible in the sense that it accepts only the same strings,
--- eg "GHC" but not "ghc". However other strings get mapped to 'OtherCompiler'.
--- The point of this is that we do not allow extra valid values that would
--- upset older Cabal versions that had a stricter parser however we cope with
--- new values more gracefully so that we'll be able to introduce new value in
--- future without breaking things so much.
---
-parseCompilerFlavorCompat :: Parse.ReadP r CompilerFlavor
-parseCompilerFlavorCompat = do
- comp <- Parse.munch1 isAlphaNum
- when (all isDigit comp) Parse.pfail
- case lookup comp compilerMap of
- Just compiler -> return compiler
- Nothing -> return (OtherCompiler comp)
- where
- compilerMap = [ (show compiler, compiler)
- | compiler <- knownCompilerFlavors
- , compiler /= YHC ]
-
buildCompilerFlavor :: CompilerFlavor
buildCompilerFlavor = classifyCompilerFlavor System.Info.compilerName
@@ -143,6 +113,31 @@ defaultCompilerFlavor = case buildCompilerFlavor of
OtherCompiler _ -> Nothing
_ -> Just buildCompilerFlavor
+-------------------------------------------------------------------------------
+-- Per compiler data
+-------------------------------------------------------------------------------
+
+-- | 'PerCompilerFlavor' carries only info per GHC and GHCJS
+--
+-- Cabal parses only @ghc-options@ and @ghcjs-options@, others are omitted.
+--
+data PerCompilerFlavor v = PerCompilerFlavor v v
+ deriving (Generic, Show, Read, Eq, Typeable, Data)
+
+instance Binary a => Binary (PerCompilerFlavor a)
+instance NFData a => NFData (PerCompilerFlavor a)
+
+perCompilerFlavorToList :: PerCompilerFlavor v -> [(CompilerFlavor, v)]
+perCompilerFlavorToList (PerCompilerFlavor a b) = [(GHC, a), (GHCJS, b)]
+
+instance Semigroup a => Semigroup (PerCompilerFlavor a) where
+ PerCompilerFlavor a b <> PerCompilerFlavor a' b' = PerCompilerFlavor
+ (a <> a') (b <> b')
+
+instance (Semigroup a, Monoid a) => Monoid (PerCompilerFlavor a) where
+ mempty = PerCompilerFlavor mempty mempty
+ mappend = (<>)
+
-- ------------------------------------------------------------
-- * Compiler Id
-- ------------------------------------------------------------
@@ -154,14 +149,15 @@ instance Binary CompilerId
instance NFData CompilerId where rnf = genericRnf
-instance Text CompilerId where
- disp (CompilerId f v)
- | v == nullVersion = disp f
- | otherwise = disp f <<>> Disp.char '-' <<>> disp v
+instance Pretty CompilerId where
+ pretty (CompilerId f v)
+ | v == nullVersion = pretty f
+ | otherwise = pretty f <<>> Disp.char '-' <<>> pretty v
- parse = do
- flavour <- parse
- version <- (Parse.char '-' >> parse) Parse.<++ return nullVersion
+instance Parsec CompilerId where
+ parsec = do
+ flavour <- parsec
+ version <- (P.char '-' >> parsec) <|> return nullVersion
return (CompilerId flavour version)
lowercase :: String -> String
@@ -200,12 +196,13 @@ data AbiTag
instance Binary AbiTag
-instance Text AbiTag where
- disp NoAbiTag = Disp.empty
- disp (AbiTag tag) = Disp.text tag
+instance Pretty AbiTag where
+ pretty NoAbiTag = Disp.empty
+ pretty (AbiTag tag) = Disp.text tag
- parse = do
- tag <- Parse.munch (\c -> isAlphaNum c || c == '_')
+instance Parsec AbiTag where
+ parsec = do
+ tag <- P.munch (\c -> isAlphaNum c || c == '_')
if null tag then return NoAbiTag else return (AbiTag tag)
abiTagString :: AbiTag -> String
diff --git a/cabal/Cabal/Distribution/FieldGrammar.hs b/cabal/Cabal/Distribution/FieldGrammar.hs
index 71a02d8..b6dc656 100644
--- a/cabal/Cabal/Distribution/FieldGrammar.hs
+++ b/cabal/Cabal/Distribution/FieldGrammar.hs
@@ -9,7 +9,6 @@ module Distribution.FieldGrammar (
optionalField,
optionalFieldDef,
monoidalField,
- deprecatedField',
-- * Concrete grammar implementations
ParsecFieldGrammar,
ParsecFieldGrammar',
@@ -36,7 +35,7 @@ import qualified Data.Map.Strict as Map
import Distribution.FieldGrammar.Class
import Distribution.FieldGrammar.Parsec
import Distribution.FieldGrammar.Pretty
-import Distribution.Parsec.Field
+import Distribution.Fields.Field
import Distribution.Utils.Generic (spanMaybe)
type ParsecFieldGrammar' a = ParsecFieldGrammar a a
diff --git a/cabal/Cabal/Distribution/FieldGrammar/Class.hs b/cabal/Cabal/Distribution/FieldGrammar/Class.hs
index 6bd391d..872b402 100644
--- a/cabal/Cabal/Distribution/FieldGrammar/Class.hs
+++ b/cabal/Cabal/Distribution/FieldGrammar/Class.hs
@@ -4,7 +4,6 @@ module Distribution.FieldGrammar.Class (
optionalField,
optionalFieldDef,
monoidalField,
- deprecatedField',
) where
import Distribution.Compat.Lens
@@ -13,10 +12,11 @@ import Prelude ()
import Data.Functor.Identity (Identity (..))
-import Distribution.Compat.Newtype (Newtype)
-import Distribution.Parsec.Class (Parsec)
-import Distribution.Parsec.Field
-import Distribution.Pretty (Pretty)
+import Distribution.CabalSpecVersion (CabalSpecVersion)
+import Distribution.Compat.Newtype (Newtype)
+import Distribution.Fields.Field
+import Distribution.Parsec (Parsec)
+import Distribution.Pretty (Pretty)
-- | 'FieldGrammar' is parametrised by
--
@@ -33,7 +33,7 @@ class FieldGrammar g where
-- | Field which should be defined, exactly once.
uniqueFieldAla
- :: (Parsec b, Pretty b, Newtype b a)
+ :: (Parsec b, Pretty b, Newtype a b)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'Newtype' pack
-> ALens' s a -- ^ lens into the field
@@ -48,7 +48,7 @@ class FieldGrammar g where
-- | Optional field.
optionalFieldAla
- :: (Parsec b, Pretty b, Newtype b a)
+ :: (Parsec b, Pretty b, Newtype a b)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'pack'
-> ALens' s (Maybe a) -- ^ lens into the field
@@ -56,13 +56,31 @@ class FieldGrammar g where
-- | Optional field with default value.
optionalFieldDefAla
- :: (Parsec b, Pretty b, Newtype b a, Eq a)
+ :: (Parsec b, Pretty b, Newtype a b, Eq a)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'Newtype' pack
-> ALens' s a -- ^ @'Lens'' s a@: lens into the field
-> a -- ^ default value
-> g s a
+ -- | Free text field is essentially 'optionalFieldDefAla` with @""@
+ -- as the default and "accept everything" parser.
+ --
+ -- @since 3.0.0.0
+ freeTextField
+ :: FieldName
+ -> ALens' s (Maybe String) -- ^ lens into the field
+ -> g s (Maybe String)
+
+ -- | Free text field is essentially 'optionalFieldDefAla` with @""@
+ -- as the default and "accept everything" parser.
+ --
+ -- @since 3.0.0.0
+ freeTextFieldDef
+ :: FieldName
+ -> ALens' s String -- ^ lens into the field
+ -> g s String
+
-- | Monoidal field.
--
-- Values are combined with 'mappend'.
@@ -70,7 +88,7 @@ class FieldGrammar g where
-- /Note:/ 'optionalFieldAla' is a @monoidalField@ with 'Last' monoid.
--
monoidalFieldAla
- :: (Parsec b, Pretty b, Monoid a, Newtype b a)
+ :: (Parsec b, Pretty b, Monoid a, Newtype a b)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'pack'
-> ALens' s a -- ^ lens into the field
@@ -90,15 +108,22 @@ class FieldGrammar g where
-- | Deprecated since
deprecatedSince
- :: [Int] -- ^ version
- -> String -- ^ deprecation message
+ :: CabalSpecVersion -- ^ version
+ -> String -- ^ deprecation message
+ -> g s a
+ -> g s a
+
+ -- | Removed in. If we occur removed field, parsing fails.
+ removedIn
+ :: CabalSpecVersion -- ^ version
+ -> String -- ^ removal message
-> g s a
-> g s a
-- | Annotate field with since spec-version.
availableSince
- :: [Int] -- ^ spec version
- -> a -- ^ default value
+ :: CabalSpecVersion -- ^ spec version
+ -> a -- ^ default value
-> g s a
-> g s a
@@ -134,14 +159,3 @@ monoidalField
-> ALens' s a -- ^ lens into the field
-> g s a
monoidalField fn = monoidalFieldAla fn Identity
-
--- | Deprecated field. If found, warning is issued.
---
--- /Note:/ also it's not pretty printed!
---
-deprecatedField'
- :: FieldGrammar g
- => String -- ^ deprecation message
- -> g s a
- -> g s a
-deprecatedField' = deprecatedSince []
diff --git a/cabal/Cabal/Distribution/FieldGrammar/FieldDescrs.hs b/cabal/Cabal/Distribution/FieldGrammar/FieldDescrs.hs
index 3bd820e..351f753 100644
--- a/cabal/Cabal/Distribution/FieldGrammar/FieldDescrs.hs
+++ b/cabal/Cabal/Distribution/FieldGrammar/FieldDescrs.hs
@@ -11,16 +11,17 @@ module Distribution.FieldGrammar.FieldDescrs (
import Distribution.Compat.Prelude
import Prelude ()
+import Data.List (dropWhileEnd)
import Distribution.Compat.Lens (aview, cloneLens)
import Distribution.Compat.Newtype
import Distribution.FieldGrammar
-import Distribution.Pretty (pretty)
-import Distribution.Utils.Generic (fromUTF8BS)
+import Distribution.Pretty (pretty, showFreeText)
-import qualified Data.Map as Map
-import qualified Distribution.Parsec.Class as P
-import qualified Distribution.Parsec.Field as P
-import qualified Text.PrettyPrint as Disp
+import qualified Data.Map as Map
+import qualified Distribution.Compat.CharParsing as C
+import qualified Distribution.Fields.Field as P
+import qualified Distribution.Parsec as P
+import qualified Text.PrettyPrint as Disp
-- strict pair
data SP s = SP
@@ -29,7 +30,7 @@ data SP s = SP
}
-- | A collection field parsers and pretty-printers.
-newtype FieldDescrs s a = F { runF :: Map String (SP s) }
+newtype FieldDescrs s a = F { runF :: Map P.FieldName (SP s) }
deriving (Functor)
instance Applicative (FieldDescrs s) where
@@ -37,20 +38,20 @@ instance Applicative (FieldDescrs s) where
f <*> x = F (mappend (runF f) (runF x))
singletonF :: P.FieldName -> (s -> Disp.Doc) -> (forall m. P.CabalParsing m => s -> m s) -> FieldDescrs s a
-singletonF fn f g = F $ Map.singleton (fromUTF8BS fn) (SP f g)
+singletonF fn f g = F $ Map.singleton fn (SP f g)
-- | Lookup a field value pretty-printer.
-fieldDescrPretty :: FieldDescrs s a -> String -> Maybe (s -> Disp.Doc)
+fieldDescrPretty :: FieldDescrs s a -> P.FieldName -> Maybe (s -> Disp.Doc)
fieldDescrPretty (F m) fn = pPretty <$> Map.lookup fn m
-- | Lookup a field value parser.
-fieldDescrParse :: P.CabalParsing m => FieldDescrs s a -> String -> Maybe (s -> m s)
+fieldDescrParse :: P.CabalParsing m => FieldDescrs s a -> P.FieldName -> Maybe (s -> m s)
fieldDescrParse (F m) fn = pParse <$> Map.lookup fn m
fieldDescrsToList
:: P.CabalParsing m
=> FieldDescrs s a
- -> [(String, s -> Disp.Doc, s -> m s)]
+ -> [(P.FieldName, s -> Disp.Doc, s -> m s)]
fieldDescrsToList = map mk . Map.toList . runF where
mk (name, SP ppr parse) = (name, ppr, parse)
@@ -76,6 +77,14 @@ instance FieldGrammar FieldDescrs where
f s = pretty (pack' _pack (aview l s))
g s = cloneLens l (const (unpack' _pack <$> P.parsec)) s
+ freeTextField fn l = singletonF fn f g where
+ f s = maybe mempty showFreeText (aview l s)
+ g s = cloneLens l (const (Just <$> parsecFreeText)) s
+
+ freeTextFieldDef fn l = singletonF fn f g where
+ f s = showFreeText (aview l s)
+ g s = cloneLens l (const parsecFreeText) s
+
monoidalFieldAla fn _pack l = singletonF fn f g where
f s = pretty (pack' _pack (aview l s))
g s = cloneLens l (\x -> mappend x . unpack' _pack <$> P.parsec) s
@@ -83,5 +92,23 @@ instance FieldGrammar FieldDescrs where
prefixedFields _fnPfx _l = F mempty
knownField _ = pure ()
deprecatedSince _ _ x = x
+ removedIn _ _ x = x
availableSince _ _ = id
hiddenField _ = F mempty
+
+parsecFreeText :: P.CabalParsing m => m String
+parsecFreeText = dropDotLines <$ C.spaces <*> many C.anyChar
+ where
+ -- Example package with dot lines
+ -- http://hackage.haskell.org/package/copilot-cbmc-0.1/copilot-cbmc.cabal
+ dropDotLines "." = "."
+ dropDotLines x = intercalate "\n" . map dotToEmpty . lines $ x
+
+ dotToEmpty x | trim' x == "." = ""
+ dotToEmpty x = trim x
+
+ trim' :: String -> String
+ trim' = dropWhileEnd (`elem` (" \t" :: String))
+
+ trim :: String -> String
+ trim = dropWhile isSpace . dropWhileEnd isSpace
diff --git a/cabal/Cabal/Distribution/FieldGrammar/Parsec.hs b/cabal/Cabal/Distribution/FieldGrammar/Parsec.hs
index 6567d68..7b712e3 100644
--- a/cabal/Cabal/Distribution/FieldGrammar/Parsec.hs
+++ b/cabal/Cabal/Distribution/FieldGrammar/Parsec.hs
@@ -61,6 +61,7 @@ module Distribution.FieldGrammar.Parsec (
Section (..),
runFieldParser,
runFieldParser',
+ fieldLinesToStream,
) where
import Data.List (dropWhileEnd)
@@ -72,18 +73,18 @@ import Distribution.Simple.Utils (fromUTF8BS)
import Prelude ()
import qualified Data.ByteString as BS
-import qualified Data.Set as Set
import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
import qualified Text.Parsec as P
import qualified Text.Parsec.Error as P
import Distribution.CabalSpecVersion
import Distribution.FieldGrammar.Class
-import Distribution.Parsec.Class
-import Distribution.Parsec.Common
-import Distribution.Parsec.Field
+import Distribution.Fields.Field
+import Distribution.Fields.ParseResult
+import Distribution.Parsec
import Distribution.Parsec.FieldLineStream
-import Distribution.Parsec.ParseResult
+import Distribution.Parsec.Position (positionRow, positionCol)
-------------------------------------------------------------------------------
-- Auxiliary types
@@ -205,6 +206,34 @@ instance FieldGrammar ParsecFieldGrammar where
| null fls = pure def
| otherwise = unpack' _pack <$> runFieldParser pos parsec v fls
+ freeTextField fn _ = ParsecFG (Set.singleton fn) Set.empty parser where
+ parser v fields = case Map.lookup fn fields of
+ Nothing -> pure Nothing
+ Just [] -> pure Nothing
+ Just [x] -> parseOne v x
+ Just xs -> do
+ warnMultipleSingularFields fn xs
+ last <$> traverse (parseOne v) xs
+
+ parseOne v (MkNamelessField pos fls)
+ | null fls = pure Nothing
+ | v >= CabalSpecV3_0 = pure (Just (fieldlinesToFreeText3 pos fls))
+ | otherwise = pure (Just (fieldlinesToFreeText fls))
+
+ freeTextFieldDef fn _ = ParsecFG (Set.singleton fn) Set.empty parser where
+ parser v fields = case Map.lookup fn fields of
+ Nothing -> pure ""
+ Just [] -> pure ""
+ Just [x] -> parseOne v x
+ Just xs -> do
+ warnMultipleSingularFields fn xs
+ last <$> traverse (parseOne v) xs
+
+ parseOne v (MkNamelessField pos fls)
+ | null fls = pure ""
+ | v >= CabalSpecV3_0 = pure (fieldlinesToFreeText3 pos fls)
+ | otherwise = pure (fieldlinesToFreeText fls)
+
monoidalFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser
where
parser v fields = case Map.lookup fn fields of
@@ -231,28 +260,54 @@ instance FieldGrammar ParsecFieldGrammar where
availableSince vs def (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'
where
parser' v values
- | cabalSpecSupports v vs = parser v values
+ | v >= vs = parser v values
| otherwise = do
let unknownFields = Map.intersection values $ Map.fromSet (const ()) names
for_ (Map.toList unknownFields) $ \(name, fields) ->
for_ fields $ \(MkNamelessField pos _) ->
parseWarning pos PWTUnknownField $
- "The field " <> show name <> " is available since Cabal " ++ show vs
+ "The field " <> show name <> " is available only since the Cabal specification version " ++ showCabalSpecVersion vs ++ ". This field will be ignored."
pure def
-- todo we know about this field
- deprecatedSince (_ : _) _ grammar = grammar -- pass on non-empty version
- deprecatedSince _ msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'
+ deprecatedSince vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'
where
- parser' v values = do
- let deprecatedFields = Map.intersection values $ Map.fromSet (const ()) names
- for_ (Map.toList deprecatedFields) $ \(name, fields) ->
- for_ fields $ \(MkNamelessField pos _) ->
- parseWarning pos PWTDeprecatedField $
- "The field " <> show name <> " is deprecated. " ++ msg
+ parser' v values
+ | v >= vs = do
+ let deprecatedFields = Map.intersection values $ Map.fromSet (const ()) names
+ for_ (Map.toList deprecatedFields) $ \(name, fields) ->
+ for_ fields $ \(MkNamelessField pos _) ->
+ parseWarning pos PWTDeprecatedField $
+ "The field " <> show name <> " is deprecated in the Cabal specification version " ++ showCabalSpecVersion vs ++ ". " ++ msg
+
+ parser v values
+
+ | otherwise = parser v values
+
+ removedIn vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser' where
+ parser' v values
+ | v >= vs = do
+ let msg' = if null msg then "" else ' ' : msg
+ let unknownFields = Map.intersection values $ Map.fromSet (const ()) names
+ let namePos =
+ [ (name, pos)
+ | (name, fields) <- Map.toList unknownFields
+ , MkNamelessField pos _ <- fields
+ ]
- parser v values
+ let makeMsg name = "The field " <> show name <> " is removed in the Cabal specification version " ++ showCabalSpecVersion vs ++ "." ++ msg'
+
+ case namePos of
+ -- no fields => proceed (with empty values, to be sure)
+ [] -> parser v mempty
+
+ -- if there's single field: fail fatally with it
+ ((name, pos) : rest) -> do
+ for_ rest $ \(name', pos') -> parseFailure pos' $ makeMsg name'
+ parseFatalFailure pos $ makeMsg name
+
+ | otherwise = parser v values
knownField fn = ParsecFG (Set.singleton fn) Set.empty (\_ _ -> pure ())
@@ -262,36 +317,92 @@ instance FieldGrammar ParsecFieldGrammar where
-- Parsec
-------------------------------------------------------------------------------
-runFieldParser' :: Position -> ParsecParser a -> CabalSpecVersion -> FieldLineStream -> ParseResult a
-runFieldParser' (Position row col) p v str = case P.runParser p' [] "<field>" str of
+runFieldParser' :: [Position] -> ParsecParser a -> CabalSpecVersion -> FieldLineStream -> ParseResult a
+runFieldParser' inputPoss p v str = case P.runParser p' [] "<field>" str of
Right (pok, ws) -> do
- -- TODO: map pos
- traverse_ (\(PWarning t pos w) -> parseWarning pos t w) ws
+ traverse_ (\(PWarning t pos w) -> parseWarning (mapPosition pos) t w) ws
pure pok
Left err -> do
let ppos = P.errorPos err
- -- Positions start from 1:1, not 0:0
- let epos = Position (row - 1 + P.sourceLine ppos) (col - 1 + P.sourceColumn ppos)
+ let epos = mapPosition $ Position (P.sourceLine ppos) (P.sourceColumn ppos)
+
let msg = P.showErrorMessages
"or" "unknown parse error" "expecting" "unexpected" "end of input"
(P.errorMessages err)
- let str' = unlines (filter (not . all isSpace) (fieldLineStreamToLines str))
-
- parseFatalFailure epos $ msg ++ "\n" ++ "\n" ++ str'
+ parseFatalFailure epos $ msg ++ "\n"
where
p' = (,) <$ P.spaces <*> unPP p v <* P.spaces <* P.eof <*> P.getState
-fieldLineStreamToLines :: FieldLineStream -> [String]
-fieldLineStreamToLines (FLSLast bs) = [ fromUTF8BS bs ]
-fieldLineStreamToLines (FLSCons bs s) = fromUTF8BS bs : fieldLineStreamToLines s
+ -- Positions start from 1:1, not 0:0
+ mapPosition (Position prow pcol) = go (prow - 1) inputPoss where
+ go _ [] = zeroPos
+ go _ [Position row col] = Position row (col + pcol - 1)
+ go n (Position row col:_) | n <= 0 = Position row (col + pcol - 1)
+ go n (_:ps) = go (n - 1) ps
runFieldParser :: Position -> ParsecParser a -> CabalSpecVersion -> [FieldLine Position] -> ParseResult a
-runFieldParser pp p v ls = runFieldParser' pos p v (fieldLinesToStream ls)
+runFieldParser pp p v ls = runFieldParser' poss p v (fieldLinesToStream ls)
where
- -- TODO: make per line lookup
- pos = case ls of
- [] -> pp
- (FieldLine pos' _ : _) -> pos'
+ poss = map (\(FieldLine pos _) -> pos) ls ++ [pp] -- add "default" position
fieldlinesToBS :: [FieldLine ann] -> BS.ByteString
fieldlinesToBS = BS.intercalate "\n" . map (\(FieldLine _ bs) -> bs)
+
+-- Example package with dot lines
+-- http://hackage.haskell.org/package/copilot-cbmc-0.1/copilot-cbmc.cabal
+fieldlinesToFreeText :: [FieldLine ann] -> String
+fieldlinesToFreeText [FieldLine _ "."] = "."
+fieldlinesToFreeText fls = intercalate "\n" (map go fls)
+ where
+ go (FieldLine _ bs)
+ | s == "." = ""
+ | otherwise = s
+ where
+ s = trim (fromUTF8BS bs)
+
+ trim :: String -> String
+ trim = dropWhile isSpace . dropWhileEnd isSpace
+
+fieldlinesToFreeText3 :: Position -> [FieldLine Position] -> String
+fieldlinesToFreeText3 _ [] = ""
+fieldlinesToFreeText3 _ [FieldLine _ bs] = fromUTF8BS bs
+fieldlinesToFreeText3 pos (FieldLine pos1 bs1 : fls2@(FieldLine pos2 _ : _))
+ -- if first line is on the same line with field name:
+ -- the indentation level is either
+ -- 1. the indentation of left most line in rest fields
+ -- 2. the indentation of the first line
+ -- whichever is leftmost
+ | positionRow pos == positionRow pos1 = concat
+ $ fromUTF8BS bs1
+ : mealy (mk mcol1) pos1 fls2
+
+ -- otherwise, also indent the first line
+ | otherwise = concat
+ $ replicate (positionCol pos1 - mcol2) ' '
+ : fromUTF8BS bs1
+ : mealy (mk mcol2) pos1 fls2
+
+ where
+ mcol1 = foldl' (\a b -> min a $ positionCol $ fieldLineAnn b) (min (positionCol pos1) (positionCol pos2)) fls2
+ mcol2 = foldl' (\a b -> min a $ positionCol $ fieldLineAnn b) (positionCol pos1) fls2
+
+ mk :: Int -> Position -> FieldLine Position -> (Position, String)
+ mk col p (FieldLine q bs) =
+ ( q
+ , replicate newlines '\n'
+ ++ replicate indent ' '
+ ++ fromUTF8BS bs
+ )
+ where
+ newlines = positionRow q - positionRow p
+ indent = positionCol q - col
+
+mealy :: (s -> a -> (s, b)) -> s -> [a] -> [b]
+mealy f = go where
+ go _ [] = []
+ go s (x : xs) = let ~(s', y) = f s x in y : go s' xs
+
+fieldLinesToStream :: [FieldLine ann] -> FieldLineStream
+fieldLinesToStream [] = fieldLineStreamEnd
+fieldLinesToStream [FieldLine _ bs] = FLSLast bs
+fieldLinesToStream (FieldLine _ bs : fs) = FLSCons bs (fieldLinesToStream fs)
diff --git a/cabal/Cabal/Distribution/FieldGrammar/Pretty.hs b/cabal/Cabal/Distribution/FieldGrammar/Pretty.hs
index d0f585c..77980f3 100644
--- a/cabal/Cabal/Distribution/FieldGrammar/Pretty.hs
+++ b/cabal/Cabal/Distribution/FieldGrammar/Pretty.hs
@@ -4,77 +4,98 @@ module Distribution.FieldGrammar.Pretty (
prettyFieldGrammar,
) where
+import Distribution.CabalSpecVersion
import Distribution.Compat.Lens
import Distribution.Compat.Newtype
import Distribution.Compat.Prelude
-import Distribution.Pretty (Pretty (..))
-import Distribution.Simple.Utils (fromUTF8BS)
+import Distribution.Fields.Field (FieldName)
+import Distribution.Fields.Pretty (PrettyField (..))
+import Distribution.Pretty (Pretty (..), showFreeText, showFreeTextV3)
+import Distribution.Simple.Utils (toUTF8BS)
import Prelude ()
-import Text.PrettyPrint (Doc)
-import qualified Text.PrettyPrint as PP
+import Text.PrettyPrint (Doc)
+import qualified Text.PrettyPrint as PP
import Distribution.FieldGrammar.Class
-import Distribution.ParseUtils (ppField)
newtype PrettyFieldGrammar s a = PrettyFG
- { fieldGrammarPretty :: s -> Doc
+ { fieldGrammarPretty :: CabalSpecVersion -> s -> [PrettyField ()]
}
deriving (Functor)
instance Applicative (PrettyFieldGrammar s) where
- pure _ = PrettyFG (\_ -> mempty)
- PrettyFG f <*> PrettyFG x = PrettyFG (\s -> f s PP.$$ x s)
+ pure _ = PrettyFG (\_ _ -> mempty)
+ PrettyFG f <*> PrettyFG x = PrettyFG (\v s -> f v s <> x v s)
-- | We can use 'PrettyFieldGrammar' to pp print the @s@.
--
-- /Note:/ there is not trailing @($+$ text "")@.
-prettyFieldGrammar :: PrettyFieldGrammar s a -> s -> Doc
-prettyFieldGrammar = fieldGrammarPretty
+prettyFieldGrammar :: CabalSpecVersion -> PrettyFieldGrammar s a -> s -> [PrettyField ()]
+prettyFieldGrammar = flip fieldGrammarPretty
instance FieldGrammar PrettyFieldGrammar where
- blurFieldGrammar f (PrettyFG pp) = PrettyFG (pp . aview f)
+ blurFieldGrammar f (PrettyFG pp) = PrettyFG (\v -> pp v . aview f)
- uniqueFieldAla fn _pack l = PrettyFG $ \s ->
- ppField (fromUTF8BS fn) (pretty (pack' _pack (aview l s)))
+ uniqueFieldAla fn _pack l = PrettyFG $ \_v s ->
+ ppField fn (pretty (pack' _pack (aview l s)))
booleanFieldDef fn l def = PrettyFG pp
where
- pp s
+ pp _v s
| b == def = mempty
- | otherwise = ppField (fromUTF8BS fn) (PP.text (show b))
+ | otherwise = ppField fn (PP.text (show b))
where
b = aview l s
optionalFieldAla fn _pack l = PrettyFG pp
where
- pp s = case aview l s of
+ pp v s = case aview l s of
Nothing -> mempty
- Just a -> ppField (fromUTF8BS fn) (pretty (pack' _pack a))
+ Just a -> ppField fn (prettyVersioned v (pack' _pack a))
optionalFieldDefAla fn _pack l def = PrettyFG pp
where
- pp s
+ pp v s
| x == def = mempty
- | otherwise = ppField (fromUTF8BS fn) (pretty (pack' _pack x))
+ | otherwise = ppField fn (prettyVersioned v (pack' _pack x))
where
x = aview l s
+ freeTextField fn l = PrettyFG pp where
+ pp v s = maybe mempty (ppField fn . showFT) (aview l s) where
+ showFT | v >= CabalSpecV3_0 = showFreeTextV3
+ | otherwise = showFreeText
+
+ -- it's ok to just show, as showFreeText of empty string is empty.
+ freeTextFieldDef fn l = PrettyFG pp where
+ pp v s = ppField fn (showFT (aview l s)) where
+ showFT | v >= CabalSpecV3_0 = showFreeTextV3
+ | otherwise = showFreeText
+
monoidalFieldAla fn _pack l = PrettyFG pp
where
- pp s = ppField (fromUTF8BS fn) (pretty (pack' _pack (aview l s)))
+ pp v s = ppField fn (prettyVersioned v (pack' _pack (aview l s)))
- prefixedFields _fnPfx l = PrettyFG (pp . aview l)
+ prefixedFields _fnPfx l = PrettyFG (\_ -> pp . aview l)
where
- pp xs = PP.vcat
- -- always print the field, even its Doc is empty
+ pp xs =
+ -- always print the field, even its Doc is empty.
-- i.e. don't use ppField
- [ PP.text n <<>> PP.colon PP.<+> (PP.vcat $ map PP.text $ lines s)
+ [ PrettyField () (toUTF8BS n) $ PP.vcat $ map PP.text $ lines s
| (n, s) <- xs
-- fnPfx `isPrefixOf` n
]
knownField _ = pure ()
- deprecatedSince [] _ _ = PrettyFG (\_ -> mempty)
- deprecatedSince _ _ x = x
+ deprecatedSince _ _ x = x
+ -- TODO: as PrettyFieldGrammar isn't aware of cabal-version: we output the field
+ -- this doesn't affect roundtrip as `removedIn` fields cannot be parsed
+ -- so invalid documents can be only manually constructed.
+ removedIn _ _ x = x
availableSince _ _ = id
hiddenField _ = PrettyFG (\_ -> mempty)
+
+ppField :: FieldName -> Doc -> [PrettyField ()]
+ppField name fielddoc
+ | PP.isEmpty fielddoc = []
+ | otherwise = [ PrettyField () name fielddoc ]
diff --git a/cabal/Cabal/Distribution/Fields.hs b/cabal/Cabal/Distribution/Fields.hs
new file mode 100644
index 0000000..7d61edd
--- /dev/null
+++ b/cabal/Cabal/Distribution/Fields.hs
@@ -0,0 +1,42 @@
+-- | Utilitiies to work with @.cabal@ like file structure.
+module Distribution.Fields (
+ -- * Types
+ Field(..),
+ Name(..),
+ FieldLine(..),
+ SectionArg(..),
+ FieldName,
+ -- * Grammar and parsing
+ --
+ -- See "Distribution.Fields.Parser" for grammar.
+ readFields,
+ readFields',
+ -- ** ParseResult
+ ParseResult,
+ runParseResult,
+ parseString,
+ parseWarning,
+ parseWarnings,
+ parseFailure,
+ parseFatalFailure,
+ -- ** Warnings
+ PWarnType (..),
+ PWarning (..),
+ showPWarning,
+ -- ** Errors
+ PError (..),
+ showPError,
+ -- * Pretty printing
+ PrettyField (..),
+ showFields,
+ -- ** Transformation from Field
+ genericFromParsecFields,
+ fromParsecFields,
+ ) where
+
+import Distribution.Fields.Field
+import Distribution.Fields.Parser
+import Distribution.Fields.ParseResult
+import Distribution.Fields.Pretty
+import Distribution.Parsec.Error
+import Distribution.Parsec.Warning
diff --git a/cabal/Cabal/Distribution/Parsec/ConfVar.hs b/cabal/Cabal/Distribution/Fields/ConfVar.hs
index 5afbc78..52f1053 100644
--- a/cabal/Cabal/Distribution/Parsec/ConfVar.hs
+++ b/cabal/Cabal/Distribution/Fields/ConfVar.hs
@@ -1,14 +1,13 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonoLocalBinds #-}
-module Distribution.Parsec.ConfVar (parseConditionConfVar) where
+module Distribution.Fields.ConfVar (parseConditionConfVar) where
import Distribution.Compat.CharParsing (char, integral)
import Distribution.Compat.Prelude
-import Distribution.Parsec.Class (Parsec (..), runParsecParser)
-import Distribution.Parsec.Common
-import Distribution.Parsec.FieldLineStream
-import Distribution.Parsec.Field (SectionArg (..))
-import Distribution.Parsec.ParseResult
+import Distribution.Parsec (Parsec (..), runParsecParser, Position (..))
+import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS)
+import Distribution.Fields.Field (SectionArg (..))
+import Distribution.Fields.ParseResult
import Distribution.Types.Condition
import Distribution.Types.GenericPackageDescription (ConfVar (..))
import Distribution.Version
@@ -39,11 +38,14 @@ parseConditionConfVar args =
type Parser = P.Parsec [SectionArg Position] ()
+sepByNonEmpty :: Parser a -> Parser sep -> Parser (NonEmpty a)
+sepByNonEmpty p sep = (:|) <$> p <*> many (sep *> p)
+
parser :: Parser (Condition ConfVar)
parser = condOr
where
- condOr = P.sepBy1 condAnd (oper "||") >>= return . foldl1 COr
- condAnd = P.sepBy1 cond (oper "&&") >>= return . foldl1 CAnd
+ condOr = sepByNonEmpty condAnd (oper "||") >>= return . foldl1 COr
+ condAnd = sepByNonEmpty cond (oper "&&") >>= return . foldl1 CAnd
cond = P.choice
[ boolLiteral, parens condOr, notCond, osCond, archCond, flagCond, implCond ]
@@ -65,8 +67,8 @@ parser = condOr
versionRange = expr
where
- expr = foldl1 unionVersionRanges <$> P.sepBy1 term (oper "||")
- term = foldl1 intersectVersionRanges <$> P.sepBy1 factor (oper "&&")
+ expr = foldl1 unionVersionRanges <$> sepByNonEmpty term (oper "||")
+ term = foldl1 intersectVersionRanges <$> sepByNonEmpty factor (oper "&&")
factor = P.choice
$ parens expr
diff --git a/cabal/Cabal/Distribution/Parsec/Field.hs b/cabal/Cabal/Distribution/Fields/Field.hs
index 91447c1..5e49d17 100644
--- a/cabal/Cabal/Distribution/Parsec/Field.hs
+++ b/cabal/Cabal/Distribution/Fields/Field.hs
@@ -1,14 +1,18 @@
{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE DeriveFoldable #-}
+{-# LANGUAGE DeriveTraversable #-}
-- | Cabal-like file AST types: 'Field', 'Section' etc
--
-- These types are parametrized by an annotation.
-module Distribution.Parsec.Field (
+module Distribution.Fields.Field (
-- * Cabal file
Field (..),
fieldName,
fieldAnn,
fieldUniverse,
FieldLine (..),
+ fieldLineAnn,
+ fieldLineBS,
SectionArg (..),
sectionArgAnn,
-- * Name
@@ -33,7 +37,7 @@ import qualified Data.Char as Char
data Field ann
= Field !(Name ann) [FieldLine ann]
| Section !(Name ann) [SectionArg ann] [Field ann]
- deriving (Eq, Show, Functor)
+ deriving (Eq, Show, Functor, Foldable, Traversable)
-- | Section of field name
fieldName :: Field ann -> Name ann
@@ -56,7 +60,15 @@ fieldUniverse f@(Field _ _) = [f]
--
-- /Invariant:/ 'ByteString' has no newlines.
data FieldLine ann = FieldLine !ann !ByteString
- deriving (Eq, Show, Functor)
+ deriving (Eq, Show, Functor, Foldable, Traversable)
+
+-- | @since 3.0.0.0
+fieldLineAnn :: FieldLine ann -> ann
+fieldLineAnn (FieldLine ann _) = ann
+
+-- | @since 3.0.0.0
+fieldLineBS :: FieldLine ann -> ByteString
+fieldLineBS (FieldLine _ bs) = bs
-- | Section arguments, e.g. name of the library
data SectionArg ann
@@ -66,7 +78,7 @@ data SectionArg ann
-- ^ quoted string
| SecArgOther !ann !ByteString
-- ^ everything else, mm. operators (e.g. in if-section conditionals)
- deriving (Eq, Show, Functor)
+ deriving (Eq, Show, Functor, Foldable, Traversable)
-- | Extract annotation from 'SectionArg'.
sectionArgAnn :: SectionArg ann -> ann
@@ -84,7 +96,7 @@ type FieldName = ByteString
--
-- /Invariant/: 'ByteString' is lower-case ASCII.
data Name ann = Name !ann !FieldName
- deriving (Eq, Show, Functor)
+ deriving (Eq, Show, Functor, Foldable, Traversable)
mkName :: ann -> FieldName -> Name ann
mkName ann bs = Name ann (B.map Char.toLower bs)
diff --git a/cabal/Cabal/Distribution/Fields/Lexer.hs b/cabal/Cabal/Distribution/Fields/Lexer.hs
new file mode 100644
index 0000000..8a6d504
--- /dev/null
+++ b/cabal/Cabal/Distribution/Fields/Lexer.hs
@@ -0,0 +1,488 @@
+{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}
+{-# LANGUAGE CPP,MagicHash #-}
+{-# LINE 1 "boot/Lexer.x" #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : Distribution.Fields.Lexer
+-- License : BSD3
+--
+-- Maintainer : cabal-devel@haskell.org
+-- Portability : portable
+--
+-- Lexer for the cabal files.
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE BangPatterns #-}
+#ifdef CABAL_PARSEC_DEBUG
+{-# LANGUAGE PatternGuards #-}
+#endif
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+module Distribution.Fields.Lexer
+ (ltest, lexToken, Token(..), LToken(..)
+ ,bol_section, in_section, in_field_layout, in_field_braces
+ ,mkLexState) where
+
+-- [Note: boostrapping parsec parser]
+--
+-- We manually produce the `Lexer.hs` file from `boot/Lexer.x` (make lexer)
+-- because boostrapping cabal-install would be otherwise tricky.
+-- Alex is (atm) tricky package to build, cabal-install has some magic
+-- to move bundled generated files in place, so rather we don't depend
+-- on it before we can build it ourselves.
+-- Therefore there is one thing less to worry in bootstrap.sh, which is a win.
+--
+-- See also https://github.com/haskell/cabal/issues/4633
+--
+
+import Prelude ()
+import qualified Prelude as Prelude
+import Distribution.Compat.Prelude
+
+import Distribution.Fields.LexerMonad
+import Distribution.Parsec.Position (Position (..), incPos, retPos)
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as B
+import qualified Data.ByteString.Char8 as B.Char8
+import qualified Data.Word as Word
+
+#ifdef CABAL_PARSEC_DEBUG
+import Debug.Trace
+import qualified Data.Vector as V
+import qualified Data.Text as T
+import qualified Data.Text.Encoding as T
+import qualified Data.Text.Encoding.Error as T
+#endif
+
+#if __GLASGOW_HASKELL__ >= 603
+#include "ghcconfig.h"
+#elif defined(__GLASGOW_HASKELL__)
+#include "config.h"
+#endif
+#if __GLASGOW_HASKELL__ >= 503
+import Data.Array
+import Data.Array.Base (unsafeAt)
+#else
+import Array
+#endif
+#if __GLASGOW_HASKELL__ >= 503
+import GHC.Exts
+#else
+import GlaExts
+#endif
+alex_tab_size :: Int
+alex_tab_size = 8
+alex_base :: AlexAddr
+alex_base = AlexA#
+ "\x12\xff\xff\xff\xf9\xff\xff\xff\xfb\xff\xff\xff\x01\x00\x00\x00\x2f\x00\x00\x00\x50\x00\x00\x00\xd0\x00\x00\x00\x48\xff\xff\xff\xdc\xff\xff\xff\x51\xff\xff\xff\x6d\xff\xff\xff\x6f\xff\xff\xff\x50\x01\x00\x00\x74\x01\x00\x00\x70\xff\xff\xff\x68\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\xa3\x01\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6a\x00\x00\x00\xd1\x01\x00\x00\xfb\x01\x00\x00\x7b\x02\x00\x00\xfb\x02\x00\x00\x00\x00\x00\x00\x7b\x03\x00\x00\x7d\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x6d\x00\x00\x00\x6b\x00\x00\x00\xfc\x03\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x6f\x00\x00\x00\x1c\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00"#
+
+alex_table :: AlexAddr
+alex_table = AlexA#
+ "\x00\x00\x09\x00\x0f\x00\x11\x00\x02\x00\x11\x00\x12\x00\x00\x00\x12\x00\x13\x00\x03\x00\x11\x00\x07\x00\x10\x00\x12\x00\x25\x00\x14\x00\x11\x00\x10\x00\x11\x00\x14\x00\x11\x00\x12\x00\x23\x00\x12\x00\x0f\x00\x28\x00\x02\x00\x2e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x08\x00\x10\x00\x00\x00\x14\x00\x00\x00\x00\x00\x08\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2a\x00\x2e\x00\xff\xff\xff\xff\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x26\x00\x28\x00\xff\xff\xff\xff\x29\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x26\x00\x0f\x00\x11\x00\x17\x00\x26\x00\x12\x00\x25\x00\x11\x00\x2a\x00\x00\x00\x12\x00\x00\x00\x15\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x17\x00\x26\x00\x00\x00\x25\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2c\x00\x00\x00\x2d\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x0e\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x23\x00\xff\xff\xff\xff\x24\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x1e\x00\x0d\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x1f\x00\x1f\x00\x1e\x00\x1e\x00\x1e\x00\x19\x00\x1a\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x1f\x00\x1e\x00\x1f\x00\x1e\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x21\x00\x1e\x00\x22\x00\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x1d\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x0c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1e\x00\xff\xff\x1e\x00\x1e\x00\x1e\x00\x1e\x00\xff\xff\xff\xff\xff\xff\x1e\x00\x1e\x00\x1e\x00\x18\x00\x1a\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1e\x00\xff\xff\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\xff\xff\xff\xff\x1e\x00\x1e\x00\x1e\x00\x1a\x00\x1a\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x1c\x00\x1e\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x1e\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\xff\xff\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#
+
+alex_check :: AlexAddr
+alex_check = AlexA#
+ "\xff\xff\xef\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\xbf\x00\x0d\x00\x2d\x00\x09\x00\x0a\x00\xbb\x00\xa0\x00\x0d\x00\xa0\x00\xa0\x00\x0a\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x0a\x00\x0d\x00\x20\x00\x0a\x00\x20\x00\x0a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x20\x00\xff\xff\x20\x00\xff\xff\xff\xff\x2d\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x09\x00\x0a\x00\x09\x00\x09\x00\x0d\x00\x09\x00\x0a\x00\x09\x00\xff\xff\x0d\x00\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\x20\x00\x20\x00\xff\xff\x20\x00\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x5c\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\x5c\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x7f\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\xff\xff\xff\xff\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\x21\x00\xff\xff\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\xff\xff\xff\xff\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\x5c\x00\xff\xff\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7c\x00\x7f\x00\x7e\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#
+
+alex_deflt :: AlexAddr
+alex_deflt = AlexA#
+ "\xff\xff\xff\xff\xff\xff\xff\xff\x2b\x00\x27\x00\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0d\x00\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x13\x00\xff\xff\xff\xff\xff\xff\xff\xff\x18\x00\x1b\x00\x1b\x00\x1b\x00\xff\xff\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x27\x00\xff\xff\xff\xff\xff\xff\x2b\x00\xff\xff\xff\xff\xff\xff\xff\xff"#
+
+alex_accept = listArray (0 :: Int, 47)
+ [ AlexAcc 29
+ , AlexAcc 28
+ , AlexAcc 27
+ , AlexAcc 26
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAccNone
+ , AlexAcc 25
+ , AlexAcc 24
+ , AlexAccSkip
+ , AlexAcc 23
+ , AlexAcc 22
+ , AlexAcc 21
+ , AlexAccSkip
+ , AlexAccSkip
+ , AlexAcc 20
+ , AlexAcc 19
+ , AlexAcc 18
+ , AlexAcc 17
+ , AlexAcc 16
+ , AlexAcc 15
+ , AlexAcc 14
+ , AlexAcc 13
+ , AlexAcc 12
+ , AlexAcc 11
+ , AlexAcc 10
+ , AlexAcc 9
+ , AlexAcc 8
+ , AlexAccSkip
+ , AlexAcc 7
+ , AlexAcc 6
+ , AlexAcc 5
+ , AlexAccSkip
+ , AlexAcc 4
+ , AlexAcc 3
+ , AlexAcc 2
+ , AlexAcc 1
+ , AlexAcc 0
+ ]
+
+alex_actions = array (0 :: Int, 30)
+ [ (29,alex_action_0)
+ , (28,alex_action_20)
+ , (27,alex_action_16)
+ , (26,alex_action_3)
+ , (25,alex_action_1)
+ , (24,alex_action_1)
+ , (23,alex_action_3)
+ , (22,alex_action_4)
+ , (21,alex_action_5)
+ , (20,alex_action_8)
+ , (19,alex_action_8)
+ , (18,alex_action_8)
+ , (17,alex_action_9)
+ , (16,alex_action_9)
+ , (15,alex_action_10)
+ , (14,alex_action_11)
+ , (13,alex_action_12)
+ , (12,alex_action_13)
+ , (11,alex_action_14)
+ , (10,alex_action_15)
+ , (9,alex_action_15)
+ , (8,alex_action_16)
+ , (7,alex_action_18)
+ , (6,alex_action_19)
+ , (5,alex_action_19)
+ , (4,alex_action_22)
+ , (3,alex_action_23)
+ , (2,alex_action_24)
+ , (1,alex_action_25)
+ , (0,alex_action_25)
+ ]
+
+{-# LINE 151 "boot/Lexer.x" #-}
+
+-- | Tokens of outer cabal file structure. Field values are treated opaquely.
+data Token = TokSym !ByteString -- ^ Haskell-like identifier, number or operator
+ | TokStr !ByteString -- ^ String in quotes
+ | TokOther !ByteString -- ^ Operators and parens
+ | Indent !Int -- ^ Indentation token
+ | TokFieldLine !ByteString -- ^ Lines after @:@
+ | Colon
+ | OpenBrace
+ | CloseBrace
+ | EOF
+ | LexicalError InputStream --TODO: add separate string lexical error
+ deriving Show
+
+data LToken = L !Position !Token
+ deriving Show
+
+toki :: (ByteString -> Token) -> Position -> Int -> ByteString -> Lex LToken
+toki t pos len input = return $! L pos (t (B.take len input))
+
+tok :: Token -> Position -> Int -> ByteString -> Lex LToken
+tok t pos _len _input = return $! L pos t
+
+checkLeadingWhitespace :: Int -> ByteString -> Lex Int
+checkLeadingWhitespace len bs
+ | B.any (== 9) (B.take len bs) = do
+ addWarning LexWarningTab
+ checkWhitespace len bs
+ | otherwise = checkWhitespace len bs
+
+checkWhitespace :: Int -> ByteString -> Lex Int
+checkWhitespace len bs
+ | B.any (== 194) (B.take len bs) = do
+ addWarning LexWarningNBSP
+ return $ len - B.count 194 (B.take len bs)
+ | otherwise = return len
+
+-- -----------------------------------------------------------------------------
+-- The input type
+
+type AlexInput = InputStream
+
+alexInputPrevChar :: AlexInput -> Char
+alexInputPrevChar _ = error "alexInputPrevChar not used"
+
+alexGetByte :: AlexInput -> Maybe (Word.Word8,AlexInput)
+alexGetByte = B.uncons
+
+lexicalError :: Position -> InputStream -> Lex LToken
+lexicalError pos inp = do
+ setInput B.empty
+ return $! L pos (LexicalError inp)
+
+lexToken :: Lex LToken
+lexToken = do
+ pos <- getPos
+ inp <- getInput
+ st <- getStartCode
+ case alexScan inp st of
+ AlexEOF -> return (L pos EOF)
+ AlexError inp' ->
+ let !len_bytes = B.length inp - B.length inp' in
+ --FIXME: we want len_chars here really
+ -- need to decode utf8 up to this point
+ lexicalError (incPos len_bytes pos) inp'
+ AlexSkip inp' len_chars -> do
+ checkPosition pos inp inp' len_chars
+ adjustPos (incPos len_chars)
+ setInput inp'
+ lexToken
+ AlexToken inp' len_chars action -> do
+ checkPosition pos inp inp' len_chars
+ adjustPos (incPos len_chars)
+ setInput inp'
+ let !len_bytes = B.length inp - B.length inp'
+ t <- action pos len_bytes inp
+ --traceShow t $ return tok
+ return t
+
+checkPosition :: Position -> ByteString -> ByteString -> Int -> Lex ()
+#ifdef CABAL_PARSEC_DEBUG
+checkPosition pos@(Position lineno colno) inp inp' len_chars = do
+ text_lines <- getDbgText
+ let len_bytes = B.length inp - B.length inp'
+ pos_txt | lineno-1 < V.length text_lines = T.take len_chars (T.drop (colno-1) (text_lines V.! (lineno-1)))
+ | otherwise = T.empty
+ real_txt = B.take len_bytes inp
+ when (pos_txt /= T.decodeUtf8 real_txt) $
+ traceShow (pos, pos_txt, T.decodeUtf8 real_txt) $
+ traceShow (take 3 (V.toList text_lines)) $ return ()
+ where
+ getDbgText = Lex $ \s@LexState{ dbgText = txt } -> LexResult s txt
+#else
+checkPosition _ _ _ _ = return ()
+#endif
+
+lexAll :: Lex [LToken]
+lexAll = do
+ t <- lexToken
+ case t of
+ L _ EOF -> return [t]
+ _ -> do ts <- lexAll
+ return (t : ts)
+
+ltest :: Int -> String -> Prelude.IO ()
+ltest code s =
+ let (ws, xs) = execLexer (setStartCode code >> lexAll) (B.Char8.pack s)
+ in traverse_ print ws >> traverse_ print xs
+
+mkLexState :: ByteString -> LexState
+mkLexState input = LexState
+ { curPos = Position 1 1
+ , curInput = input
+ , curCode = 0
+ , warnings = []
+#ifdef CABAL_PARSEC_DEBUG
+ , dbgText = V.fromList . lines' . T.decodeUtf8With T.lenientDecode $ input
+#endif
+ }
+
+#ifdef CABAL_PARSEC_DEBUG
+lines' :: T.Text -> [T.Text]
+lines' s1
+ | T.null s1 = []
+ | otherwise = case T.break (\c -> c == '\r' || c == '\n') s1 of
+ (l, s2) | Just (c,s3) <- T.uncons s2
+ -> case T.uncons s3 of
+ Just ('\n', s4) | c == '\r' -> l `T.snoc` '\r' `T.snoc` '\n' : lines' s4
+ _ -> l `T.snoc` c : lines' s3
+
+ | otherwise
+ -> [l]
+#endif
+
+bol_field_braces,bol_field_layout,bol_section,in_field_braces,in_field_layout,in_section :: Int
+bol_field_braces = 1
+bol_field_layout = 2
+bol_section = 3
+in_field_braces = 4
+in_field_layout = 5
+in_section = 6
+alex_action_0 = \_ len _ -> do
+ when (len /= 0) $ addWarning LexWarningBOM
+ setStartCode bol_section
+ lexToken
+
+alex_action_1 = \_pos len inp -> checkWhitespace len inp >> adjustPos retPos >> lexToken
+alex_action_3 = \pos len inp -> checkLeadingWhitespace len inp >>
+ if B.length inp == len
+ then return (L pos EOF)
+ else setStartCode in_section
+ >> return (L pos (Indent len))
+alex_action_4 = tok OpenBrace
+alex_action_5 = tok CloseBrace
+alex_action_8 = toki TokSym
+alex_action_9 = \pos len inp -> return $! L pos (TokStr (B.take (len - 2) (B.tail inp)))
+alex_action_10 = toki TokOther
+alex_action_11 = toki TokOther
+alex_action_12 = tok Colon
+alex_action_13 = tok OpenBrace
+alex_action_14 = tok CloseBrace
+alex_action_15 = \_ _ _ -> adjustPos retPos >> setStartCode bol_section >> lexToken
+alex_action_16 = \pos len inp -> checkLeadingWhitespace len inp >>= \len' ->
+ if B.length inp == len
+ then return (L pos EOF)
+ else setStartCode in_field_layout
+ >> return (L pos (Indent len'))
+alex_action_18 = toki TokFieldLine
+alex_action_19 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_layout >> lexToken
+alex_action_20 = \_ _ _ -> setStartCode in_field_braces >> lexToken
+alex_action_22 = toki TokFieldLine
+alex_action_23 = tok OpenBrace
+alex_action_24 = tok CloseBrace
+alex_action_25 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_braces >> lexToken
+{-# LINE 1 "templates/GenericTemplate.hs" #-}
+-- -----------------------------------------------------------------------------
+-- ALEX TEMPLATE
+--
+-- This code is in the PUBLIC DOMAIN; you may copy it freely and use
+-- it for any purpose whatsoever.
+
+-- -----------------------------------------------------------------------------
+-- INTERNALS and main scanner engine
+
+-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.
+#if __GLASGOW_HASKELL__ > 706
+#define GTE(n,m) (tagToEnum# (n >=# m))
+#define EQ(n,m) (tagToEnum# (n ==# m))
+#else
+#define GTE(n,m) (n >=# m)
+#define EQ(n,m) (n ==# m)
+#endif
+
+data AlexAddr = AlexA# Addr#
+-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.
+#if __GLASGOW_HASKELL__ < 503
+uncheckedShiftL# = shiftL#
+#endif
+
+{-# INLINE alexIndexInt16OffAddr #-}
+alexIndexInt16OffAddr (AlexA# arr) off =
+#ifdef WORDS_BIGENDIAN
+ narrow16Int# i
+ where
+ i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)
+ high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
+ low = int2Word# (ord# (indexCharOffAddr# arr off'))
+ off' = off *# 2#
+#else
+ indexInt16OffAddr# arr off
+#endif
+
+{-# INLINE alexIndexInt32OffAddr #-}
+alexIndexInt32OffAddr (AlexA# arr) off =
+#ifdef WORDS_BIGENDIAN
+ narrow32Int# i
+ where
+ i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#`
+ (b2 `uncheckedShiftL#` 16#) `or#`
+ (b1 `uncheckedShiftL#` 8#) `or#` b0)
+ b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#)))
+ b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#)))
+ b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
+ b0 = int2Word# (ord# (indexCharOffAddr# arr off'))
+ off' = off *# 4#
+#else
+ indexInt32OffAddr# arr off
+#endif
+
+#if __GLASGOW_HASKELL__ < 503
+quickIndex arr i = arr ! i
+#else
+-- GHC >= 503, unsafeAt is available from Data.Array.Base.
+quickIndex = unsafeAt
+#endif
+
+-- -----------------------------------------------------------------------------
+-- Main lexing routines
+
+data AlexReturn a
+ = AlexEOF
+ | AlexError !AlexInput
+ | AlexSkip !AlexInput !Int
+ | AlexToken !AlexInput !Int a
+
+-- alexScan :: AlexInput -> StartCode -> AlexReturn a
+alexScan input__ (I# (sc))
+ = alexScanUser undefined input__ (I# (sc))
+
+alexScanUser user__ input__ (I# (sc))
+ = case alex_scan_tkn user__ input__ 0# input__ sc AlexNone of
+ (AlexNone, input__') ->
+ case alexGetByte input__ of
+ Nothing ->
+
+ AlexEOF
+ Just _ ->
+
+ AlexError input__'
+
+ (AlexLastSkip input__'' len, _) ->
+
+ AlexSkip input__'' len
+
+ (AlexLastAcc k input__''' len, _) ->
+
+ AlexToken input__''' len (alex_actions ! k)
+
+-- Push the input through the DFA, remembering the most recent accepting
+-- state it encountered.
+
+alex_scan_tkn user__ orig_input len input__ s last_acc =
+ input__ `seq` -- strict in the input
+ let
+ new_acc = (check_accs (alex_accept `quickIndex` (I# (s))))
+ in
+ new_acc `seq`
+ case alexGetByte input__ of
+ Nothing -> (new_acc, input__)
+ Just (c, new_input) ->
+
+ case fromIntegral c of { (I# (ord_c)) ->
+ let
+ base = alexIndexInt32OffAddr alex_base s
+ offset = (base +# ord_c)
+ check = alexIndexInt16OffAddr alex_check offset
+
+ new_s = if GTE(offset,0#) && EQ(check,ord_c)
+ then alexIndexInt16OffAddr alex_table offset
+ else alexIndexInt16OffAddr alex_deflt s
+ in
+ case new_s of
+ -1# -> (new_acc, input__)
+ -- on an error, we want to keep the input *before* the
+ -- character that failed, not after.
+ _ -> alex_scan_tkn user__ orig_input (if c < 0x80 || c >= 0xC0 then (len +# 1#) else len)
+ -- note that the length is increased ONLY if this is the 1st byte in a char encoding)
+ new_input new_s new_acc
+ }
+ where
+ check_accs (AlexAccNone) = last_acc
+ check_accs (AlexAcc a ) = AlexLastAcc a input__ (I# (len))
+ check_accs (AlexAccSkip) = AlexLastSkip input__ (I# (len))
+
+data AlexLastAcc
+ = AlexNone
+ | AlexLastAcc !Int !AlexInput !Int
+ | AlexLastSkip !AlexInput !Int
+
+data AlexAcc user
+ = AlexAccNone
+ | AlexAcc Int
+ | AlexAccSkip
+
diff --git a/cabal/Cabal/Distribution/Parsec/LexerMonad.hs b/cabal/Cabal/Distribution/Fields/LexerMonad.hs
index 6eb1085..3d1fd64 100644
--- a/cabal/Cabal/Distribution/Parsec/LexerMonad.hs
+++ b/cabal/Cabal/Distribution/Fields/LexerMonad.hs
@@ -1,12 +1,12 @@
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
--- Module : Distribution.Parsec.LexerMonad
+-- Module : Distribution.Fields.LexerMonad
-- License : BSD3
--
-- Maintainer : cabal-devel@haskell.org
-- Portability : portable
-module Distribution.Parsec.LexerMonad (
+module Distribution.Fields.LexerMonad (
InputStream,
LexState(..),
LexResult(..),
@@ -31,9 +31,10 @@ module Distribution.Parsec.LexerMonad (
) where
-import qualified Data.ByteString as B
+import qualified Data.ByteString as B
import Distribution.Compat.Prelude
-import Distribution.Parsec.Common (PWarnType (..), PWarning (..), Position (..), showPos)
+import Distribution.Parsec.Position (Position (..), showPos)
+import Distribution.Parsec.Warning (PWarnType (..), PWarning (..))
import Prelude ()
import qualified Data.Map.Strict as Map
diff --git a/cabal/Cabal/Distribution/Parsec/ParseResult.hs b/cabal/Cabal/Distribution/Fields/ParseResult.hs
index 26c8cbe..52965e2 100644
--- a/cabal/Cabal/Distribution/Parsec/ParseResult.hs
+++ b/cabal/Cabal/Distribution/Fields/ParseResult.hs
@@ -3,7 +3,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
-- | A parse result type for parsers from AST to Haskell types.
-module Distribution.Parsec.ParseResult (
+module Distribution.Fields.ParseResult (
ParseResult,
runParseResult,
recoverWith,
@@ -18,16 +18,16 @@ module Distribution.Parsec.ParseResult (
parseString
) where
-import qualified Data.ByteString.Char8 as BS
-import Distribution.Compat.Prelude
-import Distribution.Parsec.Common
- ( PError (..), PWarnType (..), PWarning (..), Position (..), zeroPos
- , showPWarning, showPError)
-import Distribution.Simple.Utils (die', warn)
-import Distribution.Verbosity (Verbosity)
-import Distribution.Version (Version)
-import Prelude ()
-import System.Directory (doesFileExist)
+import qualified Data.ByteString.Char8 as BS
+import Distribution.Compat.Prelude
+import Distribution.Parsec.Error (PError (..), showPError)
+import Distribution.Parsec.Position (Position (..), zeroPos)
+import Distribution.Parsec.Warning (PWarnType (..), PWarning (..), showPWarning)
+import Distribution.Simple.Utils (die', warn)
+import Distribution.Verbosity (Verbosity)
+import Distribution.Version (Version)
+import Prelude ()
+import System.Directory (doesFileExist)
#if MIN_VERSION_base(4,10,0)
import Control.Applicative (Applicative (..))
@@ -50,13 +50,14 @@ emptyPRState = PRState [] [] Nothing
-- | Destruct a 'ParseResult' into the emitted warnings and either
-- a successful value or
-- list of errors and possibly recovered a spec-version declaration.
-runParseResult :: ParseResult a -> ([PWarning], Either (Maybe Version, [PError]) a)
+runParseResult :: ParseResult a -> ([PWarning], Either (Maybe Version, NonEmpty PError) a)
runParseResult pr = unPR pr emptyPRState failure success
where
- failure (PRState warns errs v) = (warns, Left (v, errs))
- success (PRState warns [] _) x = (warns, Right x)
+ failure (PRState warns [] v) = (warns, Left (v, PError zeroPos "panic" :| []))
+ failure (PRState warns (err:errs) v) = (warns, Left (v, err :| errs)) where
+ success (PRState warns [] _) x = (warns, Right x)
-- If there are any errors, don't return the result
- success (PRState warns errs v) _ = (warns, Left (v, errs))
+ success (PRState warns (err:errs) v) _ = (warns, Left (v, err :| errs))
instance Functor ParseResult where
fmap f (PR pr) = PR $ \ !s failure success ->
diff --git a/cabal/Cabal/Distribution/Parsec/Parser.hs b/cabal/Cabal/Distribution/Fields/Parser.hs
index 742155e..d00d2c1 100644
--- a/cabal/Cabal/Distribution/Parsec/Parser.hs
+++ b/cabal/Cabal/Distribution/Fields/Parser.hs
@@ -4,12 +4,12 @@
{-# LANGUAGE PatternGuards #-}
-----------------------------------------------------------------------------
-- |
--- Module : Distribution.Parsec.Parser
+-- Module : Distribution.Fields.Parser
-- License : BSD3
--
-- Maintainer : cabal-devel@haskell.org
-- Portability : portable
-module Distribution.Parsec.Parser (
+module Distribution.Fields.Parser (
-- * Types
Field(..),
Name(..),
@@ -31,11 +31,11 @@ import Control.Monad (guard)
import qualified Data.ByteString.Char8 as B8
import Data.Functor.Identity
import Distribution.Compat.Prelude
-import Distribution.Parsec.Common
-import Distribution.Parsec.Field
-import Distribution.Parsec.Lexer
-import Distribution.Parsec.LexerMonad
+import Distribution.Fields.Field
+import Distribution.Fields.Lexer
+import Distribution.Fields.LexerMonad
(LexResult (..), LexState (..), LexWarning (..), unLex)
+import Distribution.Parsec.Position (Position (..))
import Prelude ()
import Text.Parsec.Combinator hiding (eof, notFollowedBy)
import Text.Parsec.Error
@@ -161,42 +161,42 @@ inLexerMode (LexerMode mode) p =
-- @
-- CabalStyleFile ::= SecElems
--
--- SecElems ::= SecElem* '\n'?
--- SecElem ::= '\n' SecElemLayout | SecElemBraces
+-- SecElems ::= SecElem* '\\n'?
+-- SecElem ::= '\\n' SecElemLayout | SecElemBraces
-- SecElemLayout ::= FieldLayout | FieldBraces | SectionLayout | SectionBraces
-- SecElemBraces ::= FieldInline | FieldBraces | SectionBraces
--- FieldLayout ::= name ':' line? ('\n' line)*
--- FieldBraces ::= name ':' '\n'? '{' content '}'
+-- FieldLayout ::= name ':' line? ('\\n' line)*
+-- FieldBraces ::= name ':' '\\n'? '{' content '}'
-- FieldInline ::= name ':' content
-- SectionLayout ::= name arg* SecElems
--- SectionBraces ::= name arg* '\n'? '{' SecElems '}'
+-- SectionBraces ::= name arg* '\\n'? '{' SecElems '}'
-- @
--
-- and the same thing but left factored...
--
-- @
-- SecElems ::= SecElem*
--- SecElem ::= '\n' name SecElemLayout
+-- SecElem ::= '\\n' name SecElemLayout
-- | name SecElemBraces
-- SecElemLayout ::= ':' FieldLayoutOrBraces
-- | arg* SectionLayoutOrBraces
--- FieldLayoutOrBraces ::= '\n'? '{' content '}'
--- | line? ('\n' line)*
--- SectionLayoutOrBraces ::= '\n'? '{' SecElems '\n'? '}'
+-- FieldLayoutOrBraces ::= '\\n'? '{' content '}'
+-- | line? ('\\n' line)*
+-- SectionLayoutOrBraces ::= '\\n'? '{' SecElems '\\n'? '}'
-- | SecElems
-- SecElemBraces ::= ':' FieldInlineOrBraces
--- | arg* '\n'? '{' SecElems '\n'? '}'
--- FieldInlineOrBraces ::= '\n'? '{' content '}'
+-- | arg* '\\n'? '{' SecElems '\\n'? '}'
+-- FieldInlineOrBraces ::= '\\n'? '{' content '}'
-- | content
-- @
--
-- Note how we have several productions with the sequence:
--
--- > '\n'? '{'
+-- > '\\n'? '{'
--
-- That is, an optional newline (and indent) followed by a @{@ token.
-- In the @SectionLayoutOrBraces@ case you can see that this makes it
--- not fully left factored (because @SecElems@ can start with a @\n@).
+-- not fully left factored (because @SecElems@ can start with a @\\n@).
-- Fully left factoring here would be ugly, and though we could use a
-- lookahead of two tokens to resolve the alternatives, we can't
-- conveniently use Parsec's 'try' here to get a lookahead of only two.
@@ -223,7 +223,7 @@ elements ilevel = many (element ilevel)
-- layout style or braces style. For layout style then it must start on
-- a line on its own (so that we know its indentation level).
--
--- element ::= '\n' name elementInLayoutContext
+-- element ::= '\\n' name elementInLayoutContext
-- | name elementInNonLayoutContext
element :: IndentLevel -> Parser (Field Position)
element ilevel =
@@ -251,7 +251,7 @@ elementInLayoutContext ilevel name =
-- themselves use braces style, or inline style fields.
--
-- elementInNonLayoutContext ::= ':' FieldInlineOrBraces
--- | arg* '\n'? '{' elements '\n'? '}'
+-- | arg* '\\n'? '{' elements '\\n'? '}'
elementInNonLayoutContext :: Name Position -> Parser (Field Position)
elementInNonLayoutContext name =
(do colon; fieldInlineOrBraces name)
@@ -264,8 +264,8 @@ elementInNonLayoutContext name =
-- The body of a field, using either layout style or braces style.
--
--- fieldLayoutOrBraces ::= '\n'? '{' content '}'
--- | line? ('\n' line)*
+-- fieldLayoutOrBraces ::= '\\n'? '{' content '}'
+-- | line? ('\\n' line)*
fieldLayoutOrBraces :: IndentLevel -> Name Position -> Parser (Field Position)
fieldLayoutOrBraces ilevel name = braces <|> fieldLayout
where
@@ -283,7 +283,7 @@ fieldLayoutOrBraces ilevel name = braces <|> fieldLayout
-- The body of a section, using either layout style or braces style.
--
--- sectionLayoutOrBraces ::= '\n'? '{' elements \n? '}'
+-- sectionLayoutOrBraces ::= '\\n'? '{' elements \\n? '}'
-- | elements
sectionLayoutOrBraces :: IndentLevel -> Parser [Field Position]
sectionLayoutOrBraces ilevel =
@@ -296,7 +296,7 @@ sectionLayoutOrBraces ilevel =
-- The body of a field, using either inline style or braces.
--
--- fieldInlineOrBraces ::= '\n'? '{' content '}'
+-- fieldInlineOrBraces ::= '\\n'? '{' content '}'
-- | content
fieldInlineOrBraces :: Name Position -> Parser (Field Position)
fieldInlineOrBraces name =
diff --git a/cabal/Cabal/Distribution/Fields/Pretty.hs b/cabal/Cabal/Distribution/Fields/Pretty.hs
new file mode 100644
index 0000000..9c673a4
--- /dev/null
+++ b/cabal/Cabal/Distribution/Fields/Pretty.hs
@@ -0,0 +1,163 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE DeriveFoldable #-}
+{-# LANGUAGE DeriveTraversable #-}
+-- | Cabal-like file AST types: 'Field', 'Section' etc,
+--
+-- This (intermediate) data type is used for pretty-printing.
+--
+-- @since 3.0.0.0
+--
+module Distribution.Fields.Pretty (
+ -- * Fields
+ PrettyField (..),
+ showFields,
+ showFields',
+ -- * Transformation from 'P.Field'
+ fromParsecFields,
+ genericFromParsecFields,
+ prettyFieldLines,
+ prettySectionArgs,
+ ) where
+
+import Data.Functor.Identity (Identity (..))
+import Distribution.Compat.Prelude
+import Distribution.Pretty (showToken)
+import Prelude ()
+
+import Distribution.Fields.Field (FieldName)
+import Distribution.Simple.Utils (fromUTF8BS)
+
+import qualified Distribution.Fields.Parser as P
+
+import qualified Data.ByteString as BS
+import qualified Text.PrettyPrint as PP
+
+data PrettyField ann
+ = PrettyField ann FieldName PP.Doc
+ | PrettySection ann FieldName [PP.Doc] [PrettyField ann]
+ deriving (Functor, Foldable, Traversable)
+
+-- | Prettyprint a list of fields.
+--
+-- Note: the first argument should return 'String's without newlines
+-- and properly prefixes (with @--@) to count as comments.
+-- This unsafety is left in place so one could generate empty lines
+-- between comment lines.
+--
+showFields :: (ann -> [String]) -> [PrettyField ann] -> String
+showFields rann = showFields' rann 4
+
+-- | 'showFields' with user specified indentation.
+showFields' :: (ann -> [String]) -> Int -> [PrettyField ann] -> String
+showFields' rann n = unlines . renderFields (Opts rann indent) where
+ -- few hardcoded, "unrolled" variants.
+ indent | n == 4 = indent4
+ | n == 2 = indent2
+ | otherwise = (replicate (max n 1) ' ' ++)
+
+ indent4 :: String -> String
+ indent4 [] = []
+ indent4 xs = ' ' : ' ' : ' ' : ' ' : xs
+
+ indent2 :: String -> String
+ indent2 [] = []
+ indent2 xs = ' ' : ' ' : xs
+
+data Opts ann = Opts (ann -> [String]) (String -> String)
+
+renderFields :: Opts ann -> [PrettyField ann] -> [String]
+renderFields opts fields = flattenBlocks $ map (renderField opts len) fields
+ where
+ len = maxNameLength 0 fields
+
+ maxNameLength !acc [] = acc
+ maxNameLength !acc (PrettyField _ name _ : rest) = maxNameLength (max acc (BS.length name)) rest
+ maxNameLength !acc (PrettySection {} : rest) = maxNameLength acc rest
+
+-- | Block of lines,
+-- Boolean parameter tells whether block should be surrounded by empty lines
+data Block = Block Margin Margin [String]
+
+data Margin = Margin | NoMargin
+ deriving Eq
+
+-- | Collapse margins, any margin = margin
+instance Semigroup Margin where
+ NoMargin <> NoMargin = NoMargin
+ _ <> _ = Margin
+
+flattenBlocks :: [Block] -> [String]
+flattenBlocks = go0 where
+ go0 [] = []
+ go0 (Block _before after strs : blocks) = strs ++ go after blocks
+
+ go _surr' [] = []
+ go surr' (Block before after strs : blocks) = ins $ strs ++ go after blocks where
+ ins | surr' <> before == Margin = ("" :)
+ | otherwise = id
+
+renderField :: Opts ann -> Int -> PrettyField ann -> Block
+renderField (Opts rann indent) fw (PrettyField ann name doc) =
+ Block before after $ comments ++ lines'
+ where
+ comments = rann ann
+ before = if null comments then NoMargin else Margin
+
+ (lines', after) = case lines narrow of
+ [] -> ([ name' ++ ":" ], NoMargin)
+ [singleLine] | length singleLine < 60
+ -> ([ name' ++ ": " ++ replicate (fw - length name') ' ' ++ narrow ], NoMargin)
+ _ -> ((name' ++ ":") : map indent (lines (PP.render doc)), Margin)
+
+ name' = fromUTF8BS name
+ narrow = PP.renderStyle narrowStyle doc
+
+ narrowStyle :: PP.Style
+ narrowStyle = PP.style { PP.lineLength = PP.lineLength PP.style - fw }
+
+renderField opts@(Opts rann indent) _ (PrettySection ann name args fields) = Block Margin Margin $
+ rann ann
+ ++
+ [ PP.render $ PP.hsep $ PP.text (fromUTF8BS name) : args ]
+ ++
+ (map indent $ renderFields opts fields)
+
+-------------------------------------------------------------------------------
+-- Transform from Parsec.Field
+-------------------------------------------------------------------------------
+
+genericFromParsecFields
+ :: Applicative f
+ => (FieldName -> [P.FieldLine ann] -> f PP.Doc) -- ^ transform field contents
+ -> (FieldName -> [P.SectionArg ann] -> f [PP.Doc]) -- ^ transform section arguments
+ -> [P.Field ann]
+ -> f [PrettyField ann]
+genericFromParsecFields f g = goMany where
+ goMany = traverse go
+
+ go (P.Field (P.Name ann name) fls) = PrettyField ann name <$> f name fls
+ go (P.Section (P.Name ann name) secargs fs) = PrettySection ann name <$> g name secargs <*> goMany fs
+
+-- | Used in 'fromParsecFields'.
+prettyFieldLines :: FieldName -> [P.FieldLine ann] -> PP.Doc
+prettyFieldLines _ fls = PP.vcat
+ [ PP.text $ fromUTF8BS bs
+ | P.FieldLine _ bs <- fls
+ ]
+
+-- | Used in 'fromParsecFields'.
+prettySectionArgs :: FieldName -> [P.SectionArg ann] -> [PP.Doc]
+prettySectionArgs _ = map $ \sa -> case sa of
+ P.SecArgName _ bs -> showToken $ fromUTF8BS bs
+ P.SecArgStr _ bs -> showToken $ fromUTF8BS bs
+ P.SecArgOther _ bs -> PP.text $ fromUTF8BS bs
+
+-- | Simple variant of 'genericFromParsecField'
+fromParsecFields :: [P.Field ann] -> [PrettyField ann]
+fromParsecFields = runIdentity . genericFromParsecFields
+ (Identity .: prettyFieldLines)
+ (Identity .: prettySectionArgs)
+ where
+ (.:) :: (a -> b) -> (c -> d -> a) -> (c -> d -> b)
+ (f .: g) x y = f (g x y)
diff --git a/cabal/Cabal/Distribution/InstalledPackageInfo.hs b/cabal/Cabal/Distribution/InstalledPackageInfo.hs
index a5c84b2..a92af01 100644
--- a/cabal/Cabal/Distribution/InstalledPackageInfo.hs
+++ b/cabal/Cabal/Distribution/InstalledPackageInfo.hs
@@ -26,14 +26,12 @@
module Distribution.InstalledPackageInfo (
InstalledPackageInfo(..),
- installedPackageId,
installedComponentId,
installedOpenUnitId,
sourceComponentName,
requiredSignatures,
ExposedModule(..),
AbiDependency(..),
- ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
parseInstalledPackageInfo,
showInstalledPackageInfo,
@@ -51,18 +49,13 @@ import Distribution.CabalSpecVersion (cabalSpecLatest)
import Distribution.FieldGrammar
import Distribution.FieldGrammar.FieldDescrs
import Distribution.ModuleName
-import Distribution.Package hiding (installedPackageId, installedUnitId)
-import Distribution.ParseUtils
+import Distribution.Package hiding (installedUnitId)
import Distribution.Types.ComponentName
import Distribution.Utils.Generic (toUTF8BS)
-import qualified Data.Map as Map
-import qualified Distribution.Parsec.Common as P
-import qualified Distribution.Parsec.Parser as P
-import qualified Distribution.Parsec.ParseResult as P
-import qualified Text.Parsec.Error as Parsec
-import qualified Text.Parsec.Pos as Parsec
-import qualified Text.PrettyPrint as Disp
+import qualified Data.Map as Map
+import qualified Distribution.Fields as P
+import qualified Text.PrettyPrint as Disp
import Distribution.Types.InstalledPackageInfo
import Distribution.Types.InstalledPackageInfo.FieldGrammar
@@ -89,36 +82,29 @@ installedOpenUnitId ipi
requiredSignatures :: InstalledPackageInfo -> Set ModuleName
requiredSignatures ipi = openModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi))
-{-# DEPRECATED installedPackageId "Use installedUnitId instead" #-}
--- | Backwards compatibility with Cabal pre-1.24.
---
--- This type synonym is slightly awful because in cabal-install
--- we define an 'InstalledPackageId' but it's a ComponentId,
--- not a UnitId!
-installedPackageId :: InstalledPackageInfo -> UnitId
-installedPackageId = installedUnitId
-
-- -----------------------------------------------------------------------------
-- Munging
sourceComponentName :: InstalledPackageInfo -> ComponentName
-sourceComponentName ipi =
- case sourceLibName ipi of
- Nothing -> CLibName
- Just qn -> CSubLibName qn
+sourceComponentName = CLibName . sourceLibName
-- -----------------------------------------------------------------------------
-- Parsing
-parseInstalledPackageInfo :: String -> ParseResult InstalledPackageInfo
+-- | Return either errors, or IPI with list of warnings
+--
+-- /Note:/ errors array /may/ be empty, but the parse is still failed (it's a bug though)
+parseInstalledPackageInfo
+ :: String
+ -> Either (NonEmpty String) ([String], InstalledPackageInfo)
parseInstalledPackageInfo s = case P.readFields (toUTF8BS s) of
- Left err -> ParseFailed (NoParse (show err) $ Parsec.sourceLine $ Parsec.errorPos err)
+ Left err -> Left (show err :| [])
Right fs -> case partitionFields fs of
(fs', _) -> case P.runParseResult $ parseFieldGrammar cabalSpecLatest fs' ipiFieldGrammar of
- (ws, Right x) -> ParseOk ws' x where
- ws' = map (PWarning . P.showPWarning "") ws
- (_, Left (_, errs)) -> ParseFailed (NoParse errs' 0) where
- errs' = intercalate "; " $ map (\(P.PError _ msg) -> msg) errs
+ (ws, Right x) -> Right (ws', x) where
+ ws' = map (P.showPWarning "") ws
+ (_, Left (_, errs)) -> Left errs' where
+ errs' = fmap (P.showPError "") errs
-- -----------------------------------------------------------------------------
-- Pretty-printing
@@ -132,7 +118,7 @@ showInstalledPackageInfo ipi =
-- | The variant of 'showInstalledPackageInfo' which outputs @pkgroot@ field too.
showFullInstalledPackageInfo :: InstalledPackageInfo -> String
-showFullInstalledPackageInfo = Disp.render . (Disp.$+$ Disp.text "") . prettyFieldGrammar ipiFieldGrammar
+showFullInstalledPackageInfo = P.showFields (const []) . prettyFieldGrammar cabalSpecLatest ipiFieldGrammar
-- |
--
@@ -141,10 +127,15 @@ showFullInstalledPackageInfo = Disp.render . (Disp.$+$ Disp.text "") . prettyFie
-- Just "maintainer: Tester"
showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showInstalledPackageInfoField fn =
- fmap (\g -> Disp.render . ppField fn . g) $ fieldDescrPretty ipiFieldGrammar fn
+ fmap (\g -> Disp.render . ppField fn . g) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)
showSimpleInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showSimpleInstalledPackageInfoField fn =
- fmap (Disp.renderStyle myStyle .) $ fieldDescrPretty ipiFieldGrammar fn
+ fmap (Disp.renderStyle myStyle .) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)
where
myStyle = Disp.style { Disp.mode = Disp.LeftMode }
+
+ppField :: String -> Disp.Doc -> Disp.Doc
+ppField name fielddoc
+ | Disp.isEmpty fielddoc = mempty
+ | otherwise = Disp.text name <<>> Disp.colon Disp.<+> fielddoc
diff --git a/cabal/Cabal/Distribution/License.hs b/cabal/Cabal/Distribution/License.hs
index 5ca540c..5ec6715 100644
--- a/cabal/Cabal/Distribution/License.hs
+++ b/cabal/Cabal/Distribution/License.hs
@@ -52,14 +52,12 @@ module Distribution.License (
import Distribution.Compat.Prelude
import Prelude ()
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Pretty
-import Distribution.Text
import Distribution.Version
import qualified Distribution.Compat.CharParsing as P
import qualified Data.Map.Strict as Map
-import qualified Distribution.Compat.ReadP as Parse
import qualified Distribution.SPDX as SPDX
import qualified Text.PrettyPrint as Disp
@@ -244,32 +242,11 @@ instance Parsec License where
("AllRightsReserved", Nothing) -> AllRightsReserved
("OtherLicense", Nothing) -> OtherLicense
_ -> UnknownLicense $ name ++
- maybe "" (('-':) . display) version
-
-instance Text License where
- parse = do
- name <- Parse.munch1 (\c -> isAlphaNum c && c /= '-')
- version <- Parse.option Nothing (Parse.char '-' >> fmap Just parse)
- return $! case (name, version :: Maybe Version) of
- ("GPL", _ ) -> GPL version
- ("LGPL", _ ) -> LGPL version
- ("AGPL", _ ) -> AGPL version
- ("BSD2", Nothing) -> BSD2
- ("BSD3", Nothing) -> BSD3
- ("BSD4", Nothing) -> BSD4
- ("ISC", Nothing) -> ISC
- ("MIT", Nothing) -> MIT
- ("MPL", Just version') -> MPL version'
- ("Apache", _ ) -> Apache version
- ("PublicDomain", Nothing) -> PublicDomain
- ("AllRightsReserved", Nothing) -> AllRightsReserved
- ("OtherLicense", Nothing) -> OtherLicense
- _ -> UnknownLicense $ name ++
- maybe "" (('-':) . display) version
+ maybe "" (('-':) . prettyShow) version
dispOptVersion :: Maybe Version -> Disp.Doc
dispOptVersion Nothing = Disp.empty
dispOptVersion (Just v) = dispVersion v
dispVersion :: Version -> Disp.Doc
-dispVersion v = Disp.char '-' <<>> disp v
+dispVersion v = Disp.char '-' <<>> pretty v
diff --git a/cabal/Cabal/Distribution/Make.hs b/cabal/Cabal/Distribution/Make.hs
index 50491ca..cde201e 100644
--- a/cabal/Cabal/Distribution/Make.hs
+++ b/cabal/Cabal/Distribution/Make.hs
@@ -60,7 +60,7 @@
module Distribution.Make (
module Distribution.Package,
License(..), Version,
- defaultMain, defaultMainArgs, defaultMainNoRead
+ defaultMain, defaultMainArgs
) where
import Prelude ()
@@ -70,7 +70,6 @@ import Distribution.Compat.Prelude
import Distribution.Compat.Exception
import Distribution.Package
import Distribution.Simple.Program
-import Distribution.PackageDescription
import Distribution.Simple.Setup
import Distribution.Simple.Command
@@ -78,7 +77,7 @@ import Distribution.Simple.Utils
import Distribution.License
import Distribution.Version
-import Distribution.Text
+import Distribution.Pretty
import System.Environment (getArgs, getProgName)
import System.Exit
@@ -89,10 +88,6 @@ defaultMain = getArgs >>= defaultMainArgs
defaultMainArgs :: [String] -> IO ()
defaultMainArgs = defaultMainHelper
-{-# DEPRECATED defaultMainNoRead "it ignores its PackageDescription arg" #-}
-defaultMainNoRead :: PackageDescription -> IO ()
-defaultMainNoRead = const defaultMain
-
defaultMainHelper :: [String] -> IO ()
defaultMainHelper args =
case commandsRun (globalCommand commands) commands args of
@@ -114,9 +109,9 @@ defaultMainHelper args =
printErrors errs = do
putStr (intercalate "\n" errs)
exitWith (ExitFailure 1)
- printNumericVersion = putStrLn $ display cabalVersion
+ printNumericVersion = putStrLn $ prettyShow cabalVersion
printVersion = putStrLn $ "Cabal library version "
- ++ display cabalVersion
+ ++ prettyShow cabalVersion
progs = defaultProgramDb
commands =
diff --git a/cabal/Cabal/Distribution/ModuleName.hs b/cabal/Cabal/Distribution/ModuleName.hs
index fd5d608..e004fd1 100644
--- a/cabal/Cabal/Distribution/ModuleName.hs
+++ b/cabal/Cabal/Distribution/ModuleName.hs
@@ -19,7 +19,6 @@ module Distribution.ModuleName (
components,
toFilePath,
main,
- simple,
-- * Internal
validModuleComponent,
) where
@@ -31,11 +30,9 @@ import Distribution.Utils.ShortText
import System.FilePath ( pathSeparator )
import Distribution.Pretty
-import Distribution.Parsec.Class
-import Distribution.Text
+import Distribution.Parsec
import qualified Distribution.Compat.CharParsing as P
-import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
-- | A valid Haskell module name.
@@ -60,17 +57,6 @@ instance Parsec ModuleName where
cs <- P.munch validModuleChar
return (c:cs)
-instance Text ModuleName where
- parse = do
- ms <- Parse.sepBy1 component (Parse.char '.')
- return (ModuleName $ stlFromStrings ms)
-
- where
- component = do
- c <- Parse.satisfy isUpper
- cs <- Parse.munch validModuleChar
- return (c:cs)
-
validModuleChar :: Char -> Bool
validModuleChar c = isAlphaNum c || c == '_' || c == '\''
@@ -79,10 +65,6 @@ validModuleComponent [] = False
validModuleComponent (c:cs) = isUpper c
&& all validModuleChar cs
-{-# DEPRECATED simple "use ModuleName.fromString instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
-simple :: String -> ModuleName
-simple str = ModuleName (stlFromStrings [str])
-
-- | Construct a 'ModuleName' from a valid module name 'String'.
--
-- This is just a convenience function intended for valid module strings. It is
diff --git a/cabal/Cabal/Distribution/Package.hs b/cabal/Cabal/Distribution/Package.hs
index 0b467d1..6c2950b 100644
--- a/cabal/Cabal/Distribution/Package.hs
+++ b/cabal/Cabal/Distribution/Package.hs
@@ -28,7 +28,6 @@ module Distribution.Package
, Package(..), packageName, packageVersion
, HasMungedPackageId(..), mungedName', mungedVersion'
, HasUnitId(..)
- , installedPackageId
, PackageInstalled(..)
) where
@@ -87,11 +86,6 @@ instance HasMungedPackageId MungedPackageId where
class Package pkg => HasUnitId pkg where
installedUnitId :: pkg -> UnitId
-{-# DEPRECATED installedPackageId "Use installedUnitId instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
--- | Compatibility wrapper for Cabal pre-1.24.
-installedPackageId :: HasUnitId pkg => pkg -> UnitId
-installedPackageId = installedUnitId
-
-- | Class of installed packages.
--
-- The primary data type which is an instance of this package is
diff --git a/cabal/Cabal/Distribution/PackageDescription.hs b/cabal/Cabal/Distribution/PackageDescription.hs
index afa23f8..8c0d6d4 100644
--- a/cabal/Cabal/Distribution/PackageDescription.hs
+++ b/cabal/Cabal/Distribution/PackageDescription.hs
@@ -20,7 +20,6 @@ module Distribution.PackageDescription (
specVersion,
buildType,
license,
- descCabalVersion,
BuildType(..),
knownBuildTypes,
allLibraries,
@@ -38,7 +37,6 @@ module Distribution.PackageDescription (
hasLibs,
explicitLibModules,
libModulesAutogen,
- libModules,
-- ** Executables
Executable(..),
@@ -89,6 +87,7 @@ module Distribution.PackageDescription (
allBuildDepends,
enabledBuildDepends,
ComponentName(..),
+ LibraryName(..),
defaultLibName,
HookedBuildInfo,
emptyHookedBuildInfo,
@@ -101,7 +100,7 @@ module Distribution.PackageDescription (
FlagAssignment, mkFlagAssignment, unFlagAssignment,
nullFlagAssignment, showFlagValue,
diffFlagAssignment, lookupFlagAssignment, insertFlagAssignment,
- dispFlagAssignment, parseFlagAssignment, parsecFlagAssignment,
+ dispFlagAssignment, parsecFlagAssignment,
findDuplicateFlagAssignments,
CondTree(..), ConfVar(..), Condition(..),
cNot, cAnd, cOr,
@@ -138,5 +137,6 @@ import Distribution.Types.CondTree
import Distribution.Types.Condition
import Distribution.Types.PackageDescription
import Distribution.Types.ComponentName
+import Distribution.Types.LibraryName
import Distribution.Types.HookedBuildInfo
import Distribution.Types.SourceRepo
diff --git a/cabal/Cabal/Distribution/PackageDescription/Check.hs b/cabal/Cabal/Distribution/PackageDescription/Check.hs
index 7814967..734e52c 100644
--- a/cabal/Cabal/Distribution/PackageDescription/Check.hs
+++ b/cabal/Cabal/Distribution/PackageDescription/Check.hs
@@ -52,10 +52,10 @@ import Distribution.Simple.CCompiler
import Distribution.Simple.Glob
import Distribution.Simple.Utils hiding (findPackageDesc, notice)
import Distribution.System
-import Distribution.Text
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.CondTree
import Distribution.Types.ExeDependency
+import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
import Distribution.Utils.Generic (isAscii)
import Distribution.Verbosity
@@ -165,7 +165,7 @@ checkConfiguredPackage pkg =
++ checkFields pkg
++ checkLicense pkg
++ checkSourceRepos pkg
- ++ checkGhcOptions pkg
+ ++ checkAllGhcOptions pkg
++ checkCCOptions pkg
++ checkCxxOptions pkg
++ checkCPPOptions pkg
@@ -197,7 +197,7 @@ checkSanity pkg =
PackageBuildImpossible
"No executables, libraries, tests, or benchmarks found. Nothing to do."
- , check (any isNothing (map libName $ subLibraries pkg)) $
+ , check (any (== LMainLibName) (map libName $ subLibraries pkg)) $
PackageBuildImpossible $ "Found one or more unnamed internal libraries. "
++ "Only the non-internal library can have the same name as the package."
@@ -210,13 +210,13 @@ checkSanity pkg =
-- NB: but it's OK for executables to have the same name!
-- TODO shouldn't need to compare on the string level
- , check (any (== display (packageName pkg)) (display <$> subLibNames)) $
+ , check (any (== prettyShow (packageName pkg)) (prettyShow <$> subLibNames)) $
PackageBuildImpossible $ "Illegal internal library name "
- ++ display (packageName pkg)
+ ++ prettyShow (packageName pkg)
++ ". Internal libraries cannot have the same name as the package."
++ " Maybe you wanted a non-internal library?"
++ " If so, rewrite the section stanza"
- ++ " from 'library: '" ++ display (packageName pkg) ++ "' to 'library'."
+ ++ " from 'library: '" ++ prettyShow (packageName pkg) ++ "' to 'library'."
]
--TODO: check for name clashes case insensitively: windows file systems cannot
--cope.
@@ -231,14 +231,14 @@ checkSanity pkg =
check (specVersion pkg > cabalVersion) $
PackageBuildImpossible $
"This package description follows version "
- ++ display (specVersion pkg) ++ " of the Cabal specification. This "
- ++ "tool only supports up to version " ++ display cabalVersion ++ "."
+ ++ prettyShow (specVersion pkg) ++ " of the Cabal specification. This "
+ ++ "tool only supports up to version " ++ prettyShow cabalVersion ++ "."
]
where
-- The public 'library' gets special dispensation, because it
-- is common practice to export a library and name the executable
-- the same as the package.
- subLibNames = catMaybes . map libName $ subLibraries pkg
+ subLibNames = mapMaybe (libraryNameString . libName) $ subLibraries pkg
exeNames = map exeName $ executables pkg
testNames = map testName $ testSuites pkg
bmNames = map benchmarkName $ benchmarks pkg
@@ -251,15 +251,12 @@ checkLibrary pkg lib =
check (not (null moduleDuplicates)) $
PackageBuildImpossible $
"Duplicate modules in library: "
- ++ commaSep (map display moduleDuplicates)
+ ++ commaSep (map prettyShow moduleDuplicates)
-- TODO: This check is bogus if a required-signature was passed through
, check (null (explicitLibModules lib) && null (reexportedModules lib)) $
PackageDistSuspiciousWarn $
- "Library " ++ (case libName lib of
- Nothing -> ""
- Just n -> display n
- ) ++ "does not expose any modules"
+ showLibraryName (libName lib) ++ " does not expose any modules"
-- check use of signatures sections
, checkVersion [1,25] (not (null (signatures lib))) $
@@ -274,6 +271,12 @@ checkLibrary pkg lib =
"An 'autogen-module' is neither on 'exposed-modules' or "
++ "'other-modules'."
+ -- check that all autogen-includes appear on includes or install-includes
+ , check
+ (not $ and $ map (flip elem (allExplicitIncludes lib)) (view L.autogenIncludes lib)) $
+ PackageBuildImpossible $
+ "An include in 'autogen-includes' is neither in 'includes' or "
+ ++ "'install-includes'."
]
where
@@ -286,13 +289,16 @@ checkLibrary pkg lib =
moduleDuplicates = dups (explicitLibModules lib ++
map moduleReexportName (reexportedModules lib))
+allExplicitIncludes :: L.HasBuildInfo a => a -> [FilePath]
+allExplicitIncludes x = view L.includes x ++ view L.installIncludes x
+
checkExecutable :: PackageDescription -> Executable -> [PackageCheck]
checkExecutable pkg exe =
catMaybes [
check (null (modulePath exe)) $
PackageBuildImpossible $
- "No 'main-is' field found for executable " ++ display (exeName exe)
+ "No 'main-is' field found for executable " ++ prettyShow (exeName exe)
, check (not (null (modulePath exe))
&& (not $ fileExtensionSupportedLanguage $ modulePath exe)) $
@@ -310,15 +316,20 @@ checkExecutable pkg exe =
, check (not (null moduleDuplicates)) $
PackageBuildImpossible $
- "Duplicate modules in executable '" ++ display (exeName exe) ++ "': "
- ++ commaSep (map display moduleDuplicates)
+ "Duplicate modules in executable '" ++ prettyShow (exeName exe) ++ "': "
+ ++ commaSep (map prettyShow moduleDuplicates)
-- check that all autogen-modules appear on other-modules
, check
(not $ and $ map (flip elem (exeModules exe)) (exeModulesAutogen exe)) $
PackageBuildImpossible $
- "On executable '" ++ display (exeName exe) ++ "' an 'autogen-module' is not "
+ "On executable '" ++ prettyShow (exeName exe) ++ "' an 'autogen-module' is not "
++ "on 'other-modules'"
+
+ -- check that all autogen-includes appear on includes
+ , check
+ (not $ and $ map (flip elem (view L.includes exe)) (view L.autogenIncludes exe)) $
+ PackageBuildImpossible "An include in 'autogen-includes' is not in 'includes'."
]
where
moduleDuplicates = dups (exeModules exe)
@@ -330,21 +341,21 @@ checkTestSuite pkg test =
case testInterface test of
TestSuiteUnsupported tt@(TestTypeUnknown _ _) -> Just $
PackageBuildWarning $
- quote (display tt) ++ " is not a known type of test suite. "
+ quote (prettyShow tt) ++ " is not a known type of test suite. "
++ "The known test suite types are: "
- ++ commaSep (map display knownTestTypes)
+ ++ commaSep (map prettyShow knownTestTypes)
TestSuiteUnsupported tt -> Just $
PackageBuildWarning $
- quote (display tt) ++ " is not a supported test suite version. "
+ quote (prettyShow tt) ++ " is not a supported test suite version. "
++ "The known test suite types are: "
- ++ commaSep (map display knownTestTypes)
+ ++ commaSep (map prettyShow knownTestTypes)
_ -> Nothing
, check (not $ null moduleDuplicates) $
PackageBuildImpossible $
- "Duplicate modules in test suite '" ++ display (testName test) ++ "': "
- ++ commaSep (map display moduleDuplicates)
+ "Duplicate modules in test suite '" ++ prettyShow (testName test) ++ "': "
+ ++ commaSep (map prettyShow moduleDuplicates)
, check mainIsWrongExt $
PackageBuildImpossible $
@@ -359,13 +370,15 @@ checkTestSuite pkg test =
-- check that all autogen-modules appear on other-modules
, check
- (not $ and $ map
- (flip elem (testModules test))
- (testModulesAutogen test)
- ) $
+ (not $ and $ map (flip elem (testModules test)) (testModulesAutogen test)) $
PackageBuildImpossible $
- "On test suite '" ++ display (testName test) ++ "' an 'autogen-module' is not "
+ "On test suite '" ++ prettyShow (testName test) ++ "' an 'autogen-module' is not "
++ "on 'other-modules'"
+
+ -- check that all autogen-includes appear on includes
+ , check
+ (not $ and $ map (flip elem (view L.includes test)) (view L.autogenIncludes test)) $
+ PackageBuildImpossible "An include in 'autogen-includes' is not in 'includes'."
]
where
moduleDuplicates = dups $ testModules test
@@ -385,21 +398,21 @@ checkBenchmark _pkg bm =
case benchmarkInterface bm of
BenchmarkUnsupported tt@(BenchmarkTypeUnknown _ _) -> Just $
PackageBuildWarning $
- quote (display tt) ++ " is not a known type of benchmark. "
+ quote (prettyShow tt) ++ " is not a known type of benchmark. "
++ "The known benchmark types are: "
- ++ commaSep (map display knownBenchmarkTypes)
+ ++ commaSep (map prettyShow knownBenchmarkTypes)
BenchmarkUnsupported tt -> Just $
PackageBuildWarning $
- quote (display tt) ++ " is not a supported benchmark version. "
+ quote (prettyShow tt) ++ " is not a supported benchmark version. "
++ "The known benchmark types are: "
- ++ commaSep (map display knownBenchmarkTypes)
+ ++ commaSep (map prettyShow knownBenchmarkTypes)
_ -> Nothing
, check (not $ null moduleDuplicates) $
PackageBuildImpossible $
- "Duplicate modules in benchmark '" ++ display (benchmarkName bm) ++ "': "
- ++ commaSep (map display moduleDuplicates)
+ "Duplicate modules in benchmark '" ++ prettyShow (benchmarkName bm) ++ "': "
+ ++ commaSep (map prettyShow moduleDuplicates)
, check mainIsWrongExt $
PackageBuildImpossible $
@@ -408,13 +421,15 @@ checkBenchmark _pkg bm =
-- check that all autogen-modules appear on other-modules
, check
- (not $ and $ map
- (flip elem (benchmarkModules bm))
- (benchmarkModulesAutogen bm)
- ) $
+ (not $ and $ map (flip elem (benchmarkModules bm)) (benchmarkModulesAutogen bm)) $
PackageBuildImpossible $
- "On benchmark '" ++ display (benchmarkName bm) ++ "' an 'autogen-module' is "
+ "On benchmark '" ++ prettyShow (benchmarkName bm) ++ "' an 'autogen-module' is "
++ "not on 'other-modules'"
+
+ -- check that all autogen-includes appear on includes
+ , check
+ (not $ and $ map (flip elem (view L.includes bm)) (view L.autogenIncludes bm)) $
+ PackageBuildImpossible "An include in 'autogen-includes' is not in 'includes'."
]
where
moduleDuplicates = dups $ benchmarkModules bm
@@ -431,14 +446,14 @@ checkFields :: PackageDescription -> [PackageCheck]
checkFields pkg =
catMaybes [
- check (not . FilePath.Windows.isValid . display . packageName $ pkg) $
+ check (not . FilePath.Windows.isValid . prettyShow . packageName $ pkg) $
PackageDistInexcusable $
- "Unfortunately, the package name '" ++ display (packageName pkg)
+ "Unfortunately, the package name '" ++ prettyShow (packageName pkg)
++ "' is one of the reserved system file names on Windows. Many tools "
++ "need to convert package names to file names so using this name "
++ "would cause problems."
- , check ((isPrefixOf "z-") . display . packageName $ pkg) $
+ , check ((isPrefixOf "z-") . prettyShow . packageName $ pkg) $
PackageDistInexcusable $
"Package names with the prefix 'z-' are reserved by Cabal and "
++ "cannot be used."
@@ -477,10 +492,10 @@ checkFields pkg =
, check (not (null ourDeprecatedExtensions)) $
PackageDistSuspicious $
"Deprecated extensions: "
- ++ commaSep (map (quote . display . fst) ourDeprecatedExtensions)
+ ++ commaSep (map (quote . prettyShow . fst) ourDeprecatedExtensions)
++ ". " ++ unwords
- [ "Instead of '" ++ display ext
- ++ "' use '" ++ display replacement ++ "'."
+ [ "Instead of '" ++ prettyShow ext
+ ++ "' use '" ++ prettyShow replacement ++ "'."
| (ext, Just replacement) <- ourDeprecatedExtensions ]
, check (null (category pkg)) $
@@ -526,20 +541,17 @@ checkFields pkg =
, check (not (null testedWithImpossibleRanges)) $
PackageDistInexcusable $
"Invalid 'tested-with' version range: "
- ++ commaSep (map display testedWithImpossibleRanges)
+ ++ commaSep (map prettyShow testedWithImpossibleRanges)
++ ". To indicate that you have tested a package with multiple "
++ "different versions of the same compiler use multiple entries, "
++ "for example 'tested-with: GHC==6.10.4, GHC==6.12.3' and not "
++ "'tested-with: GHC==6.10.4 && ==6.12.3'."
- -- Disabled due to #5119: we generate loads of spurious instances of
- -- this warning. Re-enabling this check should be part of the fix to
- -- #5119.
- , check (False && not (null depInternalLibraryWithExtraVersion)) $
+ , check (not (null depInternalLibraryWithExtraVersion)) $
PackageBuildWarning $
"The package has an extraneous version range for a dependency on an "
++ "internal library: "
- ++ commaSep (map display depInternalLibraryWithExtraVersion)
+ ++ commaSep (map prettyShow depInternalLibraryWithExtraVersion)
++ ". This version range includes the current package but isn't needed "
++ "as the current package's library will always be used."
@@ -547,7 +559,7 @@ checkFields pkg =
PackageBuildImpossible $
"The package has an impossible version range for a dependency on an "
++ "internal library: "
- ++ commaSep (map display depInternalLibraryWithImpossibleVersion)
+ ++ commaSep (map prettyShow depInternalLibraryWithImpossibleVersion)
++ ". This version range does not include the current package, and must "
++ "be removed as the current package's library will always be used."
@@ -555,7 +567,7 @@ checkFields pkg =
PackageBuildWarning $
"The package has an extraneous version range for a dependency on an "
++ "internal executable: "
- ++ commaSep (map display depInternalExecutableWithExtraVersion)
+ ++ commaSep (map prettyShow depInternalExecutableWithExtraVersion)
++ ". This version range includes the current package but isn't needed "
++ "as the current package's executable will always be used."
@@ -563,14 +575,14 @@ checkFields pkg =
PackageBuildImpossible $
"The package has an impossible version range for a dependency on an "
++ "internal executable: "
- ++ commaSep (map display depInternalExecutableWithImpossibleVersion)
+ ++ commaSep (map prettyShow depInternalExecutableWithImpossibleVersion)
++ ". This version range does not include the current package, and must "
++ "be removed as the current package's executable will always be used."
, check (not (null depMissingInternalExecutable)) $
PackageBuildImpossible $
"The package depends on a missing internal executable: "
- ++ commaSep (map display depInternalExecutableWithImpossibleVersion)
+ ++ commaSep (map prettyShow depInternalExecutableWithImpossibleVersion)
]
where
unknownCompilers = [ name | (OtherCompiler name, _) <- testedWith pkg ]
@@ -578,7 +590,7 @@ checkFields pkg =
, UnknownLanguage name <- allLanguages bi ]
unknownExtensions = [ name | bi <- allBuildInfo pkg
, UnknownExtension name <- allExtensions bi
- , name `notElem` map display knownLanguages ]
+ , name `notElem` map prettyShow knownLanguages ]
ourDeprecatedExtensions = nub $ catMaybes
[ find ((==ext) . fst) deprecatedExtensions
| bi <- allBuildInfo pkg
@@ -586,15 +598,15 @@ checkFields pkg =
languagesUsedAsExtensions =
[ name | bi <- allBuildInfo pkg
, UnknownExtension name <- allExtensions bi
- , name `elem` map display knownLanguages ]
+ , name `elem` map prettyShow knownLanguages ]
testedWithImpossibleRanges =
- [ Dependency (mkPackageName (display compiler)) vr
+ [ Dependency (mkPackageName (prettyShow compiler)) vr Set.empty
| (compiler, vr) <- testedWith pkg
, isNoVersion vr ]
internalLibraries =
- map (maybe (packageName pkg) (unqualComponentNameToPackageName) . libName)
+ map (maybe (packageName pkg) (unqualComponentNameToPackageName) . libraryNameString . libName)
(allLibraries pkg)
internalExecutables = map exeName $ executables pkg
@@ -602,7 +614,7 @@ checkFields pkg =
internalLibDeps =
[ dep
| bi <- allBuildInfo pkg
- , dep@(Dependency name _) <- targetBuildDepends bi
+ , dep@(Dependency name _ _) <- targetBuildDepends bi
, name `elem` internalLibraries
]
@@ -615,14 +627,14 @@ checkFields pkg =
depInternalLibraryWithExtraVersion =
[ dep
- | dep@(Dependency _ versionRange) <- internalLibDeps
+ | dep@(Dependency _ versionRange _) <- internalLibDeps
, not $ isAnyVersion versionRange
, packageVersion pkg `withinRange` versionRange
]
depInternalLibraryWithImpossibleVersion =
[ dep
- | dep@(Dependency _ versionRange) <- internalLibDeps
+ | dep@(Dependency _ versionRange _) <- internalLibDeps
, not $ packageVersion pkg `withinRange` versionRange
]
@@ -680,7 +692,7 @@ checkOldLicense pkg lic = catMaybes
PackageBuildWarning $
quote ("license: " ++ l) ++ " is not a recognised license. The "
++ "known licenses are: "
- ++ commaSep (map display knownLicenses)
+ ++ commaSep (map prettyShow knownLicenses)
_ -> Nothing
, check (lic == BSD4) $
@@ -692,9 +704,9 @@ checkOldLicense pkg lic = catMaybes
, case unknownLicenseVersion (lic) of
Just knownVersions -> Just $
PackageDistSuspicious $
- "'license: " ++ display (lic) ++ "' is not a known "
+ "'license: " ++ prettyShow (lic) ++ "' is not a known "
++ "version of that license. The known versions are "
- ++ commaSep (map display knownVersions)
+ ++ commaSep (map prettyShow knownVersions)
++ ". If this is not a mistake and you think it should be a known "
++ "version then please file a ticket."
_ -> Nothing
@@ -766,86 +778,97 @@ checkSourceRepos pkg =
--TODO: check location looks like a URL for some repo types.
-checkGhcOptions :: PackageDescription -> [PackageCheck]
-checkGhcOptions pkg =
+-- | Checks GHC options from all ghc-*-options fields in the given
+-- PackageDescription and reports commonly misused or non-portable flags
+checkAllGhcOptions :: PackageDescription -> [PackageCheck]
+checkAllGhcOptions pkg =
+ checkGhcOptions "ghc-options" (hcOptions GHC) pkg
+ ++ checkGhcOptions "ghc-prof-options" (hcProfOptions GHC) pkg
+ ++ checkGhcOptions "ghc-shared-options" (hcSharedOptions GHC) pkg
+
+-- | Extracts GHC options belonging to the given field from the given
+-- PackageDescription using given function and checks them for commonly misused
+-- or non-portable flags
+checkGhcOptions :: String -> (BuildInfo -> [String]) -> PackageDescription -> [PackageCheck]
+checkGhcOptions fieldName getOptions pkg =
catMaybes [
checkFlags ["-fasm"] $
PackageDistInexcusable $
- "'ghc-options: -fasm' is unnecessary and will not work on CPU "
+ "'" ++ fieldName ++ ": -fasm' is unnecessary and will not work on CPU "
++ "architectures other than x86, x86-64, ppc or sparc."
, checkFlags ["-fvia-C"] $
PackageDistSuspicious $
- "'ghc-options: -fvia-C' is usually unnecessary. If your package "
+ "'" ++ fieldName ++": -fvia-C' is usually unnecessary. If your package "
++ "needs -via-C for correctness rather than performance then it "
++ "is using the FFI incorrectly and will probably not work with GHC "
++ "6.10 or later."
, checkFlags ["-fhpc"] $
PackageDistInexcusable $
- "'ghc-options: -fhpc' is not not necessary. Use the configure flag "
+ "'" ++ fieldName ++ ": -fhpc' is not not necessary. Use the configure flag "
++ " --enable-coverage instead."
, checkFlags ["-prof"] $
PackageBuildWarning $
- "'ghc-options: -prof' is not necessary and will lead to problems "
+ "'" ++ fieldName ++ ": -prof' is not necessary and will lead to problems "
++ "when used on a library. Use the configure flag "
++ "--enable-library-profiling and/or --enable-profiling."
, checkFlags ["-o"] $
PackageBuildWarning $
- "'ghc-options: -o' is not needed. "
+ "'" ++ fieldName ++ ": -o' is not needed. "
++ "The output files are named automatically."
, checkFlags ["-hide-package"] $
PackageBuildWarning $
- "'ghc-options: -hide-package' is never needed. "
+ "'" ++ fieldName ++ ": -hide-package' is never needed. "
++ "Cabal hides all packages."
, checkFlags ["--make"] $
PackageBuildWarning $
- "'ghc-options: --make' is never needed. Cabal uses this automatically."
+ "'" ++ fieldName ++ ": --make' is never needed. Cabal uses this automatically."
, checkFlags ["-main-is"] $
PackageDistSuspicious $
- "'ghc-options: -main-is' is not portable."
+ "'" ++ fieldName ++ ": -main-is' is not portable."
, checkNonTestAndBenchmarkFlags ["-O0", "-Onot"] $
PackageDistSuspicious $
- "'ghc-options: -O0' is not needed. "
+ "'" ++ fieldName ++ ": -O0' is not needed. "
++ "Use the --disable-optimization configure flag."
, checkTestAndBenchmarkFlags ["-O0", "-Onot"] $
PackageDistSuspiciousWarn $
- "'ghc-options: -O0' is not needed. "
+ "'" ++ fieldName ++ ": -O0' is not needed. "
++ "Use the --disable-optimization configure flag."
, checkFlags [ "-O", "-O1"] $
PackageDistInexcusable $
- "'ghc-options: -O' is not needed. "
+ "'" ++ fieldName ++ ": -O' is not needed. "
++ "Cabal automatically adds the '-O' flag. "
++ "Setting it yourself interferes with the --disable-optimization flag."
, checkFlags ["-O2"] $
PackageDistSuspiciousWarn $
- "'ghc-options: -O2' is rarely needed. "
+ "'" ++ fieldName ++ ": -O2' is rarely needed. "
++ "Check that it is giving a real benefit "
++ "and not just imposing longer compile times on your users."
, checkFlags ["-split-sections"] $
PackageBuildWarning $
- "'ghc-options: -split-sections' is not needed. "
+ "'" ++ fieldName ++ ": -split-sections' is not needed. "
++ "Use the --enable-split-sections configure flag."
, checkFlags ["-split-objs"] $
PackageBuildWarning $
- "'ghc-options: -split-objs' is not needed. "
+ "'" ++ fieldName ++ ": -split-objs' is not needed. "
++ "Use the --enable-split-objs configure flag."
, checkFlags ["-optl-Wl,-s", "-optl-s"] $
PackageDistInexcusable $
- "'ghc-options: -optl-Wl,-s' is not needed and is not portable to all"
+ "'" ++ fieldName ++ ": -optl-Wl,-s' is not needed and is not portable to all"
++ " operating systems. Cabal 1.4 and later automatically strip"
++ " executables. Cabal also has a flag --disable-executable-stripping"
++ " which is necessary when building packages for some Linux"
@@ -853,67 +876,64 @@ checkGhcOptions pkg =
, checkFlags ["-fglasgow-exts"] $
PackageDistSuspicious $
- "Instead of 'ghc-options: -fglasgow-exts' it is preferable to use "
+ "Instead of '" ++ fieldName ++ ": -fglasgow-exts' it is preferable to use "
++ "the 'extensions' field."
, check ("-threaded" `elem` lib_ghc_options) $
PackageBuildWarning $
- "'ghc-options: -threaded' has no effect for libraries. It should "
+ "'" ++ fieldName ++ ": -threaded' has no effect for libraries. It should "
++ "only be used for executables."
, check ("-rtsopts" `elem` lib_ghc_options) $
PackageBuildWarning $
- "'ghc-options: -rtsopts' has no effect for libraries. It should "
+ "'" ++ fieldName ++ ": -rtsopts' has no effect for libraries. It should "
++ "only be used for executables."
, check (any (\opt -> "-with-rtsopts" `isPrefixOf` opt) lib_ghc_options) $
PackageBuildWarning $
- "'ghc-options: -with-rtsopts' has no effect for libraries. It "
+ "'" ++ fieldName ++ ": -with-rtsopts' has no effect for libraries. It "
++ "should only be used for executables."
- , checkAlternatives "ghc-options" "extensions"
- [ (flag, display extension) | flag <- all_ghc_options
+ , checkAlternatives fieldName "extensions"
+ [ (flag, prettyShow extension) | flag <- all_ghc_options
, Just extension <- [ghcExtension flag] ]
- , checkAlternatives "ghc-options" "extensions"
+ , checkAlternatives fieldName "extensions"
[ (flag, extension) | flag@('-':'X':extension) <- all_ghc_options ]
- , checkAlternatives "ghc-options" "cpp-options" $
+ , checkAlternatives fieldName "cpp-options" $
[ (flag, flag) | flag@('-':'D':_) <- all_ghc_options ]
++ [ (flag, flag) | flag@('-':'U':_) <- all_ghc_options ]
- , checkAlternatives "ghc-options" "include-dirs"
+ , checkAlternatives fieldName "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_ghc_options ]
- , checkAlternatives "ghc-options" "extra-libraries"
+ , checkAlternatives fieldName "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ghc_options ]
- , checkAlternatives "ghc-options" "extra-lib-dirs"
+ , checkAlternatives fieldName "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ghc_options ]
- , checkAlternatives "ghc-options" "frameworks"
+ , checkAlternatives fieldName "frameworks"
[ (flag, fmwk) | (flag@"-framework", fmwk) <-
zip all_ghc_options (safeTail all_ghc_options) ]
- , checkAlternatives "ghc-options" "extra-framework-dirs"
+ , checkAlternatives fieldName "extra-framework-dirs"
[ (flag, dir) | (flag@"-framework-path", dir) <-
zip all_ghc_options (safeTail all_ghc_options) ]
]
where
- all_ghc_options = concatMap get_ghc_options (allBuildInfo pkg)
- lib_ghc_options = concatMap (get_ghc_options . libBuildInfo)
+ all_ghc_options = concatMap getOptions (allBuildInfo pkg)
+ lib_ghc_options = concatMap (getOptions . libBuildInfo)
(allLibraries pkg)
- get_ghc_options bi = hcOptions GHC bi ++ hcProfOptions GHC bi
- ++ hcSharedOptions GHC bi
-
- test_ghc_options = concatMap (get_ghc_options . testBuildInfo)
+ test_ghc_options = concatMap (getOptions . testBuildInfo)
(testSuites pkg)
- benchmark_ghc_options = concatMap (get_ghc_options . benchmarkBuildInfo)
+ benchmark_ghc_options = concatMap (getOptions . benchmarkBuildInfo)
(benchmarks pkg)
test_and_benchmark_ghc_options = test_ghc_options ++
benchmark_ghc_options
- non_test_and_benchmark_ghc_options = concatMap get_ghc_options
+ non_test_and_benchmark_ghc_options = concatMap getOptions
(allBuildInfo (pkg { testSuites = []
, benchmarks = []
}))
@@ -1054,7 +1074,7 @@ checkPaths pkg =
++ "manager). In addition the layout of the 'dist' directory is subject "
++ "to change in future versions of Cabal."
| bi <- allBuildInfo pkg
- , (GHC, flags) <- options bi
+ , (GHC, flags) <- perCompilerFlavorToList $ options bi
, path <- flags
, isInsideDist path ]
++
@@ -1127,7 +1147,7 @@ checkCabalVersion pkg =
PackageBuildWarning $
"Packages relying on Cabal 1.10 or later must only specify a "
++ "version range of the form 'cabal-version: >= x.y'. Use "
- ++ "'cabal-version: >= " ++ display (specVersion pkg) ++ "'."
+ ++ "'cabal-version: >= " ++ prettyShow (specVersion pkg) ++ "'."
-- check syntax of cabal-version field
, check (specVersion pkg < mkVersion [1,9]
@@ -1135,7 +1155,7 @@ checkCabalVersion pkg =
PackageDistSuspicious $
"It is recommended that the 'cabal-version' field only specify a "
++ "version range of the form '>= x.y'. Use "
- ++ "'cabal-version: >= " ++ display (specVersion pkg) ++ "'. "
+ ++ "'cabal-version: >= " ++ prettyShow (specVersion pkg) ++ "'. "
++ "Tools based on Cabal 1.10 and later will ignore upper bounds."
-- check syntax of cabal-version field
@@ -1143,7 +1163,7 @@ checkCabalVersion pkg =
PackageBuildWarning $
"With Cabal 1.10 or earlier, the 'cabal-version' field must use "
++ "range syntax rather than a simple version number. Use "
- ++ "'cabal-version: >= " ++ display (specVersion pkg) ++ "'."
+ ++ "'cabal-version: >= " ++ prettyShow (specVersion pkg) ++ "'."
-- check syntax of cabal-version field
, check (specVersion pkg >= mkVersion [1,12]
@@ -1152,7 +1172,7 @@ checkCabalVersion pkg =
"Packages relying on Cabal 1.12 or later should specify a "
++ "specific version of the Cabal spec of the form "
++ "'cabal-version: x.y'. "
- ++ "Use 'cabal-version: " ++ display (specVersion pkg) ++ "'."
+ ++ "Use 'cabal-version: " ++ prettyShow (specVersion pkg) ++ "'."
-- check use of test suite sections
, checkVersion [1,8] (not (null $ testSuites pkg)) $
@@ -1243,24 +1263,24 @@ checkCabalVersion pkg =
, checkVersion [1,6] (not (null depsUsingWildcardSyntax)) $
PackageDistInexcusable $
"The package uses wildcard syntax in the 'build-depends' field: "
- ++ commaSep (map display depsUsingWildcardSyntax)
+ ++ commaSep (map prettyShow depsUsingWildcardSyntax)
++ ". To use this new syntax the package need to specify at least "
++ "'cabal-version: >= 1.6'. Alternatively, if broader compatibility "
++ "is important then use: " ++ commaSep
- [ display (Dependency name (eliminateWildcardSyntax versionRange))
- | Dependency name versionRange <- depsUsingWildcardSyntax ]
+ [ prettyShow (Dependency name (eliminateWildcardSyntax versionRange) Set.empty)
+ | Dependency name versionRange _ <- depsUsingWildcardSyntax ]
-- check use of "build-depends: foo ^>= 1.2.3" syntax
, checkVersion [2,0] (not (null depsUsingMajorBoundSyntax)) $
PackageDistInexcusable $
"The package uses major bounded version syntax in the "
++ "'build-depends' field: "
- ++ commaSep (map display depsUsingMajorBoundSyntax)
+ ++ commaSep (map prettyShow depsUsingMajorBoundSyntax)
++ ". To use this new syntax the package need to specify at least "
++ "'cabal-version: 2.0'. Alternatively, if broader compatibility "
++ "is important then use: " ++ commaSep
- [ display (Dependency name (eliminateMajorBoundSyntax versionRange))
- | Dependency name versionRange <- depsUsingMajorBoundSyntax ]
+ [ prettyShow (Dependency name (eliminateMajorBoundSyntax versionRange) Set.empty)
+ | Dependency name versionRange _ <- depsUsingMajorBoundSyntax ]
, checkVersion [2,1] (any (not . null)
(concatMap buildInfoField
@@ -1273,6 +1293,14 @@ checkCabalVersion pkg =
++ " and 'extra-library-flavours' requires the package "
++ " to specify at least 'cabal-version: >= 2.1'."
+ , checkVersion [2,5] (any (not . null) $ buildInfoField extraDynLibFlavours) $
+ PackageDistInexcusable $
+ "The use of 'extra-dynamic-library-flavours' requires the package "
+ ++ " to specify at least 'cabal-version: >= 2.5'. The flavours are: "
+ ++ commaSep [ flav
+ | flavs <- buildInfoField extraDynLibFlavours
+ , flav <- flavs ]
+
, checkVersion [2,1] (any (not . null)
(buildInfoField virtualModules)) $
PackageDistInexcusable $
@@ -1292,12 +1320,12 @@ checkCabalVersion pkg =
, checkVersion [1,6] (not (null testedWithUsingWildcardSyntax)) $
PackageDistInexcusable $
"The package uses wildcard syntax in the 'tested-with' field: "
- ++ commaSep (map display testedWithUsingWildcardSyntax)
+ ++ commaSep (map prettyShow testedWithUsingWildcardSyntax)
++ ". To use this new syntax the package need to specify at least "
++ "'cabal-version: >= 1.6'. Alternatively, if broader compatibility "
++ "is important then use: " ++ commaSep
- [ display (Dependency name (eliminateWildcardSyntax versionRange))
- | Dependency name versionRange <- testedWithUsingWildcardSyntax ]
+ [ prettyShow (Dependency name (eliminateWildcardSyntax versionRange) Set.empty)
+ | Dependency name versionRange _ <- testedWithUsingWildcardSyntax ]
-- check use of "source-repository" section
, checkVersion [1,6] (not (null (sourceRepos pkg))) $
@@ -1310,7 +1338,7 @@ checkCabalVersion pkg =
, checkVersion [1,2,3] (not (null mentionedExtensionsThatNeedCabal12)) $
PackageDistInexcusable $
"Unfortunately the language extensions "
- ++ commaSep (map (quote . display) mentionedExtensionsThatNeedCabal12)
+ ++ commaSep (map (quote . prettyShow) mentionedExtensionsThatNeedCabal12)
++ " break the parser in earlier Cabal versions so you need to "
++ "specify 'cabal-version: >= 1.2.3'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then you may be able to "
@@ -1319,7 +1347,7 @@ checkCabalVersion pkg =
, checkVersion [1,4] (not (null mentionedExtensionsThatNeedCabal14)) $
PackageDistInexcusable $
"Unfortunately the language extensions "
- ++ commaSep (map (quote . display) mentionedExtensionsThatNeedCabal14)
+ ++ commaSep (map (quote . prettyShow) mentionedExtensionsThatNeedCabal14)
++ " break the parser in earlier Cabal versions so you need to "
++ "specify 'cabal-version: >= 1.4'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then you may be able to "
@@ -1339,7 +1367,7 @@ checkCabalVersion pkg =
&& isNothing (setupBuildInfo pkg)
&& buildType pkg == Custom) $
PackageDistSuspiciousWarn $
- "From version 1.24 cabal supports specifiying explicit dependencies "
+ "From version 1.24 cabal supports specifying explicit dependencies "
++ "for Custom setup scripts. Consider using cabal-version >= 1.24 and "
++ "adding a 'custom-setup' section with a 'setup-depends' field "
++ "that specifies the dependencies of the Setup.hs script itself. "
@@ -1371,11 +1399,11 @@ checkCabalVersion pkg =
buildInfoField field = map field (allBuildInfo pkg)
versionRangeExpressions =
- [ dep | dep@(Dependency _ vr) <- allBuildDepends pkg
+ [ dep | dep@(Dependency _ vr _) <- allBuildDepends pkg
, usesNewVersionRangeSyntax vr ]
testedWithVersionRangeExpressions =
- [ Dependency (mkPackageName (display compiler)) vr
+ [ Dependency (mkPackageName (prettyShow compiler)) vr Set.empty
| (compiler, vr) <- testedWith pkg
, usesNewVersionRangeSyntax vr ]
@@ -1399,16 +1427,16 @@ checkCabalVersion pkg =
alg (VersionRangeParensF _) = 3
alg _ = 1 :: Int
- depsUsingWildcardSyntax = [ dep | dep@(Dependency _ vr) <- allBuildDepends pkg
+ depsUsingWildcardSyntax = [ dep | dep@(Dependency _ vr _) <- allBuildDepends pkg
, usesWildcardSyntax vr ]
- depsUsingMajorBoundSyntax = [ dep | dep@(Dependency _ vr) <- allBuildDepends pkg
+ depsUsingMajorBoundSyntax = [ dep | dep@(Dependency _ vr _) <- allBuildDepends pkg
, usesMajorBoundSyntax vr ]
usesBackpackIncludes = any (not . null . mixins) (allBuildInfo pkg)
testedWithUsingWildcardSyntax =
- [ Dependency (mkPackageName (display compiler)) vr
+ [ Dependency (mkPackageName (prettyShow compiler)) vr Set.empty
| (compiler, vr) <- testedWith pkg
, usesWildcardSyntax vr ]
@@ -1497,8 +1525,8 @@ checkCabalVersion pkg =
allModuleNamesAutogen = concatMap autogenModules (allBuildInfo pkg)
displayRawDependency :: Dependency -> String
-displayRawDependency (Dependency pkg vr) =
- display pkg ++ " " ++ display vr
+displayRawDependency (Dependency pkg vr _sublibs) =
+ prettyShow pkg ++ " " ++ prettyShow vr
-- ------------------------------------------------------------
@@ -1549,7 +1577,7 @@ checkPackageVersions pkg =
foldr intersectVersionRanges anyVersion baseDeps
where
baseDeps =
- [ vr | Dependency pname vr <- allBuildDepends pkg'
+ [ vr | Dependency pname vr _ <- allBuildDepends pkg'
, pname == mkPackageName "base" ]
-- Just in case finalizePD fails for any reason,
@@ -1696,41 +1724,53 @@ checkPathsModuleExtensions pd
strings = EnableExtension OverloadedStrings
lists = EnableExtension OverloadedLists
+-- | Checks GHC options from all ghc-*-options fields from the given BuildInfo
+-- and reports flags that are OK during development process, but are
+-- unacceptable in a distrubuted package
checkDevelopmentOnlyFlagsBuildInfo :: BuildInfo -> [PackageCheck]
checkDevelopmentOnlyFlagsBuildInfo bi =
+ checkDevelopmentOnlyFlagsOptions "ghc-options" (hcOptions GHC bi)
+ ++ checkDevelopmentOnlyFlagsOptions "ghc-prof-options" (hcProfOptions GHC bi)
+ ++ checkDevelopmentOnlyFlagsOptions "ghc-shared-options" (hcSharedOptions GHC bi)
+
+-- | Checks the given list of flags belonging to the given field and reports
+-- flags that are OK during development process, but are unacceptable in a
+-- distributed package
+checkDevelopmentOnlyFlagsOptions :: String -> [String] -> [PackageCheck]
+checkDevelopmentOnlyFlagsOptions fieldName ghcOptions =
catMaybes [
check has_WerrorWall $
PackageDistInexcusable $
- "'ghc-options: -Wall -Werror' makes the package very easy to "
+ "'" ++ fieldName ++ ": -Wall -Werror' makes the package very easy to "
++ "break with future GHC versions because new GHC versions often "
- ++ "add new warnings. Use just 'ghc-options: -Wall' instead."
+ ++ "add new warnings. Use just '" ++ fieldName ++ ": -Wall' instead."
++ extraExplanation
, check (not has_WerrorWall && has_Werror) $
PackageDistInexcusable $
- "'ghc-options: -Werror' makes the package easy to "
+ "'" ++ fieldName ++ ": -Werror' makes the package easy to "
++ "break with future GHC versions because new GHC versions often "
++ "add new warnings. "
++ extraExplanation
, check (has_J) $
PackageDistInexcusable $
- "'ghc-options: -j[N]' can make sense for specific user's setup,"
+ "'" ++ fieldName ++ ": -j[N]' can make sense for specific user's setup,"
++ " but it is not appropriate for a distributed package."
++ extraExplanation
, checkFlags ["-fdefer-type-errors"] $
PackageDistInexcusable $
- "'ghc-options: -fdefer-type-errors' is fine during development but "
+ "'" ++ fieldName ++ ": -fdefer-type-errors' is fine during development but "
++ "is not appropriate for a distributed package. "
++ extraExplanation
-- -dynamic is not a debug flag
, check (any (\opt -> "-d" `isPrefixOf` opt && opt /= "-dynamic")
- ghc_options) $
+ ghcOptions) $
PackageDistInexcusable $
- "'ghc-options: -d*' debug flags are not appropriate "
+ "'" ++ fieldName ++ ": -d*' debug flags are not appropriate "
++ "for a distributed package. "
++ extraExplanation
@@ -1738,7 +1778,7 @@ checkDevelopmentOnlyFlagsBuildInfo bi =
"-fprof-cafs", "-fno-prof-count-entries",
"-auto-all", "-auto", "-caf-all"] $
PackageDistSuspicious $
- "'ghc-options/ghc-prof-options: -fprof*' profiling flags are typically not "
+ "'" ++ fieldName ++ ": -fprof*' profiling flags are typically not "
++ "appropriate for a distributed library package. These flags are "
++ "useful to profile this package, but when profiling other packages "
++ "that use this one these flags clutter the profile output with "
@@ -1754,21 +1794,18 @@ checkDevelopmentOnlyFlagsBuildInfo bi =
++ "False') and enable that flag during development."
has_WerrorWall = has_Werror && ( has_Wall || has_W )
- has_Werror = "-Werror" `elem` ghc_options
- has_Wall = "-Wall" `elem` ghc_options
- has_W = "-W" `elem` ghc_options
+ has_Werror = "-Werror" `elem` ghcOptions
+ has_Wall = "-Wall" `elem` ghcOptions
+ has_W = "-W" `elem` ghcOptions
has_J = any
(\o -> case o of
"-j" -> True
('-' : 'j' : d : _) -> isDigit d
_ -> False
)
- ghc_options
- ghc_options = hcOptions GHC bi ++ hcProfOptions GHC bi
- ++ hcSharedOptions GHC bi
-
+ ghcOptions
checkFlags :: [String] -> PackageCheck -> Maybe PackageCheck
- checkFlags flags = check (any (`elem` flags) ghc_options)
+ checkFlags flags = check (any (`elem` flags) ghcOptions)
checkDevelopmentOnlyFlags :: GenericPackageDescription -> [PackageCheck]
checkDevelopmentOnlyFlags pkg =
diff --git a/cabal/Cabal/Distribution/PackageDescription/Configuration.hs b/cabal/Cabal/Distribution/PackageDescription/Configuration.hs
index 5d9249e..49f79c7 100644
--- a/cabal/Cabal/Distribution/PackageDescription/Configuration.hs
+++ b/cabal/Cabal/Distribution/PackageDescription/Configuration.hs
@@ -1,5 +1,6 @@
-- -fno-warn-deprecations for use of Map.foldWithKey
{-# OPTIONS_GHC -fno-warn-deprecations #-}
+{-# LANGUAGE NoMonoLocalBinds #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.PackageDescription.Configuration
@@ -17,7 +18,6 @@
module Distribution.PackageDescription.Configuration (
finalizePD,
- finalizePackageDescription,
flattenPackageDescription,
-- Utils
@@ -48,11 +48,12 @@ import Distribution.PackageDescription.Utils
import Distribution.Version
import Distribution.Compiler
import Distribution.System
+import Distribution.Parsec
+import Distribution.Pretty
+import Distribution.Compat.CharParsing hiding (char)
+import qualified Distribution.Compat.CharParsing as P
import Distribution.Simple.Utils
-import Distribution.Text
import Distribution.Compat.Lens
-import Distribution.Compat.ReadP as ReadP hiding ( char )
-import qualified Distribution.Compat.ReadP as ReadP ( char )
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ForeignLib
import Distribution.Types.Component
@@ -65,6 +66,8 @@ import Distribution.Types.DependencyMap
import qualified Data.Map.Strict as Map.Strict
import qualified Data.Map.Lazy as Map
+import Data.Set ( Set )
+import qualified Data.Set as Set
import Data.Tree ( Tree(Node) )
------------------------------------------------------------------------------
@@ -107,28 +110,29 @@ simplifyWithSysParams os arch cinfo cond = (cond', flags)
--
-- | Parse a configuration condition from a string.
-parseCondition :: ReadP r (Condition ConfVar)
+parseCondition :: CabalParsing m => m (Condition ConfVar)
parseCondition = condOr
where
- condOr = sepBy1 condAnd (oper "||") >>= return . foldl1 COr
- condAnd = sepBy1 cond (oper "&&")>>= return . foldl1 CAnd
- cond = sp >> (boolLiteral +++ inparens condOr +++ notCond +++ osCond
- +++ archCond +++ flagCond +++ implCond )
- inparens = between (ReadP.char '(' >> sp) (sp >> ReadP.char ')' >> sp)
- notCond = ReadP.char '!' >> sp >> cond >>= return . CNot
+ condOr = sepByNonEmpty condAnd (oper "||") >>= return . foldl1 COr
+ condAnd = sepByNonEmpty cond (oper "&&")>>= return . foldl1 CAnd
+ -- TODO: try?
+ cond = sp >> (boolLiteral <|> inparens condOr <|> notCond <|> osCond
+ <|> archCond <|> flagCond <|> implCond )
+ inparens = between (P.char '(' >> sp) (sp >> P.char ')' >> sp)
+ notCond = P.char '!' >> sp >> cond >>= return . CNot
osCond = string "os" >> sp >> inparens osIdent >>= return . Var
archCond = string "arch" >> sp >> inparens archIdent >>= return . Var
flagCond = string "flag" >> sp >> inparens flagIdent >>= return . Var
implCond = string "impl" >> sp >> inparens implIdent >>= return . Var
- boolLiteral = fmap Lit parse
- archIdent = fmap Arch parse
- osIdent = fmap OS parse
+ boolLiteral = fmap Lit parsec
+ archIdent = fmap Arch parsec
+ osIdent = fmap OS parsec
flagIdent = fmap (Flag . mkFlagName . lowercase) (munch1 isIdentChar)
isIdentChar c = isAlphaNum c || c == '_' || c == '-'
oper s = sp >> string s >> sp
- sp = skipSpaces
- implIdent = do i <- parse
- vr <- sp >> option anyVersion parse
+ sp = spaces
+ implIdent = do i <- parsec
+ vr <- sp >> option anyVersion parsec
return $ Impl i vr
------------------------------------------------------------------------------
@@ -229,7 +233,7 @@ resolveWithFlags dom enabled os arch impl constrs trees checkDeps =
mp (Left xs) (Left ys) =
let union = Map.foldrWithKey (Map.Strict.insertWith combine)
(unDepMapUnion xs) (unDepMapUnion ys)
- combine x y = simplifyVersionRange $ unionVersionRanges x y
+ combine x y = (\(vr, cs) -> (simplifyVersionRange vr,cs)) $ unionVersionRanges' x y
in union `seq` Left (DepMapUnion union)
-- `mzero'
@@ -307,14 +311,22 @@ extractConditions f gpkg =
-- | A map of dependencies that combines version ranges using 'unionVersionRanges'.
-newtype DepMapUnion = DepMapUnion { unDepMapUnion :: Map PackageName VersionRange }
+newtype DepMapUnion = DepMapUnion { unDepMapUnion :: Map PackageName (VersionRange, Set LibraryName) }
+
+-- An union of versions should correspond to an intersection of the components.
+-- The intersection may not be necessary.
+unionVersionRanges' :: (VersionRange, Set LibraryName)
+ -> (VersionRange, Set LibraryName)
+ -> (VersionRange, Set LibraryName)
+unionVersionRanges' (vra, csa) (vrb, csb) =
+ (unionVersionRanges vra vrb, Set.intersection csa csb)
toDepMapUnion :: [Dependency] -> DepMapUnion
toDepMapUnion ds =
- DepMapUnion $ Map.fromListWith unionVersionRanges [ (p,vr) | Dependency p vr <- ds ]
+ DepMapUnion $ Map.fromListWith unionVersionRanges' [ (p,(vr,cs)) | Dependency p vr cs <- ds ]
fromDepMapUnion :: DepMapUnion -> [Dependency]
-fromDepMapUnion m = [ Dependency p vr | (p,vr) <- Map.toList (unDepMapUnion m) ]
+fromDepMapUnion m = [ Dependency p vr cs | (p,(vr,cs)) <- Map.toList (unDepMapUnion m) ]
freeVars :: CondTree ConfVar c a -> [FlagName]
freeVars t = [ f | Flag f <- freeVars' t ]
@@ -344,12 +356,14 @@ overallDependencies enabled (TargetSet targets) = mconcat depss
-- UGH. The embedded componentName in the 'Component's here is
-- BLANK. I don't know whose fault this is but I'll use the tag
-- instead. -- ezyang
- removeDisabledSections (Lib _) = componentNameRequested enabled CLibName
+ removeDisabledSections (Lib _) = componentNameRequested
+ enabled
+ (CLibName LMainLibName)
removeDisabledSections (SubComp t c)
-- Do NOT use componentName
= componentNameRequested enabled
$ case c of
- CLib _ -> CSubLibName t
+ CLib _ -> CLibName (LSubLibName t)
CFLib _ -> CFLibName t
CExe _ -> CExeName t
CTest _ -> CTestName t
@@ -365,7 +379,7 @@ flattenTaggedTargets (TargetSet targets) = foldr untag (Nothing, []) targets whe
(Lib l, (Nothing, comps)) -> (Just $ redoBD l, comps)
(SubComp n c, (mb_lib, comps))
| any ((== n) . fst) comps ->
- userBug $ "There exist several components with the same name: '" ++ display n ++ "'"
+ userBug $ "There exist several components with the same name: '" ++ prettyShow n ++ "'"
| otherwise -> (mb_lib, (n, redoBD c) : comps)
(PDNull, x) -> x -- actually this should not happen, but let's be liberal
where
@@ -441,7 +455,7 @@ finalizePD userflags enabled satisfyDep
(mb_lib, comps) = flattenTaggedTargets targetSet
mb_lib' = fmap libFillInDefaults mb_lib
comps' = flip map comps $ \(n,c) -> foldComponent
- (\l -> CLib (libFillInDefaults l) { libName = Just n
+ (\l -> CLib (libFillInDefaults l) { libName = LSubLibName n
, libExposed = False })
(\l -> CFLib (flibFillInDefaults l) { foreignLibName = n })
(\e -> CExe (exeFillInDefaults e) { exeName = n })
@@ -478,20 +492,6 @@ finalizePD userflags enabled satisfyDep
then DepOk
else MissingDeps missingDeps
-{-# DEPRECATED finalizePackageDescription "This function now always assumes tests and benchmarks are disabled; use finalizePD with ComponentRequestedSpec to specify something more specific. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
-finalizePackageDescription ::
- FlagAssignment -- ^ Explicitly specified flag assignments
- -> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of
- -- available packages? If this is unknown then use
- -- True.
- -> Platform -- ^ The 'Arch' and 'OS'
- -> CompilerInfo -- ^ Compiler information
- -> [Dependency] -- ^ Additional constraints
- -> GenericPackageDescription
- -> Either [Dependency]
- (PackageDescription, FlagAssignment)
-finalizePackageDescription flags = finalizePD flags defaultComponentRequestedSpec
-
{-
let tst_p = (CondNode [1::Int] [Distribution.Package.Dependency "a" AnyVersion] [])
let tst_p2 = (CondNode [1::Int] [Distribution.Package.Dependency "a" (EarlierVersion (Version [1,0] [])), Distribution.Package.Dependency "a" (LaterVersion (Version [2,0] []))] [])
@@ -527,14 +527,14 @@ flattenPackageDescription
}
where
mlib = f <$> mlib0
- where f lib = (libFillInDefaults . fst . ignoreConditions $ lib) { libName = Nothing }
+ where f lib = (libFillInDefaults . fst . ignoreConditions $ lib) { libName = LMainLibName }
sub_libs = flattenLib <$> sub_libs0
flibs = flattenFLib <$> flibs0
exes = flattenExe <$> exes0
tests = flattenTst <$> tests0
bms = flattenBm <$> bms0
flattenLib (n, t) = libFillInDefaults $ (fst $ ignoreConditions t)
- { libName = Just n, libExposed = False }
+ { libName = LSubLibName n, libExposed = False }
flattenFLib (n, t) = flibFillInDefaults $ (fst $ ignoreConditions t)
{ foreignLibName = n }
flattenExe (n, t) = exeFillInDefaults $ (fst $ ignoreConditions t)
diff --git a/cabal/Cabal/Distribution/PackageDescription/FieldGrammar.hs b/cabal/Cabal/Distribution/PackageDescription/FieldGrammar.hs
index 0aedbc3..285a01b 100644
--- a/cabal/Cabal/Distribution/PackageDescription/FieldGrammar.hs
+++ b/cabal/Cabal/Distribution/PackageDescription/FieldGrammar.hs
@@ -43,18 +43,20 @@ import Distribution.Compat.Lens
import Distribution.Compat.Prelude
import Prelude ()
-import Distribution.Compiler (CompilerFlavor (..))
+import Distribution.CabalSpecVersion
+import Distribution.Compiler (CompilerFlavor (..), PerCompilerFlavor (..))
import Distribution.FieldGrammar
import Distribution.ModuleName (ModuleName)
import Distribution.Package
import Distribution.PackageDescription
-import Distribution.Parsec.Common
+import Distribution.Parsec
import Distribution.Parsec.Newtypes
-import Distribution.Parsec.ParseResult
-import Distribution.Text (display)
+import Distribution.Fields
+import Distribution.Pretty (prettyShow)
import Distribution.Types.ExecutableScope
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibType
+import Distribution.Types.LibraryVisibility
import Distribution.Types.UnqualComponentName
import Distribution.Version (anyVersion)
@@ -74,18 +76,18 @@ packageDescriptionFieldGrammar = PackageDescription
<*> blurFieldGrammar L.package packageIdentifierGrammar
<*> optionalFieldDefAla "license" SpecLicense L.licenseRaw (Left SPDX.NONE)
<*> licenseFilesGrammar
- <*> optionalFieldDefAla "copyright" FreeText L.copyright ""
- <*> optionalFieldDefAla "maintainer" FreeText L.maintainer ""
- <*> optionalFieldDefAla "author" FreeText L.author ""
- <*> optionalFieldDefAla "stability" FreeText L.stability ""
+ <*> freeTextFieldDef "copyright" L.copyright
+ <*> freeTextFieldDef "maintainer" L.maintainer
+ <*> freeTextFieldDef "author" L.author
+ <*> freeTextFieldDef "stability" L.stability
<*> monoidalFieldAla "tested-with" (alaList' FSep TestedWith) L.testedWith
- <*> optionalFieldDefAla "homepage" FreeText L.homepage ""
- <*> optionalFieldDefAla "package-url" FreeText L.pkgUrl ""
- <*> optionalFieldDefAla "bug-reports" FreeText L.bugReports ""
+ <*> freeTextFieldDef "homepage" L.homepage
+ <*> freeTextFieldDef "package-url" L.pkgUrl
+ <*> freeTextFieldDef "bug-reports" L.bugReports
<*> pure [] -- source-repos are stanza
- <*> optionalFieldDefAla "synopsis" FreeText L.synopsis ""
- <*> optionalFieldDefAla "description" FreeText L.description ""
- <*> optionalFieldDefAla "category" FreeText L.category ""
+ <*> freeTextFieldDef "synopsis" L.synopsis
+ <*> freeTextFieldDef "description" L.description
+ <*> freeTextFieldDef "category" L.category
<*> prefixedFields "x-" L.customFieldsPD
<*> optionalField "build-type" L.buildTypeRaw
<*> pure Nothing -- custom-setup
@@ -121,16 +123,27 @@ packageDescriptionFieldGrammar = PackageDescription
libraryFieldGrammar
:: (FieldGrammar g, Applicative (g Library), Applicative (g BuildInfo))
- => Maybe UnqualComponentName -> g Library Library
+ => LibraryName
+ -> g Library Library
libraryFieldGrammar n = Library n
<$> monoidalFieldAla "exposed-modules" (alaList' VCat MQuoted) L.exposedModules
<*> monoidalFieldAla "reexported-modules" (alaList CommaVCat) L.reexportedModules
<*> monoidalFieldAla "signatures" (alaList' VCat MQuoted) L.signatures
- ^^^ availableSince [2,0] []
+ ^^^ availableSince CabalSpecV2_0 []
<*> booleanFieldDef "exposed" L.libExposed True
+ <*> visibilityField
<*> blurFieldGrammar L.libBuildInfo buildInfoFieldGrammar
-{-# SPECIALIZE libraryFieldGrammar :: Maybe UnqualComponentName -> ParsecFieldGrammar' Library #-}
-{-# SPECIALIZE libraryFieldGrammar :: Maybe UnqualComponentName -> PrettyFieldGrammar' Library #-}
+ where
+ visibilityField = case n of
+ -- nameless/"main" libraries are public
+ LMainLibName -> pure LibraryVisibilityPublic
+ -- named libraries have the field
+ LSubLibName _ ->
+ optionalFieldDef "visibility" L.libVisibility LibraryVisibilityPrivate
+ ^^^ availableSince CabalSpecV3_0 LibraryVisibilityPrivate
+
+{-# SPECIALIZE libraryFieldGrammar :: LibraryName -> ParsecFieldGrammar' Library #-}
+{-# SPECIALIZE libraryFieldGrammar :: LibraryName -> PrettyFieldGrammar' Library #-}
-------------------------------------------------------------------------------
-- Foreign library
@@ -160,7 +173,7 @@ executableFieldGrammar n = Executable n
-- main-is is optional as conditional blocks don't have it
<$> optionalFieldDefAla "main-is" FilePathNT L.modulePath ""
<*> optionalFieldDef "scope" L.exeScope ExecutablePublic
- ^^^ availableSince [2,0] ExecutablePublic
+ ^^^ availableSince CabalSpecV2_0 ExecutablePublic
<*> blurFieldGrammar L.buildInfo buildInfoFieldGrammar
{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> ParsecFieldGrammar' Executable #-}
{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> PrettyFieldGrammar' Executable #-}
@@ -249,10 +262,10 @@ validateTestSuite pos stanza = case _testStanzaTestType stanza of
where
missingField name tt = "The '" ++ name ++ "' field is required for the "
- ++ display tt ++ " test suite type."
+ ++ prettyShow tt ++ " test suite type."
extraField name tt = "The '" ++ name ++ "' field is not used for the '"
- ++ display tt ++ "' test suite type."
+ ++ prettyShow tt ++ "' test suite type."
unvalidateTestSuite :: TestSuite -> TestSuiteStanza
unvalidateTestSuite t = TestSuiteStanza
@@ -337,10 +350,10 @@ validateBenchmark pos stanza = case _benchmarkStanzaBenchmarkType stanza of
where
missingField name tt = "The '" ++ name ++ "' field is required for the "
- ++ display tt ++ " benchmark type."
+ ++ prettyShow tt ++ " benchmark type."
extraField name tt = "The '" ++ name ++ "' field is not used for the '"
- ++ display tt ++ "' benchmark type."
+ ++ prettyShow tt ++ "' benchmark type."
unvalidateBenchmark :: Benchmark -> BenchmarkStanza
unvalidateBenchmark b = BenchmarkStanza
@@ -365,7 +378,10 @@ buildInfoFieldGrammar
buildInfoFieldGrammar = BuildInfo
<$> booleanFieldDef "buildable" L.buildable True
<*> monoidalFieldAla "build-tools" (alaList CommaFSep) L.buildTools
- ^^^ deprecatedSince [2,0] "Please use 'build-tool-depends' field"
+ ^^^ deprecatedSince CabalSpecV2_0
+ "Please use 'build-tool-depends' field"
+ ^^^ removedIn CabalSpecV3_0
+ "Please use 'build-tool-depends' field."
<*> monoidalFieldAla "build-tool-depends" (alaList CommaFSep) L.buildToolDepends
-- {- ^^^ availableSince [2,0] [] -}
-- here, we explicitly want to recognise build-tool-depends for all Cabal files
@@ -377,7 +393,7 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "cmm-options" (alaList' NoCommaFSep Token') L.cmmOptions
<*> monoidalFieldAla "cc-options" (alaList' NoCommaFSep Token') L.ccOptions
<*> monoidalFieldAla "cxx-options" (alaList' NoCommaFSep Token') L.cxxOptions
- ^^^ availableSince [2,1] [] -- TODO change to 2,2 when version is bumped
+ ^^^ availableSince CabalSpecV2_2 []
<*> monoidalFieldAla "ld-options" (alaList' NoCommaFSep Token') L.ldOptions
<*> monoidalFieldAla "pkgconfig-depends" (alaList CommaFSep) L.pkgconfigDepends
<*> monoidalFieldAla "frameworks" (alaList' FSep Token) L.frameworks
@@ -386,35 +402,42 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "cmm-sources" (alaList' VCat FilePathNT) L.cmmSources
<*> monoidalFieldAla "c-sources" (alaList' VCat FilePathNT) L.cSources
<*> monoidalFieldAla "cxx-sources" (alaList' VCat FilePathNT) L.cxxSources
- ^^^ availableSince [2,1] [] -- TODO change to 2,2 when version is bumped
+ ^^^ availableSince CabalSpecV2_2 []
<*> monoidalFieldAla "js-sources" (alaList' VCat FilePathNT) L.jsSources
<*> hsSourceDirsGrammar
<*> monoidalFieldAla "other-modules" (alaList' VCat MQuoted) L.otherModules
<*> monoidalFieldAla "virtual-modules" (alaList' VCat MQuoted) L.virtualModules
- ^^^ availableSince [2,1] [] -- TODO change to 2,2 when version is bumped
+ ^^^ availableSince CabalSpecV2_2 []
<*> monoidalFieldAla "autogen-modules" (alaList' VCat MQuoted) L.autogenModules
<*> optionalFieldAla "default-language" MQuoted L.defaultLanguage
<*> monoidalFieldAla "other-languages" (alaList' FSep MQuoted) L.otherLanguages
<*> monoidalFieldAla "default-extensions" (alaList' FSep MQuoted) L.defaultExtensions
<*> monoidalFieldAla "other-extensions" (alaList' FSep MQuoted) L.otherExtensions
<*> monoidalFieldAla "extensions" (alaList' FSep MQuoted) L.oldExtensions
- ^^^ deprecatedSince [1,12] "Please use 'default-extensions' or 'other-extensions' fields."
+ ^^^ deprecatedSince CabalSpecV1_12
+ "Please use 'default-extensions' or 'other-extensions' fields."
+ ^^^ removedIn CabalSpecV3_0
+ "Please use 'default-extensions' or 'other-extensions' fields."
<*> monoidalFieldAla "extra-libraries" (alaList' VCat Token) L.extraLibs
<*> monoidalFieldAla "extra-ghci-libraries" (alaList' VCat Token) L.extraGHCiLibs
<*> monoidalFieldAla "extra-bundled-libraries" (alaList' VCat Token) L.extraBundledLibs
<*> monoidalFieldAla "extra-library-flavours" (alaList' VCat Token) L.extraLibFlavours
+ <*> monoidalFieldAla "extra-dynamic-library-flavours" (alaList' VCat Token) L.extraDynLibFlavours
+ ^^^ availableSince CabalSpecV3_0 []
<*> monoidalFieldAla "extra-lib-dirs" (alaList' FSep FilePathNT) L.extraLibDirs
<*> monoidalFieldAla "include-dirs" (alaList' FSep FilePathNT) L.includeDirs
<*> monoidalFieldAla "includes" (alaList' FSep FilePathNT) L.includes
+ <*> monoidalFieldAla "autogen-includes" (alaList' FSep FilePathNT) L.autogenIncludes
+ ^^^ availableSince CabalSpecV3_0 []
<*> monoidalFieldAla "install-includes" (alaList' FSep FilePathNT) L.installIncludes
<*> optionsFieldGrammar
<*> profOptionsFieldGrammar
<*> sharedOptionsFieldGrammar
- <*> pure [] -- static-options ???
+ <*> pure mempty -- static-options ???
<*> prefixedFields "x-" L.customFieldsBI
<*> monoidalFieldAla "build-depends" (alaList CommaVCat) L.targetBuildDepends
<*> monoidalFieldAla "mixins" (alaList CommaVCat) L.mixins
- ^^^ availableSince [2,0] []
+ ^^^ availableSince CabalSpecV2_0 []
{-# SPECIALIZE buildInfoFieldGrammar :: ParsecFieldGrammar' BuildInfo #-}
{-# SPECIALIZE buildInfoFieldGrammar :: PrettyFieldGrammar' BuildInfo #-}
@@ -423,13 +446,19 @@ hsSourceDirsGrammar
=> g BuildInfo [FilePath]
hsSourceDirsGrammar = (++)
<$> monoidalFieldAla "hs-source-dirs" (alaList' FSep FilePathNT) L.hsSourceDirs
- <*> monoidalFieldAla "hs-source-dir" (alaList' FSep FilePathNT) L.hsSourceDirs
- ^^^ deprecatedField' "Please use 'hs-source-dirs'"
+ <*> monoidalFieldAla "hs-source-dir" (alaList' FSep FilePathNT) wrongLens
+ --- https://github.com/haskell/cabal/commit/49e3cdae3bdf21b017ccd42e66670ca402e22b44
+ ^^^ deprecatedSince CabalSpecV1_2 "Please use 'hs-source-dirs'"
+ ^^^ removedIn CabalSpecV3_0 "Please use 'hs-source-dirs' field."
+ where
+ -- TODO: make pretty printer aware of CabalSpecVersion
+ wrongLens :: Functor f => LensLike' f BuildInfo [FilePath]
+ wrongLens f bi = (\fps -> set L.hsSourceDirs fps bi) <$> f []
optionsFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
- => g BuildInfo [(CompilerFlavor, [String])]
-optionsFieldGrammar = combine
+ => g BuildInfo (PerCompilerFlavor [String])
+optionsFieldGrammar = PerCompilerFlavor
<$> monoidalFieldAla "ghc-options" (alaList' NoCommaFSep Token') (extract GHC)
<*> monoidalFieldAla "ghcjs-options" (alaList' NoCommaFSep Token') (extract GHCJS)
-- NOTE: Hugs, NHC and JHC are not supported anymore, but these
@@ -442,51 +471,31 @@ optionsFieldGrammar = combine
extract :: CompilerFlavor -> ALens' BuildInfo [String]
extract flavor = L.options . lookupLens flavor
- combine ghc ghcjs =
- f GHC ghc ++ f GHCJS ghcjs
- where
- f _flavor [] = []
- f flavor opts = [(flavor, opts)]
-
profOptionsFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
- => g BuildInfo [(CompilerFlavor, [String])]
-profOptionsFieldGrammar = combine
+ => g BuildInfo (PerCompilerFlavor [String])
+profOptionsFieldGrammar = PerCompilerFlavor
<$> monoidalFieldAla "ghc-prof-options" (alaList' NoCommaFSep Token') (extract GHC)
<*> monoidalFieldAla "ghcjs-prof-options" (alaList' NoCommaFSep Token') (extract GHCJS)
where
extract :: CompilerFlavor -> ALens' BuildInfo [String]
extract flavor = L.profOptions . lookupLens flavor
- combine ghc ghcjs = f GHC ghc ++ f GHCJS ghcjs
- where
- f _flavor [] = []
- f flavor opts = [(flavor, opts)]
-
sharedOptionsFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
- => g BuildInfo [(CompilerFlavor, [String])]
-sharedOptionsFieldGrammar = combine
+ => g BuildInfo (PerCompilerFlavor [String])
+sharedOptionsFieldGrammar = PerCompilerFlavor
<$> monoidalFieldAla "ghc-shared-options" (alaList' NoCommaFSep Token') (extract GHC)
<*> monoidalFieldAla "ghcjs-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)
where
extract :: CompilerFlavor -> ALens' BuildInfo [String]
extract flavor = L.sharedOptions . lookupLens flavor
- combine ghc ghcjs = f GHC ghc ++ f GHCJS ghcjs
- where
- f _flavor [] = []
- f flavor opts = [(flavor, opts)]
-
-lookupLens :: (Functor f, Ord k) => k -> LensLike' f [(k, [v])] [v]
-lookupLens k f kvs = str kvs <$> f (gtr kvs)
- where
- gtr = fromMaybe [] . lookup k
-
- str [] v = [(k, v)]
- str (x@(k',_):xs) v
- | k == k' = (k, v) : xs
- | otherwise = x : str xs v
+lookupLens :: (Functor f, Monoid v) => CompilerFlavor -> LensLike' f (PerCompilerFlavor v) v
+lookupLens k f p@(PerCompilerFlavor ghc ghcjs)
+ | k == GHC = (\n -> PerCompilerFlavor n ghcjs) <$> f ghc
+ | k == GHCJS = (\n -> PerCompilerFlavor ghc n) <$> f ghcjs
+ | otherwise = p <$ f mempty
-------------------------------------------------------------------------------
-- Flag
@@ -496,7 +505,7 @@ flagFieldGrammar
:: (FieldGrammar g, Applicative (g Flag))
=> FlagName -> g Flag Flag
flagFieldGrammar name = MkFlag name
- <$> optionalFieldDefAla "description" FreeText L.flagDescription ""
+ <$> freeTextFieldDef "description" L.flagDescription
<*> booleanFieldDef "default" L.flagDefault True
<*> booleanFieldDef "manual" L.flagManual False
{-# SPECIALIZE flagFieldGrammar :: FlagName -> ParsecFieldGrammar' Flag #-}
@@ -511,7 +520,7 @@ sourceRepoFieldGrammar
=> RepoKind -> g SourceRepo SourceRepo
sourceRepoFieldGrammar kind = SourceRepo kind
<$> optionalField "type" L.repoType
- <*> optionalFieldAla "location" FreeText L.repoLocation
+ <*> freeTextField "location" L.repoLocation
<*> optionalFieldAla "module" Token L.repoModule
<*> optionalFieldAla "branch" Token L.repoBranch
<*> optionalFieldAla "tag" Token L.repoTag
diff --git a/cabal/Cabal/Distribution/PackageDescription/Parsec.hs b/cabal/Cabal/Distribution/PackageDescription/Parsec.hs
index 2a067ef..9513d4f 100644
--- a/cabal/Cabal/Distribution/PackageDescription/Parsec.hs
+++ b/cabal/Cabal/Distribution/PackageDescription/Parsec.hs
@@ -35,38 +35,41 @@ module Distribution.PackageDescription.Parsec (
import Distribution.Compat.Prelude
import Prelude ()
-import Control.Monad (guard)
-import Control.Monad.State.Strict (StateT, execStateT)
-import Control.Monad.Trans.Class (lift)
-import Data.List (partition)
+import Control.Applicative (Const (..))
+import Control.Monad (guard)
+import Control.Monad.State.Strict (StateT, execStateT)
+import Control.Monad.Trans.Class (lift)
+import Data.List (partition)
import Distribution.CabalSpecVersion
import Distribution.Compat.Lens
import Distribution.FieldGrammar
-import Distribution.FieldGrammar.Parsec (NamelessField (..))
+import Distribution.FieldGrammar.Parsec (NamelessField (..))
+import Distribution.Fields.ConfVar (parseConditionConfVar)
+import Distribution.Fields.Field (FieldName, getName)
+import Distribution.Fields.LexerMonad (LexWarning, toPWarnings)
+import Distribution.Fields.Parser
+import Distribution.Fields.ParseResult
import Distribution.PackageDescription
+import Distribution.PackageDescription.Configuration (freeVars)
import Distribution.PackageDescription.FieldGrammar
-import Distribution.PackageDescription.Quirks (patchQuirks)
-import Distribution.Parsec.Class (parsec, simpleParsec)
-import Distribution.Parsec.Common
-import Distribution.Parsec.ConfVar (parseConditionConfVar)
-import Distribution.Parsec.Field (FieldName, getName)
-import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS)
-import Distribution.Parsec.LexerMonad (LexWarning, toPWarnings)
-import Distribution.Parsec.Newtypes (CommaFSep, List, SpecVersion (..), Token)
-import Distribution.Parsec.Parser
-import Distribution.Parsec.ParseResult
-import Distribution.Pretty (prettyShow)
-import Distribution.Simple.Utils (fromUTF8BS)
-import Distribution.Text (display)
+import Distribution.PackageDescription.Quirks (patchQuirks)
+import Distribution.Parsec (parsec, simpleParsec)
+import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS)
+import Distribution.Parsec.Newtypes (CommaFSep, List, SpecVersion (..), Token)
+import Distribution.Parsec.Position (Position (..), zeroPos)
+import Distribution.Parsec.Warning (PWarnType (..))
+import Distribution.Pretty (prettyShow)
+import Distribution.Simple.Utils (fromUTF8BS)
import Distribution.Types.CondTree
-import Distribution.Types.Dependency (Dependency)
+import Distribution.Types.Dependency (Dependency)
import Distribution.Types.ForeignLib
-import Distribution.Types.ForeignLibType (knownForeignLibTypes)
-import Distribution.Types.GenericPackageDescription (emptyGenericPackageDescription)
-import Distribution.Types.PackageDescription (specVersion')
-import Distribution.Types.UnqualComponentName (UnqualComponentName, mkUnqualComponentName)
-import Distribution.Utils.Generic (breakMaybe, unfoldrM, validateUTF8)
-import Distribution.Verbosity (Verbosity)
+import Distribution.Types.ForeignLibType (knownForeignLibTypes)
+import Distribution.Types.GenericPackageDescription (emptyGenericPackageDescription)
+import Distribution.Types.LibraryVisibility (LibraryVisibility (..))
+import Distribution.Types.PackageDescription (specVersion')
+import Distribution.Types.UnqualComponentName (UnqualComponentName, mkUnqualComponentName)
+import Distribution.Utils.Generic (breakMaybe, unfoldrM, validateUTF8)
+import Distribution.Verbosity (Verbosity)
import Distribution.Version
(LowerBound (..), Version, asVersionIntervals, mkVersion, orLaterVersion, version0,
versionNumbers)
@@ -74,8 +77,11 @@ import Distribution.Version
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
import qualified Distribution.Compat.Newtype as Newtype
import qualified Distribution.Types.BuildInfo.Lens as L
+import qualified Distribution.Types.Executable.Lens as L
+import qualified Distribution.Types.ForeignLib.Lens as L
import qualified Distribution.Types.GenericPackageDescription.Lens as L
import qualified Distribution.Types.PackageDescription.Lens as L
import qualified Text.Parsec as P
@@ -100,7 +106,7 @@ parseGenericPackageDescription bs = do
setCabalSpecVersion ver
-- if we get too new version, fail right away
case ver of
- Just v | v > mkVersion [2,4] -> parseFailure zeroPos
+ Just v | v > mkVersion [3,0] -> parseFailure zeroPos
"Unsupported cabal-version. See https://github.com/haskell/cabal/issues/4899."
_ -> pure ()
@@ -174,13 +180,7 @@ parseGenericPackageDescription' cabalVerM lexWarnings utf8WarnPos fs = do
return v
- let specVer
- | cabalVer >= mkVersion [2,3] = CabalSpecV2_4
- | cabalVer >= mkVersion [2,1] = CabalSpecV2_2
- | cabalVer >= mkVersion [1,25] = CabalSpecV2_0
- | cabalVer >= mkVersion [1,23] = CabalSpecV1_24
- | cabalVer >= mkVersion [1,21] = CabalSpecV1_22
- | otherwise = CabalSpecOld
+ let specVer = cabalSpecFromVersionDigits (versionNumbers cabalVer)
-- reset cabal version
setCabalSpecVersion (Just cabalVer)
@@ -197,8 +197,10 @@ parseGenericPackageDescription' cabalVerM lexWarnings utf8WarnPos fs = do
-- Sections
let gpd = emptyGenericPackageDescription & L.packageDescription .~ pd
+ gpd1 <- view stateGpd <$> execStateT (goSections specVer sectionFields) (SectionS gpd Map.empty)
- view stateGpd <$> execStateT (goSections specVer sectionFields) (SectionS gpd Map.empty)
+ checkForUndefinedFlags gpd1
+ return gpd1
where
safeLast :: [a] -> Maybe a
safeLast = listToMaybe . reverse
@@ -220,11 +222,11 @@ parseGenericPackageDescription' cabalVerM lexWarnings utf8WarnPos fs = do
++ displaySpecVersion (specVersionRaw pkg)
++ "' must use section syntax. See the Cabal user guide for details."
where
- displaySpecVersion (Left version) = display version
+ displaySpecVersion (Left version) = prettyShow version
displaySpecVersion (Right versionRange) =
case asVersionIntervals versionRange of
- [] {- impossible -} -> display versionRange
- ((LowerBound version _, _):_) -> display (orLaterVersion version)
+ [] {- impossible -} -> prettyShow versionRange
+ ((LowerBound version _, _):_) -> prettyShow (orLaterVersion version)
maybeWarnCabalVersion _ _ = return ()
@@ -243,8 +245,9 @@ goSections specVer = traverse_ process
-- we need signature, because this is polymorphic, but not-closed
parseCondTree'
- :: FromBuildInfo a
+ :: L.HasBuildInfo a
=> ParsecFieldGrammar' a -- ^ grammar
+ -> (BuildInfo -> a)
-> Map String CondTreeBuildInfo -- ^ common stanzas
-> [Field Position]
-> ParseResult (CondTree ConfVar [Dependency] a)
@@ -258,7 +261,7 @@ goSections specVer = traverse_ process
| name == "common" = do
commonStanzas <- use stateCommonStanzas
name' <- lift $ parseCommonName pos args
- biTree <- lift $ parseCondTree' buildInfoFieldGrammar commonStanzas fields
+ biTree <- lift $ parseCondTree' buildInfoFieldGrammar id commonStanzas fields
case Map.lookup name' commonStanzas of
Nothing -> stateCommonStanzas .= Map.insert name' biTree commonStanzas
@@ -266,9 +269,15 @@ goSections specVer = traverse_ process
"Duplicate common stanza: " ++ name'
| name == "library" && null args = do
+ prev <- use $ stateGpd . L.condLibrary
+ when (isJust prev) $ lift $ parseFailure pos $
+ "Multiple main libraries; have you forgotten to specify a name for an internal library?"
+
commonStanzas <- use stateCommonStanzas
- lib <- lift $ parseCondTree' (libraryFieldGrammar Nothing) commonStanzas fields
- -- TODO: check that library is defined once
+ let name'' = LMainLibName
+ lib <- lift $ parseCondTree' (libraryFieldGrammar name'') (libraryFromBuildInfo name'') commonStanzas fields
+ --
+ -- TODO check that not set
stateGpd . L.condLibrary ?= lib
-- Sublibraries
@@ -276,7 +285,8 @@ goSections specVer = traverse_ process
| name == "library" = do
commonStanzas <- use stateCommonStanzas
name' <- parseUnqualComponentName pos args
- lib <- lift $ parseCondTree' (libraryFieldGrammar $ Just name') commonStanzas fields
+ let name'' = LSubLibName name'
+ lib <- lift $ parseCondTree' (libraryFieldGrammar name'') (libraryFromBuildInfo name'') commonStanzas fields
-- TODO check duplicate name here?
stateGpd . L.condSubLibraries %= snoc (name', lib)
@@ -284,15 +294,15 @@ goSections specVer = traverse_ process
| name == "foreign-library" = do
commonStanzas <- use stateCommonStanzas
name' <- parseUnqualComponentName pos args
- flib <- lift $ parseCondTree' (foreignLibFieldGrammar name') commonStanzas fields
+ flib <- lift $ parseCondTree' (foreignLibFieldGrammar name') (fromBuildInfo' name') commonStanzas fields
let hasType ts = foreignLibType ts /= foreignLibType mempty
unless (onAllBranches hasType flib) $ lift $ parseFailure pos $ concat
- [ "Foreign library " ++ show (display name')
+ [ "Foreign library " ++ show (prettyShow name')
, " is missing required field \"type\" or the field "
, "is not present in all conditional branches. The "
, "available test types are: "
- , intercalate ", " (map display knownForeignLibTypes)
+ , intercalate ", " (map prettyShow knownForeignLibTypes)
]
-- TODO check duplicate name here?
@@ -301,23 +311,23 @@ goSections specVer = traverse_ process
| name == "executable" = do
commonStanzas <- use stateCommonStanzas
name' <- parseUnqualComponentName pos args
- exe <- lift $ parseCondTree' (executableFieldGrammar name') commonStanzas fields
+ exe <- lift $ parseCondTree' (executableFieldGrammar name') (fromBuildInfo' name') commonStanzas fields
-- TODO check duplicate name here?
stateGpd . L.condExecutables %= snoc (name', exe)
| name == "test-suite" = do
commonStanzas <- use stateCommonStanzas
name' <- parseUnqualComponentName pos args
- testStanza <- lift $ parseCondTree' testSuiteFieldGrammar commonStanzas fields
+ testStanza <- lift $ parseCondTree' testSuiteFieldGrammar (fromBuildInfo' name') commonStanzas fields
testSuite <- lift $ traverse (validateTestSuite pos) testStanza
let hasType ts = testInterface ts /= testInterface mempty
unless (onAllBranches hasType testSuite) $ lift $ parseFailure pos $ concat
- [ "Test suite " ++ show (display name')
+ [ "Test suite " ++ show (prettyShow name')
, " is missing required field \"type\" or the field "
, "is not present in all conditional branches. The "
, "available test types are: "
- , intercalate ", " (map display knownTestTypes)
+ , intercalate ", " (map prettyShow knownTestTypes)
]
-- TODO check duplicate name here?
@@ -326,16 +336,16 @@ goSections specVer = traverse_ process
| name == "benchmark" = do
commonStanzas <- use stateCommonStanzas
name' <- parseUnqualComponentName pos args
- benchStanza <- lift $ parseCondTree' benchmarkFieldGrammar commonStanzas fields
+ benchStanza <- lift $ parseCondTree' benchmarkFieldGrammar (fromBuildInfo' name') commonStanzas fields
bench <- lift $ traverse (validateBenchmark pos) benchStanza
let hasType ts = benchmarkInterface ts /= benchmarkInterface mempty
unless (onAllBranches hasType bench) $ lift $ parseFailure pos $ concat
- [ "Benchmark " ++ show (display name')
+ [ "Benchmark " ++ show (prettyShow name')
, " is missing required field \"type\" or the field "
, "is not present in all conditional branches. The "
, "available benchmark types are: "
- , intercalate ", " (map display knownBenchmarkTypes)
+ , intercalate ", " (map prettyShow knownBenchmarkTypes)
]
-- TODO check duplicate name here?
@@ -343,7 +353,7 @@ goSections specVer = traverse_ process
| name == "flag" = do
name' <- parseNameBS pos args
- name'' <- lift $ runFieldParser' pos parsec specVer (fieldLineStreamFromBS name') `recoverWith` mkFlagName ""
+ name'' <- lift $ runFieldParser' [pos] parsec specVer (fieldLineStreamFromBS name') `recoverWith` mkFlagName ""
flag <- lift $ parseFields specVer fields (flagFieldGrammar name'')
-- Check default flag
stateGpd . L.genPackageFlags %= snoc flag
@@ -355,7 +365,7 @@ goSections specVer = traverse_ process
| name == "source-repository" = do
kind <- lift $ case args of
[SecArgName spos secName] ->
- runFieldParser' spos parsec specVer (fieldLineStreamFromBS secName) `recoverWith` RepoHead
+ runFieldParser' [spos] parsec specVer (fieldLineStreamFromBS secName) `recoverWith` RepoHead
[] -> do
parseFailure pos "'source-repository' requires exactly one argument"
pure RepoHead
@@ -418,30 +428,36 @@ parseFields v fields grammar = do
warnInvalidSubsection :: Section Position -> ParseResult ()
warnInvalidSubsection (MkSection (Name pos name) _ _) =
- void (parseFailure pos $ "invalid subsection " ++ show name)
+ void $ parseFailure pos $ "invalid subsection " ++ show name
parseCondTree
- :: forall a c.
- CabalSpecVersion
- -> HasElif -- ^ accept @elif@
- -> ParsecFieldGrammar' a -- ^ grammar
- -> (a -> c) -- ^ condition extractor
+ :: forall a. L.HasBuildInfo a
+ => CabalSpecVersion
+ -> HasElif -- ^ accept @elif@
+ -> ParsecFieldGrammar' a -- ^ grammar
+ -> Map String CondTreeBuildInfo -- ^ common stanzas
+ -> (BuildInfo -> a) -- ^ constructor from buildInfo
+ -> (a -> [Dependency]) -- ^ condition extractor
-> [Field Position]
- -> ParseResult (CondTree ConfVar c a)
-parseCondTree v hasElif grammar cond = go
+ -> ParseResult (CondTree ConfVar [Dependency] a)
+parseCondTree v hasElif grammar commonStanzas fromBuildInfo cond = go
where
- go fields = do
+ go fields0 = do
+ (fields, endo) <-
+ if v >= CabalSpecV3_0
+ then processImports v fromBuildInfo commonStanzas fields0
+ else traverse (warnImport v) fields0 >>= \fields1 -> return (catMaybes fields1, id)
+
let (fs, ss) = partitionFields fields
x <- parseFieldGrammar v fs grammar
branches <- concat <$> traverse parseIfs ss
- return (CondNode x (cond x) branches) -- TODO: branches
+ return $ endo $ CondNode x (cond x) branches
- parseIfs :: [Section Position] -> ParseResult [CondBranch ConfVar c a]
+ parseIfs :: [Section Position] -> ParseResult [CondBranch ConfVar [Dependency] a]
parseIfs [] = return []
parseIfs (MkSection (Name _ name) test fields : sections) | name == "if" = do
test' <- parseConditionConfVar test
fields' <- go fields
- -- TODO: else
(elseFields, sections') <- parseElseIfs sections
return (CondBranch test' fields' elseFields : sections')
parseIfs (MkSection (Name pos name) _ _ : sections) = do
@@ -450,7 +466,7 @@ parseCondTree v hasElif grammar cond = go
parseElseIfs
:: [Section Position]
- -> ParseResult (Maybe (CondTree ConfVar c a), [CondBranch ConfVar c a])
+ -> ParseResult (Maybe (CondTree ConfVar [Dependency] a), [CondBranch ConfVar [Dependency] a])
parseElseIfs [] = return (Nothing, [])
parseElseIfs (MkSection (Name pos name) args fields : sections) | name == "else" = do
unless (null args) $
@@ -459,10 +475,7 @@ parseCondTree v hasElif grammar cond = go
sections' <- parseIfs sections
return (Just elseFields, sections')
-
-
parseElseIfs (MkSection (Name _ name) test fields : sections) | hasElif == HasElif, name == "elif" = do
- -- TODO: check cabal-version
test' <- parseConditionConfVar test
fields' <- go fields
(elseFields, sections') <- parseElseIfs sections
@@ -536,44 +549,67 @@ with new AST, this all need to be rewritten.
type CondTreeBuildInfo = CondTree ConfVar [Dependency] BuildInfo
-- | Create @a@ from 'BuildInfo'.
+-- This class is used to implement common stanza parsing.
--
-- Law: @view buildInfo . fromBuildInfo = id@
+--
+-- This takes name, as 'FieldGrammar's take names too.
class L.HasBuildInfo a => FromBuildInfo a where
- fromBuildInfo :: BuildInfo -> a
+ fromBuildInfo' :: UnqualComponentName -> BuildInfo -> a
+
+libraryFromBuildInfo :: LibraryName -> BuildInfo -> Library
+libraryFromBuildInfo n bi = emptyLibrary
+ { libName = n
+ , libVisibility = case n of
+ LMainLibName -> LibraryVisibilityPublic
+ LSubLibName _ -> LibraryVisibilityPrivate
+ , libBuildInfo = bi
+ }
-instance FromBuildInfo BuildInfo where fromBuildInfo = id
-instance FromBuildInfo Library where fromBuildInfo bi = set L.buildInfo bi emptyLibrary
-instance FromBuildInfo ForeignLib where fromBuildInfo bi = set L.buildInfo bi emptyForeignLib
-instance FromBuildInfo Executable where fromBuildInfo bi = set L.buildInfo bi emptyExecutable
+instance FromBuildInfo BuildInfo where fromBuildInfo' _ = id
+instance FromBuildInfo ForeignLib where fromBuildInfo' n bi = set L.foreignLibName n $ set L.buildInfo bi emptyForeignLib
+instance FromBuildInfo Executable where fromBuildInfo' n bi = set L.exeName n $ set L.buildInfo bi emptyExecutable
instance FromBuildInfo TestSuiteStanza where
- fromBuildInfo = TestSuiteStanza Nothing Nothing Nothing
+ fromBuildInfo' _ bi = TestSuiteStanza Nothing Nothing Nothing bi
instance FromBuildInfo BenchmarkStanza where
- fromBuildInfo = BenchmarkStanza Nothing Nothing Nothing
+ fromBuildInfo' _ bi = BenchmarkStanza Nothing Nothing Nothing bi
parseCondTreeWithCommonStanzas
- :: forall a. FromBuildInfo a
+ :: forall a. L.HasBuildInfo a
=> CabalSpecVersion
-> ParsecFieldGrammar' a -- ^ grammar
+ -> (BuildInfo -> a) -- ^ construct fromBuildInfo
-> Map String CondTreeBuildInfo -- ^ common stanzas
-> [Field Position]
-> ParseResult (CondTree ConfVar [Dependency] a)
-parseCondTreeWithCommonStanzas v grammar commonStanzas = goImports []
+parseCondTreeWithCommonStanzas v grammar fromBuildInfo commonStanzas fields = do
+ (fields', endo) <- processImports v fromBuildInfo commonStanzas fields
+ x <- parseCondTree v hasElif grammar commonStanzas fromBuildInfo (view L.targetBuildDepends) fields'
+ return (endo x)
where
hasElif = specHasElif v
+
+processImports
+ :: forall a. L.HasBuildInfo a
+ => CabalSpecVersion
+ -> (BuildInfo -> a) -- ^ construct fromBuildInfo
+ -> Map String CondTreeBuildInfo -- ^ common stanzas
+ -> [Field Position]
+ -> ParseResult ([Field Position], CondTree ConfVar [Dependency] a -> CondTree ConfVar [Dependency] a)
+processImports v fromBuildInfo commonStanzas = go []
+ where
hasCommonStanzas = specHasCommonStanzas v
getList' :: List CommaFSep Token String -> [String]
getList' = Newtype.unpack
- -- parse leading imports
- -- not supported:
- goImports acc (Field (Name pos name) _ : fields) | name == "import", hasCommonStanzas == NoCommonStanzas = do
+ go acc (Field (Name pos name) _ : fields) | name == "import", hasCommonStanzas == NoCommonStanzas = do
parseWarning pos PWTUnknownField "Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas"
- goImports acc fields
+ go acc fields
-- supported:
- goImports acc (Field (Name pos name) fls : fields) | name == "import" = do
+ go acc (Field (Name pos name) fls : fields) | name == "import" = do
names <- getList' <$> runFieldParser pos parsec v fls
names' <- for names $ \commonName ->
case Map.lookup commonName commonStanzas of
@@ -583,23 +619,29 @@ parseCondTreeWithCommonStanzas v grammar commonStanzas = goImports []
Just commonTree ->
pure (Just commonTree)
- goImports (acc ++ catMaybes names') fields
-
- -- Go to parsing condTree after first non-import 'Field'.
- goImports acc fields = go acc fields
+ go (acc ++ catMaybes names') fields
-- parse actual CondTree
- go :: [CondTreeBuildInfo] -> [Field Position] -> ParseResult (CondTree ConfVar [Dependency] a)
- go bis fields = do
- x <- parseCondTree v hasElif grammar (view L.targetBuildDepends) fields
- pure $ foldr mergeCommonStanza x bis
+ go acc fields = do
+ fields' <- catMaybes <$> traverse (warnImport v) fields
+ pure $ (fields', \x -> foldr (mergeCommonStanza fromBuildInfo) x acc)
+
+-- | Warn on "import" fields, also map to Maybe, so errorneous fields can be filtered
+warnImport :: CabalSpecVersion -> Field Position -> ParseResult (Maybe (Field Position))
+warnImport v (Field (Name pos name) _) | name == "import" = do
+ if specHasCommonStanzas v == NoCommonStanzas
+ then parseWarning pos PWTUnknownField "Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas"
+ else parseWarning pos PWTUnknownField "Unknown field: import. Common stanza imports should be at the top of the enclosing section"
+ return Nothing
+warnImport _ f = pure (Just f)
mergeCommonStanza
- :: forall a. FromBuildInfo a
- => CondTree ConfVar [Dependency] BuildInfo
+ :: L.HasBuildInfo a
+ => (BuildInfo -> a)
+ -> CondTree ConfVar [Dependency] BuildInfo
-> CondTree ConfVar [Dependency] a
-> CondTree ConfVar [Dependency] a
-mergeCommonStanza (CondNode bi _ bis) (CondNode x _ cs) =
+mergeCommonStanza fromBuildInfo (CondNode bi _ bis) (CondNode x _ cs) =
CondNode x' (x' ^. L.targetBuildDepends) cs'
where
-- new value is old value with buildInfo field _prepended_.
@@ -631,6 +673,24 @@ onAllBranches p = go mempty
goBranch acc (CondBranch _ t (Just e)) = go acc t && go acc e
-------------------------------------------------------------------------------
+-- Flag check
+-------------------------------------------------------------------------------
+
+checkForUndefinedFlags :: GenericPackageDescription -> ParseResult ()
+checkForUndefinedFlags gpd = do
+ let definedFlags, usedFlags :: Set.Set FlagName
+ definedFlags = toSetOf (L.genPackageFlags . traverse . getting flagName) gpd
+ usedFlags = getConst $ L.allCondTrees f gpd
+
+ -- Note: we can check for defined, but unused flags here too.
+ unless (usedFlags `Set.isSubsetOf` definedFlags) $ parseFailure zeroPos $
+ "These flags are used without having been defined: " ++
+ intercalate ", " [ unFlagName fn | fn <- Set.toList $ usedFlags `Set.difference` definedFlags ]
+ where
+ f :: CondTree ConfVar c a -> Const (Set.Set FlagName) (CondTree ConfVar c a)
+ f ct = Const (Set.fromList (freeVars ct))
+
+-------------------------------------------------------------------------------
-- Old syntax
-------------------------------------------------------------------------------
@@ -698,7 +758,7 @@ data Syntax = OldSyntax | NewSyntax
-- TODO:
libFieldNames :: [FieldName]
-libFieldNames = fieldGrammarKnownFieldList (libraryFieldGrammar Nothing)
+libFieldNames = fieldGrammarKnownFieldList (libraryFieldGrammar LMainLibName)
-------------------------------------------------------------------------------
-- Suplementary build information
diff --git a/cabal/Cabal/Distribution/PackageDescription/PrettyPrint.hs b/cabal/Cabal/Distribution/PackageDescription/PrettyPrint.hs
index ed82819..f7cf2f6 100644
--- a/cabal/Cabal/Distribution/PackageDescription/PrettyPrint.hs
+++ b/cabal/Cabal/Distribution/PackageDescription/PrettyPrint.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.PackageDescription.PrettyPrint
@@ -16,6 +17,7 @@ module Distribution.PackageDescription.PrettyPrint (
-- * Generic package descriptions
writeGenericPackageDescription,
showGenericPackageDescription,
+ ppGenericPackageDescription,
-- * Package descriptions
writePackageDescription,
@@ -26,31 +28,31 @@ module Distribution.PackageDescription.PrettyPrint (
showHookedBuildInfo,
) where
-import Prelude ()
import Distribution.Compat.Prelude
+import Prelude ()
+import Distribution.Types.CondTree
import Distribution.Types.Dependency
-import Distribution.Types.ForeignLib (ForeignLib (foreignLibName))
+import Distribution.Types.ForeignLib (ForeignLib (foreignLibName))
+import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
-import Distribution.Types.CondTree
+import Distribution.CabalSpecVersion
+import Distribution.Fields.Pretty
import Distribution.PackageDescription
+import Distribution.Pretty
import Distribution.Simple.Utils
-import Distribution.ParseUtils
-import Distribution.Text
+import Distribution.Types.Version (versionNumbers)
-import Distribution.FieldGrammar (PrettyFieldGrammar', prettyFieldGrammar)
+import Distribution.FieldGrammar (PrettyFieldGrammar', prettyFieldGrammar)
import Distribution.PackageDescription.FieldGrammar
- (packageDescriptionFieldGrammar, buildInfoFieldGrammar,
- flagFieldGrammar, foreignLibFieldGrammar, libraryFieldGrammar,
- benchmarkFieldGrammar, testSuiteFieldGrammar,
- setupBInfoFieldGrammar, sourceRepoFieldGrammar, executableFieldGrammar)
+ (benchmarkFieldGrammar, buildInfoFieldGrammar, executableFieldGrammar, flagFieldGrammar,
+ foreignLibFieldGrammar, libraryFieldGrammar, packageDescriptionFieldGrammar,
+ setupBInfoFieldGrammar, sourceRepoFieldGrammar, testSuiteFieldGrammar)
import qualified Distribution.PackageDescription.FieldGrammar as FG
-import Text.PrettyPrint
- (hsep, space, parens, char, nest, ($$), (<+>),
- text, vcat, ($+$), Doc, render)
+import Text.PrettyPrint (Doc, char, hsep, parens, text, (<+>))
import qualified Data.ByteString.Lazy.Char8 as BS.Char8
@@ -60,63 +62,66 @@ writeGenericPackageDescription fpath pkg = writeUTF8File fpath (showGenericPacka
-- | Writes a generic package description to a string
showGenericPackageDescription :: GenericPackageDescription -> String
-showGenericPackageDescription = render . ($+$ text "") . ppGenericPackageDescription
-
-ppGenericPackageDescription :: GenericPackageDescription -> Doc
-ppGenericPackageDescription gpd =
- ppPackageDescription (packageDescription gpd)
- $+$ ppSetupBInfo (setupBuildInfo (packageDescription gpd))
- $+$ ppGenPackageFlags (genPackageFlags gpd)
- $+$ ppCondLibrary (condLibrary gpd)
- $+$ ppCondSubLibraries (condSubLibraries gpd)
- $+$ ppCondForeignLibs (condForeignLibs gpd)
- $+$ ppCondExecutables (condExecutables gpd)
- $+$ ppCondTestSuites (condTestSuites gpd)
- $+$ ppCondBenchmarks (condBenchmarks gpd)
-
-ppPackageDescription :: PackageDescription -> Doc
-ppPackageDescription pd =
- prettyFieldGrammar packageDescriptionFieldGrammar pd
- $+$ ppSourceRepos (sourceRepos pd)
-
-ppSourceRepos :: [SourceRepo] -> Doc
-ppSourceRepos [] = mempty
-ppSourceRepos (hd:tl) = ppSourceRepo hd $+$ ppSourceRepos tl
-
-ppSourceRepo :: SourceRepo -> Doc
-ppSourceRepo repo =
- emptyLine $ text "source-repository" <+> disp kind $+$
- nest indentWith (prettyFieldGrammar (sourceRepoFieldGrammar kind) repo)
+showGenericPackageDescription gpd = showFields (const []) $ ppGenericPackageDescription v gpd
+ where
+ v = cabalSpecFromVersionDigits
+ $ versionNumbers
+ $ specVersion
+ $ packageDescription gpd
+
+-- | Convert a generic package description to 'PrettyField's.
+ppGenericPackageDescription :: CabalSpecVersion -> GenericPackageDescription -> [PrettyField ()]
+ppGenericPackageDescription v gpd = concat
+ [ ppPackageDescription v (packageDescription gpd)
+ , ppSetupBInfo v (setupBuildInfo (packageDescription gpd))
+ , ppGenPackageFlags v (genPackageFlags gpd)
+ , ppCondLibrary v (condLibrary gpd)
+ , ppCondSubLibraries v (condSubLibraries gpd)
+ , ppCondForeignLibs v (condForeignLibs gpd)
+ , ppCondExecutables v (condExecutables gpd)
+ , ppCondTestSuites v (condTestSuites gpd)
+ , ppCondBenchmarks v (condBenchmarks gpd)
+ ]
+
+ppPackageDescription :: CabalSpecVersion -> PackageDescription -> [PrettyField ()]
+ppPackageDescription v pd =
+ prettyFieldGrammar v packageDescriptionFieldGrammar pd
+ ++ ppSourceRepos v (sourceRepos pd)
+
+ppSourceRepos :: CabalSpecVersion -> [SourceRepo] -> [PrettyField ()]
+ppSourceRepos = map . ppSourceRepo
+
+ppSourceRepo :: CabalSpecVersion -> SourceRepo -> PrettyField ()
+ppSourceRepo v repo = PrettySection () "source-repository" [pretty kind] $
+ prettyFieldGrammar v (sourceRepoFieldGrammar kind) repo
where
kind = repoKind repo
-ppSetupBInfo :: Maybe SetupBuildInfo -> Doc
-ppSetupBInfo Nothing = mempty
-ppSetupBInfo (Just sbi)
+ppSetupBInfo :: CabalSpecVersion -> Maybe SetupBuildInfo -> [PrettyField ()]
+ppSetupBInfo _ Nothing = mempty
+ppSetupBInfo v (Just sbi)
| defaultSetupDepends sbi = mempty
- | otherwise =
- emptyLine $ text "custom-setup" $+$
- nest indentWith (prettyFieldGrammar (setupBInfoFieldGrammar False) sbi)
+ | otherwise = pure $ PrettySection () "custom-setup" [] $
+ prettyFieldGrammar v (setupBInfoFieldGrammar False) sbi
-ppGenPackageFlags :: [Flag] -> Doc
-ppGenPackageFlags flds = vcat [ppFlag f | f <- flds]
+ppGenPackageFlags :: CabalSpecVersion -> [Flag] -> [PrettyField ()]
+ppGenPackageFlags = map . ppFlag
-ppFlag :: Flag -> Doc
-ppFlag flag@(MkFlag name _ _ _) =
- emptyLine $ text "flag" <+> ppFlagName name $+$
- nest indentWith (prettyFieldGrammar (flagFieldGrammar name) flag)
+ppFlag :: CabalSpecVersion -> Flag -> PrettyField ()
+ppFlag v flag@(MkFlag name _ _ _) = PrettySection () "flag" [ppFlagName name] $
+ prettyFieldGrammar v (flagFieldGrammar name) flag
-ppCondTree2 :: PrettyFieldGrammar' s -> CondTree ConfVar [Dependency] s -> Doc
-ppCondTree2 grammar = go
+ppCondTree2 :: CabalSpecVersion -> PrettyFieldGrammar' s -> CondTree ConfVar [Dependency] s -> [PrettyField ()]
+ppCondTree2 v grammar = go
where
-- TODO: recognise elif opportunities
go (CondNode it _ ifs) =
- prettyFieldGrammar grammar it
- $+$ vcat (map ppIf ifs)
+ prettyFieldGrammar v grammar it ++
+ concatMap ppIf ifs
ppIf (CondBranch c thenTree Nothing)
-- | isEmpty thenDoc = mempty
- | otherwise = ppIfCondition c $$ nest indentWith thenDoc
+ | otherwise = [ppIfCondition c thenDoc]
where
thenDoc = go thenTree
@@ -124,52 +129,52 @@ ppCondTree2 grammar = go
case (False, False) of
-- case (isEmpty thenDoc, isEmpty elseDoc) of
(True, True) -> mempty
- (False, True) -> ppIfCondition c $$ nest indentWith thenDoc
- (True, False) -> ppIfCondition (cNot c) $$ nest indentWith elseDoc
- (False, False) -> (ppIfCondition c $$ nest indentWith thenDoc)
- $+$ (text "else" $$ nest indentWith elseDoc)
+ (False, True) -> [ ppIfCondition c thenDoc ]
+ (True, False) -> [ ppIfCondition (cNot c) elseDoc ]
+ (False, False) -> [ ppIfCondition c thenDoc
+ , PrettySection () "else" [] elseDoc
+ ]
where
thenDoc = go thenTree
elseDoc = go elseTree
-ppCondLibrary :: Maybe (CondTree ConfVar [Dependency] Library) -> Doc
-ppCondLibrary Nothing = mempty
-ppCondLibrary (Just condTree) =
- emptyLine $ text "library" $+$
- nest indentWith (ppCondTree2 (libraryFieldGrammar Nothing) condTree)
+ppCondLibrary :: CabalSpecVersion -> Maybe (CondTree ConfVar [Dependency] Library) -> [PrettyField ()]
+ppCondLibrary _ Nothing = mempty
+ppCondLibrary v (Just condTree) = pure $ PrettySection () "library" [] $
+ ppCondTree2 v (libraryFieldGrammar LMainLibName) condTree
-ppCondSubLibraries :: [(UnqualComponentName, CondTree ConfVar [Dependency] Library)] -> Doc
-ppCondSubLibraries libs = vcat
- [ emptyLine $ (text "library" <+> disp n) $+$
- nest indentWith (ppCondTree2 (libraryFieldGrammar $ Just n) condTree)
+ppCondSubLibraries :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)] -> [PrettyField ()]
+ppCondSubLibraries v libs =
+ [ PrettySection () "library" [pretty n]
+ $ ppCondTree2 v (libraryFieldGrammar $ LSubLibName n) condTree
| (n, condTree) <- libs
]
-ppCondForeignLibs :: [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)] -> Doc
-ppCondForeignLibs flibs = vcat
- [ emptyLine $ (text "foreign-library" <+> disp n) $+$
- nest indentWith (ppCondTree2 (foreignLibFieldGrammar n) condTree)
+ppCondForeignLibs :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)] -> [PrettyField ()]
+ppCondForeignLibs v flibs =
+ [ PrettySection () "foreign-library" [pretty n]
+ $ ppCondTree2 v (foreignLibFieldGrammar n) condTree
| (n, condTree) <- flibs
]
-ppCondExecutables :: [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)] -> Doc
-ppCondExecutables exes = vcat
- [ emptyLine $ (text "executable" <+> disp n) $+$
- nest indentWith (ppCondTree2 (executableFieldGrammar n) condTree)
+ppCondExecutables :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)] -> [PrettyField ()]
+ppCondExecutables v exes =
+ [ PrettySection () "executable" [pretty n]
+ $ ppCondTree2 v (executableFieldGrammar n) condTree
| (n, condTree) <- exes
]
-ppCondTestSuites :: [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)] -> Doc
-ppCondTestSuites suites = vcat
- [ emptyLine $ (text "test-suite" <+> disp n) $+$
- nest indentWith (ppCondTree2 testSuiteFieldGrammar (fmap FG.unvalidateTestSuite condTree))
+ppCondTestSuites :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)] -> [PrettyField ()]
+ppCondTestSuites v suites =
+ [ PrettySection () "test-suite" [pretty n]
+ $ ppCondTree2 v testSuiteFieldGrammar (fmap FG.unvalidateTestSuite condTree)
| (n, condTree) <- suites
]
-ppCondBenchmarks :: [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)] -> Doc
-ppCondBenchmarks suites = vcat
- [ emptyLine $ (text "benchmark" <+> disp n) $+$
- nest indentWith (ppCondTree2 benchmarkFieldGrammar (fmap FG.unvalidateBenchmark condTree))
+ppCondBenchmarks :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)] -> [PrettyField ()]
+ppCondBenchmarks v suites =
+ [ PrettySection () "benchmark" [pretty n]
+ $ ppCondTree2 v benchmarkFieldGrammar (fmap FG.unvalidateBenchmark condTree)
| (n, condTree) <- suites
]
@@ -182,19 +187,16 @@ ppCondition (COr c1 c2) = parens (hsep [ppCondition c1, text "|
ppCondition (CAnd c1 c2) = parens (hsep [ppCondition c1, text "&&"
<+> ppCondition c2])
ppConfVar :: ConfVar -> Doc
-ppConfVar (OS os) = text "os" <<>> parens (disp os)
-ppConfVar (Arch arch) = text "arch" <<>> parens (disp arch)
+ppConfVar (OS os) = text "os" <<>> parens (pretty os)
+ppConfVar (Arch arch) = text "arch" <<>> parens (pretty arch)
ppConfVar (Flag name) = text "flag" <<>> parens (ppFlagName name)
-ppConfVar (Impl c v) = text "impl" <<>> parens (disp c <+> disp v)
+ppConfVar (Impl c v) = text "impl" <<>> parens (pretty c <+> pretty v)
ppFlagName :: FlagName -> Doc
ppFlagName = text . unFlagName
-ppIfCondition :: (Condition ConfVar) -> Doc
-ppIfCondition c = (emptyLine $ text "if" <+> ppCondition c)
-
-emptyLine :: Doc -> Doc
-emptyLine d = text "" $+$ d
+ppIfCondition :: Condition ConfVar -> [PrettyField ()] -> PrettyField ()
+ppIfCondition c = PrettySection () "if" [ppCondition c]
-- | @since 2.0.0.2
writePackageDescription :: FilePath -> PackageDescription -> NoCallStackIO ()
@@ -222,7 +224,7 @@ pdToGpd pd = GenericPackageDescription
-- We set CondTree's [Dependency] to an empty list, as it
-- is not pretty printed anyway.
mkCondTree x = CondNode x [] []
- mkCondTreeL l = (fromMaybe (mkUnqualComponentName "") (libName l), CondNode l [] [])
+ mkCondTreeL l = (fromMaybe (mkUnqualComponentName "") (libraryNameString (libName l)), CondNode l [] [])
mkCondTree'
:: (a -> UnqualComponentName)
@@ -236,12 +238,9 @@ writeHookedBuildInfo fpath = writeFileAtomic fpath . BS.Char8.pack
-- | @since 2.0.0.2
showHookedBuildInfo :: HookedBuildInfo -> String
-showHookedBuildInfo (mb_lib_bi, ex_bis) = render $
- maybe mempty (prettyFieldGrammar buildInfoFieldGrammar) mb_lib_bi
- $$ vcat
- [ space
- $$ (text "executable:" <+> disp name)
- $$ prettyFieldGrammar buildInfoFieldGrammar bi
- | (name, bi) <- ex_bis
- ]
- $+$ text ""
+showHookedBuildInfo (mb_lib_bi, ex_bis) = showFields (const []) $
+ maybe mempty (prettyFieldGrammar cabalSpecLatest buildInfoFieldGrammar) mb_lib_bi ++
+ [ PrettySection () "executable:" [pretty name]
+ $ prettyFieldGrammar cabalSpecLatest buildInfoFieldGrammar bi
+ | (name, bi) <- ex_bis
+ ]
diff --git a/cabal/Cabal/Distribution/PackageDescription/Quirks.hs b/cabal/Cabal/Distribution/PackageDescription/Quirks.hs
index 0a7e28c..37d75e8 100644
--- a/cabal/Cabal/Distribution/PackageDescription/Quirks.hs
+++ b/cabal/Cabal/Distribution/PackageDescription/Quirks.hs
@@ -152,6 +152,95 @@ patches = Map.fromList
(Fingerprint 13690322768477779172 19704059263540994)
(Fingerprint 11189374824645442376 8363528115442591078)
(bsReplace "&&!" "&& !")
+ -- flag used, but not defined
+ , mk "name: brainheck\nversion: 0.1.0.2\nsynopsis: Brainh*ck interpreter in haskell\ndescription: Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\nhomepage: https://gi"
+ (Fingerprint 6910727116443152200 15401634478524888973)
+ (Fingerprint 16551412117098094368 16260377389127603629)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: brainheck\r\nversion: 0.1.0.2\r\nx-revision: 1\r\nsynopsis: Brainh*ck interpreter in haskell\r\ndescription: Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage: "
+ (Fingerprint 14320987921316832277 10031098243571536929)
+ (Fingerprint 7959395602414037224 13279941216182213050)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: brainheck\r\nversion: 0.1.0.2\r\nx-revision: 2\r\nsynopsis: Brainh*ck interpreter in haskell\r\ndescription: Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage: "
+ (Fingerprint 3809078390223299128 10796026010775813741)
+ (Fingerprint 1127231189459220796 12088367524333209349)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: brainheck\r\nversion: 0.1.0.2\r\nx-revision: 3\r\nsynopsis: Brainh*ck interpreter in haskell\r\ndescription: Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage: "
+ (Fingerprint 13860013038089410950 12479824176801390651)
+ (Fingerprint 4687484721703340391 8013395164515771785)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: wordchoice\nversion: 0.1.0.1\nsynopsis: Get word counts and distributions\ndescription: A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"
+ (Fingerprint 16215911397419608203 15594928482155652475)
+ (Fingerprint 15120681510314491047 2666192399775157359)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: wordchoice\r\nversion: 0.1.0.1\r\nx-revision: 1\r\nsynopsis: Get word counts and distributions\r\ndescription: A command line tool to compute the word distribution from various types of document, converting to te"
+ (Fingerprint 16593139224723441188 4052919014346212001)
+ (Fingerprint 3577381082410411593 11481899387780544641)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: wordchoice\nversion: 0.1.0.2\nsynopsis: Get word counts and distributions\ndescription: A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"
+ (Fingerprint 9321301260802539374 1316392715016096607)
+ (Fingerprint 3784628652257760949 12662640594755291035)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: wordchoice\r\nversion: 0.1.0.2\r\nx-revision: 1\r\nsynopsis: Get word counts and distributions\r\ndescription: A command line tool to compute the word distribution from various types of document, converting to te"
+ (Fingerprint 2546901804824433337 2059732715322561176)
+ (Fingerprint 8082068680348326500 615008613291421947)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: wordchoice\nversion: 0.1.0.3\nsynopsis: Get word counts and distributions\ndescription: A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"
+ (Fingerprint 2282380737467965407 12457554753171662424)
+ (Fingerprint 17324757216926991616 17172911843227482125)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: wordchoice\r\nversion: 0.1.0.3\r\nx-revision: 1\r\nsynopsis: Get word counts and distributions\r\ndescription: A command line tool to compute the word distribution from various types of document, converting to te"
+ (Fingerprint 12907988890480595481 11078473638628359710)
+ (Fingerprint 13246185333368731848 4663060731847518614)
+ (bsReplace "flag(llvm-fast)" "False")
+ , mk "name: hw-prim-bits\nversion: 0.1.0.0\nsynopsis: Primitive support for bit manipulation\ndescription: Please see README.md\nhomepage: https://github.com/githubuser/hw-prim-bits#readme\nlicense: "
+ (Fingerprint 12386777729082870356 17414156731912743711)
+ (Fingerprint 3452290353395041602 14102887112483033720)
+ (bsReplace "flag(sse42)" "False")
+ , mk "name: hw-prim-bits\nversion: 0.1.0.1\nsynopsis: Primitive support for bit manipulation\ndescription: Please see README.md\nhomepage: https://github.com/githubuser/hw-prim-bits#readme\nlicen"
+ (Fingerprint 6870520675313101180 14553457351296240636)
+ (Fingerprint 12481021059537696455 14711088786769892762)
+ (bsReplace "flag(sse42)" "False")
+ -- leading zeros in version digits
+ -- https://github.com/haskell-infra/hackage-trustees/issues/128
+ -- https://github.com/haskell/cabal/issues/5092
+ -- https://github.com/haskell/cabal/issues/5138
+ , mk "name: Sit\nversion: 0.2017.02.26\nbuild-type: Simple\ncabal-version: >= 1.8\nlicense: OtherLicense\nlicense-file: LICENSE\nauthor: Anonymous\nmaintainer: Anonymous\nhomepage: NONE\ncategory: Dependent"
+ (Fingerprint 8458530898096910998 3228538743646501413)
+ (Fingerprint 14470502514907936793 17514354054641875371)
+ (bsReplace "0.2017.02.26" "0.2017.2.26")
+ , mk "name: Sit\nversion: 0.2017.05.01\nbuild-type: Simple\ncabal-version: >= 1.8\nlicense: OtherLicense\nlicense-file: LICENSE\nauthor: Andreas Abel <andreas.abel@gu.se>\nmaintainer: Andreas Abel <andreas.abel@gu.se>\n"
+ (Fingerprint 1450130849535097473 11742099607098860444)
+ (Fingerprint 16679762943850814021 4253724355613883542)
+ (bsReplace "0.2017.05.01" "0.2017.5.1")
+ , mk "name: Sit\nversion: 0.2017.05.02\nbuild-type: Simple\ncabal-version: >= 1.8\nlicense: OtherLicense\nlicense-file: LICENSE\nauthor: Andreas Abel <andreas.abel@gu.se>\nmaintainer: Andreas Abel <andreas.abel@gu.se>\n"
+ (Fingerprint 297248532398492441 17322625167861324800)
+ (Fingerprint 634812045126693280 1755581866539318862)
+ (bsReplace "0.2017.05.02" "0.2017.5.2")
+ , mk "name: Sit\nversion: 0.2017.5.02\nx-revision: 1\n-- x-revision:1 see https://github.com/haskell-infra/hackage-trustees/issues/128\nbuild-type: Simple\ncabal-version: >= 1.8\nlicense: OtherLicense\nlicense-file: LICENSE\nauthor: "
+ (Fingerprint 3697869560530373941 3942982281026987312)
+ (Fingerprint 14344526114710295386 16386400353475114712)
+ (bsReplace "0.2017.5.02" "0.2017.5.2")
+ , mk "name: MiniAgda\nversion: 0.2017.02.18\nbuild-type: Simple\ncabal-version: >= 1.22\nlicense: OtherLicense\nlicense-file: LICENSE\nauthor: Andreas Abel and Karl Mehltretter\nmaintainer: Andreas Abel <andreas.abel@i"
+ (Fingerprint 17167128953451088679 4300350537748753465)
+ (Fingerprint 12402236925293025673 7715084875284020606)
+ (bsReplace "0.2017.02.18" "0.2017.2.18")
+ , mk "cabal-version:\n 2.0\nname:\n fast-downward\nversion:\n 0.1.0.0\nbuild-type:\n Simple\nsynopsis:\n Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n @fast-downward@ is a library for modelling classical planning probl"
+ (Fingerprint 11256076039027887363 6867903407496243216)
+ (Fingerprint 12159816716813155434 5278015399212299853)
+ (bsReplace "1.2.03.0" "1.2.3.0")
+ , mk "cabal-version:\r\n 2.0\r\nname:\r\n fast-downward\r\nversion:\r\n 0.1.0.0\r\nx-revision: \r\n 1\r\nbuild-type:\r\n Simple\r\nsynopsis:\r\n Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\r\ndescription:\r\n @fast-downward@ is a library for mode"
+ (Fingerprint 9216193973149680231 893446343655828508)
+ (Fingerprint 10020169545407746427 1828336750379510675)
+ (bsReplace "1.2.03.0" "1.2.3.0")
+ , mk "cabal-version:\n 2.0\nname:\n fast-downward\nversion:\n 0.1.0.1\nbuild-type:\n Simple\nsynopsis:\n Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n @fast-downward@ is a library for modelling classical planning probl"
+ (Fingerprint 9899886602574848632 5980433644983783334)
+ (Fingerprint 12007469255857289958 8321466548645225439)
+ (bsReplace "1.2.03.0" "1.2.3.0")
+ , mk "cabal-version:\n 2.0\nname:\n fast-downward\nversion:\n 0.1.1.0\nbuild-type:\n Simple\nsynopsis:\n Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n @fast-downward@ is a library for modelling classical planning probl"
+ (Fingerprint 12694656661460787751 1902242956706735615)
+ (Fingerprint 15433152131513403849 2284712791516353264)
+ (bsReplace "1.2.03.0" "1.2.3.0")
]
where
mk a b c d = ((a, b), (c, d))
diff --git a/cabal/Cabal/Distribution/Parsec/Class.hs b/cabal/Cabal/Distribution/Parsec.hs
index d65ea54..3b23a31 100644
--- a/cabal/Cabal/Distribution/Parsec/Class.hs
+++ b/cabal/Cabal/Distribution/Parsec.hs
@@ -1,18 +1,32 @@
-{-# LANGUAGE GADTs #-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
-module Distribution.Parsec.Class (
+module Distribution.Parsec (
Parsec(..),
ParsecParser (..),
runParsecParser,
+ runParsecParser',
simpleParsec,
lexemeParsec,
eitherParsec,
explicitEitherParsec,
- -- * CabalParsing & warnings
+ -- * CabalParsing and and diagnostics
CabalParsing (..),
+ -- ** Warnings
PWarnType (..),
+ PWarning (..),
+ showPWarning,
+ -- ** Errors
+ PError (..),
+ showPError,
+ -- * Position
+ Position (..),
+ incPos,
+ retPos,
+ showPos,
+ zeroPos,
-- * Utilities
parsecToken,
parsecToken',
@@ -22,23 +36,25 @@ module Distribution.Parsec.Class (
parsecCommaList,
parsecLeadingCommaList,
parsecOptCommaList,
+ parsecLeadingOptCommaList,
parsecStandard,
parsecUnqualComponentName,
) where
-import Data.Char (digitToInt, intToDigit)
-import Data.Functor.Identity (Identity (..))
-import Data.List (transpose)
+import Data.Char (digitToInt, intToDigit)
+import Data.Functor.Identity (Identity (..))
+import Data.List (transpose)
import Distribution.CabalSpecVersion
import Distribution.Compat.Prelude
-import Distribution.Parsec.FieldLineStream
-import Distribution.Parsec.Common (PWarnType (..), PWarning (..), Position (..))
-import Numeric (showIntAtBase)
+import Distribution.Parsec.Error (PError (..), showPError)
+import Distribution.Parsec.FieldLineStream (FieldLineStream, fieldLineStreamFromString)
+import Distribution.Parsec.Position (Position (..), incPos, retPos, showPos, zeroPos)
+import Distribution.Parsec.Warning (PWarnType (..), PWarning (..), showPWarning)
+import Numeric (showIntAtBase)
import Prelude ()
import qualified Distribution.Compat.CharParsing as P
import qualified Distribution.Compat.MonadFail as Fail
-import qualified Distribution.Compat.ReadP as ReadP
import qualified Text.Parsec as Parsec
-------------------------------------------------------------------------------
@@ -46,6 +62,9 @@ import qualified Text.Parsec as Parsec
-------------------------------------------------------------------------------
-- | Class for parsing with @parsec@. Mainly used for @.cabal@ file fields.
+--
+-- For parsing @.cabal@ like file structure, see "Distribution.Fields".
+--
class Parsec a where
parsec :: CabalParsing m => m a
@@ -55,7 +74,7 @@ class Parsec a where
--
-- * knows @cabal-version@ we work with
--
-class (P.CharParsing m, MonadPlus m) => CabalParsing m where
+class (P.CharParsing m, MonadPlus m, Fail.MonadFail m) => CabalParsing m where
parsecWarning :: PWarnType -> String -> m ()
parsecHaskellString :: m String
@@ -63,10 +82,6 @@ class (P.CharParsing m, MonadPlus m) => CabalParsing m where
askCabalSpecVersion :: m CabalSpecVersion
-instance t ~ Char => CabalParsing (ReadP.Parser r t) where
- parsecWarning _ _ = pure ()
- askCabalSpecVersion = pure cabalSpecLatest
-
-- | 'parsec' /could/ consume trailing spaces, this function /will/ consume.
lexemeParsec :: (CabalParsing m, Parsec a) => m a
lexemeParsec = parsec <* P.spaces
@@ -116,7 +131,9 @@ instance Monad ParsecParser where
(>>) = (*>)
{-# INLINE (>>) #-}
+#if !(MIN_VERSION_base(4,13,0))
fail = Fail.fail
+#endif
instance MonadPlus ParsecParser where
mzero = empty
@@ -142,7 +159,10 @@ instance P.CharParsing ParsecParser where
string = liftParsec . P.string
instance CabalParsing ParsecParser where
- parsecWarning t w = liftParsec $ Parsec.modifyState (PWarning t (Position 0 0) w :)
+ parsecWarning t w = liftParsec $ do
+ spos <- Parsec.getPosition
+ Parsec.modifyState
+ (PWarning t (Position (Parsec.sourceLine spos) (Parsec.sourceColumn spos)) w :)
askCabalSpecVersion = PP pure
-- | Parse a 'String' with 'lexemeParsec'.
@@ -165,7 +185,14 @@ explicitEitherParsec parser
-- | Run 'ParsecParser' with 'cabalSpecLatest'.
runParsecParser :: ParsecParser a -> FilePath -> FieldLineStream -> Either Parsec.ParseError a
-runParsecParser p n = Parsec.runParser (unPP p cabalSpecLatest <* P.eof) [] n
+runParsecParser = runParsecParser' cabalSpecLatest
+
+-- | Like 'runParsecParser' but lets specify 'CabalSpecVersion' used.
+--
+-- @since 3.0.0.0
+--
+runParsecParser' :: CabalSpecVersion -> ParsecParser a -> FilePath -> FieldLineStream -> Either Parsec.ParseError a
+runParsecParser' v p n = Parsec.runParser (unPP p v <* P.eof) [] n
instance Parsec a => Parsec (Identity a) where
parsec = Identity <$> parsec
@@ -244,6 +271,37 @@ parsecOptCommaList p = P.sepBy (p <* P.spaces) (P.optional comma)
where
comma = P.char ',' *> P.spaces
+-- | Like 'parsecOptCommaList' but
+--
+-- * require all or none commas
+-- * accept leading or trailing comma.
+--
+-- @
+-- p (comma p)* -- p `sepBy` comma
+-- (comma p)* -- leading comma
+-- (p comma)* -- trailing comma
+-- p* -- no commas: many p
+-- @
+--
+-- @since 3.0.0.0
+--
+parsecLeadingOptCommaList :: CabalParsing m => m a -> m [a]
+parsecLeadingOptCommaList p = do
+ c <- P.optional comma
+ case c of
+ Nothing -> sepEndBy1Start <|> pure []
+ Just _ -> P.sepBy1 lp comma
+ where
+ lp = p <* P.spaces
+ comma = P.char ',' *> P.spaces P.<?> "comma"
+
+ sepEndBy1Start = do
+ x <- lp
+ c <- P.optional comma
+ case c of
+ Nothing -> (x :) <$> many lp
+ Just _ -> (x :) <$> P.sepEndBy lp comma
+
-- | Content isn't unquoted
parsecQuoted :: CabalParsing m => m a -> m a
parsecQuoted = P.between (P.char '"') (P.char '"')
diff --git a/cabal/Cabal/Distribution/Parsec/Error.hs b/cabal/Cabal/Distribution/Parsec/Error.hs
new file mode 100644
index 0000000..2e958de
--- /dev/null
+++ b/cabal/Cabal/Distribution/Parsec/Error.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE DeriveGeneric #-}
+module Distribution.Parsec.Error (
+ PError (..),
+ showPError,
+ ) where
+
+import Distribution.Compat.Prelude
+import Distribution.Parsec.Position
+import Prelude ()
+import System.FilePath (normalise)
+
+-- | Parser error.
+data PError = PError Position String
+ deriving (Show, Generic)
+
+instance Binary PError
+instance NFData PError where rnf = genericRnf
+
+showPError :: FilePath -> PError -> String
+showPError fpath (PError pos msg) =
+ normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg
diff --git a/cabal/Cabal/Distribution/Parsec/FieldLineStream.hs b/cabal/Cabal/Distribution/Parsec/FieldLineStream.hs
index 1ac772c..670fa85 100644
--- a/cabal/Cabal/Distribution/Parsec/FieldLineStream.hs
+++ b/cabal/Cabal/Distribution/Parsec/FieldLineStream.hs
@@ -1,37 +1,32 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings , ScopedTypeVariables #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Distribution.Parsec.FieldLineStream (
FieldLineStream (..),
- fieldLinesToStream,
fieldLineStreamFromString,
fieldLineStreamFromBS,
+ fieldLineStreamEnd,
) where
import Data.Bits
import Data.ByteString (ByteString)
import Distribution.Compat.Prelude
-import Distribution.Parsec.Field (FieldLine (..))
import Distribution.Utils.Generic (toUTF8BS)
import Prelude ()
import qualified Data.ByteString as BS
import qualified Text.Parsec as Parsec
--- | This is essentially a lazy bytestring, but chunks are glued with newline '\n'.
+-- | This is essentially a lazy bytestring, but chunks are glued with newline @\'\\n\'@.
data FieldLineStream
= FLSLast !ByteString
| FLSCons {-# UNPACK #-} !ByteString FieldLineStream
deriving Show
-fieldLinesToStream :: [FieldLine ann] -> FieldLineStream
-fieldLinesToStream [] = end
-fieldLinesToStream [FieldLine _ bs] = FLSLast bs
-fieldLinesToStream (FieldLine _ bs : fs) = FLSCons bs (fieldLinesToStream fs)
-
-end :: FieldLineStream
-end = FLSLast ""
+fieldLineStreamEnd :: FieldLineStream
+fieldLineStreamEnd = FLSLast mempty
-- | Convert 'String' to 'FieldLineStream'.
--
@@ -45,14 +40,14 @@ fieldLineStreamFromBS = FLSLast
instance Monad m => Parsec.Stream FieldLineStream m Char where
uncons (FLSLast bs) = return $ case BS.uncons bs of
Nothing -> Nothing
- Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSLast bs'') end)
+ Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSLast bs'') fieldLineStreamEnd)
uncons (FLSCons bs s) = return $ case BS.uncons bs of
-- as lines are glued with '\n', we return '\n' here!
Nothing -> Just ('\n', s)
Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSCons bs'' s) s)
--- Bssed on implementation 'decodeStringUtf8'
+-- Based on implementation 'decodeStringUtf8'
unconsChar :: forall a. Word8 -> ByteString -> (ByteString -> a) -> a -> (Char, a)
unconsChar c0 bs0 f next
| c0 <= 0x7F = (chr (fromIntegral c0), f bs0)
diff --git a/cabal/Cabal/Distribution/Parsec/Lexer.hs b/cabal/Cabal/Distribution/Parsec/Lexer.hs
deleted file mode 100644
index 64f5222..0000000
--- a/cabal/Cabal/Distribution/Parsec/Lexer.hs
+++ /dev/null
@@ -1,422 +0,0 @@
-{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}
-{-# LANGUAGE CPP,MagicHash #-}
-{-# LINE 1 "boot/Lexer.x" #-}
-
------------------------------------------------------------------------------
--- |
--- Module : Distribution.Parsec.Lexer
--- License : BSD3
---
--- Maintainer : cabal-devel@haskell.org
--- Portability : portable
---
--- Lexer for the cabal files.
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE BangPatterns #-}
-#ifdef CABAL_PARSEC_DEBUG
-{-# LANGUAGE PatternGuards #-}
-#endif
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-module Distribution.Parsec.Lexer
- (ltest, lexToken, Token(..), LToken(..)
- ,bol_section, in_section, in_field_layout, in_field_braces
- ,mkLexState) where
-
--- [Note: boostrapping parsec parser]
---
--- We manually produce the `Lexer.hs` file from `boot/Lexer.x` (make lexer)
--- because boostrapping cabal-install would be otherwise tricky.
--- Alex is (atm) tricky package to build, cabal-install has some magic
--- to move bundled generated files in place, so rather we don't depend
--- on it before we can build it ourselves.
--- Therefore there is one thing less to worry in bootstrap.sh, which is a win.
---
--- See also https://github.com/haskell/cabal/issues/4633
---
-
-import Prelude ()
-import qualified Prelude as Prelude
-import Distribution.Compat.Prelude
-
-import Distribution.Parsec.LexerMonad
-import Distribution.Parsec.Common (Position (..), incPos, retPos)
-import Data.ByteString (ByteString)
-import qualified Data.ByteString as B
-import qualified Data.ByteString.Char8 as B.Char8
-import qualified Data.Word as Word
-
-#ifdef CABAL_PARSEC_DEBUG
-import Debug.Trace
-import qualified Data.Vector as V
-import qualified Data.Text as T
-import qualified Data.Text.Encoding as T
-import qualified Data.Text.Encoding.Error as T
-#endif
-
-#if __GLASGOW_HASKELL__ >= 603
-#include "ghcconfig.h"
-#elif defined(__GLASGOW_HASKELL__)
-#include "config.h"
-#endif
-#if __GLASGOW_HASKELL__ >= 503
-import Data.Array
-import Data.Array.Base (unsafeAt)
-#else
-import Array
-#endif
-#if __GLASGOW_HASKELL__ >= 503
-import GHC.Exts
-#else
-import GlaExts
-#endif
-alex_tab_size :: Int
-alex_tab_size = 8
-alex_base :: AlexAddr
-alex_base = AlexA# "\x12\xff\xff\xff\xf9\xff\xff\xff\xfb\xff\xff\xff\x01\x00\x00\x00\x2f\x00\x00\x00\x50\x00\x00\x00\xd0\x00\x00\x00\x48\xff\xff\xff\xdc\xff\xff\xff\x51\xff\xff\xff\x6d\xff\xff\xff\x6f\xff\xff\xff\x50\x01\x00\x00\x74\x01\x00\x00\x70\xff\xff\xff\x68\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\xa3\x01\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6a\x00\x00\x00\xd1\x01\x00\x00\xfb\x01\x00\x00\x7b\x02\x00\x00\xfb\x02\x00\x00\x00\x00\x00\x00\x7b\x03\x00\x00\x7d\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x6d\x00\x00\x00\x6b\x00\x00\x00\xfc\x03\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x6f\x00\x00\x00\x1c\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00"#
-
-alex_table :: AlexAddr
-alex_table = AlexA# "\x00\x00\x09\x00\x0f\x00\x11\x00\x02\x00\x11\x00\x12\x00\x00\x00\x12\x00\x13\x00\x03\x00\x11\x00\x07\x00\x10\x00\x12\x00\x25\x00\x14\x00\x11\x00\x10\x00\x11\x00\x14\x00\x11\x00\x12\x00\x23\x00\x12\x00\x0f\x00\x28\x00\x02\x00\x2e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x08\x00\x10\x00\x00\x00\x14\x00\x00\x00\x00\x00\x08\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2a\x00\x2e\x00\xff\xff\xff\xff\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x26\x00\x28\x00\xff\xff\xff\xff\x29\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x26\x00\x0f\x00\x11\x00\x17\x00\x26\x00\x12\x00\x25\x00\x11\x00\x2a\x00\x00\x00\x12\x00\x00\x00\x15\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x17\x00\x26\x00\x00\x00\x25\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2c\x00\x00\x00\x2d\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x0e\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x23\x00\xff\xff\xff\xff\x24\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x1e\x00\x0d\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x1f\x00\x1f\x00\x1e\x00\x1e\x00\x1e\x00\x19\x00\x1a\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x1f\x00\x1e\x00\x1f\x00\x1e\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x21\x00\x1e\x00\x22\x00\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x1d\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x0c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1e\x00\xff\xff\x1e\x00\x1e\x00\x1e\x00\x1e\x00\xff\xff\xff\xff\xff\xff\x1e\x00\x1e\x00\x1e\x00\x18\x00\x1a\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1e\x00\xff\xff\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\xff\xff\xff\xff\x1e\x00\x1e\x00\x1e\x00\x1a\x00\x1a\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x1e\x00\xff\xff\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x1c\x00\x1e\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x1e\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\xff\xff\x1e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#
-
-alex_check :: AlexAddr
-alex_check = AlexA# "\xff\xff\xef\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\xbf\x00\x0d\x00\x2d\x00\x09\x00\x0a\x00\xbb\x00\xa0\x00\x0d\x00\xa0\x00\xa0\x00\x0a\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x0a\x00\x0d\x00\x20\x00\x0a\x00\x20\x00\x0a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x20\x00\xff\xff\x20\x00\xff\xff\xff\xff\x2d\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x09\x00\x0a\x00\x09\x00\x09\x00\x0d\x00\x09\x00\x0a\x00\x09\x00\xff\xff\x0d\x00\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\x20\x00\x20\x00\xff\xff\x20\x00\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x5c\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\x5c\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x7f\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\xff\xff\xff\xff\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\x21\x00\xff\xff\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\xff\xff\xff\xff\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\x5c\x00\xff\xff\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7c\x00\x7f\x00\x7e\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#
-
-alex_deflt :: AlexAddr
-alex_deflt = AlexA# "\xff\xff\xff\xff\xff\xff\xff\xff\x2b\x00\x27\x00\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0d\x00\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x13\x00\xff\xff\xff\xff\xff\xff\xff\xff\x18\x00\x1b\x00\x1b\x00\x1b\x00\xff\xff\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x27\x00\xff\xff\xff\xff\xff\xff\x2b\x00\xff\xff\xff\xff\xff\xff\xff\xff"#
-
-alex_accept = listArray (0::Int,47) [AlexAcc (alex_action_0),AlexAcc (alex_action_20),AlexAcc (alex_action_16),AlexAcc (alex_action_3),AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAcc (alex_action_1),AlexAcc (alex_action_1),AlexAccSkip,AlexAcc (alex_action_3),AlexAcc (alex_action_4),AlexAcc (alex_action_5),AlexAccSkip,AlexAccSkip,AlexAcc (alex_action_8),AlexAcc (alex_action_8),AlexAcc (alex_action_8),AlexAcc (alex_action_9),AlexAcc (alex_action_9),AlexAcc (alex_action_10),AlexAcc (alex_action_11),AlexAcc (alex_action_12),AlexAcc (alex_action_13),AlexAcc (alex_action_14),AlexAcc (alex_action_15),AlexAcc (alex_action_15),AlexAcc (alex_action_16),AlexAccSkip,AlexAcc (alex_action_18),AlexAcc (alex_action_19),AlexAcc (alex_action_19),AlexAccSkip,AlexAcc (alex_action_22),AlexAcc (alex_action_23),AlexAcc (alex_action_24),AlexAcc (alex_action_25),AlexAcc (alex_action_25)]
-{-# LINE 151 "boot/Lexer.x" #-}
-
--- | Tokens of outer cabal file structure. Field values are treated opaquely.
-data Token = TokSym !ByteString -- ^ Haskell-like identifier, number or operator
- | TokStr !ByteString -- ^ String in quotes
- | TokOther !ByteString -- ^ Operators and parens
- | Indent !Int -- ^ Indentation token
- | TokFieldLine !ByteString -- ^ Lines after @:@
- | Colon
- | OpenBrace
- | CloseBrace
- | EOF
- | LexicalError InputStream --TODO: add separate string lexical error
- deriving Show
-
-data LToken = L !Position !Token
- deriving Show
-
-toki :: (ByteString -> Token) -> Position -> Int -> ByteString -> Lex LToken
-toki t pos len input = return $! L pos (t (B.take len input))
-
-tok :: Token -> Position -> Int -> ByteString -> Lex LToken
-tok t pos _len _input = return $! L pos t
-
-checkLeadingWhitespace :: Int -> ByteString -> Lex Int
-checkLeadingWhitespace len bs
- | B.any (== 9) (B.take len bs) = do
- addWarning LexWarningTab
- checkWhitespace len bs
- | otherwise = checkWhitespace len bs
-
-checkWhitespace :: Int -> ByteString -> Lex Int
-checkWhitespace len bs
- | B.any (== 194) (B.take len bs) = do
- addWarning LexWarningNBSP
- return $ len - B.count 194 (B.take len bs)
- | otherwise = return len
-
--- -----------------------------------------------------------------------------
--- The input type
-
-type AlexInput = InputStream
-
-alexInputPrevChar :: AlexInput -> Char
-alexInputPrevChar _ = error "alexInputPrevChar not used"
-
-alexGetByte :: AlexInput -> Maybe (Word.Word8,AlexInput)
-alexGetByte = B.uncons
-
-lexicalError :: Position -> InputStream -> Lex LToken
-lexicalError pos inp = do
- setInput B.empty
- return $! L pos (LexicalError inp)
-
-lexToken :: Lex LToken
-lexToken = do
- pos <- getPos
- inp <- getInput
- st <- getStartCode
- case alexScan inp st of
- AlexEOF -> return (L pos EOF)
- AlexError inp' ->
- let !len_bytes = B.length inp - B.length inp' in
- --FIXME: we want len_chars here really
- -- need to decode utf8 up to this point
- lexicalError (incPos len_bytes pos) inp'
- AlexSkip inp' len_chars -> do
- checkPosition pos inp inp' len_chars
- adjustPos (incPos len_chars)
- setInput inp'
- lexToken
- AlexToken inp' len_chars action -> do
- checkPosition pos inp inp' len_chars
- adjustPos (incPos len_chars)
- setInput inp'
- let !len_bytes = B.length inp - B.length inp'
- t <- action pos len_bytes inp
- --traceShow t $ return tok
- return t
-
-checkPosition :: Position -> ByteString -> ByteString -> Int -> Lex ()
-#ifdef CABAL_PARSEC_DEBUG
-checkPosition pos@(Position lineno colno) inp inp' len_chars = do
- text_lines <- getDbgText
- let len_bytes = B.length inp - B.length inp'
- pos_txt | lineno-1 < V.length text_lines = T.take len_chars (T.drop (colno-1) (text_lines V.! (lineno-1)))
- | otherwise = T.empty
- real_txt = B.take len_bytes inp
- when (pos_txt /= T.decodeUtf8 real_txt) $
- traceShow (pos, pos_txt, T.decodeUtf8 real_txt) $
- traceShow (take 3 (V.toList text_lines)) $ return ()
- where
- getDbgText = Lex $ \s@LexState{ dbgText = txt } -> LexResult s txt
-#else
-checkPosition _ _ _ _ = return ()
-#endif
-
-lexAll :: Lex [LToken]
-lexAll = do
- t <- lexToken
- case t of
- L _ EOF -> return [t]
- _ -> do ts <- lexAll
- return (t : ts)
-
-ltest :: Int -> String -> Prelude.IO ()
-ltest code s =
- let (ws, xs) = execLexer (setStartCode code >> lexAll) (B.Char8.pack s)
- in traverse_ print ws >> traverse_ print xs
-
-mkLexState :: ByteString -> LexState
-mkLexState input = LexState
- { curPos = Position 1 1
- , curInput = input
- , curCode = 0
- , warnings = []
-#ifdef CABAL_PARSEC_DEBUG
- , dbgText = V.fromList . lines' . T.decodeUtf8With T.lenientDecode $ input
-#endif
- }
-
-#ifdef CABAL_PARSEC_DEBUG
-lines' :: T.Text -> [T.Text]
-lines' s1
- | T.null s1 = []
- | otherwise = case T.break (\c -> c == '\r' || c == '\n') s1 of
- (l, s2) | Just (c,s3) <- T.uncons s2
- -> case T.uncons s3 of
- Just ('\n', s4) | c == '\r' -> l `T.snoc` '\r' `T.snoc` '\n' : lines' s4
- _ -> l `T.snoc` c : lines' s3
-
- | otherwise
- -> [l]
-#endif
-
-bol_field_braces,bol_field_layout,bol_section,in_field_braces,in_field_layout,in_section :: Int
-bol_field_braces = 1
-bol_field_layout = 2
-bol_section = 3
-in_field_braces = 4
-in_field_layout = 5
-in_section = 6
-alex_action_0 = \_ len _ -> do
- when (len /= 0) $ addWarning LexWarningBOM
- setStartCode bol_section
- lexToken
-
-alex_action_1 = \_pos len inp -> checkWhitespace len inp >> adjustPos retPos >> lexToken
-alex_action_3 = \pos len inp -> checkLeadingWhitespace len inp >>
- if B.length inp == len
- then return (L pos EOF)
- else setStartCode in_section
- >> return (L pos (Indent len))
-alex_action_4 = tok OpenBrace
-alex_action_5 = tok CloseBrace
-alex_action_8 = toki TokSym
-alex_action_9 = \pos len inp -> return $! L pos (TokStr (B.take (len - 2) (B.tail inp)))
-alex_action_10 = toki TokOther
-alex_action_11 = toki TokOther
-alex_action_12 = tok Colon
-alex_action_13 = tok OpenBrace
-alex_action_14 = tok CloseBrace
-alex_action_15 = \_ _ _ -> adjustPos retPos >> setStartCode bol_section >> lexToken
-alex_action_16 = \pos len inp -> checkLeadingWhitespace len inp >>= \len' ->
- if B.length inp == len
- then return (L pos EOF)
- else setStartCode in_field_layout
- >> return (L pos (Indent len'))
-alex_action_18 = toki TokFieldLine
-alex_action_19 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_layout >> lexToken
-alex_action_20 = \_ _ _ -> setStartCode in_field_braces >> lexToken
-alex_action_22 = toki TokFieldLine
-alex_action_23 = tok OpenBrace
-alex_action_24 = tok CloseBrace
-alex_action_25 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_braces >> lexToken
-{-# LINE 1 "templates/GenericTemplate.hs" #-}
-{-# LINE 1 "templates/GenericTemplate.hs" #-}
-{-# LINE 1 "<built-in>" #-}
-{-# LINE 1 "<command-line>" #-}
-{-# LINE 10 "<command-line>" #-}
-# 1 "/usr/include/stdc-predef.h" 1 3 4
-
-# 17 "/usr/include/stdc-predef.h" 3 4
-
-{-# LINE 10 "<command-line>" #-}
-{-# LINE 1 "/opt/ghc/7.10.3/lib/ghc-7.10.3/include/ghcversion.h" #-}
-
-{-# LINE 10 "<command-line>" #-}
-{-# LINE 1 "templates/GenericTemplate.hs" #-}
--- -----------------------------------------------------------------------------
--- ALEX TEMPLATE
---
--- This code is in the PUBLIC DOMAIN; you may copy it freely and use
--- it for any purpose whatsoever.
-
--- -----------------------------------------------------------------------------
--- INTERNALS and main scanner engine
-
-{-# LINE 21 "templates/GenericTemplate.hs" #-}
-
--- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.
-#if __GLASGOW_HASKELL__ > 706
-#define GTE(n,m) (tagToEnum# (n >=# m))
-#define EQ(n,m) (tagToEnum# (n ==# m))
-#else
-#define GTE(n,m) (n >=# m)
-#define EQ(n,m) (n ==# m)
-#endif
-{-# LINE 51 "templates/GenericTemplate.hs" #-}
-
-data AlexAddr = AlexA# Addr#
--- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.
-#if __GLASGOW_HASKELL__ < 503
-uncheckedShiftL# = shiftL#
-#endif
-
-{-# INLINE alexIndexInt16OffAddr #-}
-alexIndexInt16OffAddr (AlexA# arr) off =
-#ifdef WORDS_BIGENDIAN
- narrow16Int# i
- where
- i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)
- high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
- low = int2Word# (ord# (indexCharOffAddr# arr off'))
- off' = off *# 2#
-#else
- indexInt16OffAddr# arr off
-#endif
-
-{-# INLINE alexIndexInt32OffAddr #-}
-alexIndexInt32OffAddr (AlexA# arr) off =
-#ifdef WORDS_BIGENDIAN
- narrow32Int# i
- where
- i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#`
- (b2 `uncheckedShiftL#` 16#) `or#`
- (b1 `uncheckedShiftL#` 8#) `or#` b0)
- b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#)))
- b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#)))
- b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
- b0 = int2Word# (ord# (indexCharOffAddr# arr off'))
- off' = off *# 4#
-#else
- indexInt32OffAddr# arr off
-#endif
-
-#if __GLASGOW_HASKELL__ < 503
-quickIndex arr i = arr ! i
-#else
--- GHC >= 503, unsafeAt is available from Data.Array.Base.
-quickIndex = unsafeAt
-#endif
-
--- -----------------------------------------------------------------------------
--- Main lexing routines
-
-data AlexReturn a
- = AlexEOF
- | AlexError !AlexInput
- | AlexSkip !AlexInput !Int
- | AlexToken !AlexInput !Int a
-
--- alexScan :: AlexInput -> StartCode -> AlexReturn a
-alexScan input (I# (sc))
- = alexScanUser undefined input (I# (sc))
-
-alexScanUser user input (I# (sc))
- = case alex_scan_tkn user input 0# input sc AlexNone of
- (AlexNone, input') ->
- case alexGetByte input of
- Nothing ->
-
- AlexEOF
- Just _ ->
-
- AlexError input'
-
- (AlexLastSkip input'' len, _) ->
-
- AlexSkip input'' len
-
- (AlexLastAcc k input''' len, _) ->
-
- AlexToken input''' len k
-
--- Push the input through the DFA, remembering the most recent accepting
--- state it encountered.
-
-alex_scan_tkn user orig_input len input s last_acc =
- input `seq` -- strict in the input
- let
- new_acc = (check_accs (alex_accept `quickIndex` (I# (s))))
- in
- new_acc `seq`
- case alexGetByte input of
- Nothing -> (new_acc, input)
- Just (c, new_input) ->
-
- case fromIntegral c of { (I# (ord_c)) ->
- let
- base = alexIndexInt32OffAddr alex_base s
- offset = (base +# ord_c)
- check = alexIndexInt16OffAddr alex_check offset
-
- new_s = if GTE(offset,0#) && EQ(check,ord_c)
- then alexIndexInt16OffAddr alex_table offset
- else alexIndexInt16OffAddr alex_deflt s
- in
- case new_s of
- -1# -> (new_acc, input)
- -- on an error, we want to keep the input *before* the
- -- character that failed, not after.
- _ -> alex_scan_tkn user orig_input (if c < 0x80 || c >= 0xC0 then (len +# 1#) else len)
- -- note that the length is increased ONLY if this is the 1st byte in a char encoding)
- new_input new_s new_acc
- }
- where
- check_accs (AlexAccNone) = last_acc
- check_accs (AlexAcc a ) = AlexLastAcc a input (I# (len))
- check_accs (AlexAccSkip) = AlexLastSkip input (I# (len))
-{-# LINE 198 "templates/GenericTemplate.hs" #-}
-
-data AlexLastAcc a
- = AlexNone
- | AlexLastAcc a !AlexInput !Int
- | AlexLastSkip !AlexInput !Int
-
-instance Functor AlexLastAcc where
- fmap _ AlexNone = AlexNone
- fmap f (AlexLastAcc x y z) = AlexLastAcc (f x) y z
- fmap _ (AlexLastSkip x y) = AlexLastSkip x y
-
-data AlexAcc a user
- = AlexAccNone
- | AlexAcc a
- | AlexAccSkip
diff --git a/cabal/Cabal/Distribution/Parsec/Newtypes.hs b/cabal/Cabal/Distribution/Parsec/Newtypes.hs
index 7f3e138..f48ef8d 100644
--- a/cabal/Cabal/Distribution/Parsec/Newtypes.hs
+++ b/cabal/Cabal/Distribution/Parsec/Newtypes.hs
@@ -15,6 +15,7 @@ module Distribution.Parsec.Newtypes (
VCat (..),
FSep (..),
NoCommaFSep (..),
+ Sep (..),
-- ** Type
List,
-- * Version & License
@@ -25,7 +26,6 @@ module Distribution.Parsec.Newtypes (
Token (..),
Token' (..),
MQuoted (..),
- FreeText (..),
FilePathNT (..),
) where
@@ -34,11 +34,10 @@ import Distribution.Compat.Prelude
import Prelude ()
import Data.Functor.Identity (Identity (..))
-import Data.List (dropWhileEnd)
import Distribution.CabalSpecVersion
import Distribution.Compiler (CompilerFlavor)
import Distribution.License (License)
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Pretty
import Distribution.Version
(LowerBound (..), Version, VersionRange, anyVersion, asVersionIntervals, mkVersion)
@@ -82,17 +81,21 @@ instance Sep CommaFSep where
if v >= CabalSpecV2_2 then parsecLeadingCommaList p else parsecCommaList p
instance Sep VCat where
prettySep _ = vcat
- parseSep _ = parsecOptCommaList
+ parseSep _ p = do
+ v <- askCabalSpecVersion
+ if v >= CabalSpecV3_0 then parsecLeadingOptCommaList p else parsecOptCommaList p
instance Sep FSep where
prettySep _ = fsep
- parseSep _ = parsecOptCommaList
+ parseSep _ p = do
+ v <- askCabalSpecVersion
+ if v >= CabalSpecV3_0 then parsecLeadingOptCommaList p else parsecOptCommaList p
instance Sep NoCommaFSep where
prettySep _ = fsep
parseSep _ p = many (p <* P.spaces)
-- | List separated with optional commas. Displayed with @sep@, arguments of
-- type @a@ are parsed and pretty-printed as @b@.
-newtype List sep b a = List { getList :: [a] }
+newtype List sep b a = List { _getList :: [a] }
-- | 'alaList' and 'alaList'' are simply 'List', with additional phantom
-- arguments to constraint the resulting type
@@ -110,22 +113,18 @@ alaList _ = List
alaList' :: sep -> (a -> b) -> [a] -> List sep b a
alaList' _ _ = List
-instance Newtype (List sep wrapper a) [a] where
- pack = List
- unpack = getList
+instance Newtype [a] (List sep wrapper a)
-instance (Newtype b a, Sep sep, Parsec b) => Parsec (List sep b a) where
+instance (Newtype a b, Sep sep, Parsec b) => Parsec (List sep b a) where
parsec = pack . map (unpack :: b -> a) <$> parseSep (P :: P sep) parsec
-instance (Newtype b a, Sep sep, Pretty b) => Pretty (List sep b a) where
+instance (Newtype a b, Sep sep, Pretty b) => Pretty (List sep b a) where
pretty = prettySep (P :: P sep) . map (pretty . (pack :: a -> b)) . unpack
-- | Haskell string or @[^ ,]+@
newtype Token = Token { getToken :: String }
-instance Newtype Token String where
- pack = Token
- unpack = getToken
+instance Newtype String Token
instance Parsec Token where
parsec = pack <$> parsecToken
@@ -136,9 +135,7 @@ instance Pretty Token where
-- | Haskell string or @[^ ]+@
newtype Token' = Token' { getToken' :: String }
-instance Newtype Token' String where
- pack = Token'
- unpack = getToken'
+instance Newtype String Token'
instance Parsec Token' where
parsec = pack <$> parsecToken'
@@ -149,9 +146,7 @@ instance Pretty Token' where
-- | Either @"quoted"@ or @un-quoted@.
newtype MQuoted a = MQuoted { getMQuoted :: a }
-instance Newtype (MQuoted a) a where
- pack = MQuoted
- unpack = getMQuoted
+instance Newtype a (MQuoted a)
instance Parsec a => Parsec (MQuoted a) where
parsec = pack <$> parsecMaybeQuoted parsec
@@ -170,9 +165,7 @@ instance Pretty a => Pretty (MQuoted a) where
--
newtype SpecVersion = SpecVersion { getSpecVersion :: Either Version VersionRange }
-instance Newtype SpecVersion (Either Version VersionRange) where
- pack = SpecVersion
- unpack = getSpecVersion
+instance Newtype (Either Version VersionRange) SpecVersion
instance Parsec SpecVersion where
parsec = pack <$> parsecSpecVersion
@@ -195,9 +188,7 @@ specVersionFromRange versionRange = case asVersionIntervals versionRange of
-- | SPDX License expression or legacy license
newtype SpecLicense = SpecLicense { getSpecLicense :: Either SPDX.License License }
-instance Newtype SpecLicense (Either SPDX.License License) where
- pack = SpecLicense
- unpack = getSpecLicense
+instance Newtype (Either SPDX.License License) SpecLicense
instance Parsec SpecLicense where
parsec = do
@@ -212,9 +203,7 @@ instance Pretty SpecLicense where
-- | Version range or just version
newtype TestedWith = TestedWith { getTestedWith :: (CompilerFlavor, VersionRange) }
-instance Newtype TestedWith (CompilerFlavor, VersionRange) where
- pack = TestedWith
- unpack = getTestedWith
+instance Newtype (CompilerFlavor, VersionRange) TestedWith
instance Parsec TestedWith where
parsec = pack <$> parsecTestedWith
@@ -223,43 +212,10 @@ instance Pretty TestedWith where
pretty x = case unpack x of
(compiler, vr) -> pretty compiler <+> pretty vr
--- | This is /almost/ @'many' 'Distribution.Compat.P.anyChar'@, but it
---
--- * trims whitespace from ends of the lines,
---
--- * converts lines with only single dot into empty line.
---
-newtype FreeText = FreeText { getFreeText :: String }
-
-instance Newtype FreeText String where
- pack = FreeText
- unpack = getFreeText
-
-instance Parsec FreeText where
- parsec = pack . dropDotLines <$ P.spaces <*> many P.anyChar
- where
- -- Example package with dot lines
- -- http://hackage.haskell.org/package/copilot-cbmc-0.1/copilot-cbmc.cabal
- dropDotLines "." = "."
- dropDotLines x = intercalate "\n" . map dotToEmpty . lines $ x
- dotToEmpty x | trim' x == "." = ""
- dotToEmpty x = trim x
-
- trim' :: String -> String
- trim' = dropWhileEnd (`elem` (" \t" :: String))
-
- trim :: String -> String
- trim = dropWhile isSpace . dropWhileEnd isSpace
-
-instance Pretty FreeText where
- pretty = showFreeText . unpack
-
-- | Filepath are parsed as 'Token'.
newtype FilePathNT = FilePathNT { getFilePathNT :: String }
-instance Newtype FilePathNT String where
- pack = FilePathNT
- unpack = getFilePathNT
+instance Newtype String FilePathNT
instance Parsec FilePathNT where
parsec = pack <$> parsecToken
diff --git a/cabal/Cabal/Distribution/Parsec/Position.hs b/cabal/Cabal/Distribution/Parsec/Position.hs
new file mode 100644
index 0000000..5fe20fe
--- /dev/null
+++ b/cabal/Cabal/Distribution/Parsec/Position.hs
@@ -0,0 +1,44 @@
+{-# LANGUAGE DeriveGeneric #-}
+module Distribution.Parsec.Position (
+ Position (..),
+ incPos,
+ retPos,
+ showPos,
+ zeroPos,
+ positionCol,
+ positionRow,
+ ) where
+
+import Distribution.Compat.Prelude
+import Prelude ()
+
+-- | 1-indexed row and column positions in a file.
+data Position = Position
+ {-# UNPACK #-} !Int -- row
+ {-# UNPACK #-} !Int -- column
+ deriving (Eq, Ord, Show, Generic)
+
+instance Binary Position
+instance NFData Position where rnf = genericRnf
+
+-- | Shift position by n columns to the right.
+incPos :: Int -> Position -> Position
+incPos n (Position row col) = Position row (col + n)
+
+-- | Shift position to beginning of next row.
+retPos :: Position -> Position
+retPos (Position row _col) = Position (row + 1) 1
+
+showPos :: Position -> String
+showPos (Position row col) = show row ++ ":" ++ show col
+
+zeroPos :: Position
+zeroPos = Position 0 0
+
+-- | @since 3.0.0.0
+positionCol :: Position -> Int
+positionCol (Position _ c) = c
+
+-- | @since 3.0.0.0
+positionRow :: Position -> Int
+positionRow (Position r _) = r
diff --git a/cabal/Cabal/Distribution/Parsec/Common.hs b/cabal/Cabal/Distribution/Parsec/Warning.hs
index bc569ad..4db9932 100644
--- a/cabal/Cabal/Distribution/Parsec/Common.hs
+++ b/cabal/Cabal/Distribution/Parsec/Warning.hs
@@ -1,30 +1,14 @@
{-# LANGUAGE DeriveGeneric #-}
--- | Module containing small types
-module Distribution.Parsec.Common (
- -- * Diagnostics
- PError (..),
- showPError,
+module Distribution.Parsec.Warning (
PWarning (..),
PWarnType (..),
showPWarning,
- -- * Position
- Position (..),
- incPos,
- retPos,
- showPos,
- zeroPos,
) where
import Distribution.Compat.Prelude
+import Distribution.Parsec.Position
import Prelude ()
-import System.FilePath (normalise)
-
--- | Parser error.
-data PError = PError Position String
- deriving (Show, Generic)
-
-instance Binary PError
-instance NFData PError where rnf = genericRnf
+import System.FilePath (normalise)
-- | Type of parser warning. We do classify warnings.
--
@@ -51,7 +35,6 @@ data PWarnType
| PWTDoubleDash -- ^ Double dash token, most likely it's a mistake - it's not a comment
| PWTMultipleSingularField -- ^ e.g. name or version should be specified only once.
| PWTBuildTypeDefault -- ^ Workaround for derive-package having build-type: Default. See <https://github.com/haskell/cabal/issues/5020>.
- | PWTVersionLeadingZeros -- ^ See https://github.com/haskell-infra/hackage-trustees/issues/128
deriving (Eq, Ord, Show, Enum, Bounded, Generic)
instance Binary PWarnType
@@ -66,35 +49,4 @@ instance NFData PWarning where rnf = genericRnf
showPWarning :: FilePath -> PWarning -> String
showPWarning fpath (PWarning _ pos msg) =
- normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg
-
-showPError :: FilePath -> PError -> String
-showPError fpath (PError pos msg) =
- normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg
-
--------------------------------------------------------------------------------
--- Position
--------------------------------------------------------------------------------
-
--- | 1-indexed row and column positions in a file.
-data Position = Position
- {-# UNPACK #-} !Int -- row
- {-# UNPACK #-} !Int -- column
- deriving (Eq, Ord, Show, Generic)
-
-instance Binary Position
-instance NFData Position where rnf = genericRnf
-
--- | Shift position by n columns to the right.
-incPos :: Int -> Position -> Position
-incPos n (Position row col) = Position row (col + n)
-
--- | Shift position to beginning of next row.
-retPos :: Position -> Position
-retPos (Position row _col) = Position (row + 1) 1
-
-showPos :: Position -> String
-showPos (Position row col) = show row ++ ":" ++ show col
-
-zeroPos :: Position
-zeroPos = Position 0 0
+ normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg
diff --git a/cabal/Cabal/Distribution/Pretty.hs b/cabal/Cabal/Distribution/Pretty.hs
index 09b56bb..d7c2c25 100644
--- a/cabal/Cabal/Distribution/Pretty.hs
+++ b/cabal/Cabal/Distribution/Pretty.hs
@@ -7,20 +7,24 @@ module Distribution.Pretty (
showFilePath,
showToken,
showFreeText,
- indentWith,
+ showFreeTextV3,
-- * Deprecated
Separator,
) where
-import Prelude ()
+import Data.Functor.Identity (Identity (..))
+import Distribution.CabalSpecVersion
import Distribution.Compat.Prelude
-import Data.Functor.Identity (Identity (..))
+import Prelude ()
import qualified Text.PrettyPrint as PP
class Pretty a where
pretty :: a -> PP.Doc
+ prettyVersioned :: CabalSpecVersion -> a -> PP.Doc
+ prettyVersioned _ = pretty
+
instance Pretty Bool where
pretty = PP.text . show
@@ -31,7 +35,7 @@ instance Pretty a => Pretty (Identity a) where
pretty = pretty . runIdentity
prettyShow :: Pretty a => a -> String
-prettyShow = PP.renderStyle defaultStyle . pretty
+prettyShow = PP.renderStyle defaultStyle . pretty
-- | The default rendering style used in Cabal for console
-- output. It has a fixed page width and adds line breaks
@@ -80,6 +84,14 @@ showFreeText :: String -> PP.Doc
showFreeText "" = mempty
showFreeText s = PP.vcat [ PP.text (if null l then "." else l) | l <- lines_ s ]
+-- | Pretty-print free-format text.
+-- Since @cabal-version: 3.0@ we don't replace blank lines with dots.
+--
+-- @since 3.0.0.0
+showFreeTextV3 :: String -> PP.Doc
+showFreeTextV3 "" = mempty
+showFreeTextV3 s = PP.vcat [ PP.text l | l <- lines_ s ]
+
-- | 'lines_' breaks a string up into a list of strings at newline
-- characters. The resulting strings do not contain newlines.
lines_ :: String -> [String]
@@ -89,7 +101,3 @@ lines_ s =
in l : case s' of
[] -> []
(_:s'') -> lines_ s''
-
--- | the indentation used for pretty printing
-indentWith :: Int
-indentWith = 4
diff --git a/cabal/Cabal/Distribution/PrettyUtils.hs b/cabal/Cabal/Distribution/PrettyUtils.hs
deleted file mode 100644
index 7e1bd8d..0000000
--- a/cabal/Cabal/Distribution/PrettyUtils.hs
+++ /dev/null
@@ -1,23 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : Distribution.PrettyUtils
--- Copyright : (c) The University of Glasgow 2004
--- License : BSD3
---
--- Maintainer : cabal-devel@haskell.org
--- Portability : portable
---
--- Utilities for pretty printing.
-{-# OPTIONS_HADDOCK hide #-}
-module Distribution.PrettyUtils {-# DEPRECATED "Use Distribution.Pretty. This module will be removed in Cabal-3.0 (est. Mar 2019)." #-} (
- Separator,
- -- * Internal
- showFilePath,
- showToken,
- showTestedWith,
- showFreeText,
- indentWith,
- ) where
-
-import Distribution.Pretty
-import Distribution.ParseUtils
diff --git a/cabal/Cabal/Distribution/ReadE.hs b/cabal/Cabal/Distribution/ReadE.hs
index af60e5e..863049d 100644
--- a/cabal/Cabal/Distribution/ReadE.hs
+++ b/cabal/Cabal/Distribution/ReadE.hs
@@ -13,16 +13,14 @@ module Distribution.ReadE (
-- * ReadE
ReadE(..), succeedReadE, failReadE,
-- * Projections
- parseReadE, readEOrFail,
- readP_to_E,
+ readEOrFail,
parsecToReadE,
) where
import Distribution.Compat.Prelude
import Prelude ()
-import Distribution.Compat.ReadP
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Parsec.FieldLineStream
-- | Parser with simple error reporting
@@ -40,22 +38,9 @@ succeedReadE f = ReadE (Right . f)
failReadE :: ErrorMsg -> ReadE a
failReadE = ReadE . const . Left
-parseReadE :: ReadE a -> ReadP r a
-parseReadE (ReadE p) = do
- txt <- look
- either fail return (p txt)
-
readEOrFail :: ReadE a -> String -> a
readEOrFail r = either error id . runReadE r
--- {-# DEPRECATED readP_to_E "Use parsecToReadE. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
-readP_to_E :: (String -> ErrorMsg) -> ReadP a a -> ReadE a
-readP_to_E err r =
- ReadE $ \txt -> case [ p | (p, s) <- readP_to_S r txt
- , all isSpace s ]
- of [] -> Left (err txt)
- (p:_) -> Right p
-
parsecToReadE :: (String -> ErrorMsg) -> ParsecParser a -> ReadE a
parsecToReadE err p = ReadE $ \txt ->
case runParsecParser p "<parsecToReadE>" (fieldLineStreamFromString txt) of
diff --git a/cabal/Cabal/Distribution/SPDX/License.hs b/cabal/Cabal/Distribution/SPDX/License.hs
index ea552e4..d9bbf39 100644
--- a/cabal/Cabal/Distribution/SPDX/License.hs
+++ b/cabal/Cabal/Distribution/SPDX/License.hs
@@ -8,7 +8,7 @@ import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Pretty
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.SPDX.LicenseExpression
import qualified Distribution.Compat.CharParsing as P
diff --git a/cabal/Cabal/Distribution/SPDX/LicenseExceptionId.hs b/cabal/Cabal/Distribution/SPDX/LicenseExceptionId.hs
index 4f435ca..ffceb47 100644
--- a/cabal/Cabal/Distribution/SPDX/LicenseExceptionId.hs
+++ b/cabal/Cabal/Distribution/SPDX/LicenseExceptionId.hs
@@ -13,10 +13,12 @@ import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Pretty
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Utils.Generic (isAsciiAlphaNum)
import Distribution.SPDX.LicenseListVersion
+import qualified Data.Binary.Get as Binary
+import qualified Data.Binary.Put as Binary
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
@@ -43,25 +45,35 @@ data LicenseExceptionId
| GCC_exception_2_0 -- ^ @GCC-exception-2.0@, GCC Runtime Library exception 2.0
| GCC_exception_3_1 -- ^ @GCC-exception-3.1@, GCC Runtime Library exception 3.1
| Gnu_javamail_exception -- ^ @gnu-javamail-exception@, GNU JavaMail exception
+ | GPL_CC_1_0 -- ^ @GPL-CC-1.0@, GPL Cooperation Commitment 1.0, SPDX License List 3.6
| I2p_gpl_java_exception -- ^ @i2p-gpl-java-exception@, i2p GPL+Java Exception
| Libtool_exception -- ^ @Libtool-exception@, Libtool Exception
| Linux_syscall_note -- ^ @Linux-syscall-note@, Linux Syscall Note
- | LLVM_exception -- ^ @LLVM-exception@, LLVM Exception, SPDX License List 3.2
+ | LLVM_exception -- ^ @LLVM-exception@, LLVM Exception, SPDX License List 3.2, SPDX License List 3.6
| LZMA_exception -- ^ @LZMA-exception@, LZMA exception
| Mif_exception -- ^ @mif-exception@, Macros and Inline Functions Exception
- | Nokia_Qt_exception_1_1 -- ^ @Nokia-Qt-exception-1.1@, Nokia Qt LGPL exception 1.1
+ | Nokia_Qt_exception_1_1 -- ^ @Nokia-Qt-exception-1.1@, Nokia Qt LGPL exception 1.1, SPDX License List 3.0, SPDX License List 3.2
+ | OCaml_LGPL_linking_exception -- ^ @OCaml-LGPL-linking-exception@, OCaml LGPL Linking Exception, SPDX License List 3.6
| OCCT_exception_1_0 -- ^ @OCCT-exception-1.0@, Open CASCADE Exception 1.0
- | OpenJDK_assembly_exception_1_0 -- ^ @OpenJDK-assembly-exception-1.0@, OpenJDK Assembly exception 1.0, SPDX License List 3.2
+ | OpenJDK_assembly_exception_1_0 -- ^ @OpenJDK-assembly-exception-1.0@, OpenJDK Assembly exception 1.0, SPDX License List 3.2, SPDX License List 3.6
| Openvpn_openssl_exception -- ^ @openvpn-openssl-exception@, OpenVPN OpenSSL Exception
- | PS_or_PDF_font_exception_20170817 -- ^ @PS-or-PDF-font-exception-20170817@, PS/PDF font exception (2017-08-17), SPDX License List 3.2
- | Qt_GPL_exception_1_0 -- ^ @Qt-GPL-exception-1.0@, Qt GPL exception 1.0, SPDX License List 3.2
- | Qt_LGPL_exception_1_1 -- ^ @Qt-LGPL-exception-1.1@, Qt LGPL exception 1.1, SPDX License List 3.2
+ | PS_or_PDF_font_exception_20170817 -- ^ @PS-or-PDF-font-exception-20170817@, PS/PDF font exception (2017-08-17), SPDX License List 3.2, SPDX License List 3.6
+ | Qt_GPL_exception_1_0 -- ^ @Qt-GPL-exception-1.0@, Qt GPL exception 1.0, SPDX License List 3.2, SPDX License List 3.6
+ | Qt_LGPL_exception_1_1 -- ^ @Qt-LGPL-exception-1.1@, Qt LGPL exception 1.1, SPDX License List 3.2, SPDX License List 3.6
| Qwt_exception_1_0 -- ^ @Qwt-exception-1.0@, Qwt exception 1.0
+ | Swift_exception -- ^ @Swift-exception@, Swift Exception, SPDX License List 3.6
| U_boot_exception_2_0 -- ^ @u-boot-exception-2.0@, U-Boot exception 2.0
+ | Universal_FOSS_exception_1_0 -- ^ @Universal-FOSS-exception-1.0@, Universal FOSS Exception, Version 1.0, SPDX License List 3.6
| WxWindows_exception_3_1 -- ^ @WxWindows-exception-3.1@, WxWindows Library Exception 3.1
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data, Generic)
-instance Binary LicenseExceptionId
+instance Binary LicenseExceptionId where
+ put = Binary.putWord8 . fromIntegral . fromEnum
+ get = do
+ i <- Binary.getWord8
+ if i > fromIntegral (fromEnum (maxBound :: LicenseExceptionId))
+ then fail "Too large LicenseExceptionId tag"
+ else return (toEnum (fromIntegral i))
instance Pretty LicenseExceptionId where
pretty = Disp.text . licenseExceptionId
@@ -98,6 +110,7 @@ licenseExceptionId Freertos_exception_2_0 = "freertos-exception-2.0"
licenseExceptionId GCC_exception_2_0 = "GCC-exception-2.0"
licenseExceptionId GCC_exception_3_1 = "GCC-exception-3.1"
licenseExceptionId Gnu_javamail_exception = "gnu-javamail-exception"
+licenseExceptionId GPL_CC_1_0 = "GPL-CC-1.0"
licenseExceptionId I2p_gpl_java_exception = "i2p-gpl-java-exception"
licenseExceptionId Libtool_exception = "Libtool-exception"
licenseExceptionId Linux_syscall_note = "Linux-syscall-note"
@@ -105,6 +118,7 @@ licenseExceptionId LLVM_exception = "LLVM-exception"
licenseExceptionId LZMA_exception = "LZMA-exception"
licenseExceptionId Mif_exception = "mif-exception"
licenseExceptionId Nokia_Qt_exception_1_1 = "Nokia-Qt-exception-1.1"
+licenseExceptionId OCaml_LGPL_linking_exception = "OCaml-LGPL-linking-exception"
licenseExceptionId OCCT_exception_1_0 = "OCCT-exception-1.0"
licenseExceptionId OpenJDK_assembly_exception_1_0 = "OpenJDK-assembly-exception-1.0"
licenseExceptionId Openvpn_openssl_exception = "openvpn-openssl-exception"
@@ -112,7 +126,9 @@ licenseExceptionId PS_or_PDF_font_exception_20170817 = "PS-or-PDF-font-exception
licenseExceptionId Qt_GPL_exception_1_0 = "Qt-GPL-exception-1.0"
licenseExceptionId Qt_LGPL_exception_1_1 = "Qt-LGPL-exception-1.1"
licenseExceptionId Qwt_exception_1_0 = "Qwt-exception-1.0"
+licenseExceptionId Swift_exception = "Swift-exception"
licenseExceptionId U_boot_exception_2_0 = "u-boot-exception-2.0"
+licenseExceptionId Universal_FOSS_exception_1_0 = "Universal-FOSS-exception-1.0"
licenseExceptionId WxWindows_exception_3_1 = "WxWindows-exception-3.1"
-- | License name, e.g. @"GNU General Public License v2.0 only"@
@@ -133,6 +149,7 @@ licenseExceptionName Freertos_exception_2_0 = "FreeRTOS Exception 2.0"
licenseExceptionName GCC_exception_2_0 = "GCC Runtime Library exception 2.0"
licenseExceptionName GCC_exception_3_1 = "GCC Runtime Library exception 3.1"
licenseExceptionName Gnu_javamail_exception = "GNU JavaMail exception"
+licenseExceptionName GPL_CC_1_0 = "GPL Cooperation Commitment 1.0"
licenseExceptionName I2p_gpl_java_exception = "i2p GPL+Java Exception"
licenseExceptionName Libtool_exception = "Libtool Exception"
licenseExceptionName Linux_syscall_note = "Linux Syscall Note"
@@ -140,6 +157,7 @@ licenseExceptionName LLVM_exception = "LLVM Exception"
licenseExceptionName LZMA_exception = "LZMA exception"
licenseExceptionName Mif_exception = "Macros and Inline Functions Exception"
licenseExceptionName Nokia_Qt_exception_1_1 = "Nokia Qt LGPL exception 1.1"
+licenseExceptionName OCaml_LGPL_linking_exception = "OCaml LGPL Linking Exception"
licenseExceptionName OCCT_exception_1_0 = "Open CASCADE Exception 1.0"
licenseExceptionName OpenJDK_assembly_exception_1_0 = "OpenJDK Assembly exception 1.0"
licenseExceptionName Openvpn_openssl_exception = "OpenVPN OpenSSL Exception"
@@ -147,7 +165,9 @@ licenseExceptionName PS_or_PDF_font_exception_20170817 = "PS/PDF font exception
licenseExceptionName Qt_GPL_exception_1_0 = "Qt GPL exception 1.0"
licenseExceptionName Qt_LGPL_exception_1_1 = "Qt LGPL exception 1.1"
licenseExceptionName Qwt_exception_1_0 = "Qwt exception 1.0"
+licenseExceptionName Swift_exception = "Swift Exception"
licenseExceptionName U_boot_exception_2_0 = "U-Boot exception 2.0"
+licenseExceptionName Universal_FOSS_exception_1_0 = "Universal FOSS Exception, Version 1.0"
licenseExceptionName WxWindows_exception_3_1 = "WxWindows Library Exception 3.1"
-------------------------------------------------------------------------------
@@ -156,14 +176,28 @@ licenseExceptionName WxWindows_exception_3_1 = "WxWindows Library Exception 3.1"
licenseExceptionIdList :: LicenseListVersion -> [LicenseExceptionId]
licenseExceptionIdList LicenseListVersion_3_0 =
- []
+ [ Nokia_Qt_exception_1_1
+ ]
++ bulkOfLicenses
licenseExceptionIdList LicenseListVersion_3_2 =
[ LLVM_exception
+ , Nokia_Qt_exception_1_1
+ , OpenJDK_assembly_exception_1_0
+ , PS_or_PDF_font_exception_20170817
+ , Qt_GPL_exception_1_0
+ , Qt_LGPL_exception_1_1
+ ]
+ ++ bulkOfLicenses
+licenseExceptionIdList LicenseListVersion_3_6 =
+ [ GPL_CC_1_0
+ , LLVM_exception
+ , OCaml_LGPL_linking_exception
, OpenJDK_assembly_exception_1_0
, PS_or_PDF_font_exception_20170817
, Qt_GPL_exception_1_0
, Qt_LGPL_exception_1_1
+ , Swift_exception
+ , Universal_FOSS_exception_1_0
]
++ bulkOfLicenses
@@ -171,6 +205,7 @@ licenseExceptionIdList LicenseListVersion_3_2 =
mkLicenseExceptionId :: LicenseListVersion -> String -> Maybe LicenseExceptionId
mkLicenseExceptionId LicenseListVersion_3_0 s = Map.lookup s stringLookup_3_0
mkLicenseExceptionId LicenseListVersion_3_2 s = Map.lookup s stringLookup_3_2
+mkLicenseExceptionId LicenseListVersion_3_6 s = Map.lookup s stringLookup_3_6
stringLookup_3_0 :: Map String LicenseExceptionId
stringLookup_3_0 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
@@ -180,6 +215,10 @@ stringLookup_3_2 :: Map String LicenseExceptionId
stringLookup_3_2 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
licenseExceptionIdList LicenseListVersion_3_2
+stringLookup_3_6 :: Map String LicenseExceptionId
+stringLookup_3_6 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
+ licenseExceptionIdList LicenseListVersion_3_6
+
-- | License exceptions in all SPDX License lists
bulkOfLicenses :: [LicenseExceptionId]
bulkOfLicenses =
@@ -204,7 +243,6 @@ bulkOfLicenses =
, Linux_syscall_note
, LZMA_exception
, Mif_exception
- , Nokia_Qt_exception_1_1
, OCCT_exception_1_0
, Openvpn_openssl_exception
, Qwt_exception_1_0
diff --git a/cabal/Cabal/Distribution/SPDX/LicenseExpression.hs b/cabal/Cabal/Distribution/SPDX/LicenseExpression.hs
index 4d38a8c..790a066 100644
--- a/cabal/Cabal/Distribution/SPDX/LicenseExpression.hs
+++ b/cabal/Cabal/Distribution/SPDX/LicenseExpression.hs
@@ -9,7 +9,7 @@ module Distribution.SPDX.LicenseExpression (
import Distribution.Compat.Prelude
import Prelude ()
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Pretty
import Distribution.SPDX.LicenseExceptionId
import Distribution.SPDX.LicenseId
diff --git a/cabal/Cabal/Distribution/SPDX/LicenseId.hs b/cabal/Cabal/Distribution/SPDX/LicenseId.hs
index 5516319..6643276 100644
--- a/cabal/Cabal/Distribution/SPDX/LicenseId.hs
+++ b/cabal/Cabal/Distribution/SPDX/LicenseId.hs
@@ -16,10 +16,12 @@ import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Pretty
-import Distribution.Parsec.Class
+import Distribution.Parsec
import Distribution.Utils.Generic (isAsciiAlphaNum)
import Distribution.SPDX.LicenseListVersion
+import qualified Data.Binary.Get as Binary
+import qualified Data.Binary.Put as Binary
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
@@ -43,8 +45,8 @@ data LicenseId
| AFL_3_0 -- ^ @AFL-3.0@, Academic Free License v3.0
| Afmparse -- ^ @Afmparse@, Afmparse License
| AGPL_1_0 -- ^ @AGPL-1.0@, Affero General Public License v1.0, SPDX License List 3.0
- | AGPL_1_0_only -- ^ @AGPL-1.0-only@, Affero General Public License v1.0 only, SPDX License List 3.2
- | AGPL_1_0_or_later -- ^ @AGPL-1.0-or-later@, Affero General Public License v1.0 or later, SPDX License List 3.2
+ | AGPL_1_0_only -- ^ @AGPL-1.0-only@, Affero General Public License v1.0 only, SPDX License List 3.2, SPDX License List 3.6
+ | AGPL_1_0_or_later -- ^ @AGPL-1.0-or-later@, Affero General Public License v1.0 or later, SPDX License List 3.2, SPDX License List 3.6
| AGPL_3_0_only -- ^ @AGPL-3.0-only@, GNU Affero General Public License v3.0 only
| AGPL_3_0_or_later -- ^ @AGPL-3.0-or-later@, GNU Affero General Public License v3.0 or later
| Aladdin -- ^ @Aladdin@, Aladdin Free Public License
@@ -70,6 +72,8 @@ data LicenseId
| Beerware -- ^ @Beerware@, Beerware License
| BitTorrent_1_0 -- ^ @BitTorrent-1.0@, BitTorrent Open Source License v1.0
| BitTorrent_1_1 -- ^ @BitTorrent-1.1@, BitTorrent Open Source License v1.1
+ | Blessing -- ^ @blessing@, SQLite Blessing, SPDX License List 3.6
+ | BlueOak_1_0_0 -- ^ @BlueOak-1.0.0@, Blue Oak Model License 1.0.0, SPDX License List 3.6
| Borceux -- ^ @Borceux@, Borceux license
| BSD_1_Clause -- ^ @BSD-1-Clause@, BSD 1-Clause License
| BSD_2_Clause_FreeBSD -- ^ @BSD-2-Clause-FreeBSD@, BSD 2-Clause FreeBSD License
@@ -82,6 +86,7 @@ data LicenseId
| BSD_3_Clause_No_Nuclear_License_2014 -- ^ @BSD-3-Clause-No-Nuclear-License-2014@, BSD 3-Clause No Nuclear License 2014
| BSD_3_Clause_No_Nuclear_License -- ^ @BSD-3-Clause-No-Nuclear-License@, BSD 3-Clause No Nuclear License
| BSD_3_Clause_No_Nuclear_Warranty -- ^ @BSD-3-Clause-No-Nuclear-Warranty@, BSD 3-Clause No Nuclear Warranty
+ | BSD_3_Clause_Open_MPI -- ^ @BSD-3-Clause-Open-MPI@, BSD 3-Clause Open MPI variant, SPDX License List 3.6
| BSD_3_Clause -- ^ @BSD-3-Clause@, BSD 3-Clause "New" or "Revised" License
| BSD_4_Clause_UC -- ^ @BSD-4-Clause-UC@, BSD-4-Clause (University of California-Specific)
| BSD_4_Clause -- ^ @BSD-4-Clause@, BSD 4-Clause "Original" or "Old" License
@@ -122,6 +127,7 @@ data LicenseId
| CC_BY_SA_2_5 -- ^ @CC-BY-SA-2.5@, Creative Commons Attribution Share Alike 2.5 Generic
| CC_BY_SA_3_0 -- ^ @CC-BY-SA-3.0@, Creative Commons Attribution Share Alike 3.0 Unported
| CC_BY_SA_4_0 -- ^ @CC-BY-SA-4.0@, Creative Commons Attribution Share Alike 4.0 International
+ | CC_PDDC -- ^ @CC-PDDC@, Creative Commons Public Domain Dedication and Certification, SPDX License List 3.6
| CC0_1_0 -- ^ @CC0-1.0@, Creative Commons Zero v1.0 Universal
| CDDL_1_0 -- ^ @CDDL-1.0@, Common Development and Distribution License 1.0
| CDDL_1_1 -- ^ @CDDL-1.1@, Common Development and Distribution License 1.1
@@ -133,11 +139,15 @@ data LicenseId
| CECILL_2_1 -- ^ @CECILL-2.1@, CeCILL Free Software License Agreement v2.1
| CECILL_B -- ^ @CECILL-B@, CeCILL-B Free Software License Agreement
| CECILL_C -- ^ @CECILL-C@, CeCILL-C Free Software License Agreement
+ | CERN_OHL_1_1 -- ^ @CERN-OHL-1.1@, CERN Open Hardware License v1.1, SPDX License List 3.6
+ | CERN_OHL_1_2 -- ^ @CERN-OHL-1.2@, CERN Open Hardware Licence v1.2, SPDX License List 3.6
| ClArtistic -- ^ @ClArtistic@, Clarified Artistic License
| CNRI_Jython -- ^ @CNRI-Jython@, CNRI Jython License
| CNRI_Python_GPL_Compatible -- ^ @CNRI-Python-GPL-Compatible@, CNRI Python Open Source GPL Compatible License Agreement
| CNRI_Python -- ^ @CNRI-Python@, CNRI Python License
| Condor_1_1 -- ^ @Condor-1.1@, Condor Public License v1.1
+ | Copyleft_next_0_3_0 -- ^ @copyleft-next-0.3.0@, copyleft-next 0.3.0, SPDX License List 3.6
+ | Copyleft_next_0_3_1 -- ^ @copyleft-next-0.3.1@, copyleft-next 0.3.1, SPDX License List 3.6
| CPAL_1_0 -- ^ @CPAL-1.0@, Common Public Attribution License 1.0
| CPL_1_0 -- ^ @CPL-1.0@, Common Public License 1.0
| CPOL_1_02 -- ^ @CPOL-1.02@, Code Project Open License 1.02
@@ -170,8 +180,8 @@ data LicenseId
| Frameworx_1_0 -- ^ @Frameworx-1.0@, Frameworx Open License 1.0
| FreeImage -- ^ @FreeImage@, FreeImage Public License v1.0
| FSFAP -- ^ @FSFAP@, FSF All Permissive License
- | FSFUL -- ^ @FSFUL@, FSF Unlimited License
| FSFULLR -- ^ @FSFULLR@, FSF Unlimited License (with License Retention)
+ | FSFUL -- ^ @FSFUL@, FSF Unlimited License
| FTL -- ^ @FTL@, Freetype Project License
| GFDL_1_1_only -- ^ @GFDL-1.1-only@, GNU Free Documentation License v1.1 only
| GFDL_1_1_or_later -- ^ @GFDL-1.1-or-later@, GNU Free Documentation License v1.1 or later
@@ -192,6 +202,7 @@ data LicenseId
| GPL_3_0_or_later -- ^ @GPL-3.0-or-later@, GNU General Public License v3.0 or later
| GSOAP_1_3b -- ^ @gSOAP-1.3b@, gSOAP Public License v1.3b
| HaskellReport -- ^ @HaskellReport@, Haskell Language Report License
+ | HPND_sell_variant -- ^ @HPND-sell-variant@, Historical Permission Notice and Disclaimer - sell variant, SPDX License List 3.6
| HPND -- ^ @HPND@, Historical Permission Notice and Disclaimer
| IBM_pibs -- ^ @IBM-pibs@, IBM PowerPC Initialization and Boot Software
| ICU -- ^ @ICU@, ICU License
@@ -207,6 +218,7 @@ data LicenseId
| IPL_1_0 -- ^ @IPL-1.0@, IBM Public License v1.0
| ISC -- ^ @ISC@, ISC License
| JasPer_2_0 -- ^ @JasPer-2.0@, JasPer License
+ | JPNIC -- ^ @JPNIC@, Japan Network Information Center License, SPDX License List 3.6
| JSON -- ^ @JSON@, JSON License
| LAL_1_2 -- ^ @LAL-1.2@, Licence Art Libre 1.2
| LAL_1_3 -- ^ @LAL-1.3@, Licence Art Libre 1.3
@@ -219,14 +231,15 @@ data LicenseId
| LGPL_3_0_only -- ^ @LGPL-3.0-only@, GNU Lesser General Public License v3.0 only
| LGPL_3_0_or_later -- ^ @LGPL-3.0-or-later@, GNU Lesser General Public License v3.0 or later
| LGPLLR -- ^ @LGPLLR@, Lesser General Public License For Linguistic Resources
+ | Libpng_2_0 -- ^ @libpng-2.0@, PNG Reference Library version 2, SPDX License List 3.6
| Libpng -- ^ @Libpng@, libpng License
| Libtiff -- ^ @libtiff@, libtiff License
| LiLiQ_P_1_1 -- ^ @LiLiQ-P-1.1@, Licence Libre du Québec – Permissive version 1.1
| LiLiQ_R_1_1 -- ^ @LiLiQ-R-1.1@, Licence Libre du Québec – Réciprocité version 1.1
| LiLiQ_Rplus_1_1 -- ^ @LiLiQ-Rplus-1.1@, Licence Libre du Québec – Réciprocité forte version 1.1
- | Linux_OpenIB -- ^ @Linux-OpenIB@, Linux Kernel Variant of OpenIB.org license, SPDX License List 3.2
- | LPL_1_0 -- ^ @LPL-1.0@, Lucent Public License Version 1.0
+ | Linux_OpenIB -- ^ @Linux-OpenIB@, Linux Kernel Variant of OpenIB.org license, SPDX License List 3.2, SPDX License List 3.6
| LPL_1_02 -- ^ @LPL-1.02@, Lucent Public License v1.02
+ | LPL_1_0 -- ^ @LPL-1.0@, Lucent Public License Version 1.0
| LPPL_1_0 -- ^ @LPPL-1.0@, LaTeX Project Public License v1.0
| LPPL_1_1 -- ^ @LPPL-1.1@, LaTeX Project Public License v1.1
| LPPL_1_2 -- ^ @LPPL-1.2@, LaTeX Project Public License v1.2
@@ -234,13 +247,13 @@ data LicenseId
| LPPL_1_3c -- ^ @LPPL-1.3c@, LaTeX Project Public License v1.3c
| MakeIndex -- ^ @MakeIndex@, MakeIndex License
| MirOS -- ^ @MirOS@, MirOS License
- | MIT_0 -- ^ @MIT-0@, MIT No Attribution, SPDX License List 3.2
+ | MIT_0 -- ^ @MIT-0@, MIT No Attribution, SPDX License List 3.2, SPDX License List 3.6
| MIT_advertising -- ^ @MIT-advertising@, Enlightenment License (e16)
| MIT_CMU -- ^ @MIT-CMU@, CMU License
| MIT_enna -- ^ @MIT-enna@, enna License
| MIT_feh -- ^ @MIT-feh@, feh License
- | MIT -- ^ @MIT@, MIT License
| MITNFA -- ^ @MITNFA@, MIT +no-false-attribs license
+ | MIT -- ^ @MIT@, MIT License
| Motosoto -- ^ @Motosoto@, Motosoto License
| Mpich2 -- ^ @mpich2@, mpich2 License
| MPL_1_0 -- ^ @MPL-1.0@, Mozilla Public License 1.0
@@ -273,9 +286,12 @@ data LicenseId
| OCCT_PL -- ^ @OCCT-PL@, Open CASCADE Technology Public License
| OCLC_2_0 -- ^ @OCLC-2.0@, OCLC Research Public License 2.0
| ODbL_1_0 -- ^ @ODbL-1.0@, ODC Open Database License v1.0
- | ODC_By_1_0 -- ^ @ODC-By-1.0@, Open Data Commons Attribution License v1.0, SPDX License List 3.2
+ | ODC_By_1_0 -- ^ @ODC-By-1.0@, Open Data Commons Attribution License v1.0, SPDX License List 3.2, SPDX License List 3.6
| OFL_1_0 -- ^ @OFL-1.0@, SIL Open Font License 1.0
| OFL_1_1 -- ^ @OFL-1.1@, SIL Open Font License 1.1
+ | OGL_UK_1_0 -- ^ @OGL-UK-1.0@, Open Government Licence v1.0, SPDX License List 3.6
+ | OGL_UK_2_0 -- ^ @OGL-UK-2.0@, Open Government Licence v2.0, SPDX License List 3.6
+ | OGL_UK_3_0 -- ^ @OGL-UK-3.0@, Open Government Licence v3.0, SPDX License List 3.6
| OGTSL -- ^ @OGTSL@, Open Group Test Suite License
| OLDAP_1_1 -- ^ @OLDAP-1.1@, Open LDAP Public License v1.1
| OLDAP_1_2 -- ^ @OLDAP-1.2@, Open LDAP Public License v1.2
@@ -302,9 +318,10 @@ data LicenseId
| OSL_2_0 -- ^ @OSL-2.0@, Open Software License 2.0
| OSL_2_1 -- ^ @OSL-2.1@, Open Software License 2.1
| OSL_3_0 -- ^ @OSL-3.0@, Open Software License 3.0
+ | Parity_6_0_0 -- ^ @Parity-6.0.0@, The Parity Public License 6.0.0, SPDX License List 3.6
| PDDL_1_0 -- ^ @PDDL-1.0@, ODC Public Domain Dedication & License 1.0
- | PHP_3_0 -- ^ @PHP-3.0@, PHP License v3.0
| PHP_3_01 -- ^ @PHP-3.01@, PHP License v3.01
+ | PHP_3_0 -- ^ @PHP-3.0@, PHP License v3.0
| Plexus -- ^ @Plexus@, Plexus Classworlds License
| PostgreSQL -- ^ @PostgreSQL@, PostgreSQL License
| Psfrag -- ^ @psfrag@, psfrag License
@@ -323,10 +340,13 @@ data LicenseId
| SAX_PD -- ^ @SAX-PD@, Sax Public Domain Notice
| Saxpath -- ^ @Saxpath@, Saxpath License
| SCEA -- ^ @SCEA@, SCEA Shared Source License
+ | Sendmail_8_23 -- ^ @Sendmail-8.23@, Sendmail License 8.23, SPDX License List 3.6
| Sendmail -- ^ @Sendmail@, Sendmail License
| SGI_B_1_0 -- ^ @SGI-B-1.0@, SGI Free Software License B v1.0
| SGI_B_1_1 -- ^ @SGI-B-1.1@, SGI Free Software License B v1.1
| SGI_B_2_0 -- ^ @SGI-B-2.0@, SGI Free Software License B v2.0
+ | SHL_0_51 -- ^ @SHL-0.51@, Solderpad Hardware License, Version 0.51, SPDX License List 3.6
+ | SHL_0_5 -- ^ @SHL-0.5@, Solderpad Hardware License v0.5, SPDX License List 3.6
| SimPL_2_0 -- ^ @SimPL-2.0@, Simple Public License 2.0
| SISSL_1_2 -- ^ @SISSL-1.2@, Sun Industry Standards Source License v1.2
| SISSL -- ^ @SISSL@, Sun Industry Standards Source License v1.1
@@ -338,15 +358,17 @@ data LicenseId
| Spencer_94 -- ^ @Spencer-94@, Spencer License 94
| Spencer_99 -- ^ @Spencer-99@, Spencer License 99
| SPL_1_0 -- ^ @SPL-1.0@, Sun Public License v1.0
+ | SSPL_1_0 -- ^ @SSPL-1.0@, Server Side Public License, v 1, SPDX License List 3.6
| SugarCRM_1_1_3 -- ^ @SugarCRM-1.1.3@, SugarCRM Public License v1.1.3
| SWL -- ^ @SWL@, Scheme Widget Library (SWL) Software License Agreement
+ | TAPR_OHL_1_0 -- ^ @TAPR-OHL-1.0@, TAPR Open Hardware License v1.0, SPDX License List 3.6
| TCL -- ^ @TCL@, TCL/TK License
| TCP_wrappers -- ^ @TCP-wrappers@, TCP Wrappers License
| TMate -- ^ @TMate@, TMate Open Source License
| TORQUE_1_1 -- ^ @TORQUE-1.1@, TORQUE v2.5+ Software License v1.1
| TOSL -- ^ @TOSL@, Trusster Open Source License
- | TU_Berlin_1_0 -- ^ @TU-Berlin-1.0@, Technische Universitaet Berlin License 1.0, SPDX License List 3.2
- | TU_Berlin_2_0 -- ^ @TU-Berlin-2.0@, Technische Universitaet Berlin License 2.0, SPDX License List 3.2
+ | TU_Berlin_1_0 -- ^ @TU-Berlin-1.0@, Technische Universitaet Berlin License 1.0, SPDX License List 3.2, SPDX License List 3.6
+ | TU_Berlin_2_0 -- ^ @TU-Berlin-2.0@, Technische Universitaet Berlin License 2.0, SPDX License List 3.2, SPDX License List 3.6
| Unicode_DFS_2015 -- ^ @Unicode-DFS-2015@, Unicode License Agreement - Data Files and Software (2015)
| Unicode_DFS_2016 -- ^ @Unicode-DFS-2016@, Unicode License Agreement - Data Files and Software (2016)
| Unicode_TOU -- ^ @Unicode-TOU@, Unicode Terms of Use
@@ -381,7 +403,15 @@ data LicenseId
| ZPL_2_1 -- ^ @ZPL-2.1@, Zope Public License 2.1
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data, Generic)
-instance Binary LicenseId
+instance Binary LicenseId where
+ -- Word16 is encoded in big endianess
+ -- https://github.com/kolmodin/binary/blob/master/src/Data/Binary/Class.hs#L220-LL227
+ put = Binary.putWord16be . fromIntegral . fromEnum
+ get = do
+ i <- Binary.getWord16be
+ if i > fromIntegral (fromEnum (maxBound :: LicenseId))
+ then fail "Too large LicenseId tag"
+ else return (toEnum (fromIntegral i))
instance Pretty LicenseId where
pretty = Disp.text . licenseId
@@ -489,6 +519,8 @@ licenseId Barr = "Barr"
licenseId Beerware = "Beerware"
licenseId BitTorrent_1_0 = "BitTorrent-1.0"
licenseId BitTorrent_1_1 = "BitTorrent-1.1"
+licenseId Blessing = "blessing"
+licenseId BlueOak_1_0_0 = "BlueOak-1.0.0"
licenseId Borceux = "Borceux"
licenseId BSD_1_Clause = "BSD-1-Clause"
licenseId BSD_2_Clause_FreeBSD = "BSD-2-Clause-FreeBSD"
@@ -501,6 +533,7 @@ licenseId BSD_3_Clause_LBNL = "BSD-3-Clause-LBNL"
licenseId BSD_3_Clause_No_Nuclear_License_2014 = "BSD-3-Clause-No-Nuclear-License-2014"
licenseId BSD_3_Clause_No_Nuclear_License = "BSD-3-Clause-No-Nuclear-License"
licenseId BSD_3_Clause_No_Nuclear_Warranty = "BSD-3-Clause-No-Nuclear-Warranty"
+licenseId BSD_3_Clause_Open_MPI = "BSD-3-Clause-Open-MPI"
licenseId BSD_3_Clause = "BSD-3-Clause"
licenseId BSD_4_Clause_UC = "BSD-4-Clause-UC"
licenseId BSD_4_Clause = "BSD-4-Clause"
@@ -541,6 +574,7 @@ licenseId CC_BY_SA_2_0 = "CC-BY-SA-2.0"
licenseId CC_BY_SA_2_5 = "CC-BY-SA-2.5"
licenseId CC_BY_SA_3_0 = "CC-BY-SA-3.0"
licenseId CC_BY_SA_4_0 = "CC-BY-SA-4.0"
+licenseId CC_PDDC = "CC-PDDC"
licenseId CC0_1_0 = "CC0-1.0"
licenseId CDDL_1_0 = "CDDL-1.0"
licenseId CDDL_1_1 = "CDDL-1.1"
@@ -552,11 +586,15 @@ licenseId CECILL_2_0 = "CECILL-2.0"
licenseId CECILL_2_1 = "CECILL-2.1"
licenseId CECILL_B = "CECILL-B"
licenseId CECILL_C = "CECILL-C"
+licenseId CERN_OHL_1_1 = "CERN-OHL-1.1"
+licenseId CERN_OHL_1_2 = "CERN-OHL-1.2"
licenseId ClArtistic = "ClArtistic"
licenseId CNRI_Jython = "CNRI-Jython"
licenseId CNRI_Python_GPL_Compatible = "CNRI-Python-GPL-Compatible"
licenseId CNRI_Python = "CNRI-Python"
licenseId Condor_1_1 = "Condor-1.1"
+licenseId Copyleft_next_0_3_0 = "copyleft-next-0.3.0"
+licenseId Copyleft_next_0_3_1 = "copyleft-next-0.3.1"
licenseId CPAL_1_0 = "CPAL-1.0"
licenseId CPL_1_0 = "CPL-1.0"
licenseId CPOL_1_02 = "CPOL-1.02"
@@ -589,8 +627,8 @@ licenseId Fair = "Fair"
licenseId Frameworx_1_0 = "Frameworx-1.0"
licenseId FreeImage = "FreeImage"
licenseId FSFAP = "FSFAP"
-licenseId FSFUL = "FSFUL"
licenseId FSFULLR = "FSFULLR"
+licenseId FSFUL = "FSFUL"
licenseId FTL = "FTL"
licenseId GFDL_1_1_only = "GFDL-1.1-only"
licenseId GFDL_1_1_or_later = "GFDL-1.1-or-later"
@@ -611,6 +649,7 @@ licenseId GPL_3_0_only = "GPL-3.0-only"
licenseId GPL_3_0_or_later = "GPL-3.0-or-later"
licenseId GSOAP_1_3b = "gSOAP-1.3b"
licenseId HaskellReport = "HaskellReport"
+licenseId HPND_sell_variant = "HPND-sell-variant"
licenseId HPND = "HPND"
licenseId IBM_pibs = "IBM-pibs"
licenseId ICU = "ICU"
@@ -626,6 +665,7 @@ licenseId IPA = "IPA"
licenseId IPL_1_0 = "IPL-1.0"
licenseId ISC = "ISC"
licenseId JasPer_2_0 = "JasPer-2.0"
+licenseId JPNIC = "JPNIC"
licenseId JSON = "JSON"
licenseId LAL_1_2 = "LAL-1.2"
licenseId LAL_1_3 = "LAL-1.3"
@@ -638,14 +678,15 @@ licenseId LGPL_2_1_or_later = "LGPL-2.1-or-later"
licenseId LGPL_3_0_only = "LGPL-3.0-only"
licenseId LGPL_3_0_or_later = "LGPL-3.0-or-later"
licenseId LGPLLR = "LGPLLR"
+licenseId Libpng_2_0 = "libpng-2.0"
licenseId Libpng = "Libpng"
licenseId Libtiff = "libtiff"
licenseId LiLiQ_P_1_1 = "LiLiQ-P-1.1"
licenseId LiLiQ_R_1_1 = "LiLiQ-R-1.1"
licenseId LiLiQ_Rplus_1_1 = "LiLiQ-Rplus-1.1"
licenseId Linux_OpenIB = "Linux-OpenIB"
-licenseId LPL_1_0 = "LPL-1.0"
licenseId LPL_1_02 = "LPL-1.02"
+licenseId LPL_1_0 = "LPL-1.0"
licenseId LPPL_1_0 = "LPPL-1.0"
licenseId LPPL_1_1 = "LPPL-1.1"
licenseId LPPL_1_2 = "LPPL-1.2"
@@ -658,8 +699,8 @@ licenseId MIT_advertising = "MIT-advertising"
licenseId MIT_CMU = "MIT-CMU"
licenseId MIT_enna = "MIT-enna"
licenseId MIT_feh = "MIT-feh"
-licenseId MIT = "MIT"
licenseId MITNFA = "MITNFA"
+licenseId MIT = "MIT"
licenseId Motosoto = "Motosoto"
licenseId Mpich2 = "mpich2"
licenseId MPL_1_0 = "MPL-1.0"
@@ -695,6 +736,9 @@ licenseId ODbL_1_0 = "ODbL-1.0"
licenseId ODC_By_1_0 = "ODC-By-1.0"
licenseId OFL_1_0 = "OFL-1.0"
licenseId OFL_1_1 = "OFL-1.1"
+licenseId OGL_UK_1_0 = "OGL-UK-1.0"
+licenseId OGL_UK_2_0 = "OGL-UK-2.0"
+licenseId OGL_UK_3_0 = "OGL-UK-3.0"
licenseId OGTSL = "OGTSL"
licenseId OLDAP_1_1 = "OLDAP-1.1"
licenseId OLDAP_1_2 = "OLDAP-1.2"
@@ -721,9 +765,10 @@ licenseId OSL_1_1 = "OSL-1.1"
licenseId OSL_2_0 = "OSL-2.0"
licenseId OSL_2_1 = "OSL-2.1"
licenseId OSL_3_0 = "OSL-3.0"
+licenseId Parity_6_0_0 = "Parity-6.0.0"
licenseId PDDL_1_0 = "PDDL-1.0"
-licenseId PHP_3_0 = "PHP-3.0"
licenseId PHP_3_01 = "PHP-3.01"
+licenseId PHP_3_0 = "PHP-3.0"
licenseId Plexus = "Plexus"
licenseId PostgreSQL = "PostgreSQL"
licenseId Psfrag = "psfrag"
@@ -742,10 +787,13 @@ licenseId Ruby = "Ruby"
licenseId SAX_PD = "SAX-PD"
licenseId Saxpath = "Saxpath"
licenseId SCEA = "SCEA"
+licenseId Sendmail_8_23 = "Sendmail-8.23"
licenseId Sendmail = "Sendmail"
licenseId SGI_B_1_0 = "SGI-B-1.0"
licenseId SGI_B_1_1 = "SGI-B-1.1"
licenseId SGI_B_2_0 = "SGI-B-2.0"
+licenseId SHL_0_51 = "SHL-0.51"
+licenseId SHL_0_5 = "SHL-0.5"
licenseId SimPL_2_0 = "SimPL-2.0"
licenseId SISSL_1_2 = "SISSL-1.2"
licenseId SISSL = "SISSL"
@@ -757,8 +805,10 @@ licenseId Spencer_86 = "Spencer-86"
licenseId Spencer_94 = "Spencer-94"
licenseId Spencer_99 = "Spencer-99"
licenseId SPL_1_0 = "SPL-1.0"
+licenseId SSPL_1_0 = "SSPL-1.0"
licenseId SugarCRM_1_1_3 = "SugarCRM-1.1.3"
licenseId SWL = "SWL"
+licenseId TAPR_OHL_1_0 = "TAPR-OHL-1.0"
licenseId TCL = "TCL"
licenseId TCP_wrappers = "TCP-wrappers"
licenseId TMate = "TMate"
@@ -841,6 +891,8 @@ licenseName Barr = "Barr License"
licenseName Beerware = "Beerware License"
licenseName BitTorrent_1_0 = "BitTorrent Open Source License v1.0"
licenseName BitTorrent_1_1 = "BitTorrent Open Source License v1.1"
+licenseName Blessing = "SQLite Blessing"
+licenseName BlueOak_1_0_0 = "Blue Oak Model License 1.0.0"
licenseName Borceux = "Borceux license"
licenseName BSD_1_Clause = "BSD 1-Clause License"
licenseName BSD_2_Clause_FreeBSD = "BSD 2-Clause FreeBSD License"
@@ -853,6 +905,7 @@ licenseName BSD_3_Clause_LBNL = "Lawrence Berkeley National Labs BSD variant lic
licenseName BSD_3_Clause_No_Nuclear_License_2014 = "BSD 3-Clause No Nuclear License 2014"
licenseName BSD_3_Clause_No_Nuclear_License = "BSD 3-Clause No Nuclear License"
licenseName BSD_3_Clause_No_Nuclear_Warranty = "BSD 3-Clause No Nuclear Warranty"
+licenseName BSD_3_Clause_Open_MPI = "BSD 3-Clause Open MPI variant"
licenseName BSD_3_Clause = "BSD 3-Clause \"New\" or \"Revised\" License"
licenseName BSD_4_Clause_UC = "BSD-4-Clause (University of California-Specific)"
licenseName BSD_4_Clause = "BSD 4-Clause \"Original\" or \"Old\" License"
@@ -893,6 +946,7 @@ licenseName CC_BY_SA_2_0 = "Creative Commons Attribution Share Alike 2.0 Generic
licenseName CC_BY_SA_2_5 = "Creative Commons Attribution Share Alike 2.5 Generic"
licenseName CC_BY_SA_3_0 = "Creative Commons Attribution Share Alike 3.0 Unported"
licenseName CC_BY_SA_4_0 = "Creative Commons Attribution Share Alike 4.0 International"
+licenseName CC_PDDC = "Creative Commons Public Domain Dedication and Certification"
licenseName CC0_1_0 = "Creative Commons Zero v1.0 Universal"
licenseName CDDL_1_0 = "Common Development and Distribution License 1.0"
licenseName CDDL_1_1 = "Common Development and Distribution License 1.1"
@@ -904,11 +958,15 @@ licenseName CECILL_2_0 = "CeCILL Free Software License Agreement v2.0"
licenseName CECILL_2_1 = "CeCILL Free Software License Agreement v2.1"
licenseName CECILL_B = "CeCILL-B Free Software License Agreement"
licenseName CECILL_C = "CeCILL-C Free Software License Agreement"
+licenseName CERN_OHL_1_1 = "CERN Open Hardware License v1.1"
+licenseName CERN_OHL_1_2 = "CERN Open Hardware Licence v1.2"
licenseName ClArtistic = "Clarified Artistic License"
licenseName CNRI_Jython = "CNRI Jython License"
licenseName CNRI_Python_GPL_Compatible = "CNRI Python Open Source GPL Compatible License Agreement"
licenseName CNRI_Python = "CNRI Python License"
licenseName Condor_1_1 = "Condor Public License v1.1"
+licenseName Copyleft_next_0_3_0 = "copyleft-next 0.3.0"
+licenseName Copyleft_next_0_3_1 = "copyleft-next 0.3.1"
licenseName CPAL_1_0 = "Common Public Attribution License 1.0"
licenseName CPL_1_0 = "Common Public License 1.0"
licenseName CPOL_1_02 = "Code Project Open License 1.02"
@@ -941,8 +999,8 @@ licenseName Fair = "Fair License"
licenseName Frameworx_1_0 = "Frameworx Open License 1.0"
licenseName FreeImage = "FreeImage Public License v1.0"
licenseName FSFAP = "FSF All Permissive License"
-licenseName FSFUL = "FSF Unlimited License"
licenseName FSFULLR = "FSF Unlimited License (with License Retention)"
+licenseName FSFUL = "FSF Unlimited License"
licenseName FTL = "Freetype Project License"
licenseName GFDL_1_1_only = "GNU Free Documentation License v1.1 only"
licenseName GFDL_1_1_or_later = "GNU Free Documentation License v1.1 or later"
@@ -963,6 +1021,7 @@ licenseName GPL_3_0_only = "GNU General Public License v3.0 only"
licenseName GPL_3_0_or_later = "GNU General Public License v3.0 or later"
licenseName GSOAP_1_3b = "gSOAP Public License v1.3b"
licenseName HaskellReport = "Haskell Language Report License"
+licenseName HPND_sell_variant = "Historical Permission Notice and Disclaimer - sell variant"
licenseName HPND = "Historical Permission Notice and Disclaimer"
licenseName IBM_pibs = "IBM PowerPC Initialization and Boot Software"
licenseName ICU = "ICU License"
@@ -978,6 +1037,7 @@ licenseName IPA = "IPA Font License"
licenseName IPL_1_0 = "IBM Public License v1.0"
licenseName ISC = "ISC License"
licenseName JasPer_2_0 = "JasPer License"
+licenseName JPNIC = "Japan Network Information Center License"
licenseName JSON = "JSON License"
licenseName LAL_1_2 = "Licence Art Libre 1.2"
licenseName LAL_1_3 = "Licence Art Libre 1.3"
@@ -990,14 +1050,15 @@ licenseName LGPL_2_1_or_later = "GNU Lesser General Public License v2.1 or later
licenseName LGPL_3_0_only = "GNU Lesser General Public License v3.0 only"
licenseName LGPL_3_0_or_later = "GNU Lesser General Public License v3.0 or later"
licenseName LGPLLR = "Lesser General Public License For Linguistic Resources"
+licenseName Libpng_2_0 = "PNG Reference Library version 2"
licenseName Libpng = "libpng License"
licenseName Libtiff = "libtiff License"
licenseName LiLiQ_P_1_1 = "Licence Libre du Qu\233bec \8211 Permissive version 1.1"
licenseName LiLiQ_R_1_1 = "Licence Libre du Qu\233bec \8211 R\233ciprocit\233 version 1.1"
licenseName LiLiQ_Rplus_1_1 = "Licence Libre du Qu\233bec \8211 R\233ciprocit\233 forte version 1.1"
licenseName Linux_OpenIB = "Linux Kernel Variant of OpenIB.org license"
-licenseName LPL_1_0 = "Lucent Public License Version 1.0"
licenseName LPL_1_02 = "Lucent Public License v1.02"
+licenseName LPL_1_0 = "Lucent Public License Version 1.0"
licenseName LPPL_1_0 = "LaTeX Project Public License v1.0"
licenseName LPPL_1_1 = "LaTeX Project Public License v1.1"
licenseName LPPL_1_2 = "LaTeX Project Public License v1.2"
@@ -1010,8 +1071,8 @@ licenseName MIT_advertising = "Enlightenment License (e16)"
licenseName MIT_CMU = "CMU License"
licenseName MIT_enna = "enna License"
licenseName MIT_feh = "feh License"
-licenseName MIT = "MIT License"
licenseName MITNFA = "MIT +no-false-attribs license"
+licenseName MIT = "MIT License"
licenseName Motosoto = "Motosoto License"
licenseName Mpich2 = "mpich2 License"
licenseName MPL_1_0 = "Mozilla Public License 1.0"
@@ -1047,6 +1108,9 @@ licenseName ODbL_1_0 = "ODC Open Database License v1.0"
licenseName ODC_By_1_0 = "Open Data Commons Attribution License v1.0"
licenseName OFL_1_0 = "SIL Open Font License 1.0"
licenseName OFL_1_1 = "SIL Open Font License 1.1"
+licenseName OGL_UK_1_0 = "Open Government Licence v1.0"
+licenseName OGL_UK_2_0 = "Open Government Licence v2.0"
+licenseName OGL_UK_3_0 = "Open Government Licence v3.0"
licenseName OGTSL = "Open Group Test Suite License"
licenseName OLDAP_1_1 = "Open LDAP Public License v1.1"
licenseName OLDAP_1_2 = "Open LDAP Public License v1.2"
@@ -1073,9 +1137,10 @@ licenseName OSL_1_1 = "Open Software License 1.1"
licenseName OSL_2_0 = "Open Software License 2.0"
licenseName OSL_2_1 = "Open Software License 2.1"
licenseName OSL_3_0 = "Open Software License 3.0"
+licenseName Parity_6_0_0 = "The Parity Public License 6.0.0"
licenseName PDDL_1_0 = "ODC Public Domain Dedication & License 1.0"
-licenseName PHP_3_0 = "PHP License v3.0"
licenseName PHP_3_01 = "PHP License v3.01"
+licenseName PHP_3_0 = "PHP License v3.0"
licenseName Plexus = "Plexus Classworlds License"
licenseName PostgreSQL = "PostgreSQL License"
licenseName Psfrag = "psfrag License"
@@ -1094,10 +1159,13 @@ licenseName Ruby = "Ruby License"
licenseName SAX_PD = "Sax Public Domain Notice"
licenseName Saxpath = "Saxpath License"
licenseName SCEA = "SCEA Shared Source License"
+licenseName Sendmail_8_23 = "Sendmail License 8.23"
licenseName Sendmail = "Sendmail License"
licenseName SGI_B_1_0 = "SGI Free Software License B v1.0"
licenseName SGI_B_1_1 = "SGI Free Software License B v1.1"
licenseName SGI_B_2_0 = "SGI Free Software License B v2.0"
+licenseName SHL_0_51 = "Solderpad Hardware License, Version 0.51"
+licenseName SHL_0_5 = "Solderpad Hardware License v0.5"
licenseName SimPL_2_0 = "Simple Public License 2.0"
licenseName SISSL_1_2 = "Sun Industry Standards Source License v1.2"
licenseName SISSL = "Sun Industry Standards Source License v1.1"
@@ -1109,8 +1177,10 @@ licenseName Spencer_86 = "Spencer License 86"
licenseName Spencer_94 = "Spencer License 94"
licenseName Spencer_99 = "Spencer License 99"
licenseName SPL_1_0 = "Sun Public License v1.0"
+licenseName SSPL_1_0 = "Server Side Public License, v 1"
licenseName SugarCRM_1_1_3 = "SugarCRM Public License v1.1.3"
licenseName SWL = "Scheme Widget Library (SWL) Software License Agreement"
+licenseName TAPR_OHL_1_0 = "TAPR Open Hardware License v1.0"
licenseName TCL = "TCL/TK License"
licenseName TCP_wrappers = "TCP Wrappers License"
licenseName TMate = "TMate Open Source License"
@@ -1155,7 +1225,7 @@ licenseName ZPL_2_1 = "Zope Public License 2.1"
--
-- See <https://opensource.org/licenses/alphabetical>.
licenseIsOsiApproved :: LicenseId -> Bool
-licenseIsOsiApproved NullBSD = False
+licenseIsOsiApproved NullBSD = True
licenseIsOsiApproved AAL = True
licenseIsOsiApproved Abstyles = False
licenseIsOsiApproved Adobe_2006 = False
@@ -1195,6 +1265,8 @@ licenseIsOsiApproved Barr = False
licenseIsOsiApproved Beerware = False
licenseIsOsiApproved BitTorrent_1_0 = False
licenseIsOsiApproved BitTorrent_1_1 = False
+licenseIsOsiApproved Blessing = False
+licenseIsOsiApproved BlueOak_1_0_0 = False
licenseIsOsiApproved Borceux = False
licenseIsOsiApproved BSD_1_Clause = False
licenseIsOsiApproved BSD_2_Clause_FreeBSD = False
@@ -1203,10 +1275,11 @@ licenseIsOsiApproved BSD_2_Clause_Patent = True
licenseIsOsiApproved BSD_2_Clause = True
licenseIsOsiApproved BSD_3_Clause_Attribution = False
licenseIsOsiApproved BSD_3_Clause_Clear = False
-licenseIsOsiApproved BSD_3_Clause_LBNL = False
+licenseIsOsiApproved BSD_3_Clause_LBNL = True
licenseIsOsiApproved BSD_3_Clause_No_Nuclear_License_2014 = False
licenseIsOsiApproved BSD_3_Clause_No_Nuclear_License = False
licenseIsOsiApproved BSD_3_Clause_No_Nuclear_Warranty = False
+licenseIsOsiApproved BSD_3_Clause_Open_MPI = False
licenseIsOsiApproved BSD_3_Clause = True
licenseIsOsiApproved BSD_4_Clause_UC = False
licenseIsOsiApproved BSD_4_Clause = False
@@ -1247,6 +1320,7 @@ licenseIsOsiApproved CC_BY_SA_2_0 = False
licenseIsOsiApproved CC_BY_SA_2_5 = False
licenseIsOsiApproved CC_BY_SA_3_0 = False
licenseIsOsiApproved CC_BY_SA_4_0 = False
+licenseIsOsiApproved CC_PDDC = False
licenseIsOsiApproved CC0_1_0 = False
licenseIsOsiApproved CDDL_1_0 = True
licenseIsOsiApproved CDDL_1_1 = False
@@ -1258,11 +1332,15 @@ licenseIsOsiApproved CECILL_2_0 = False
licenseIsOsiApproved CECILL_2_1 = True
licenseIsOsiApproved CECILL_B = False
licenseIsOsiApproved CECILL_C = False
+licenseIsOsiApproved CERN_OHL_1_1 = False
+licenseIsOsiApproved CERN_OHL_1_2 = False
licenseIsOsiApproved ClArtistic = False
licenseIsOsiApproved CNRI_Jython = False
licenseIsOsiApproved CNRI_Python_GPL_Compatible = False
licenseIsOsiApproved CNRI_Python = True
licenseIsOsiApproved Condor_1_1 = False
+licenseIsOsiApproved Copyleft_next_0_3_0 = False
+licenseIsOsiApproved Copyleft_next_0_3_1 = False
licenseIsOsiApproved CPAL_1_0 = True
licenseIsOsiApproved CPL_1_0 = True
licenseIsOsiApproved CPOL_1_02 = False
@@ -1295,8 +1373,8 @@ licenseIsOsiApproved Fair = True
licenseIsOsiApproved Frameworx_1_0 = True
licenseIsOsiApproved FreeImage = False
licenseIsOsiApproved FSFAP = False
-licenseIsOsiApproved FSFUL = False
licenseIsOsiApproved FSFULLR = False
+licenseIsOsiApproved FSFUL = False
licenseIsOsiApproved FTL = False
licenseIsOsiApproved GFDL_1_1_only = False
licenseIsOsiApproved GFDL_1_1_or_later = False
@@ -1317,6 +1395,7 @@ licenseIsOsiApproved GPL_3_0_only = True
licenseIsOsiApproved GPL_3_0_or_later = True
licenseIsOsiApproved GSOAP_1_3b = False
licenseIsOsiApproved HaskellReport = False
+licenseIsOsiApproved HPND_sell_variant = False
licenseIsOsiApproved HPND = True
licenseIsOsiApproved IBM_pibs = False
licenseIsOsiApproved ICU = False
@@ -1332,6 +1411,7 @@ licenseIsOsiApproved IPA = True
licenseIsOsiApproved IPL_1_0 = True
licenseIsOsiApproved ISC = True
licenseIsOsiApproved JasPer_2_0 = False
+licenseIsOsiApproved JPNIC = False
licenseIsOsiApproved JSON = False
licenseIsOsiApproved LAL_1_2 = False
licenseIsOsiApproved LAL_1_3 = False
@@ -1344,14 +1424,15 @@ licenseIsOsiApproved LGPL_2_1_or_later = True
licenseIsOsiApproved LGPL_3_0_only = True
licenseIsOsiApproved LGPL_3_0_or_later = True
licenseIsOsiApproved LGPLLR = False
+licenseIsOsiApproved Libpng_2_0 = False
licenseIsOsiApproved Libpng = False
licenseIsOsiApproved Libtiff = False
licenseIsOsiApproved LiLiQ_P_1_1 = True
licenseIsOsiApproved LiLiQ_R_1_1 = True
licenseIsOsiApproved LiLiQ_Rplus_1_1 = True
licenseIsOsiApproved Linux_OpenIB = False
-licenseIsOsiApproved LPL_1_0 = True
licenseIsOsiApproved LPL_1_02 = True
+licenseIsOsiApproved LPL_1_0 = True
licenseIsOsiApproved LPPL_1_0 = False
licenseIsOsiApproved LPPL_1_1 = False
licenseIsOsiApproved LPPL_1_2 = False
@@ -1364,8 +1445,8 @@ licenseIsOsiApproved MIT_advertising = False
licenseIsOsiApproved MIT_CMU = False
licenseIsOsiApproved MIT_enna = False
licenseIsOsiApproved MIT_feh = False
-licenseIsOsiApproved MIT = True
licenseIsOsiApproved MITNFA = False
+licenseIsOsiApproved MIT = True
licenseIsOsiApproved Motosoto = True
licenseIsOsiApproved Mpich2 = False
licenseIsOsiApproved MPL_1_0 = True
@@ -1401,6 +1482,9 @@ licenseIsOsiApproved ODbL_1_0 = False
licenseIsOsiApproved ODC_By_1_0 = False
licenseIsOsiApproved OFL_1_0 = False
licenseIsOsiApproved OFL_1_1 = True
+licenseIsOsiApproved OGL_UK_1_0 = False
+licenseIsOsiApproved OGL_UK_2_0 = False
+licenseIsOsiApproved OGL_UK_3_0 = False
licenseIsOsiApproved OGTSL = True
licenseIsOsiApproved OLDAP_1_1 = False
licenseIsOsiApproved OLDAP_1_2 = False
@@ -1427,9 +1511,10 @@ licenseIsOsiApproved OSL_1_1 = False
licenseIsOsiApproved OSL_2_0 = True
licenseIsOsiApproved OSL_2_1 = True
licenseIsOsiApproved OSL_3_0 = True
+licenseIsOsiApproved Parity_6_0_0 = False
licenseIsOsiApproved PDDL_1_0 = False
-licenseIsOsiApproved PHP_3_0 = True
licenseIsOsiApproved PHP_3_01 = False
+licenseIsOsiApproved PHP_3_0 = True
licenseIsOsiApproved Plexus = False
licenseIsOsiApproved PostgreSQL = True
licenseIsOsiApproved Psfrag = False
@@ -1448,10 +1533,13 @@ licenseIsOsiApproved Ruby = False
licenseIsOsiApproved SAX_PD = False
licenseIsOsiApproved Saxpath = False
licenseIsOsiApproved SCEA = False
+licenseIsOsiApproved Sendmail_8_23 = False
licenseIsOsiApproved Sendmail = False
licenseIsOsiApproved SGI_B_1_0 = False
licenseIsOsiApproved SGI_B_1_1 = False
licenseIsOsiApproved SGI_B_2_0 = False
+licenseIsOsiApproved SHL_0_51 = False
+licenseIsOsiApproved SHL_0_5 = False
licenseIsOsiApproved SimPL_2_0 = True
licenseIsOsiApproved SISSL_1_2 = False
licenseIsOsiApproved SISSL = True
@@ -1463,8 +1551,10 @@ licenseIsOsiApproved Spencer_86 = False
licenseIsOsiApproved Spencer_94 = False
licenseIsOsiApproved Spencer_99 = False
licenseIsOsiApproved SPL_1_0 = True
+licenseIsOsiApproved SSPL_1_0 = False
licenseIsOsiApproved SugarCRM_1_1_3 = False
licenseIsOsiApproved SWL = False
+licenseIsOsiApproved TAPR_OHL_1_0 = False
licenseIsOsiApproved TCL = False
licenseIsOsiApproved TCP_wrappers = False
licenseIsOsiApproved TMate = False
@@ -1524,11 +1614,42 @@ licenseIdList LicenseListVersion_3_2 =
, TU_Berlin_2_0
]
++ bulkOfLicenses
+licenseIdList LicenseListVersion_3_6 =
+ [ AGPL_1_0_only
+ , AGPL_1_0_or_later
+ , Blessing
+ , BlueOak_1_0_0
+ , BSD_3_Clause_Open_MPI
+ , CC_PDDC
+ , CERN_OHL_1_1
+ , CERN_OHL_1_2
+ , Copyleft_next_0_3_0
+ , Copyleft_next_0_3_1
+ , HPND_sell_variant
+ , JPNIC
+ , Libpng_2_0
+ , Linux_OpenIB
+ , MIT_0
+ , ODC_By_1_0
+ , OGL_UK_1_0
+ , OGL_UK_2_0
+ , OGL_UK_3_0
+ , Parity_6_0_0
+ , Sendmail_8_23
+ , SHL_0_51
+ , SHL_0_5
+ , SSPL_1_0
+ , TAPR_OHL_1_0
+ , TU_Berlin_1_0
+ , TU_Berlin_2_0
+ ]
+ ++ bulkOfLicenses
-- | Create a 'LicenseId' from a 'String'.
mkLicenseId :: LicenseListVersion -> String -> Maybe LicenseId
mkLicenseId LicenseListVersion_3_0 s = Map.lookup s stringLookup_3_0
mkLicenseId LicenseListVersion_3_2 s = Map.lookup s stringLookup_3_2
+mkLicenseId LicenseListVersion_3_6 s = Map.lookup s stringLookup_3_6
stringLookup_3_0 :: Map String LicenseId
stringLookup_3_0 = Map.fromList $ map (\i -> (licenseId i, i)) $
@@ -1538,6 +1659,10 @@ stringLookup_3_2 :: Map String LicenseId
stringLookup_3_2 = Map.fromList $ map (\i -> (licenseId i, i)) $
licenseIdList LicenseListVersion_3_2
+stringLookup_3_6 :: Map String LicenseId
+stringLookup_3_6 = Map.fromList $ map (\i -> (licenseId i, i)) $
+ licenseIdList LicenseListVersion_3_6
+
-- | Licenses in all SPDX License lists
bulkOfLicenses :: [LicenseId]
bulkOfLicenses =
@@ -1678,8 +1803,8 @@ bulkOfLicenses =
, Frameworx_1_0
, FreeImage
, FSFAP
- , FSFUL
, FSFULLR
+ , FSFUL
, FTL
, GFDL_1_1_only
, GFDL_1_1_or_later
@@ -1732,8 +1857,8 @@ bulkOfLicenses =
, LiLiQ_P_1_1
, LiLiQ_R_1_1
, LiLiQ_Rplus_1_1
- , LPL_1_0
, LPL_1_02
+ , LPL_1_0
, LPPL_1_0
, LPPL_1_1
, LPPL_1_2
@@ -1745,8 +1870,8 @@ bulkOfLicenses =
, MIT_CMU
, MIT_enna
, MIT_feh
- , MIT
, MITNFA
+ , MIT
, Motosoto
, Mpich2
, MPL_1_0
@@ -1808,8 +1933,8 @@ bulkOfLicenses =
, OSL_2_1
, OSL_3_0
, PDDL_1_0
- , PHP_3_0
, PHP_3_01
+ , PHP_3_0
, Plexus
, PostgreSQL
, Psfrag
diff --git a/cabal/Cabal/Distribution/SPDX/LicenseListVersion.hs b/cabal/Cabal/Distribution/SPDX/LicenseListVersion.hs
index 43fbfab..2f32c15 100644
--- a/cabal/Cabal/Distribution/SPDX/LicenseListVersion.hs
+++ b/cabal/Cabal/Distribution/SPDX/LicenseListVersion.hs
@@ -9,8 +9,10 @@ import Distribution.CabalSpecVersion
data LicenseListVersion
= LicenseListVersion_3_0
| LicenseListVersion_3_2
+ | LicenseListVersion_3_6
deriving (Eq, Ord, Show, Enum, Bounded)
cabalSpecVersionToSPDXListVersion :: CabalSpecVersion -> LicenseListVersion
+cabalSpecVersionToSPDXListVersion CabalSpecV3_0 = LicenseListVersion_3_6
cabalSpecVersionToSPDXListVersion CabalSpecV2_4 = LicenseListVersion_3_2
cabalSpecVersionToSPDXListVersion _ = LicenseListVersion_3_0
diff --git a/cabal/Cabal/Distribution/SPDX/LicenseReference.hs b/cabal/Cabal/Distribution/SPDX/LicenseReference.hs
index b3a98b8..a645ec5 100644
--- a/cabal/Cabal/Distribution/SPDX/LicenseReference.hs
+++ b/cabal/Cabal/Distribution/SPDX/LicenseReference.hs
@@ -13,7 +13,7 @@ import Distribution.Compat.Prelude
import Distribution.Utils.Generic (isAsciiAlphaNum)
import Distribution.Pretty
-import Distribution.Parsec.Class
+import Distribution.Parsec
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
diff --git a/cabal/Cabal/Distribution/Simple.hs b/cabal/Cabal/Distribution/Simple.hs
index 1ea5717..e632acc 100644
--- a/cabal/Cabal/Distribution/Simple.hs
+++ b/cabal/Cabal/Distribution/Simple.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
-
+{-# LANGUAGE LambdaCase #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple
@@ -52,13 +52,12 @@ module Distribution.Simple (
-- ** Standard sets of hooks
simpleUserHooks,
autoconfUserHooks,
- defaultUserHooks, emptyUserHooks,
- -- ** Utils
- defaultHookedPackageDesc
+ emptyUserHooks,
) where
-import Prelude ()
import Control.Exception (try)
+
+import Prelude ()
import Distribution.Compat.Prelude
-- local
@@ -92,7 +91,8 @@ import Distribution.Verbosity
import Language.Haskell.Extension
import Distribution.Version
import Distribution.License
-import Distribution.Text
+import Distribution.Pretty
+import Distribution.System (buildPlatform)
-- Base
import System.Environment (getArgs, getProgName)
@@ -100,6 +100,7 @@ import System.Directory (removeFile, doesFileExist
,doesDirectoryExist, removeDirectoryRecursive)
import System.Exit (exitWith,ExitCode(..))
import System.FilePath (searchPathSeparator, takeDirectory, (</>), splitDirectories, dropDrive)
+import Distribution.Compat.ResponseFile (expandResponse)
import Distribution.Compat.Directory (makeAbsolute)
import Distribution.Compat.Environment (getEnvironment)
import Distribution.Compat.GetShortPathName (getShortPathName)
@@ -148,8 +149,9 @@ defaultMainWithHooksNoReadArgs hooks pkg_descr =
defaultMainHelper hooks { readDesc = return (Just pkg_descr) }
defaultMainHelper :: UserHooks -> Args -> IO ()
-defaultMainHelper hooks args = topHandler $
- case commandsRun (globalCommand commands) commands args of
+defaultMainHelper hooks args = topHandler $ do
+ args' <- expandResponse args
+ case commandsRun (globalCommand commands) commands args' of
CommandHelp help -> printHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
@@ -168,15 +170,16 @@ defaultMainHelper hooks args = topHandler $
printErrors errs = do
putStr (intercalate "\n" errs)
exitWith (ExitFailure 1)
- printNumericVersion = putStrLn $ display cabalVersion
+ printNumericVersion = putStrLn $ prettyShow cabalVersion
printVersion = putStrLn $ "Cabal library version "
- ++ display cabalVersion
+ ++ prettyShow cabalVersion
progs = addKnownPrograms (hookedPrograms hooks) defaultProgramDb
commands =
[configureCommand progs `commandAddAction`
\fs as -> configureAction hooks fs as >> return ()
,buildCommand progs `commandAddAction` buildAction hooks
+ ,showBuildInfoCommand progs `commandAddAction` showBuildInfoAction hooks
,replCommand progs `commandAddAction` replAction hooks
,installCommand `commandAddAction` installAction hooks
,copyCommand `commandAddAction` copyAction hooks
@@ -258,10 +261,37 @@ buildAction hooks flags args = do
(buildProgramArgs flags')
(withPrograms lbi)
- hookedAction preBuild buildHook postBuild
+ hookedAction verbosity preBuild buildHook postBuild
(return lbi { withPrograms = progs })
hooks flags' { buildArgs = args } args
+showBuildInfoAction :: UserHooks -> ShowBuildInfoFlags -> Args -> IO ()
+showBuildInfoAction hooks (ShowBuildInfoFlags flags fileOutput) args = do
+ distPref <- findDistPrefOrDefault (buildDistPref flags)
+ let verbosity = fromFlag $ buildVerbosity flags
+ lbi <- getBuildConfig hooks verbosity distPref
+ let flags' = flags { buildDistPref = toFlag distPref
+ , buildCabalFilePath = maybeToFlag (cabalFilePath lbi)
+ }
+
+ progs <- reconfigurePrograms verbosity
+ (buildProgramPaths flags')
+ (buildProgramArgs flags')
+ (withPrograms lbi)
+
+ pbi <- preBuild hooks args flags'
+ let lbi' = lbi { withPrograms = progs }
+ pkg_descr0 = localPkgDescr lbi'
+ pkg_descr = updatePackageDescription pbi pkg_descr0
+ -- TODO: Somehow don't ignore build hook?
+ buildInfoString <- showBuildInfo pkg_descr lbi' flags
+
+ case fileOutput of
+ Nothing -> putStr buildInfoString
+ Just fp -> writeFile fp buildInfoString
+
+ postBuild hooks args flags' pkg_descr lbi'
+
replAction :: UserHooks -> ReplFlags -> Args -> IO ()
replAction hooks flags args = do
distPref <- findDistPrefOrDefault (replDistPref flags)
@@ -279,7 +309,7 @@ replAction hooks flags args = do
-- takes the args explicitly. UGH. -- ezyang
pbi <- preRepl hooks args flags'
let pkg_descr0 = localPkgDescr lbi
- sanityCheckHookedBuildInfo pkg_descr0 pbi
+ sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
lbi' = lbi { withPrograms = progs
, localPkgDescr = pkg_descr }
@@ -294,7 +324,7 @@ hscolourAction hooks flags args = do
let flags' = flags { hscolourDistPref = toFlag distPref
, hscolourCabalFilePath = maybeToFlag (cabalFilePath lbi)}
- hookedAction preHscolour hscolourHook postHscolour
+ hookedAction verbosity preHscolour hscolourHook postHscolour
(getBuildConfig hooks verbosity distPref)
hooks flags' args
@@ -310,7 +340,7 @@ doctestAction hooks flags args = do
(doctestProgramArgs flags')
(withPrograms lbi)
- hookedAction preDoctest doctestHook postDoctest
+ hookedAction verbosity preDoctest doctestHook postDoctest
(return lbi { withPrograms = progs })
hooks flags' args
@@ -327,7 +357,7 @@ haddockAction hooks flags args = do
(haddockProgramArgs flags')
(withPrograms lbi)
- hookedAction preHaddock haddockHook postHaddock
+ hookedAction verbosity preHaddock haddockHook postHaddock
(return lbi { withPrograms = progs })
hooks flags' { haddockArgs = args } args
@@ -353,7 +383,7 @@ cleanAction hooks flags args = do
let pkg_descr0 = flattenPackageDescription ppd
-- We don't sanity check for clean as an error
-- here would prevent cleaning:
- --sanityCheckHookedBuildInfo pkg_descr0 pbi
+ --sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
cleanHook hooks pkg_descr () hooks flags'
@@ -368,7 +398,7 @@ copyAction hooks flags args = do
lbi <- getBuildConfig hooks verbosity distPref
let flags' = flags { copyDistPref = toFlag distPref
, copyCabalFilePath = maybeToFlag (cabalFilePath lbi)}
- hookedAction preCopy copyHook postCopy
+ hookedAction verbosity preCopy copyHook postCopy
(getBuildConfig hooks verbosity distPref)
hooks flags' { copyArgs = args } args
@@ -379,15 +409,14 @@ installAction hooks flags args = do
lbi <- getBuildConfig hooks verbosity distPref
let flags' = flags { installDistPref = toFlag distPref
, installCabalFilePath = maybeToFlag (cabalFilePath lbi)}
- hookedAction preInst instHook postInst
+ hookedAction verbosity preInst instHook postInst
(getBuildConfig hooks verbosity distPref)
hooks flags' args
sdistAction :: UserHooks -> SDistFlags -> Args -> IO ()
-sdistAction hooks flags args = do
+sdistAction hooks flags _args = do
distPref <- findDistPrefOrDefault (sDistDistPref flags)
- let flags' = flags { sDistDistPref = toFlag distPref }
- pbi <- preSDist hooks args flags'
+ let pbi = emptyHookedBuildInfo
mlbi <- maybeGetPersistBuildConfig distPref
@@ -404,12 +433,11 @@ sdistAction hooks flags args = do
(_, ppd) <- confPkgDescr hooks verbosity Nothing
let pkg_descr0 = flattenPackageDescription ppd
- sanityCheckHookedBuildInfo pkg_descr0 pbi
+ sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
mlbi' = fmap (\lbi -> lbi { localPkgDescr = pkg_descr }) mlbi
- sDistHook hooks pkg_descr mlbi' hooks flags'
- postSDist hooks args flags' pkg_descr mlbi'
+ sdist pkg_descr mlbi' flags srcPref (allSuffixHandlers hooks)
where
verbosity = fromFlag (sDistVerbosity flags)
@@ -419,13 +447,7 @@ testAction hooks flags args = do
let verbosity = fromFlag $ testVerbosity flags
flags' = flags { testDistPref = toFlag distPref }
- localBuildInfo <- getBuildConfig hooks verbosity distPref
- let pkg_descr = localPkgDescr localBuildInfo
- -- It is safe to do 'runTests' before the new test handler because the
- -- default action is a no-op and if the package uses the old test interface
- -- the new handler will find no tests.
- runTests hooks args False pkg_descr localBuildInfo
- hookedActionWithArgs preTest testHook postTest
+ hookedActionWithArgs verbosity preTest testHook postTest
(getBuildConfig hooks verbosity distPref)
hooks flags' args
@@ -434,7 +456,7 @@ benchAction hooks flags args = do
distPref <- findDistPrefOrDefault (benchmarkDistPref flags)
let verbosity = fromFlag $ benchmarkVerbosity flags
flags' = flags { benchmarkDistPref = toFlag distPref }
- hookedActionWithArgs preBench benchHook postBench
+ hookedActionWithArgs verbosity preBench benchHook postBench
(getBuildConfig hooks verbosity distPref)
hooks flags' args
@@ -445,7 +467,7 @@ registerAction hooks flags args = do
lbi <- getBuildConfig hooks verbosity distPref
let flags' = flags { regDistPref = toFlag distPref
, regCabalFilePath = maybeToFlag (cabalFilePath lbi)}
- hookedAction preReg regHook postReg
+ hookedAction verbosity preReg regHook postReg
(getBuildConfig hooks verbosity distPref)
hooks flags' { regArgs = args } args
@@ -456,55 +478,62 @@ unregisterAction hooks flags args = do
lbi <- getBuildConfig hooks verbosity distPref
let flags' = flags { regDistPref = toFlag distPref
, regCabalFilePath = maybeToFlag (cabalFilePath lbi)}
- hookedAction preUnreg unregHook postUnreg
+ hookedAction verbosity preUnreg unregHook postUnreg
(getBuildConfig hooks verbosity distPref)
hooks flags' args
-hookedAction :: (UserHooks -> Args -> flags -> IO HookedBuildInfo)
- -> (UserHooks -> PackageDescription -> LocalBuildInfo
- -> UserHooks -> flags -> IO ())
- -> (UserHooks -> Args -> flags -> PackageDescription
- -> LocalBuildInfo -> IO ())
- -> IO LocalBuildInfo
- -> UserHooks -> flags -> Args -> IO ()
-hookedAction pre_hook cmd_hook =
- hookedActionWithArgs pre_hook (\h _ pd lbi uh flags ->
- cmd_hook h pd lbi uh flags)
-
-hookedActionWithArgs :: (UserHooks -> Args -> flags -> IO HookedBuildInfo)
- -> (UserHooks -> Args -> PackageDescription -> LocalBuildInfo
- -> UserHooks -> flags -> IO ())