123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133(*****************************************************************************)(* *)(* 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)->letopenResult_syntaxinlet*acc=facciteminfold_left_efaccseqletrecfold_left_sfaccseq=letopenLwt_syntaxinmatchseq()with|Nil->returnacc|Cons(item,seq)->let*acc=facciteminfold_left_sfaccseqletfold_left_sfaccseq=letopenLwt_syntaxinmatchseq()with|Nil->returnacc|Cons(item,seq)->let*acc=lwt_apply2facciteminfold_left_sfaccseqletrecfold_left_esfaccseq=letopenLwt_result_syntaxinmatchseq()with|Nil->returnacc|Cons(item,seq)->let*acc=facciteminfold_left_esfaccseqletfold_left_esfaccseq=letopenLwt_result_syntaxinmatchseq()with|Nil->returnacc|Cons(item,seq)->let*acc=lwt_apply2facciteminfold_left_esfaccseqletreciter_efseq=letopenResult_syntaxinmatchseq()with|Nil->return_unit|Cons(item,seq)->let*()=fiteminiter_efseqletreciter_sfseq=letopenLwt_syntaxinmatchseq()with|Nil->return_unit|Cons(item,seq)->let*()=fiteminiter_sfseqletiter_sfseq=letopenLwt_syntaxinmatchseq()with|Nil->return_unit|Cons(item,seq)->let*()=Lwt.applyfiteminiter_sfseqletreciter_esfseq=letopenLwt_result_syntaxinmatchseq()with|Nil->return_unit|Cons(item,seq)->let*()=fiteminiter_esfseqletiter_esfseq=letopenLwt_result_syntaxinmatchseq()with|Nil->return_unit|Cons(item,seq)->let*()=Lwt.applyfiteminiter_esfseqletiter_epfseq=letreciter_epfseq(acc:(unit,'error)resultLwt.tlist)=matchseq()with|Nil->Lwt_result_syntax.joinacc|Cons(item,seq)->iter_epfseq(Lwt.applyfitem::acc)initer_epfseq[]letiter_pfseq=letreciter_pfseqacc=matchseq()with|Nil->Lwt_syntax.joinacc|Cons(item,seq)->iter_pfseq(Lwt.applyfitem::acc)initer_pfseq[]letrecunfoldfa()=matchfawithNone->Nil|Some(item,a)->Cons(item,unfoldfa)