A boolean has the type
bool and can be either
false. Common operations:
&&: logical and
||: logical or
!: logical not.
==: structural equal, compares data structures deeply:
(1, 2) == (1, 2)is
true. Convenient, but use with caution
===: referential equal, compares shallowly.
(1, 2) === (1, 2)is
let myTuple = (1, 2); myTuple === myTupleis
!=: structural unequal
!==: referential unequal
false compile to JS
false since Bucklescript 3.0. Before that release you had to use
Js.Boolean.to_js_boolean but thankfully this is no longer the case!
#Tips & Tricks
Use structural equal tastefully. It's convenient, but might accidentally make you compare two deeply nested data structures and incur a big performance hit. It's also not always clear what counts as "equal". For example, is a piece of data
foo equal to a lazy
foo? Ideally, it'd have been pluggable. Future changes are coming to make this possible and reliable; if you're interested, check modular implicit.