I wrote two of these functions in my app; <||>
is my lazy version, e.g. Some(5) <||> lazy (Some (6+3))
, and <|>
for cases that can use a strict second argument. I decided I didn’t want to overload boolean ||
.
I also added <??>
for the “or default” variant of this logic, e.g. Some(5) <??> lazy (6+3)
), and <?!>
which takes a strict value. I chose this name because I’m teaching ReasonML to JS programmers, and it’s modelled on the JavaScript nullish coalescing operator (??
). Unfortunately, while I can define ??
, the associativity difference renders it fairly pointless in use.