-
Notifications
You must be signed in to change notification settings - Fork 211
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
Conversation
|
||
instance Show CompileError where | ||
show BareNone = | ||
Data.Text.unpack $ | ||
_ERROR <> ": A bare ❰None❱ is not valid \n\ |
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.
❰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\ |
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.
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\ |
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.
`None` is a function
\ \n\ | ||
\ \n\ | ||
\ ┌─────────────────────────────────┐ \n\ | ||
\ │ None Natural : Optional Natural │ This is a valid ❰Optional❱ value (an \n\ |
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.
`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❱. " |
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.
only translates the fully applied form (e.g. `None Natural`)
I have a few suggestions that make the error message a bit clearer. |
@Profpatsch: Since this is already merged, could you submit a pull request? |
Fixes #896