The way I see it, there are two options. Option one is a function with optional named arguments
type example = {
stuff: string,
num: int
}
let makeExample = (~stuff: string="", ~num: int=0, ()) => {
stuff,
num
}
let myExample = makeExample(~stuff="hi", ())
or option two, spreading the default values
let default = {
stuff: "",
num: 0
}
let myExample2 = {...default, stuff: "hi"}
Is one of those better? Is there something other than those two I missed. The way I see it, the first one is slightly better because it allows me to hide the definition of example, thus making the function the only way to create an example, with less room for error.