It’s not pretty, but the boilerplate can be written in rescript, via the object spread operator. Working off of the initial example:
type a = {
t ?: string,
l ?: int,
p ?: array<int>
}
type b = {
t ?: string,
l ?: string,
p ?: string
}
let updateT : (b, a) => b = (b, a) => {
switch a.t {
| Some(r) => {...b, t: r}
| None => b
}
}
let updateL : (b, a) => b = (b, a) => {
switch a.l {
| Some(r) => {...b, l: "int"}
| None => b
}
}
let updateP : (b, a) => b = (b, a) => {
switch a.p {
| Some(r) => {...b, p: "array"}
| None => b
}
}
let mapper: (a) => b = (a) =>
{}
->updateT(a)
->updateL(a)
->updateP(a)