Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file result.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235open!ImportmoduleEither=Either0type('a,'b)t=('a,'b)Caml.result=|Okof'a|Errorof'b[@@deriving_inlinesexp,compare,equal,hash]lett_of_sexp:typeab.(Ppx_sexp_conv_lib.Sexp.t->a)->(Ppx_sexp_conv_lib.Sexp.t->b)->Ppx_sexp_conv_lib.Sexp.t->(a,b)t=let_tp_loc="result.ml.t"infun_of_a_of_b->function|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.Atom(("ok"|"Ok")as_tag)::sexp_args)as_sexp->(matchsexp_argswith|[v0]->letv0=_of_av0inOkv0|_->Ppx_sexp_conv_lib.Conv_error.stag_incorrect_n_args_tp_loc_tag_sexp)|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.Atom(("error"|"Error")as_tag)::sexp_args)as_sexp->(matchsexp_argswith|[v0]->letv0=_of_bv0inErrorv0|_->Ppx_sexp_conv_lib.Conv_error.stag_incorrect_n_args_tp_loc_tag_sexp)|Ppx_sexp_conv_lib.Sexp.Atom("ok"|"Ok")assexp->Ppx_sexp_conv_lib.Conv_error.stag_takes_args_tp_locsexp|Ppx_sexp_conv_lib.Sexp.Atom("error"|"Error")assexp->Ppx_sexp_conv_lib.Conv_error.stag_takes_args_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.List_::_)assexp->Ppx_sexp_conv_lib.Conv_error.nested_list_invalid_sum_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List[]assexp->Ppx_sexp_conv_lib.Conv_error.empty_list_invalid_sum_tp_locsexp|sexp->Ppx_sexp_conv_lib.Conv_error.unexpected_stag_tp_locsexp;;letsexp_of_t:typeab.(a->Ppx_sexp_conv_lib.Sexp.t)->(b->Ppx_sexp_conv_lib.Sexp.t)->(a,b)t->Ppx_sexp_conv_lib.Sexp.t=fun_of_a_of_b->function|Okv0->letv0=_of_av0inPpx_sexp_conv_lib.Sexp.List[Ppx_sexp_conv_lib.Sexp.Atom"Ok";v0]|Errorv0->letv0=_of_bv0inPpx_sexp_conv_lib.Sexp.List[Ppx_sexp_conv_lib.Sexp.Atom"Error";v0];;letcompare:'a'b.('a->'a->int)->('b->'b->int)->('a,'b)t->('a,'b)t->int=fun_cmp__a_cmp__ba__001_b__002_->ifPpx_compare_lib.phys_equala__001_b__002_then0else(matcha__001_,b__002_with|Ok_a__003_,Ok_b__004_->_cmp__a_a__003__b__004_|Ok_,_->-1|_,Ok_->1|Error_a__005_,Error_b__006_->_cmp__b_a__005__b__006_);;letequal:'a'b.('a->'a->bool)->('b->'b->bool)->('a,'b)t->('a,'b)t->bool=fun_cmp__a_cmp__ba__007_b__008_->ifPpx_compare_lib.phys_equala__007_b__008_thentrueelse(matcha__007_,b__008_with|Ok_a__009_,Ok_b__010_->_cmp__a_a__009__b__010_|Ok_,_->false|_,Ok_->false|Error_a__011_,Error_b__012_->_cmp__b_a__011__b__012_);;lethash_fold_t:typeab.(Ppx_hash_lib.Std.Hash.state->a->Ppx_hash_lib.Std.Hash.state)->(Ppx_hash_lib.Std.Hash.state->b->Ppx_hash_lib.Std.Hash.state)->Ppx_hash_lib.Std.Hash.state->(a,b)t->Ppx_hash_lib.Std.Hash.state=fun_hash_fold_a_hash_fold_bhsvarg->matchargwith|Ok_a0->lethsv=Ppx_hash_lib.Std.Hash.fold_inthsv0inlethsv=hsvin_hash_fold_ahsv_a0|Error_a0->lethsv=Ppx_hash_lib.Std.Hash.fold_inthsv1inlethsv=hsvin_hash_fold_bhsv_a0;;[@@@end]includeMonad.Make2(structtypenonrec('a,'b)t=('a,'b)tletbindx~f=matchxwith|Error_asx->x|Okx->fx;;letmapx~f=matchxwith|Error_asx->x|Okx->Ok(fx);;letmap=`Custommapletreturnx=Okxend)letinvariantcheck_okcheck_errort=matchtwith|Okok->check_okok|Errorerror->check_errorerror;;letfailx=Errorxletfailfformat=Printf.ksprintffailformatletmap_errort~f=matchtwith|Ok_asx->x|Errorx->Error(fx);;letis_ok=function|Ok_->true|Error_->false;;letis_error=function|Ok_->false|Error_->true;;letok=function|Okx->Somex|Error_->None;;leterror=function|Ok_->None|Errorx->Somex;;letof_optionopt~error=matchoptwith|Somex->Okx|None->Errorerror;;letiterv~f=matchvwith|Okx->fx|Error_->();;letiter_errorv~f=matchvwith|Ok_->()|Errorx->fx;;letto_either:_t->_Either.t=function|Okx->Firstx|Errorx->Secondx;;letof_either:_Either.t->_t=function|Firstx->Okx|Secondx->Errorx;;letok_if_truebool~error=ifboolthenOk()elseErrorerrorlettry_withf=tryOk(f())with|exn->Errorexn;;letok_exn=function|Okx->x|Errorexn->raiseexn;;letok_or_failwith=function|Okx->x|Errorstr->failwithstr;;moduleExport=structtype('ok,'err)_result=('ok,'err)t=|Okof'ok|Errorof'errletis_error=is_errorletis_ok=is_okendletcombinet1t2~ok~err=matcht1,t2with|Ok_,Errore|Errore,Ok_->Errore|Okok1,Okok2->Ok(okok1ok2)|Errorerr1,Errorerr2->Error(errerr1err2);;letcombine_errorsl=letok,errs=List1.partition_mapl~f:to_eitherinmatcherrswith|[]->Okok|_::_->Errorerrs;;letcombine_errors_unitl=map(combine_errorsl)~f:(fun(_:unitlist)->())(* deprecated binding for export only *)letok_fst=to_either