package async

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Deferred.Or_errorSource

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.Applicative.S with type 'a t := 'a t
Sourceval both : 'a t -> 'b t -> ('a * 'b) t
Sourceval (<*>) : ('a -> 'b) t -> 'a t -> 'b t

same as apply

Sourceval (<*) : 'a t -> unit t -> 'a t
Sourceval (*>) : unit t -> 'a t -> 'a t
Sourceval apply : ('a -> 'b) t -> 'a t -> 'b t
Sourceval map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
Sourceval map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t

return x = Deferred.return (Ok x) *

include Core.Monad.S with type 'a t := 'a t
Sourceval (>>=) : 'a t -> ('a -> 'b t) -> 'b t

t >>= f returns a computation that sequences the computations represented by two monad elements. The resulting computation first does t to yield a value v, and then runs the computation returned by f v.

Sourceval (>>|) : 'a t -> ('a -> 'b) -> 'b t

t >>| f is t >>= (fun a -> return (f a)).

Sourceval bind : 'a t -> f:('a -> 'b t) -> 'b t

bind t ~f = t >>= f

Sourceval return : 'a -> 'a t

return v returns the (trivial) computation that returns v.

Sourceval map : 'a t -> f:('a -> 'b) -> 'b t

map t ~f is t >>| f.

Sourceval join : 'a t t -> 'a t

join t is t >>= (fun t' -> t').

Sourceval ignore_m : 'a t -> unit t

ignore_m t is map t ~f:(fun _ -> ()). ignore_m used to be called ignore, but we decided that was a bad name, because it shadowed the widely used Stdlib.ignore. Some monads still do let ignore = ignore_m for historical reasons.

Sourceval all : 'a t list -> 'a list t
Sourceval all_unit : unit t list -> unit t

Like all, but ensures that every monadic value in the list produces a unit value, all of which are discarded rather than being collected into a list.

Sourceval fail : Core.Error.t -> _ t

fail error = Deferred.return (Error error) *

Sourceval ok_exn : 'a t -> 'a Async_kernel.Deferred.t

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

Sourceval of_exn : ?backtrace:[ `Get | `This of string ] -> exn -> _ t
Sourceval of_exn_result : ?backtrace:[ `Get | `This of string ] -> ('a, exn) Core.Result.t Async_kernel.Deferred.t -> 'a t
Sourceval error : string -> 'a -> ('a -> Core.Sexp.t) -> _ t
Sourceval error_s : Core.Sexp.t -> _ t
Sourceval error_string : string -> _ t
Sourceval errorf : ('a, unit, string, _ t) Core.format4 -> 'a
Sourceval tag : 'a t -> tag:string -> 'a t
Sourceval tag_s : 'a t -> tag:Core.Sexp.t -> 'a t
Sourceval tag_s_lazy : 'a t -> tag:Core.Sexp.t Core.Lazy.t -> 'a t
Sourceval tag_arg : 'a t -> string -> 'b -> ('b -> Core.Sexp.t) -> 'a t
Sourceval unimplemented : string -> _ t
Sourceval combine_errors : 'a t list -> 'a list t
Sourceval combine_errors_unit : unit t list -> unit t
Sourceval filter_ok_at_least_one : 'a t list -> 'a list t
Sourceval 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).

Sourceval ok_unit : unit t

ok_unit = return ()

Sourceval try_with : ?extract_exn:bool -> ?run:[ `Now | `Schedule ] -> ?rest:[ `Log | `Raise | `Call of exn -> unit ] -> ?here:Lexing.position -> ?name:string -> (unit -> 'a Async_kernel.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).

The ~rest argument controls how exceptions are handled after the try_with deferred becomes determined. They may be logged, raised, or passed to a callback.

The ~run argument controls when f gets called. `Now calls f immediately; `Schedule schedules an asynchronous job to run f.

Sourceval try_with_join : ?extract_exn:bool -> ?run:[ `Now | `Schedule ] -> ?rest:[ `Log | `Raise | `Call of exn -> unit ] -> ?here:Lexing.position -> ?name:string -> (unit -> 'a t) -> 'a t

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

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

repeat_until_finished initial_state f works 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.

Sourcemodule Expect_test_config : sig ... end
OCaml

Innovation. Community. Security.