dhall-haskell icon indicating copy to clipboard operation
dhall-haskell copied to clipboard

associative lists need some love

Open geniusisme opened this issue 3 years ago • 1 comments

This is probaly a mix between core dhall and dhall-to-yaml

Consider the following:

〉'toMap { one = 1, two = 2}' | dhall-to-yaml
one: 1
two: 2

Good so far. Now let's try this:

〉'toMap { 1 = one, 2 = two}' | dhall-to-yaml


Error: Invalid input

(input):1:9:
  |
1 | toMap { 1 = one, 2 = two}
  |         ^
unexpected '1'
expecting ',', =, any label, keyword, whitespace, or }

But why? Let's dig deeper:

〉'[ { mapKey = 1, mapValue = "one"} ]' | dhall-to-yaml
- mapKey: 1
  mapValue: one

Not the result we were looking for. Maybe this?

〉'[ { mapKey = "1", mapValue = "one"} ]' | dhall-to-yaml
'1': one

Ok, we made this work. But still, this is not ideal. Preferably, there is a way to getting just 1: one. Also, it would be nice to work with Natrurals in the dhall code. And, of course, having toMap to be more generic would be nice, too.

geniusisme avatar Jul 06 '22 08:07 geniusisme

Not sure if that helps, but you can also use backtick with this syntax:

{ `1` = "one" }

dhall-to-yaml produces:

'1': one

TristanCacqueray avatar Jul 06 '22 11:07 TristanCacqueray

Closing this one since an solution to the problem has been provided. Please reopen if the answer is unsatisfying.

mmhat avatar Feb 01 '23 15:02 mmhat