Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file result.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283open!ImportmoduleEither=Either0type('a,'b)t=('a,'b)Caml.result=|Okof'a|Errorof'b[@@deriving_inlinesexp,sexp_grammar,compare,equal,hash]lett_of_sexp:'a'b.(Sexplib0.Sexp.t->'a)->(Sexplib0.Sexp.t->'b)->Sexplib0.Sexp.t->('a,'b)t=fun(typea__017_b__018_):((Sexplib0.Sexp.t->a__017_)->(Sexplib0.Sexp.t->b__018_)->Sexplib0.Sexp.t->(a__017_,b__018_)t)->leterror_source__005_="result.ml.t"infun_of_a__001__of_b__002_->function|Sexplib0.Sexp.List(Sexplib0.Sexp.Atom(("ok"|"Ok")as_tag__008_)::sexp_args__009_)as_sexp__007_->(matchsexp_args__009_with|[arg0__010_]->letres0__011_=_of_a__001_arg0__010_inOkres0__011_|_->Sexplib0.Sexp_conv_error.stag_incorrect_n_argserror_source__005__tag__008__sexp__007_)|Sexplib0.Sexp.List(Sexplib0.Sexp.Atom(("error"|"Error")as_tag__013_)::sexp_args__014_)as_sexp__012_->(matchsexp_args__014_with|[arg0__015_]->letres0__016_=_of_b__002_arg0__015_inErrorres0__016_|_->Sexplib0.Sexp_conv_error.stag_incorrect_n_argserror_source__005__tag__013__sexp__012_)|Sexplib0.Sexp.Atom("ok"|"Ok")assexp__006_->Sexplib0.Sexp_conv_error.stag_takes_argserror_source__005_sexp__006_|Sexplib0.Sexp.Atom("error"|"Error")assexp__006_->Sexplib0.Sexp_conv_error.stag_takes_argserror_source__005_sexp__006_|Sexplib0.Sexp.List(Sexplib0.Sexp.List_::_)assexp__004_->Sexplib0.Sexp_conv_error.nested_list_invalid_sumerror_source__005_sexp__004_|Sexplib0.Sexp.List[]assexp__004_->Sexplib0.Sexp_conv_error.empty_list_invalid_sumerror_source__005_sexp__004_|sexp__004_->Sexplib0.Sexp_conv_error.unexpected_stagerror_source__005_sexp__004_;;letsexp_of_t:'a'b.('a->Sexplib0.Sexp.t)->('b->Sexplib0.Sexp.t)->('a,'b)t->Sexplib0.Sexp.t=fun(typea__025_b__026_):((a__025_->Sexplib0.Sexp.t)->(b__026_->Sexplib0.Sexp.t)->(a__025_,b__026_)t->Sexplib0.Sexp.t)->fun_of_a__019__of_b__020_->function|Okarg0__021_->letres0__022_=_of_a__019_arg0__021_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"Ok";res0__022_]|Errorarg0__023_->letres0__024_=_of_b__020_arg0__023_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"Error";res0__024_];;let(t_sexp_grammar:'aSexplib0.Sexp_grammar.t->'bSexplib0.Sexp_grammar.t->('a,'b)tSexplib0.Sexp_grammar.t)=fun_'a_sexp_grammar_'b_sexp_grammar->{untyped=Variant{case_sensitivity=Case_sensitive_except_first_character;clauses=[No_tag{name="Ok";clause_kind=List_clause{args=Cons(_'a_sexp_grammar.untyped,Empty)}};No_tag{name="Error";clause_kind=List_clause{args=Cons(_'b_sexp_grammar.untyped,Empty)}}]}};;letcompare:'a'b.('a->'a->int)->('b->'b->int)->('a,'b)t->('a,'b)t->int=fun_cmp__a_cmp__ba__027_b__028_->ifPpx_compare_lib.phys_equala__027_b__028_then0else(matcha__027_,b__028_with|Ok_a__029_,Ok_b__030_->_cmp__a_a__029__b__030_|Ok_,_->-1|_,Ok_->1|Error_a__031_,Error_b__032_->_cmp__b_a__031__b__032_);;letequal:'a'b.('a->'a->bool)->('b->'b->bool)->('a,'b)t->('a,'b)t->bool=fun_cmp__a_cmp__ba__033_b__034_->ifPpx_compare_lib.phys_equala__033_b__034_thentrueelse(matcha__033_,b__034_with|Ok_a__035_,Ok_b__036_->_cmp__a_a__035__b__036_|Ok_,_->false|_,Ok_->false|Error_a__037_,Error_b__038_->_cmp__b_a__037__b__038_);;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);;moduleError=Monad.Make2(structtypenonrec('a,'b)t=('b,'a)tletbindx~f=matchxwith|Ok_asok->ok|Errore->fe;;letmap=`Custommap_errorletreturne=Erroreend)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