Module Deferred.Result

include Core.Monad.S2 with type ('a, 'b) t = ('a, 'b) Core.Result.t Async_kernel.Deferred.t
type ('a, 'b) t = ('a, 'b) Core.Result.t Async_kernel.Deferred.t
val return : 'a 'i 'p 'q. 'a -> ('a, 'p) t

Convert a value to a t.

val map : 'a 'b 'i 'j 'p 'q. ('a, 'p) t -> f:('a -> 'b) -> ('b, 'p) t

Transforms the contents of a t.

val bind : 'a 'b 'i 'j 'k 'p 'q. ('a, 'p) t -> f:('a -> ('b, 'p) t) -> ('b, 'p) t

Sequences computations. bind t ~f computes f v for value(s) v in t. Well-behaved monads satisfy these "laws" (where ( >>= ) is the infix bind operator):

  • map t ~f is equivalent to bind t ~f:(fun x -> return (f x))
  • return x >>= f is equivalent to f x
  • t >>= return is equivalent to t
  • (t >>= f) >>= g is equivalent to t >>= fun x -> f x >>= g
val join : 'a 'i 'j 'k 'p 'q. (('a, 'p) t, 'p) t -> ('a, 'p) t

Combines nested t into just one layer. Equivalent to bind t ~f:Fn.id.

val ignore_m : 'a 'i 'j 'p 'q. ('a, 'p) t -> (unit, 'p) t

Ignores contained values of t. Equivalent to map t ~f:ignore.

val all : 'a 'i 'p 'q. ('a, 'p) t list -> ('a list, 'p) t

Combines a list of t.

val all_unit : 'i 'p 'q. (unit, 'p) t list -> (unit, 'p) t

Combines a list of t whose contents are unimportant.

val (>>=) : 'a 'b 'i 'j 'k 'p 'q. ('a, 'p) t -> ('a -> ('b, 'p) t) -> ('b, 'p) t

Infix bind.

val (>>|) : 'a 'b 'i 'j 'p 'q. ('a, 'p) t -> ('a -> 'b) -> ('b, 'p) t

Infix map.

module Monad_infix : sig ... end
module Let_syntax : sig ... end
val fail : 'err -> (_, 'err) t
val failf : ('a, unit, string, (_, string) t) Core.format4 -> 'a

e.g., failf "Couldn't find bloogle %s" (Bloogle.to_string b).

val map_error : ('ok, 'error1) t -> f:('error1 -> 'error2) -> ('ok, 'error2) t
val combine : ('ok1, 'err) t -> ('ok2, 'err) t -> ok:('ok1 -> 'ok2 -> 'ok3) -> err:('err -> 'err -> 'err) -> ('ok3, 'err) t

combine waits on both inputs and combines their results using Result.combine.

module List : Async_kernel.Monad_sequence.S2_result with type ('a, 'e) monad := ('a, 'e) t with type 'a t := 'a list