From the type definition of O.Option<A> = A|null|undefined, where A is regarded as Some<A>, and null | undefined as None, I thought that literal null values should behave the same as undefined literal values.
I've just written some examples from ts-belt's live editor.
nullish values
O.match
O.isNone
null
undefined
for example, the O.match is described as follows, where the null value could passed into someFn.
function _match(option, someFn, noneFn) {
if (option !== undefined) {
return someFn(Caml_option.valFromOption(option));
} else {
return noneFn(undefined);
}
}
and O.isNone seems generated from the gentype utility from the rescript-compiler.
I found that O.fromNullable for every null occurring situation, but it's very cumbersome, and so unintuitive because of O.Option's type mismatches with these behaviors.
From the type definition of
O.Option<A> = A|null|undefined
, whereA
is regarded asSome<A>
, andnull | undefined
asNone
, I thought that literal null values should behave the same as undefined literal values.null
undefined
for example, the O.match is described as follows, where the
null
value could passed into someFn.and O.isNone seems generated from the gentype utility from the rescript-compiler.
I found that O.fromNullable for every null occurring situation, but it's very cumbersome, and so unintuitive because of O.Option's type mismatches with these behaviors.