Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file option.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)openMonadincludeStdlib.Optionletsome_unit=Some()letsome_unit_e=Oksome_unitletsome_unit_s=Lwt.returnsome_unitletsome_unit_es=Lwt.returnsome_unit_eletsome_nil=Some[]letsome_nil_e=Oksome_nilletsome_nil_s=Lwt.returnsome_nilletsome_nil_es=Lwt.returnsome_nil_eletsome_true=Sometrueletsome_true_e=Oksome_trueletsome_true_s=Lwt.returnsome_trueletsome_true_es=Lwt.returnsome_true_eletsome_false=Somefalseletsome_false_e=Oksome_falseletsome_false_s=Lwt.returnsome_falseletsome_false_es=Lwt.returnsome_false_eletsome_ev=Ok(Somev)letsome_sv=Lwt.return(Somev)letsome_esv=Lwt.return(Ok(Somev))letnone_e=OkNoneletnone_s=Lwt.returnNoneletnone_es=Lwt.returnnone_eletvalue_eo~error=to_result~none:erroroletvalue_fo~default=matchowithNone->default()|Somev->vletvalue_feo~error=matchowithNone->Error(error())|Somev->Okvleteitheroaob=matchoawithSome_->oa|None->obleteither_foaob=matchoawithSome_->oa|None->ob()letmergefoaob=match(oa,ob)with|(None,None)->None|(Somer,None)|(None,Somer)->Somer|(Somea,Someb)->Some(fab)letmerge_efoaob=letopenResult_syntaxinmatch(oa,ob)with|(None,None)->return_none|(Somer,None)|(None,Somer)->return_somer|(Somea,Someb)->let*r=fabinreturn_somerletmerge_sfoaob=letopenLwt_syntaxinmatch(oa,ob)with|(None,None)->return_none|(Somer,None)|(None,Somer)->return_somer|(Somea,Someb)->let*r=fabinreturn_somerletmerge_esfoaob=letopenLwt_result_syntaxinmatch(oa,ob)with|(None,None)->return_none|(Somer,None)|(None,Somer)->return_somer|(Somea,Someb)->let*r=fabinreturn_somerletmap_efo=letopenResult_syntaxinmatchowith|None->return_none|Somev->let*r=fvinreturn_somerletmap_sfo=letopenLwt_syntaxinmatchowith|None->return_none|Somev->let*r=fvinreturn_somerletmap_esfo=letopenLwt_result_syntaxinmatchowith|None->return_none|Somev->let*r=fvinreturn_somerletfold_s~none~some=functionNone->Lwt.returnnone|Somev->somevletfold_f~none~some=functionNone->none()|Somev->somevletfilterpo=matchowithSomexwhenpx->o|Some_|None->Noneletfilter_spo=letopenLwt_syntaxinmatchowith|None->return_none|Somex->let*b=pxinifbthenreturnoelsereturn_noneletfilter_epo=letopenResult_syntaxinmatchowith|None->return_none|Somex->let*b=pxinifbthenreturnoelsereturn_noneletfilter_espo=letopenLwt_result_syntaxinmatchowith|None->return_none|Somex->let*b=pxinifbthenreturnoelsereturn_noneletfilter_mapfo=bindofletfilter_map_sfo=matchowithNone->none_s|Somex->fxletfilter_map_efo=matchowithNone->none_e|Somex->fxletfilter_map_esfo=matchowithNone->none_es|Somex->fxletfilter_ok=functionSome(Okx)->Somex|Some(Error_)|None->Noneletfilter_error=function|Some(Errorx)->Somex|Some(Ok_)|None->Noneletiter_sf=functionNone->Lwt.return_unit|Somev->fvletiter_ef=functionNone->Ok()|Somev->fvletiter_esf=functionNone->Lwt.return_ok()|Somev->fvletof_result=functionOkv->Somev|Error_->Noneletcatch?(catch_only=fun_->true)f=matchf()with|v->Somev|exception((Stack_overflow|Out_of_memory)ase)->raisee|exceptione->ifcatch_onlyethenNoneelseraiseeletcatch_o?(catch_only=fun_->true)f=matchf()with|v->v|exception((Stack_overflow|Out_of_memory)ase)->raisee|exceptione->ifcatch_onlyethenNoneelseraiseeletcatch_s?(catch_only=fun_->true)f=Lwt.try_bindfLwt.return_some(function|(Stack_overflow|Out_of_memory)ase->raisee|e->ifcatch_onlyethenLwt.return_noneelseraisee)letcatch_os?(catch_only=fun_->true)f=Lwt.catchf(function|(Stack_overflow|Out_of_memory)ase->raisee|e->ifcatch_onlyethenLwt.return_noneelseraisee)