This is a newbie question, but I couldn't find a quick answer anywhere.
Does Facebook's Reason language support nullable types? If so, in what form?
As mentioned by Neil, Reason itself has the option
type. However, if you have to deal with possible null
or undefined
values from JavaScript, there's also Js.Nullable.t
. It can be converted to an option
when needed using Js.toOption
.
There are also more specific types that only handle either null
or undefined
but the other, Js.Null.t
and Js.Undefined.t
respectively, but you'll rarely if ever need these. I mention them just for the sake of completeness.
There is no null
. The closest we have is option variant. See various documentation below:
https://reasonml.github.io/docs/en/newcomer-examples.html#using-the-option-type https://reasonml.github.io/docs/en/variant.html#option
Let me know if there is a specific kind of situation that you would have a null
in JavaScript that you would like to see the Reason equivalent.