Dhall-haskell: Unhelpful type error message with yaml-to-dhall

Created on 6 Nov 2019  Â·  2Comments  Â·  Source: dhall-lang/dhall-haskell

$ yaml-to-dhall '{ foo : List Natural, bar : { baz : True } }' < example.yaml


Error: Invalid field type

I wonder why yaml-to-dhall doesn't show the source like dhall:

$ echo '{ foo : List Natural, bar : { baz : True } }' | dhall

Use "dhall --explain" for detailed errors

Error: Invalid field type

1│                             { baz : True } 

(stdin):1:29

In any case I think the short error message should include the field name.

bug error messages

All 2 comments

@sjakobi: The reason it doesn't preserve the source is because Dhall.JSONToDhall.resolveSchemaToExpr (incorrectly) normalizes the resolved type before passing it to the next stage:

https://github.com/dhall-lang/dhall-haskell/blob/e931451a2b2892fa373c9dfc94b31bcd764131be/dhall-json/src/Dhall/JSONToDhall.hs#L341

This is problematic for two reasons:

  • One reason is that source spans are lost upon normalization (as you just noticed)
  • The second reason is that it's not safe to normalize an expression before it has been type-checked

Looks like we simply forgot the type checking step hinted at by the haddock comment.

https://github.com/dhall-lang/dhall-haskell/blob/e931451a2b2892fa373c9dfc94b31bcd764131be/dhall-json/src/Dhall/JSONToDhall.hs#L333-L341

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Michael-Kateregga picture Michael-Kateregga  Â·  26Comments

EggBaconAndSpam picture EggBaconAndSpam  Â·  21Comments

thebritican picture thebritican  Â·  17Comments

justinwoo picture justinwoo  Â·  19Comments

quasicomputational picture quasicomputational  Â·  19Comments