Some time later, I’m not super excited anymore about this solution. My nameof
operator, it always needs a type annotation like nameof((o: Domain.Firebase.order) => o.isProcessed)
and I don’t find it very ergonomic.
I’m wondering if ppx
would not be convenient to generate string constants of my fields instead.
%something
type foo = {
x: int,
y: string,
bar: array<string>
}
and generate
// Not sure about casing, but you get the idea
module FooKeys = {
let X = "x"
let Y = "y"
let BAR = "bar"
}
Would such a PPX thing be possible in ReScript? I would guess, AST wise it is not that hard to construct.