Repository navigation
Fix pretty-printer to preserve original numeric literals - #1674
Conversation
sjakobi
left a comment
There was a problem hiding this comment.
👍 for preserving hexadecimals!
Will this also work for dhall lint and dhall freeze?
| 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.
What's the motivation for including Doubles here?
There was a problem hiding this comment.
Same rationale: to preserve them the way the user wrote them
There was a problem hiding this comment.
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 Doubles 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.
@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