package core
Module Core.Or_error
This module extends Base.Or_error with bin_io.
include Bin_prot.Binable.S1 with type 'a t := 'a t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.tval bin_size_t : ('a, 'a t) Bin_prot.Size.sizer1val bin_write_t : ('a, 'a t) Bin_prot.Write.writer1val bin_read_t : ('a, 'a t) Bin_prot.Read.reader1val __bin_read_t__ : ('a, int -> 'a t) Bin_prot.Read.reader1val bin_writer_t : ('a, 'a t) Bin_prot.Type_class.S1.writerval bin_reader_t : ('a, 'a t) Bin_prot.Type_class.S1.readerval bin_t : ('a, 'a t) Bin_prot.Type_class.S1.tval hash_fold_t :
(Base.Hash.state -> 'a -> Base.Hash.state) ->
Base.Hash.state ->
'a t ->
Base.Hash.stateinclude Sexplib0.Sexpable.S1 with type 'a t := 'a t
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a tval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.tval t_sexp_grammar : 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_grammar.tApplicative 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.
include Base.Applicative.S with type 'a t := 'a t
module Applicative_infix = Base.Or_error.Applicative_infixinclude Base.Invariant.S1 with type 'a t := 'a t
val invariant : ('a -> unit) -> 'a t -> unitinclude Base.Monad.S with type 'a t := 'a 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.
module Monad_infix = Base.Or_error.Monad_infixval return : 'a -> 'a treturn v returns the (trivial) computation that returns 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 Caml.ignore. Some monads still do let ignore = ignore_m for historical reasons.
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.
module Let_syntax = Base.Or_error.Let_syntaxval is_ok : _ t -> boolval is_error : _ t -> boolval try_with : ?backtrace:bool -> (unit -> 'a) -> 'a ttry_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 ok : 'ok t -> 'ok optionok t returns None if t is an Error, and otherwise returns the contents of the Ok constructor.
val ok_exn : 'a t -> 'aok_exn t throws an exception if t is an Error, and otherwise returns the contents of the Ok constructor.
val of_exn : ?backtrace:[ `Get | `This of string ] -> exn -> _ tof_exn ?backtrace exn is Error (Error.of_exn ?backtrace exn).
val of_exn_result :
?backtrace:[ `Get | `This of string ] ->
('a, exn) Base.Result.t ->
'a tof_exn_result ?backtrace (Ok a) = Ok a
of_exn_result ?backtrace (Error exn) = of_exn ?backtrace exn
val error :
?here:Caml.Lexing.position ->
?strict:unit ->
string ->
'a ->
('a -> Base.Sexp.t) ->
_ terror 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.
val error_s : Base.Sexp.t -> _ tval error_string : string -> _ terror_string message is Error (Error.of_string message).
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.
val tag_s : 'a t -> tag:Base.Sexp.t -> 'a ttag_s is like tag with a sexp tag.
val tag_s_lazy : 'a t -> tag:Base.Sexp.t Base.Lazy.t -> 'a ttag_s_lazy is like tag with a lazy sexp tag.
val tag_arg : 'a t -> string -> 'b -> ('b -> Base.Sexp.t) -> 'a ttag_arg is like tag, with a tag that has a sexpable argument.
val unimplemented : string -> _ tFor 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.
val iter : 'a t -> f:('a -> unit) -> unitval iter_error : _ t -> f:(Base.Error.t -> unit) -> unitcombine_errors ts returns Ok if every element in ts is Ok, else it returns Error with all the errors in ts. More precisely:
combine_errors [Ok a1; ...; Ok an] = Ok [a1; ...; an]combine_errors [...; Error e1; ...; Error en; ...] = Error (Error.of_list [e1; ...; en])
combine_errors_unit ts returns Ok if every element in ts is Ok (), else it returns Error with all the errors in ts, like combine_errors.
filter_ok_at_least_one ts returns all values in ts that are Ok if there is at least one, otherwise it returns the same error as combine_errors ts.
find_ok ts returns the first value in ts that is Ok, otherwise it returns the same error as combine_errors ts.
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 (List.map l ~f).
module Stable : sig ... end