Visitar URL original
Fix pretty-printer to preserve original numeric literals by Gabriella439 · Pull Request #1674 · dhall-lang/dhall-haskell · GitHub
Skip to content

Fix pretty-printer to preserve original numeric literals - #1674

Merged
Gabriella439 merged 1 commit into
masterfrom
gabriel/preserveSource
Feb 15, 2020
Merged

Gabriella439 merged 1 commit into
masterfrom
gabriel/preserveSource

Conversation

@Gabriella439

Copy link
Copy Markdown
Collaborator

Fixes #1671

@sjakobi sjakobi left a comment

Copy link
Copy Markdown
Collaborator

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?

prettyEnvironmentVariable t = Pretty.pretty (escapeEnvironmentVariable t)

preserveSource :: Expr Src a -> Maybe (Doc Ann)
preserveSource (Note Src{..} (DoubleLit {})) = Just (Pretty.pretty srcText)

Copy link
Copy Markdown
Collaborator

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 Doubles here?

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Collaborator

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 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.

Copy link
Copy Markdown
Collaborator Author

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.

@Gabriella439

Copy link
Copy Markdown
Collaborator Author

@sjakobi: Yes, this will work for dhall lint and dhall freeze

@Gabriella439
Gabriella439 merged commit e320661 into master Feb 15, 2020
@Gabriella439
Gabriella439 deleted the gabriel/preserveSource branch February 15, 2020 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dhall format converts hexadecimal to decimal

2 participants