Source

spotlib / lib / option.mli

Full commit
include Monad_intf.T 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 need to be created
    dynamically.
*)

val catch : (fail:(unit -> 'exn) -> 'a) -> 'a option
val catch_exn : (unit -> 'a) -> 'a option