-
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
dhall-json: Throw error when union value is incompatible with Inline nesting #1226
Conversation
dhall-json/src/Dhall/JSON.hs
Outdated
\ \n\ | ||
\The following Dhall expression could not be translated to JSON: \n\ | ||
\ \n\ | ||
\↳ " <> Core.pretty record <> " \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 pretty-printing here (and probably in the other errors too) needs improvement. Currently it looks like this:
The following Dhall expression could not be translated to JSON:
↳ { contents = < Left : { foo : Natural } | Middle : Natural | Right : { bar : Bool } >.Middle 0, field = "name", nesting = < Inline | Nested : Text >.Inline }
... because
↳ 0
... is not a record.
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.
You can use Dhall.Util.insert
, which is the same thing type-checking error messages use:
dhall-haskell/dhall/src/Dhall/Util.hs
Lines 76 to 79 in 4c1736b
-- | Function to insert an aligned pretty expression | |
insert :: Pretty a => a -> Doc Ann | |
insert expression = | |
"↳ " <> Pretty.align (snipDoc (Pretty.pretty expression)) |
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.
Thanks, I'm using Dhall.Util.insert
now. I had to expose Dhall.Util
from dhall
though. I hope that's ok.
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.
Yeah, that's fine
dhall-json/src/Dhall/JSON.hs
Outdated
\ \n\ | ||
\The following Dhall expression could not be translated to JSON: \n\ | ||
\ \n\ | ||
\↳ " <> Core.pretty record <> " \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.
You can use Dhall.Util.insert
, which is the same thing type-checking error messages use:
dhall-haskell/dhall/src/Dhall/Util.hs
Lines 76 to 79 in 4c1736b
-- | Function to insert an aligned pretty expression | |
insert :: Pretty a => a -> Doc Ann | |
insert expression = | |
"↳ " <> Pretty.align (snipDoc (Pretty.pretty expression)) |
9d2b3cb
to
07964d2
Compare
No description provided.