-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fix pretty-printer to preserve original numeric literals #1674
Conversation
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.
👍 for preserving hexadecimals!
Will this also work for dhall lint
and dhall freeze
?
@@ -473,6 +473,12 @@ prettyVar (V x n) = label (Pretty.unAnnotate (prettyLabel x <> "@" <> prettyInt | |||
prettyEnvironmentVariable :: Text -> Doc ann | |||
prettyEnvironmentVariable t = Pretty.pretty (escapeEnvironmentVariable t) | |||
|
|||
preserveSource :: Expr Src a -> Maybe (Doc Ann) | |||
preserveSource (Note Src{..} (DoubleLit {})) = Just (Pretty.pretty srcText) |
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.
What's the motivation for including Double
s here?
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.
Same rationale: to preserve them the way the user wrote them
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.
Well in the case of Integer
and Natural
I understand that we want to preserve an original hexadecimal formatting for readability. In the case of Double
s it's not so obvious to me why we should prefer an original 001.20
over a "standard" 1.2
. Although we may assume that the user may have their reasons to write 001.20
in the first place.
I guess I'm just wondering where we draw the line between expressions where we apply the standard formatting, and expressions where we preserve the original formatting. For example, we could also try to preserve the formatting of Text
literals.
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.
@sjakobi: People have requested that we do a better job of preserving user formatting in general (see the requests for Vonderhaar-style pretty-printing), but in this specific case I preserved the formatting of Double
literals because I felt that it was in the same spirit as preserving formatting for hexadecimal literals.
@sjakobi: Yes, this will work for |
Fixes #1671