module Async_or_error:sig..end
Core.Or_error. It is exposed in std.ml as
Deferred.Or_error.
The mental model for a function returning an 'a Deferred.Or_error.t is that the
function never raises. All error cases are caught and expressed as an Error _
result. This module preserves that property.
Unfortunately, there is no way to enforce this property using the type system, so it
is more like a convention, or idiom. A function whose type ends with ... -> 'a
Deferred.Or_error.t and still raises should be considered broken, and be fixed. With
that property in mind, Deferred.Or_error.List.iter, for example, does not wrap the
execution of the given iter function f inside a monitor. If one of these
application raises, the whole function Deferred.Or_error.List.iter will raise as a
way to try to alert the developer that one the function is broken and needs attention
and fixing, rather than silently catching the error and converting it to
Or_error.Error.
This behavior is consistent with Core.Or_error's treatment of user-supplied
functions.
If you have to deal with a function that does not respect this idiom, you can use
Deferred.Or_error.try_with_join to wrap its execution and enforce this property.
type'at ='a Core.Std.Or_error.t Deferred.t
include Monad.S
val return : 'ok -> 'ok tval fail : Core.Std.Error.t -> 'a tval of_exn : exn -> 'a tval failwith : string -> 'a tval ok_unit : unit tval never : unit -> 'a tval try_with : ?name:string -> f:('arg -> 'a Deferred.t) -> 'arg -> 'a tval try_with_join : ?name:string ->
f:('arg -> 'a t) -> 'arg -> 'a tmodule List:Deferred_intf.Monad_sequencewith type 'a monad := 'a twith type 'a t := 'a list