I'm trying to define type like:
type aaa = NULL | {a: int; b: int};;
But the compiler does not allow to do it. I'm not sure of the reason why we can't mix record type with anything else.
I need to match a value if it is the record type or null record and I'm tired of creating dummy record like {a = -999; b = -999}.
is there a better way ?
The "record" part of the definition has to be done in a separate type. Then you can wrap that in an "option" type if you want to express "None" or "Some value".
type aaa = {a: int; b: int}
type bbb = aaa option
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With