package spotlib

  1. Overview
  2. Docs
type 'a t = 'a option

Monad.T with type 'a t := 'a option, but Infix contains extra operators

include Monad.S with type 'a t := 'a option
val return : 'a -> 'a option
val bind : 'a option -> ('a -> 'b option) -> 'b option
include Monad.EX with type 'a t := 'a 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

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

Not tail recursive

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

Iteration with index starting from 0. Not tail recursive.

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

for like iteration. Not tail recursive

val join : 'a option option -> 'a option
module Infix : sig ... end
include module type of struct include Infix end
include Monad.Infix with type 'a t := 'a option
val (>>=) : 'a option -> ('a -> 'b option) -> 'b option

synonym of bind

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

synonum of fmap, with the flipped arguments

Applicative style binops

val (^<$>) : ('a -> 'b) -> 'a option -> 'b option

same as map, <$> in Haskell

val (/<*>) : ('a -> 'b) option -> 'a option -> 'b option

<*> in Haskell

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 (//) : 'a t -> 'a -> 'a

Same as default but the default value is always evaluated

val (>>=!) : 'a t -> (unit -> 'a t) -> 'a t

bindE.

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.