Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file seq.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105(*****************************************************************************)(* *)(* 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.Seqletconsitemt()=Cons(item,t)letrecappendtatb()=matchta()withNil->tb()|Cons(item,ta)->Cons(item,appendtatb)letfirsts=matchs()withNil->None|Cons(x,_)->Somexletrecfold_left_efaccseq=matchseq()with|Nil->Okacc|Cons(item,seq)->faccitem>>?funacc->fold_left_efaccseqletrecfold_left_sfaccseq=matchseq()with|Nil->Lwt.returnacc|Cons(item,seq)->faccitem>>=funacc->fold_left_sfaccseqletfold_left_sfaccseq=matchseq()with|Nil->Lwt.returnacc|Cons(item,seq)->lwt_apply2faccitem>>=funacc->fold_left_sfaccseqletrecfold_left_esfaccseq=matchseq()with|Nil->Monad.returnacc|Cons(item,seq)->faccitem>>=?funacc->fold_left_esfaccseqletfold_left_esfaccseq=matchseq()with|Nil->Monad.returnacc|Cons(item,seq)->lwt_apply2faccitem>>=?funacc->fold_left_esfaccseqletreciter_efseq=matchseq()with|Nil->unit_e|Cons(item,seq)->fitem>>?fun()->iter_efseqletreciter_sfseq=matchseq()with|Nil->unit_s|Cons(item,seq)->fitem>>=fun()->iter_sfseqletiter_sfseq=matchseq()with|Nil->unit_s|Cons(item,seq)->Lwt.applyfitem>>=fun()->iter_sfseqletreciter_esfseq=matchseq()with|Nil->unit_es|Cons(item,seq)->fitem>>=?fun()->iter_esfseqletiter_esfseq=matchseq()with|Nil->unit_es|Cons(item,seq)->Lwt.applyfitem>>=?fun()->iter_esfseqletiter_epfseq=letreciter_epfseq(acc:(unit,'error)resultLwt.tlist)=matchseq()with|Nil->join_epacc|Cons(item,seq)->iter_epfseq(Lwt.applyfitem::acc)initer_epfseq[]letiter_pfseq=letreciter_pfseqacc=matchseq()with|Nil->join_pacc|Cons(item,seq)->iter_pfseq(Lwt.applyfitem::acc)initer_pfseq[]letrecunfoldfa()=matchfawithNone->Nil|Some(item,a)->Cons(item,unfoldfa)