Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file option.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155(*****************************************************************************)(* *)(* 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=match(oa,ob)with|(None,None)->none_e|(Somer,None)|(None,Somer)->some_er|(Somea,Someb)->fab>>?some_eletmerge_sfoaob=match(oa,ob)with|(None,None)->none_s|(Somer,None)|(None,Somer)->some_sr|(Somea,Someb)->fab>>=some_sletmerge_esfoaob=match(oa,ob)with|(None,None)->none_es|(Somer,None)|(None,Somer)->some_esr|(Somea,Someb)->fab>>=?some_esletmap_sfo=matchowithNone->Lwt.return_none|Somev->fv>>=Lwt.return_someletmap_efo=matchowithNone->none_e|Somev->Result.mapsome(fv)letmap_esfo=matchowithNone->none_es|Somev->fv>|=?someletfold_s~none~some=functionNone->Lwt.returnnone|Somev->somevletfold_f~none~some=functionNone->none()|Somev->somevletfilterpo=matchowithSomexwhenpx->o|Some_|None->Noneletfilter_spo=matchowith|None->none_s|Somex->(px>>=functiontrue->Lwt.returno|false->none_s)letfilter_epo=matchowith|None->none_e|Somex->(px>>?functiontrue->Oko|false->none_e)letfilter_espo=matchowith|None->none_es|Somex->(px>>=?functiontrue->Monad.returno|false->none_es)letfilter_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_->None