dhall-haskell
dhall-haskell copied to clipboard
associative lists need some love
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.
Not sure if that helps, but you can also use backtick with this syntax:
{ `1` = "one" }
dhall-to-yaml produces:
'1': one
Closing this one since an solution to the problem has been provided. Please reopen if the answer is unsatisfying.