Skip to content
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

Add a better error message when decoding a bare None #895

Merged
merged 1 commit into from
Apr 19, 2019

Conversation

Gabriella439
Copy link
Collaborator

@Gabriella439 Gabriella439 commented Apr 18, 2019

Fixes #896

@Gabriella439 Gabriella439 merged commit 1f40b63 into master Apr 19, 2019
@Gabriella439 Gabriella439 deleted the gabriel/none_error branch April 19, 2019 16:30

instance Show CompileError where
show BareNone =
Data.Text.unpack $
_ERROR <> ": A bare ❰None❱ is not valid \n\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❰None❱ on its own is not valid

\ \n\
\Explanation: The conversion to JSON/YAML does not accept ❰None❱ in isolation as \n\
\a valid way to represent ❰null❱. In Dhall, ❰None❱ is a function whose input is \n\
\a type and whose output is an absent value of that type. \n\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “output is an absent value of that type” formulation is a bit confusing.

whose output is an `Optional` of that type

\For example: \n\
\ \n\
\ \n\
\ ┌─────────────────────────────────┐ This is a function whose result is an \n\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`None` is a function

\ \n\
\ \n\
\ ┌─────────────────────────────────┐ \n\
\ │ None Natural : Optional Natural │ This is a valid ❰Optional❱ value (an \n\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`None Natural` is a valid

\ └─────────────────────────────────┘ absent ❰Natural❱ number in this case) \n\
\ \n\
\ \n\
\The conversion to JSON/YAML only translates the latter form to ❰null❱. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only translates the fully applied form (e.g. `None Natural`)

@Profpatsch
Copy link
Member

I have a few suggestions that make the error message a bit clearer.

@Gabriella439
Copy link
Collaborator Author

@Profpatsch: Since this is already merged, could you submit a pull request?

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-to-json None value not supported for optionals.
2 participants