-
Notifications
You must be signed in to change notification settings - Fork 711
RFC: new intermediate cabal file representation. #3614
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
Comments
Would be nice to have something like that for config files as well. |
@23Skidoo, isn't config files flat: i.e. no sections? We could experiment on them first, as they are simpler. |
From IRC discussion: starting with Also: @dcoutts' experiment: http://code.haskell.org/~duncan/cabal-ast-experiment/ |
@dcoutts also proposed to change |
@phadej No, they have sections: |
@23Skidoo: yes, but sections are predefined and used to group fields. i.e. the file could be flat. |
@phadej so when I thought about it some time ago I concluded that there were only a few kinds of fields. Lets see if I can remember what they are:
The point is, it may be possible to pre-split the list fields and then only keep pos info at that level, not within the AST of the field entries. |
@dcoutts makes sense. Compound expressions are still tricky. |
Also to remember: https://github.com/alanz/cabal-ast-play |
Here is a brain dump from me Based on my GHC / ghc-exactprint experiences I would suggest using an initial (from the parser) AST that has a clear mapping to the underlying cabal file, and generally keeps things in order. So resist putting all like things together, especially if they can be interleaved in the file. Then have an ann parameter, which can have location info initially, and delta info later to be pretty printed. If the initial AST gets processed for use, it makes sense to track in some clear way how each part is derived from the initial one, even if that is done via an annotation at that level too. So the annotations are never part of the main line of processing, only ever used for round-tripping (with possible modification the cabal file). |
I updated the description. Also to complement @dcoutts comment, current |
Uh oh!
There was an error while loading. Please reload this page.
Problem: Ultimately we want formatting-preserving programmagic refactorings of
.cabal
files.Current situation:
Field
structure is annotated with source position (parametrised overann
), butByteString
sField
could represent any cabal-file-like structure (e.g. nested sections)GenericPackageDescription
build-depends
) on the same level are merged.Solution:
CabalAst ann
) with source annotations, which represents valid (to some degree) cabal files.Field ann → GenericPackageDescription
toField ann → CabalAst ann → GenericPackageDescription
cabal gen-bounds
to work onCabalAst ann
This RFC doesn't propose how
CabalAst
would look like specifically, as some exprerimentation on implementation is needed.ghc-exactprint
.ping @alanz @hvr @dcoutts
The text was updated successfully, but these errors were encountered: