package octez-libs
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
    
    
  sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13
    
    
  doc/octez-libs.lwt-result-stdlib/Tezos_lwt_result_stdlib/Lwtreslib/Bare/Result/index.html
Module Bare.ResultSource
val ok : 'a -> ('a, 'e) resultval error : 'e -> ('a, 'e) resultval value : ('a, 'e) result -> default:'a -> 'aval value_f : ('a, 'e) result -> default:(unit -> 'a) -> 'aval fold : ok:('a -> 'c) -> error:('e -> 'c) -> ('a, 'e) result -> 'cval iter : ('a -> unit) -> ('a, 'e) result -> unitval iter_error : ('e -> unit) -> ('a, 'e) result -> unitval is_ok : ('a, 'e) result -> boolval is_error : ('a, 'e) result -> boolval to_option : ('a, 'e) result -> 'a optionval of_option : error:'e -> 'a option -> ('a, 'e) resultval to_list : ('a, 'e) result -> 'a listval catch : ?catch_only:(exn -> bool) -> (unit -> 'a) -> ('a, exn) resultcatch f is try Ok (f ()) with e -> Error e: it is Ok x if f () evaluates to x, and it is Error e if f () raises e.
See WithExceptions.S.Result.to_exn for a converse function.
If catch_only is set, then only exceptions e such that catch_only e is true are caught.
Whether catch_only is set or not, this function never catches non-deterministic runtime exceptions of OCaml such as Stack_overflow and Out_of_memory.
val catch_f : 
  ?catch_only:(exn -> bool) ->
  (unit -> 'a) ->
  (exn -> 'e) ->
  ('a, 'e) resultcatch_f f handler is equivalent to map_error (catch f) handler. In other words, it catches exceptions in f () and either returns the value in an Ok or passes the exception to handler for the Error.
No attempt is made to catch the exceptions raised by handler.
catch_only has the same use as with catch. The same restriction on catching non-deterministic runtime exceptions applies.
val catch_ef : 
  ?catch_only:(exn -> bool) ->
  (unit -> ('a, 'error) result) ->
  (exn -> 'error) ->
  ('a, 'error) resultcatch_ef f handler is equivalent to join @@ map_error (catch f) handler. In other words, it catches exceptions in f () and either returns the value as is or passes the exception to handler for the Error. The handler must return an error of the same type as that carried by f ().
No attempt is made to catch the exceptions raised by handler.
catch_only has the same use as with catch. The same restriction on catching non-deterministic runtime exceptions applies.
catch_s is catch but for Lwt promises. Specifically, catch_s f returns a promise that resolves to Ok x if and when f () resolves to x, or to Error exc if and when f () is rejected with exc.
If catch_only is set, then only exceptions e such that catch_only e is true are caught.
Whether catch_only is set or not, this function never catches non-deterministic runtime exceptions of OCaml such as Stack_overflow and Out_of_memory.
We do not provide catch_s_f because (a) the suffix becomes confusing, (b) it's not used, (c) it is not obvious whether we want the handler to be within Lwt (gives more flexibility) or not (gives more guarantee about the timeliness of learning about rejections). We will revisit this if a needs for it arises.