-
Notifications
You must be signed in to change notification settings - Fork 723
Defer merging of common stanzas #11277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Defer merging of common stanzas #11277
Conversation
Currently we have achieve the following: - Stop merging, the merging function "endo" is id - CondTree are completly retained in bigger types such as libarry and executable We will need to do the following: - Allow merging in the accessor We broke: - A bunch of Read and Ord instances
This reverts commit 21636db.
We isolated the type TestSuiteStanza and the logic to infer test type
We isolated the BenchmarkStanza type and the logic to infer benchmark type.
We now use the WithImports type to tag imports
we fixed GenericPackageDescription's constructor
492ad9e to
d8a1fcc
Compare
This guarantees that unmerged internal representation is correct
|
Here are the benchmark results by timing the
|
|
I'm not sure why validate is used for benchmarking parser changes. Validate is likely dominated by completely unrelated factors (e. g. solver). Would it be possible to just download a bunch of cabal files from Hackage (see clc-stackage for a curated set of packages) and run only the parser on them? |
This is the second part of the exact print parser. We changed the parser so that it doesn't merge the common stanzas during the parsing stage.
Depends on #11285 to update the test suite (after which the diff will be significantly smaller).
Background
Common stanzas are merged into their corresponding section during the parsing stage. This merging process doesn't retain the definition of the imports (i.e.
common <name> ...) nor where they are used (import: <name>). To achieve exact printing and to be able to programmatically update the import list, we need to retain this information.This PR is to remedy exactly that by deferring the merging process.
Implementation
We insert a new field
gpdCommonStanza :: Map ImportName (CondTree ConfVar [Dependency] BuildInfo)in theGenericPackageDescriptiondata type to track all the defined common stanzas. The merging is run only when the new accessors are called on aGenericPackageDescription.We also added a bidirectional
PatternSynonymthat uses the old record syntax. The impact on existing code should be very low. Comparing against my PR to update the test suite is promising leana8959/cabal@accessor-tests...leana8959:cabal:no-flatten-package-description.Please let me know your thoughts :)
Checklist below:
This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significantin the changelog file.