Bool(3)
πΈ NAME πΈ
Bool β Boolean values. That's it, that's the vibe, bestie π
π¦ Module π¦
Okay so this is the OCaml library manual, and the module is literally:
Module Bool
: sig end
β¨ Documentation β¨
Here's the whole little icon:
Module Bool
: sig end
Boolean values. Periodt. π
Since 4.08 β yes queen, it's been here since 4.08 π
π Booleans π
The type is giving main-character truth values:
type t = bool =
| false
| true
The type of booleans (truth values). π
The constructors false and true are included here so that they have paths, but they are not intended to be used in user-defined data types. No cap, that's the rule π«Ά
val not : bool -> boolβnot bis the boolean negation ofb. Flip it and reverse it β¨val (&&) : bool -> bool -> boolβe0 && e1is the lazy boolean conjunction of expressionse0ande1. Ife0evaluates tofalse,e1is not evaluated. Right-associative operator at precedence level3/11. Lazy queen behavior, we love to see it πval (||) : bool -> bool -> boolβe0 || e1is the lazy boolean disjunction of expressionse0ande1. Ife0evaluates totrue,e1is not evaluated. Right-associative operator at precedence level2/11. Again: lazy, but make it fashion π₯val logand : bool -> bool -> boolβlogand b1 b2istrueif and only ifb1andb2are bothtrue. Both. Not one. Both. Okay?? πval logor : bool -> bool -> boolβlogor b1 b2istrueif and only if eitherb1orb2istrue. At least one bestie has to show up πval logxor : bool -> bool -> boolβlogxor b1 b2istrueif exactly one ofb1andb2istrue. Exactly one. It's giving exclusive party π
π Predicates and comparisons π
val equal : bool -> bool -> boolβequal b0 b1istrueif and only ifb0andb1are bothtrueor bothfalse. Twin vibes only π―ββοΈval compare : bool -> bool -> intβcompare b0 b1is a total order on boolean values.falseis smaller thantrue. So yes,falseis lowkey the underdog, but it comes first in the order π
π Converting π
val to_int : bool -> intβto_int bis0ifbisfalseand1ifbistrue. Glow-up from bool to int, slay β¨val to_float : bool -> floatβto_float bis0.ifbisfalseand1.ifbistrue. Same energy, but floaty πval to_string : bool -> stringβto_string bis"true"ifbistrueand"false"ifbisfalse. Literally putting it into words, iykyk π¦val seeded_hash : int -> bool -> intβ A seeded hash function for booleans, with the same output value asHashtbl.seeded_hash. This function allows this module to be passed as argument to the functorHashtbl.MakeSeeded.Since 5.1β new-ish, iconic, no notes πval hash : bool -> intβ An unseeded hash function for booleans, with the same output value asHashtbl.hash. This function allows this module to be passed as argument to the functorHashtbl.Make.Since 5.1β same era, same slay π
Bestie reminder: boolean is literally justfalseortrue. That's the whole personality. But now you know every little function around it, so go be the main character of your OCaml file π§
Mwah π β this iconic page was served up by OCamldoc on 2026-06-22, and yes it's literally Bool(3), no cap. πβ¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms