Hi, I’m looking for help constructing a function. I’m trying to build a wrapper on top of the ReactNative.Style bindings (Getting Started | ReScript React Native) that makes them a bit more concise to use by passing in Varients and using them to construct the style object.
A rough sketch of what I’m looking for is below:
type output = {
a: option<int>,
b: option<int>,
c: option<int>,
}
@obj external foo: (~a: int=?, ~b: int=?, ~c: int=?, unit) => output = ""
type builder = WithA(int) | WithB(int) | WithC(int)
type build = array<builder> => output
/* Desired Usage:
let x = build([WithA(1), WithC(4)]) // x = {a:1, c:4}
let y = build([WithB(2), WithC(4)]) // x = {b:2, c:4}
*/
I can’t figure out how to write the build function, any ideas?