Module Tablecloth.Bool Source Functions for working with boolean (true or false) values.
Functions for working with boolean values.
Booleans in OCaml / Reason are represented by the true and false literals.
Whilst a bool isnt a variant, you will get warnings if you haven't exhaustively pattern match on them:
let bool = false
let string =
match bool with
| false -> "false"
(*
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
true
*) CreateSource val from_int : int -> bool option Convert an Int into a Bool .
Examples
Bool.from_int 0 = Some falseBool.from_int 1 = Some trueBool.from_int 8 = NoneBool.from_int (-3) = NoneSource val from_string : string -> bool option Convert a String into a Bool .
Examples
Bool.from_string "true" = Some trueBool.from_string "false" = Some falseBool.from_string "True" = NoneBool.from_string "False" = NoneBool.from_string "0" = NoneBool.from_string "1" = NoneBool.from_string "Not even close" = None Basic operationsSource val (&&) : bool -> bool -> boolThe lazy logical AND operator.
Returns true if both of its operands evaluate to true.
If the 'left' operand evaluates to false, the 'right' operand is not evaluated.
Examples
Bool.(true && true) = trueBool.(true && false) = falseBool.(false && true) = falseBool.(false && false) = falseSource val (||) : bool -> bool -> boolThe lazy logical OR operator.
Returns true if one of its operands evaluates to true.
If the 'left' operand evaluates to true, the 'right' operand is not evaluated.
Examples
Bool.(true || true) = trueBool.(true || false) = trueBool.(false || true) = trueBool.(false || false) = falseSource val xor : bool -> bool -> boolThe exclusive or operator.
Returns true if exactly one of its operands is true.
Examples
Bool.xor true true = falseBool.xor true false = trueBool.xor false true = trueBool.xor false false = falseNegate a bool.
Examples
Bool.not false = trueBool.not true = falseSource val and_ : bool -> bool -> boolThe logical conjunction AND operator.
Returns true if both of its operands are true. If the 'left' operand evaluates to false, the 'right' operand is not evaluated.
Examples
Bool.and_ true true == trueBool.and_ true false == falseBool.and_ false true == falseBool.and_ false false == false ConvertSource val to_string : bool -> stringConvert a bool to a String
Examples
Bool.to_string true = "true"Bool.to_string false = "false"Source val to_int : bool -> intConvert a bool to an Int .
Examples
Bool.to_int true = 1Bool.to_int false = 0 CompareSource val equal : bool -> bool -> boolTest for the equality of two bool values.
Examples
Bool.equal true true = trueBool.equal false false = trueBool.equal false true = falseSource val compare : bool -> bool -> intCompare two bool values.
Examples
Bool.compare true false = 1Bool.compare false true = -1Bool.compare true true = 0Bool.compare false false = 0