Module Js.Opt

Standard functions for manipulating possibly null values.

type 'a t = 'a opt
val empty : 'a t

No value.

val return : 'a -> 'a t

Consider a value as an optional value.

val map : 'a t -> ('a -> 'b) -> 'b t

Apply a function to an optional value if it is available. Returns the result of the application.

val bind : 'a t -> ('a -> 'b t) -> 'b t

Apply a function returning an optional value to an optional value

val test : 'a t -> bool

Returns true if a value is available, false otherwise.

val iter : 'a t -> ('a -> unit) -> unit

Apply a function to an optional value if it is available.

val case : 'a t -> (unit -> 'b) -> ('a -> 'b) -> 'b

Pattern matching on optional values.

val get : 'a t -> (unit -> 'a) -> 'a

Get the value. If no value available, an alternative function is called to get a default value.

val option : 'a option -> 'a t

Convert option type.

val to_option : 'a t -> 'a option

Convert to option type.

val equals : _ t -> _ t -> bool

Javascript == equality operator.

val strict_equals : _ t -> _ t -> bool

Javascript === equality operator.