dhall-lang / dhall-haskell

Maintainable configuration files
https://dhall-lang.org/
BSD 3-Clause "New" or "Revised" License
908 stars 211 forks source link

to-directory-tree with Empty Map causes an error #2598

Open hllizi opened 6 days ago

hllizi commented 6 days ago

Hi everyone.

I've been making increased use of to-directory-tree recently and found that, counter-intuitively, it refuses to turn an empty Map into an empty directory:

dhall to-directory-tree <<< "[] : List {mapKey : Text, mapValue : Text}" --output result

results in:

You tried to translate the following expression to a directory tree:

↳ [] : List { mapKey : Text, mapValue : Text }

... which is not an expression that can be translated to a directory tree.

So whenever I want to generate a directory from a possibly empty Map, I have to turn it into an Optional-valued Map and enclose a dummy object with value None Text, which is rather inconvenient.

This seem like a bug to me. Is there a good reason for this behaviour?