Repr(3)

πŸŽ€ NAME πŸŽ€

Okay so bestie, welcome to Repr β€” manual section 3, OCaml library β€” and it is literally all about functions defined on the low-level representations of values. Periodt. ✨

πŸ¦‹ Module πŸ¦‹

The module is named Repr. That's the whole module section, bestie β€” short and iconic. 🫢

✨ Documentation ✨

Here's the signature vibe:

Module Repr
 : sig end

It's giving low-level representation energy: Functions defined on the low-level representations of values.

Since 5.4 🌸

πŸ’… Physical comparison πŸ’…

val phys_equal : 'a -> 'a -> bool

phys_equal e1 e2 tests for physical equality of e1 and e2. On mutable types such as references, arrays, byte sequences, records with mutable fields and objects with mutable instance variables, phys_equal e1 e2 is true if and only if physical modification of e1 also affects e2. On non-mutable types, the behavior of phys_equal is implementation-dependent; however, it is guaranteed that phys_equal e1 e2 implies compare e1 e2 = 0. No cap. πŸ”₯

🌈 Polymorphic comparison 🌈

val equal : 'a -> 'a -> bool

equal e1 e2 tests for structural equality of e1 and e2. Mutable structures (e.g. references and arrays) are equal if and only if their current contents are structurally equal, even if the two mutable objects are not the same physical object.

⚠️ Heads up: equality between functional values raises Invalid_argument. Equality between cyclic data structures may not terminate. πŸ’€

val compare : 'a -> 'a -> int

compare x y returns 0 if x is equal to y, a negative integer if x is less than y, and a positive integer if x is greater than y. The ordering implemented by compare is compatible with the comparison predicates (=), (<) and (>), as well as the equal function defined above, with one difference on the treatment of the float value nan. Namely, the comparison predicates treat nan as different from any other float value, including itself; while compare treats nan as equal to itself and less than any other float value. This treatment of nan highkey ensures that compare defines a total ordering relation. πŸ‘‘

compare applied to functional values may raise Invalid_argument. compare applied to cyclic structures may not terminate.

The compare function can be used as the comparison function required by the Set.Make and Map.Make functors, as well as the List.sort and Array.sort functions. Versatile queen behavior. ✨

val min : 'a -> 'a -> 'a

Return the smaller of the two arguments. The result is unspecified if one of the arguments contains the float value nan.

val max : 'a -> 'a -> 'a

Return the greater of the two arguments. The result is unspecified if one of the arguments contains the float value nan.

🫢 Tiny warning for both: if one of the arguments contains the float value nan, the result is unspecified. That's not me being shady, that's literally the docs. πŸ’…

And that's the whole page, bestie! πŸ’– Brought to you by OCamldoc, dated 2026-06-22, sitting pretty in Repr(3). Bye! πŸŽ€

πŸ“¦ where this page comes from