Dhall-haskell: trailing commas

Created on 1 Mar 2017  Â·  4Comments  Â·  Source: dhall-lang/dhall-haskell

If a format should be human-editable, trailing commas in lists & attrsets should be valid.
Right now it aborts with a confusing/unfitting error message:

→ echo "[1,2,3,]" | dhall
(stdin):1:1: error: expected: "\8704",
    "\955", "\\", "forall", "if",
    "let", "merge"
[1,2,3,] 
^        
→ echo "{foo=2,bar=4,}" | dhall
(stdin):1:1: error: expected: "[",
    "\8704", "\955", "\\", "forall",
    "if", "let", "merge"
{foo=2,bar=4,} 
^       

Most helpful comment

I fixed the confusing error message with baa08c649872a058b75c71b89bc6e43c231e94b0, so you should now get these errors:

$ echo "[1,2,3,]" | dist/build/Dhall/dhall
(stdin):1:8: error: expected: "''",
    "(", "+", "-", "[", "\8704",
    "\955", "\\", "forall", "if",
    "let", "merge", built-in value,
    double, import, integer, label,
    list literal, natural,
    record literal, record type,
    string, union literal,
    union type
[1,2,3,]
       ^
$ echo "{foo=2,bar=4,}" | dist/build/Dhall/dhall
(stdin):1:14: error: expected: label
{foo=2,bar=4,}
             ^

I'll add support for trailing commas in a separate commit

All 4 comments

I fixed the confusing error message with baa08c649872a058b75c71b89bc6e43c231e94b0, so you should now get these errors:

$ echo "[1,2,3,]" | dist/build/Dhall/dhall
(stdin):1:8: error: expected: "''",
    "(", "+", "-", "[", "\8704",
    "\955", "\\", "forall", "if",
    "let", "merge", built-in value,
    double, import, integer, label,
    list literal, natural,
    record literal, record type,
    string, union literal,
    union type
[1,2,3,]
       ^
$ echo "{foo=2,bar=4,}" | dist/build/Dhall/dhall
(stdin):1:14: error: expected: label
{foo=2,bar=4,}
             ^

I'll add support for trailing commas in a separate commit

I would like to reopen this issue because I'm considering removing support for trailing commas and bars now that I'm standardizing Dhall's grammar

The two main reasons that I suggest removing them are:

  • They complicate the grammar, especially when combined with support for union literals that let you assign a value in the interior of the literal, like this:

    < Foo : Integer, Bar = True, Baz : Double >
    
  • The new dhall-format utility does not make use of trailing commas or bars

Would that be alright or do you still feel that Dhall should support trailing commas and bars?

Yeah, sure.

Alright, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DrSensor picture DrSensor  Â·  6Comments

mgajda picture mgajda  Â·  3Comments

quasicomputational picture quasicomputational  Â·  4Comments

aljce picture aljce  Â·  4Comments

jvanbruegge picture jvanbruegge  Â·  4Comments