Records with truly optional fields


#21

I think you might have mixed Neuron and its type. From the error it looks like you gave Neuron the type { Type = ..., default = ... }. But Neuron should have the value { Type = ..., default = ... } and the type { Type : Type, default : ... } (note the difference between = and :.


#22

FWIW, your solution is virtually equivalent to the one suggested in dhall-haskell issue #1521 and the problem is very similar as well.


#23

It’s probably worth documenting somewhere then


#24

@Nadrieril: I can try to write this up as a quick How-to guide or addition to the FAQ for the Dhall wiki


#25

Keep in mind that by naively using // you will run into issues with nested merges, should you choose to later implement them.

It’ll be fine if all of your fields stay in the top level though.


#26

in retrospective I wasn’t very clear when I wrote

so that you can merge the defaults in the application and allow the user to truly omit the optional fields

The only “downside” I see is that you must check the configuration with neuron and not with dhall itself but that’s probably a good thing since it might involve more than typechecking :smile: