s-zeng / dhall-python

Up-to-date and maintained python bindings for dhall, a functional configuration language
https://pypi.org/project/dhall/
Apache License 2.0
44 stars 6 forks source link

How to distinguish between integers and natural numbers? #34

Open jchia opened 3 years ago

jchia commented 3 years ago

Is there a way to distinguish between integers and natural numbers when dumping? E.g. if I dump 4, it shows up as '4' instead of '+4' and that does not work if a reader using the Haskell binding expects an integer ('+4') instead of a natural number ('4').

Furthermore, if I dump [4, -4], I'll get '[4, -4]', which I think is not valid Dhall because 4 is a natural number but -4 is an integer and elements of a list needs to be the same type.

$ echo '[+4, -4]' | dhall
[ +4, -4 ]
$ echo '[4, -4]' | dhall

Use "dhall --explain" for detailed errors

Error: List elements should all have the same type

- Natural
+ Integer

1│     -4

(input):1:5

This is probably related to #1.

s-zeng commented 3 years ago

I'm working on something to fix this and #1, though I'm a bit busy for the next while. Expect something from me maybe around October, unless someone needs this urgently