Nadrieril / dhall-rust

Maintainable configuration files, for Rust users
Other
303 stars 27 forks source link

Make SimpleValue public and add from_simple_value() #183

Closed io12 closed 3 years ago

io12 commented 3 years ago

Fixes https://github.com/Nadrieril/dhall-rust/issues/177.

Nadrieril commented 3 years ago

Thanks for having a go at this! This looks good. My worry is that a SimpleValue can't be turned into a Dhall value because it lacks type information. Typically, we'd need to carry a type for the None case. This might be surprising? An option is to keep SimpleValue like this, but ask for a type in order to convert it to dhall. I think that's what I do in my serialization branch. @rushsteve1 would the PR as proposed work for you?

rushsteve1 commented 3 years ago

This should work, especially since @io12 is working on the same project as me.

That said I don't fully understand what you mean when you say "SimpleValue can't be turned into a Dhall type" and the problem with None cases.

Nadrieril commented 3 years ago

This should work, especially since @io12 is working on the same project as me.

Ok great!

That said I don't fully understand what you mean when you say "SimpleValue can't be turned into a Dhall type" and the problem with None cases.

I'm saying we can't write e.g. a function to_dhall_string(x: SimpleValue) -> String that would print a SimpleValue into dhall text. That's because given SimpleValue::Optional(None), you can't know whether it's a None Natural, None Bool, or something else. Same applies to unions: we'd need the whole union type, not just the variant name.

But anyways, I'm happy to merge this as is. We can always add more things later if we need them

Nadrieril commented 3 years ago

Published in 0.7.3!