package js_of_ocaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Standard functions for manipulating possibly undefined values.

type 'a t = 'a optdef
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.

OCaml

Innovation. Community. Security.