Module Kxclib.Option

include module type of struct include Option0 end
include module type of struct include Stdlib.Option end
type !'a t = 'a option =
  1. | None
  2. | Some of 'a
val none : 'a option
val some : 'a -> 'a option
val value : 'a option -> default:'a -> 'a
val bind : 'a option -> ('a -> 'b option) -> 'b option
val join : 'a option option -> 'a option
val map : ('a -> 'b) -> 'a option -> 'b option
val fold : none:'a -> some:('b -> 'a) -> 'b option -> 'a
val iter : ('a -> unit) -> 'a option -> unit
val is_none : 'a option -> bool
val is_some : 'a option -> bool
val equal : ('a -> 'a -> bool) -> 'a option -> 'a option -> bool
val compare : ('a -> 'a -> int) -> 'a option -> 'a option -> int
val to_result : none:'e -> 'a option -> ('a, 'e) Stdlib.result
val to_list : 'a option -> 'a list
val to_seq : 'a option -> 'a Stdlib.Seq.t
val return : 'a -> 'a option
val get : 'a t -> 'b
val v : 'a -> 'b t -> 'c
val v' : (unit -> 'a) -> 'b t -> 'c
val or_raise : exn -> 'a t -> 'b
val otherwise : 'a t -> 'b t -> 'a t
val otherwise' : (unit -> 'a t) -> 'b t -> 'a t
val pp : (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'b t -> unit
val filter : ('a -> bool) -> 'b t -> 'c t
val fmap : ('a -> 'b t t) -> 'c t -> 'b t
val of_bool : bool -> unit t
val some_if : bool -> 'a -> 'b t
val protect : ?capture:(exn -> bool) -> ('x -> 'y) -> 'x -> 'y option

protect ~capture f x returns Some (f x) except when

  • f x throws an exn s.t. capture exn = true, it returns None
  • f x throws an exn s.t. capture exn = false, it rethrows exn

~capture defaults to fun _exn -> true

val try_make : ?capture:(exn -> bool) -> (unit -> 'x) -> 'x option

try_make ~capture f is protect ~capture f (), thus see protect

~capture defaults to fun _exn -> true

val if_found : (unit -> 'x) -> 'x option

a specialized version of try_make where ~capture is fixed to function Not_found -> true | _ -> false

module Ops_monad : sig ... end
module Ops : sig ... end