OCaml Basics
Expressions
Primitive Types
Integers
OCaml integers range from 262 to 262 − 1 on modern platforms. They are implemented with 64-bit machine words, which is the size of a register on 64-bit processor. But one of those bits is "stolen" by the OCaml implementation, leading to a 63-bit representation. That bit is used at run time to distinguish integers from pointers. For applications that need true 64-bit integers, there is an Int64 module in the standard library. And for applications that need arbitrary-precision integers, there is a separate Zarith library. But for most purposes, the built-in int type suffices and offers the best performance. (Clarkson 2025, 33)
Float
Bool
Char
String
More Operators
Assertions
If Expressions
Let Expressions
Scope
Type Annotations
References:
Clarkson, Michael Ryan. 2025. Ocaml Programming: Correct + Efficient + Beautiful. https://cs3110.github.io/textbook/.