Stdlib.Option(3) OCaml library Stdlib.Option(3)

# [NAME](#NAME)

Stdlib.Option - no description

# [Module](#Module)

Module Stdlib.Option

# [Documentation](#Documentation)

Module **Option**  
: **(module Stdlib\_\_Option)**

## [Options](#Options)

*type* **'a** *t* = **'a option** =  
| None  
| Some **of** **'a**

The type for option values. Either **None** or a value **Some v** .

*val none* : **'a option**

**none** is **None** .

*val some* : **'a -&gt; 'a option**

**some v** is **Some v** .

*val value* : **'a option -&gt; default:'a -&gt; 'a**

**value o ~default** is **v** if **o** is **Some v** and **default** otherwise.

*val get* : **'a option -&gt; 'a**

**get o** is **v** if **o** is **Some v** and raise otherwise.

**Raises Invalid\_argument** if **o** is **None** .

*val bind* : **'a option -&gt; ('a -&gt; 'b option) -&gt; 'b option**

**bind o f** is **f v** if **o** is **Some v** and **None** if **o** is **None** .

*val join* : **'a option option -&gt; 'a option**

**join oo** is **Some v** if **oo** is **Some (Some v)** and **None** otherwise.

*val map* : **('a -&gt; 'b) -&gt; 'a option -&gt; 'b option**

**map f o** is **None** if **o** is **None** and **Some (f v)** is **o** is **Some v** .

*val fold* : **none:'a -&gt; some:('b -&gt; 'a) -&gt; 'b option -&gt; 'a**

**fold ~none ~some o** is **none** if **o** is **None** and **some v** if **o** is **Some v** .

*val iter* : **('a -&gt; unit) -&gt; 'a option -&gt; unit**

**iter f o** is **f v** if **o** is **Some v** and **()** otherwise.

## [Predicates and comparisons](#Predicates_and_comparisons)

*val is\_none* : **'a option -&gt; bool**

**is\_none o** is **true** if and only if **o** is **None** .

*val is\_some* : **'a option -&gt; bool**

**is\_some o** is **true** if and only if **o** is **Some o** .

*val equal* : **('a -&gt; 'a -&gt; bool) -&gt; 'a option -&gt; 'a option -&gt; bool**

**equal eq o0 o1** is **true** if and only if **o0** and **o1** are both **None** or if they are **Some v0** and **Some v1** and **eq v0 v1** is **true** .

*val compare* : **('a -&gt; 'a -&gt; int) -&gt; 'a option -&gt; 'a option -&gt; int**

**compare cmp o0 o1** is a total order on options using **cmp** to compare values wrapped by **Some \_** . **None** is smaller than **Some \_** values.

## [Converting](#Converting)

*val to\_result* : **none:'e -&gt; 'a option -&gt; ('a, 'e) result**

**to\_result ~none o** is **Ok v** if **o** is **Some v** and **Error none** otherwise.

*val to\_list* : **'a option -&gt; 'a list**

**to\_list o** is **\[]** if **o** is **None** and **\[v]** if **o** is **Some v** .

*val to\_seq* : **'a option -&gt; 'a Seq.t**

**to\_seq o** is **o** as a sequence. **None** is the empty sequence and **Some v** is the singleton sequence containing **v** .

2026-10-27 OCamldoc

---

Document: Stdlib.Option(3o) from ocaml-4 4.14.4-r4 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
