jon.recoil.org

Module Stdlib_stable.Or_nullSource

Nullable values.

Nullable values explicitly indicate the presence or absence of a value, representing present values as themselves and absent ones as null pointers. Unlike the regular option, the or_null type can't be nested.

This module mirrors Option, except for join which can't be defined.

Sourcetype 'a t : (value_or_null mod everything) with 'a = 'a or_null

The type of nullable values. Either Null or a value This v. 'a or_null has a non-standard value_or_null layout, preventing the type constructor from being nested.

Sourceval null : 'a t @@ portable

null is Null.

Sourceval this : 'a -> 'a t @@ portable

this v is This v.

Sourceval value : 'a t -> default:'a -> 'a @@ portable

value o ~default is v if o is This v and default otherwise.

Sourceval get : 'a t -> 'a @@ portable

get o is v if o is This v and raise otherwise.

Sourceval bind : 'a t -> ('a -> 'b or_null) -> 'b or_null @@ portable

bind o f is f v if o is This v and Null if o is Null.

Sourceval map : ('a -> 'b) -> 'a t -> 'b or_null @@ portable

map f o is Null if o is Null and This v if o is This v.

Sourceval fold : null:'a -> this:('b -> 'a) -> 'b or_null -> 'a @@ portable

fold ~null ~this o is null if o is Null and this v if o is This v.

Sourceval iter : ('a -> unit) -> 'a t -> unit @@ portable

iter f o is f v if o is This v and () otherwise.

Sourceval is_null : 'a t -> bool @@ portable

is_null o is true if o is Null and false otherwise.

Sourceval is_this : 'a t -> bool @@ portable

is_this o is true if o is This v and false otherwise.

Sourceval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool @@ portable

equal eq o0 o1 is true if and only if o0 and o1 are both Null or if they are This v0 and This v1 and eq v0 v1 is true.

Sourceval compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int @@ portable

compare f o o' is a total order on or_null using cmp to compare values wrapped by This _. Null is smaller than This _ values.

Sourceval to_result : null:'e -> 'a t -> ('a, 'e) result @@ portable

to_result ~null o is Ok v if o is This v and Error null otherwise.

Sourceval to_list : 'a t -> 'a list @@ portable

to_list is [] if o is Null and [v] if o is This v.

Sourceval to_seq : 'a t -> 'a Seq.t @@ portable

to_seq o is o as a sequence. Null is the empty sequence and This v is the singleton sequence containing v.

Sourceval to_option : 'a t -> 'a option @@ portable

to_option o is Some v if o is This v and None otherwise.

Sourceval of_option : 'a option -> 'a t @@ portable

of_option o is This v if o is Some v and Null otherwise.