package spotlib

  1. Overview
  2. Docs
type 'a t = 'a option
include Monad.T with type 'a t := 'a option
val return : 'a -> 'a option
val bind : 'a option -> ('a -> 'b option) -> 'b option
val fmap : ('a -> 'b) -> 'a option -> 'b option

fmap in Haskell

val liftM : ('a -> 'b) -> 'a option -> 'b option

synonym of fmap

val fmap2 : ('a -> 'b -> 'c) -> 'a option -> 'b option -> 'c option

fmap2 in Haskell

val liftM2 : ('a -> 'b -> 'c) -> 'a option -> 'b option -> 'c option

synonym of fmap2

val void : 'a option -> unit option
val seq : 'a option list -> 'a list option

sequence in Haskell. Not tail recursive.

val seq_ : unit option list -> unit option

sequence_ in Haskell. Not tail recursive.

val mapM : ('a -> 'b option) -> 'a list -> 'b list option

Not tail recursive by default

val mapM_ : ('a -> unit option) -> 'a list -> unit option

Not tail recursive by default

val iteri : (int -> 'a -> unit option) -> 'a list -> unit option

Iteration with index starting from 0. Not tail recursive by default

val for_ : int -> int -> (int -> unit option) -> unit option

for like iteration. Not tail recursive by default

val join : 'a option option -> 'a option
module Infix : sig ... end
module Syntax : Monad.Syntax with type 'a t := 'a option
val default : 'a t -> (unit -> 'a) -> 'a

Haskell's fromMaybe.

Ex. default (Some v) f = v default None f = f ()

The default value is provided not as a direct value of type 'a but as a thunk (unit -> 'a), since such a value may be created dynamically.

val catch : (fail:(unit -> 'exn) -> 'a) -> 'a option
val catch_exn : (unit -> 'a) -> 'a option
val to_result : 'a option -> ('a, [> `None ]) result
val to_poly_result : 'a option -> ('a, [> `None ]) Poly_result.t
val from_Some : 'a option -> 'a

may raise Invalid_argument

val to_list : 'a option -> 'a list

Conversion to a list

val format : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a option -> unit
val iter : ('a -> unit) -> 'a option -> unit
module Stdlib : sig ... end
OCaml

Innovation. Community. Security.