-
Notifications
You must be signed in to change notification settings - Fork 217
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
Pretty-print RecordField comments #2021
Conversation
@sjakobi: Thank you for doing this! 🙂 Would you like me to begin reviewing or do you want to wait until the PR is out of draft status? |
The actual code still needs a lot of work and is probably not worth reviewing yet. If you have feedback on the test output though, I can try to incorporate that. |
Some normalization logic seems to need updating:
|
I've been staring it this part of dhall-haskell/dhall/src/Dhall/Normalize.hs Lines 782 to 785 in f77549a
The issue is that dhall-haskell/dhall/src/Dhall/Normalize.hs Line 652 in f77549a
How about removing this |
That would probably make pattern matching on dhall-haskell/dhall/src/Dhall/Normalize.hs Lines 660 to 685 in f77549a
|
@sjakobi: Not necessarily. You could still do the App (shallowDenote -> App (shallowDenote -> … … possibly with a short-hand synonym for shallowDenote to save characters. |
-- Dhall.Core.isNormalized ignores 'Note's and other annotations. | ||
-- So we do the same when checking the result of 'normalize'. | ||
return $ isNormalized === (nf == denotedExpression) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with this simple test fix in order to keep the focus on the pretty-printer changes.
4dc37ac
to
f3a24ce
Compare
BTW, note that I'll be mostly AFK during the weekend. I expect to be able to address any review feedback on Monday. Feel free to take over the PR if you would like to merge it sooner. |
The output is worth another look at this stage. I'm pretty happy with it. The code still needs a bit of cleanup though. |
@Gabriel439 Could you review? |
I guess preserving and pretty-printing comment for Union type is out of scope, but will those changes also facilitate such addition? |
Definitely. The pretty-printer will be well-prepared after this PR. What remains to be done is updating the parser and updating the code in response to the necessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern with the implementation is that it confuses me a little the difference between render
and pretty
in some functions (prettyComment
and renderComment
for example) but I don't have better names for those.
I believe that the output of the formatter is OK as I'm not too opinionated about the result. Making dhall format
not delete comment it's the main goal from my POV
3e17684
to
8108411
Compare
Thanks for the review @german1608! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing this! 🙂
Also: * Use tasty-silver for format tests * Ignore annotations in isNormalizedIsConsistentWithNormalize
8108411
to
948988b
Compare
Context: #145