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 b is the boolean negation of b. Flip it and reverse it ✨
  • val (&&) : bool -> bool -> bool β€” e0 && e1 is the lazy boolean conjunction of expressions e0 and e1. If e0 evaluates to false, e1 is not evaluated. Right-associative operator at precedence level 3/11. Lazy queen behavior, we love to see it πŸ’€
  • val (||) : bool -> bool -> bool β€” e0 || e1 is the lazy boolean disjunction of expressions e0 and e1. If e0 evaluates to true, e1 is not evaluated. Right-associative operator at precedence level 2/11. Again: lazy, but make it fashion πŸ”₯
  • val logand : bool -> bool -> bool β€” logand b1 b2 is true if and only if b1 and b2 are both true. Both. Not one. Both. Okay?? 😭
  • val logor : bool -> bool -> bool β€” logor b1 b2 is true if and only if either b1 or b2 is true. At least one bestie has to show up πŸ’–
  • val logxor : bool -> bool -> bool β€” logxor b1 b2 is true if exactly one of b1 and b2 is true. Exactly one. It's giving exclusive party πŸŽ€

πŸ’… 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. Twin vibes only πŸ‘―β€β™€οΈ
  • val compare : bool -> bool -> int β€” compare b0 b1 is a total order on boolean values. false is smaller than true. So yes, false is lowkey the underdog, but it comes first in the order πŸ’€

πŸ“ Converting πŸ“

  • val to_int : bool -> int β€” to_int b is 0 if b is false and 1 if b is true. Glow-up from bool to int, slay ✨
  • val to_float : bool -> float β€” to_float b is 0. if b is false and 1. if b is true. Same energy, but floaty 🌈
  • val to_string : bool -> string β€” to_string b is "true" if b is true and "false" if b is false. Literally putting it into words, iykyk πŸ¦‹
  • 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 β€” new-ish, iconic, no notes πŸ‘‘
  • 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 β€” same era, same slay πŸ’–

Bestie reminder: boolean is literally just false or true. 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