Stdlib.Bool(3)

πŸ¦‹ NAME

Stdlib.Bool β€” bestie, the description is literally "no description" 😭 that's it, that's the whole entry, and honestly? iconic minimalism. It's part of the OCaml library (manual section 3) πŸ’…


πŸŽ€ Module

The module in question: Stdlib.Bool ✨


πŸ’– Documentation

🧚 Module Bool

So this whole thing is : (module Stdlib__Bool) β€” that's the exact line, no cap:

: (module Stdlib__Bool)

Okay so let's get into the actual booleans πŸ‘‘

🌸 Booleans

type t = bool =
  | false
  | true

This is the type of booleans β€” truth values, yes/no, the whole vibe check of logic 🫢

Now listen: the constructors false and true are included here so that they have paths, but heads up β€” they are not intended to be used in user-defined data types. So don't go building your own variant and sneaking them in there, that's not the move πŸ™ˆ

val not : bool -> bool

not b is the boolean negation of b β€” flips the vibe entirely, flip flopper behavior πŸ’€

val (&&) : bool -> bool -> bool

e0 && e1 is the lazy boolean conjunction of expressions e0 and e1. And ooh, the key part: if e0 evaluates to false, then e1 is not evaluated β€” short circuit, she's efficient, she's not doing extra work for nobody ✨

Also: right-associative operator at precedence level 3/11 β€” yes, 3/11, exactly that, write it down πŸŽ€

val (||) : bool -> bool -> bool

e0 || e1 is the lazy boolean disjunction of expressions e0 and e1. And if e0 evaluates to true, then e1 is not evaluated β€” again, why would she 😌

Also again: right-associative operator at precedence level 2/11 ⭐

val logand : bool -> bool -> bool

logand b1 b2 is true if and only if b1 and b2 are both true 🫢

val logor : bool -> bool -> bool

logor b1 b2 is true if and only if either b1 or b2 is true πŸ’œ

val logxor : bool -> bool -> bool

logxor b1 b2 is true if exactly one of b1 and b2 is true β€” exactly one, she does not share, it's giving exclusive πŸ’…

🌈 Predicates and comparisons

val equal : bool -> bool -> bool

equal b0 b1 is true if and only if b0 and b1 are both true or both false β€” matching energies only πŸŽ€

val compare : bool -> bool -> int

compare b0 b1 is a total order on boolean values. And the ranking is locked in: false is smaller than true πŸ‘‘

πŸ“ Converting

val to_int : bool -> int

to_int b is 0 if b is false and 1 if b is true πŸ”₯

val to_float : bool -> float

to_float b is 0. if b is false and 1. if b is true β€” yes those are floats with the little dot, don't come for me ⭐

val to_string : bool -> string

to_string b is "true" if b is true and "false" if b is false 🌸

val seeded_hash : int -> bool -> int

A seeded hash function for booleans, with the same output value as Hashtbl.seeded_hash. This function allows this module to be passed as argument to the functor Hashtbl.MakeSeeded 🧚

Since 5.1 ✨

val hash : bool -> int

An unseeded hash function for booleans, with the same output value as Hashtbl.hash. This function allows this module to be passed as argument to the functor Hashtbl.Make πŸ¦‹

Since 5.1 ✨


Literally the entire boolean alphabet in one module and she ate every single time πŸ‘‘ no notes.

Made with love by OCamldoc, dated 2026-06-22, and this page is Stdlib.Bool(3) β€” mwah, bye bestie πŸ’‹πŸ’–

πŸ“¦ where this page comes from