-
Notifications
You must be signed in to change notification settings - Fork 697
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
Annotationless exact-printer #9385
base: master
Are you sure you want to change the base?
Conversation
After thinking about it for a while, I do not think helper functions for updating the data structure make sense here. Every use-case has a completely different flow:
On top of this the data structure itself is rather simple, so if someone needs to go from |
Note that while this is written using All of my work on this has stalled back in November. The first step, which is the exact-printer of the format, works and alone qualifies for a PR. Some minor adjustments could be applied, such as converting to The second step would be decoupling every single field format, which turned out to be far more complex. Not only is the Field Syntax poorly documented, currently parsing couples format with implementation: for example Consider this draft to be on an indefinite hiatus until feedback arrives. |
@BurningWitness I just want to thank you for the update and commend you for having a go at this. I had been working on a different approach (that I have so far kept to myself). If I ever put something out, I will ping you. |
Potentially closes #7544.
Skeleton parser
Currently able to parse every single manifest stored on Hackage and to render it back into the exact same representation.
Implementation choices:
All whitespace is treated as spaces;
Data representation cannot be delayed in either dimension:
parsec
not supporting returning the remainder of the input (parsec
is the only available parser, per Meta: Exact-printer Mega-issue #7544 (comment)).Curly bracket syntax is treated more leniently than in the lexer (see Meta: Exact-printer Mega-issue #7544 (comment) for examples, all of these are accepted here);
Trailing whitespace and newlines are preserved everywhere in the format due to curly bracket positions depending on them.
Fields are allowed to have names with spaces in them, due to the fact that certain extremely old packages allowed that (see e.g.Patches are the current fix to this specific issue, field representation has been narrowed down to exclude spaces.build depends
at the very end of smartworld-0.0.0.5).Further extensions
Layout
encoding with automatic consistent offset incrementsLayout -> [Field Position]
Discarded ideas
Layout
manipulation (e.g. Meta: Exact-printer Mega-issue #7544 (comment))