123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** A replacement for {!Stdlib.Result} which
- is exception-safe,
- includes Lwt-, result-, and Lwt-result-aware traversors.
See {!Lwtreslib} and {!Seq} for general description of traversors and the
meaning of [_s], [_e], and [_es] suffixes. *)moduletypeS=sigtype('a,'e)t=('a,'e)result=Okof'a|Errorof'e(***)valok:'a->('a,'e)resultvalok_s:'a->('a,'e)resultLwt.tvalerror:'e->('a,'e)resultvalerror_s:'e->('a,'e)resultLwt.tvalvalue:('a,'e)result->default:'a->'avalvalue_f:('a,'e)result->default:(unit->'a)->'avalbind:('a,'e)result->('a->('b,'e)result)->('b,'e)resultvalbind_s:('a,'e)result->('a->('b,'e)resultLwt.t)->('b,'e)resultLwt.tvalbind_error:('a,'e)result->('e->('a,'f)result)->('a,'f)resultvalbind_error_s:('a,'e)result->('e->('a,'f)resultLwt.t)->('a,'f)resultLwt.tvaljoin:(('a,'e)result,'e)result->('a,'e)resultvalmap:('a->'b)->('a,'e)result->('b,'e)result(* NOTE: [map_e] is [bind] *)valmap_e:('a->('b,'e)result)->('a,'e)result->('b,'e)resultvalmap_s:('a->'bLwt.t)->('a,'e)result->('b,'e)resultLwt.t(* NOTE: [map_es] is [bind_s] *)valmap_es:('a->('b,'e)resultLwt.t)->('a,'e)result->('b,'e)resultLwt.tvalmap_error:('e->'f)->('a,'e)result->('a,'f)result(* NOTE: [map_error_e] is [bind_error] *)valmap_error_e:('e->('a,'f)result)->('a,'e)result->('a,'f)resultvalmap_error_s:('e->'fLwt.t)->('a,'e)result->('a,'f)resultLwt.t(* NOTE: [map_error_es] is [bind_error_s] *)valmap_error_es:('e->('a,'f)resultLwt.t)->('a,'e)result->('a,'f)resultLwt.tvalfold:ok:('a->'c)->error:('e->'c)->('a,'e)result->'cvaliter:('a->unit)->('a,'e)result->unitvaliter_s:('a->unitLwt.t)->('a,'e)result->unitLwt.tvaliter_error:('e->unit)->('a,'e)result->unitvaliter_error_s:('e->unitLwt.t)->('a,'e)result->unitLwt.tvalis_ok:('a,'e)result->boolvalis_error:('a,'e)result->boolvalequal:ok:('a->'a->bool)->error:('e->'e->bool)->('a,'e)result->('a,'e)result->boolvalcompare:ok:('a->'a->int)->error:('e->'e->int)->('a,'e)result->('a,'e)result->intvalto_option:('a,'e)result->'aoptionvalof_option:error:'e->'aoption->('a,'e)resultvalto_list:('a,'e)result->'alistvalto_seq:('a,'e)result->'aStdlib.Seq.tend