package async

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Async_kernel.Deferred.Or_error end

The applicative operations match the behavior of the applicative operations in Or_error. This means that all and all_unit are equivalent to combine_errors and combine_errors_unit respectively.

include Core_kernel.Applicative.S with type 'a t := 'a t
val both : 'a t -> 'b t -> ('a * 'b) t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
val (<*) : 'a t -> unit t -> 'a t
val (*>) : unit t -> 'a t -> 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t

return x = Deferred.return (Ok x) *

include Core_kernel.Monad.S with type 'a t := 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
val bind : 'a t -> f:('a -> 'b t) -> 'b t
val return : 'a -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val join : 'a t t -> 'a t
val ignore_m : 'a t -> unit t
val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t
val all_ignore : unit t list -> unit t
  • deprecated [since 2018-02] Use [all_unit]
val fail : Core_kernel.Error.t -> _ t

fail error = Deferred.return (Error error) *

val ignore : _ t -> unit t
val ok_exn : 'a t -> 'a Deferred.t

These functions are direct analogs of the corresponding Core.Or_error functions.

val of_exn : exn -> _ t
val of_exn_result : ('a, exn) Core_kernel.Result.t Deferred.t -> 'a t
val error : string -> 'a -> ('a -> Core_kernel.Sexp.t) -> _ t
val error_s : Core_kernel.Sexp.t -> _ t
val error_string : string -> _ t
val errorf : ('a, unit, string, _ t) Core_kernel.format4 -> 'a
val tag : 'a t -> tag:string -> 'a t
val tag_arg : 'a t -> string -> 'b -> ('b -> Core_kernel.Sexp.t) -> 'a t
val unimplemented : string -> _ t
val combine_errors : 'a t list -> 'a list t
val combine_errors_unit : unit t list -> unit t
val find_map_ok : 'a list -> f:('a -> 'b t) -> 'b t

find_map_ok l ~f returns the first value in l for which f returns Ok, otherwise it returns the same error as combine_errors (Deferred.List.map l ~f).

val ok_unit : unit t

ok_unit = return ()

val try_with : ?extract_exn:bool -> ?here:Stdlib.Lexing.position -> ?name:string -> (unit -> 'a Deferred.t) -> 'a t

try_with f catches exceptions thrown by f and returns them in the Result.t as an Error.t. try_with_join is like try_with, except that f can throw exceptions or return an Error directly, without ending up with a nested error; it is equivalent to try_with f >>| Result.join.

The option extract_exn is passed along to Monitor.try_with ?extract_exn and specifies whether or not the monitor exn wrapper should be skipped (extract_exn:true or kept (extract_exn:false).

val try_with_join : ?extract_exn:bool -> ?here:Stdlib.Lexing.position -> ?name:string -> (unit -> 'a t) -> 'a t

All of the List functions that take a how argument treat it the following way:

val repeat_until_finished : 'state -> ('state -> [ `Repeat of 'state | `Finished of 'result ] t) -> 'result t

repeat_until_finished initial_state f works the just like Deferred.repeat_until_finished but with the Deferred.Or_error monad. If f returns an Or_error.Error the loop terminates and returns.

module Expect_test_config : sig ... end
OCaml

Innovation. Community. Security.