Applicative functions don't have quite the same semantics as Applicative.of_Monad(Or_error) would give -- apply (Error e1) (Error e2) returns the combination of e1 and e2, whereas it would only return e1 if it were defined using bind.
val fold : 'at->init:'accum->f:('accum->'a->'accum)->'accum
fold t ~init ~f returns f (... f (f (f init e1) e2) e3 ...) en, where e1..en are the elements of t
val fold_result :
'at->init:'accum->f:('accum->'a->('accum, 'e)Result.t)->('accum, 'e)Result.t
fold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.
fold_until t ~init ~f is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed.
Returns a minimum (resp maximum) element from the collection using the provided cmp function, or None if the collection is empty. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold.
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.
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 Pervasives.ignore. Some monads still do let ignore = ignore_m for historical reasons.
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 Result.join (try_with f).
val try_with_join : ?backtrace:bool ->(unit ->'at)->'at
of_exn_result (Ok a) = Ok a, of_exn_result (Error exn) = of_exn exn
val error : ?strict:unit ->string ->'a->('a->Sexp.t)->_t
error is a wrapper around Error.create:
error ?strict message a sexp_of_a
= Error (Error.create ?strict message a sexp_of_a)
As with Error.create, sexp_of_a a is lazily computed, when the info is converted to a sexp. So, if a is mutated in the time between the call to create and the sexp conversion, those mutations will be reflected in the sexp. Use ~strict:() to force sexp_of_a a to be computed immediately.
errorf format arg1 arg2 ... is Error (sprintf format arg1 arg2 ...). Note that it calculates the string eagerly, so when performance matters you may want to use error instead.
For marking a given value as unimplemented. Typically combined with conditional compilation, where on some platforms the function is defined normally, and on some platforms it is defined as unimplemented. The supplied string should be the name of the function that is unimplemented.