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

dhall-nix Use z-encoding for nix symbol names

Open Profpatsch opened this issue 3 years ago • 2 comments

When trying to encode a function like

\(Foo/Bar: Text) -> Foo/Bar

I get the nix code

Foo/Bar:
  Foo/Bar

which fails with the nix parsing error

error: syntax error, unexpected ':', expecting end of file

       at «string»:1:8:

            1| Foo/Bar:
             |        ^

… this is not good, because “namespaced” symbols like that are quite frequent in dhall code.

I would suggest using the Z-Encoding scheme that is also used by GHC to create nix symbols.

Profpatsch avatar Jun 18 '22 21:06 Profpatsch

You can escape identifiers using backticks, like this:

λ(`Foo/Bar` : Text) → `Foo/Bar`

Gabriella439 avatar Jun 18 '22 23:06 Gabriella439

Yeah, but the generated nix code is still not valid nix syntax, this generates

Foo/Bar:
  Foo/Bar

Profpatsch avatar Jun 19 '22 02:06 Profpatsch