-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addressing excessive usage of Optional
values.
#2434
Comments
Optional
values.Optional
values.
$ yaml-to-dhall '{ x : Optional Natural, y : Optional Natural }' <<< 'x: 1' { x = Some 1, y = None Natural } … and you can pipe that through Also, |
I meant avoiding optionals all-together by using a different set of defaults. This would look something like this: yaml-to-dhall '{ Type: {x: Natural, y: Natural}, default: {x: 1, y: 1}}' <<< 'x: 2' result: { x = 2, y = 1 } I presume let schema = '../schema'
schema::MySchema {
x = 2
} Similarly dhall-to-yaml would omit defaults, i.e. dhall-to-yaml of the above with a specified schema: would emit x: 2 In the above, |
Oh, I see what you mean now. Yeah, I would accept a PR to implement something like that, but I likely would not have time to do it myself |
One of the complaints I receive when introducing Dhall to other developers is the overuse of
Optional
fields.I believe these could be more easily avoided, especially during migrations from
yaml
orjson
if the tools provided some more options. For example:yaml-to-dhall
(and from JSON) could receive a Schema (a pair of Type and defaults) and fill-in the missing fields with the defaultsdhall-to-yaml
(and JSON) could receive --remove-defaults which would in turn strip the default values from the outputThe text was updated successfully, but these errors were encountered: