123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)moduleMake(Trace:Traced_sigs.Trace.S):Traced_sigs.Monad.Swithtype'errortrace='errorTrace.trace=structincludeBare_structs.Monadtype'errortrace='errorTrace.tracemoduleTraced_result_syntax=structincludeResult_syntaxlet(fail[@ocaml.inline"always"])=fune->fail(Trace.makee)letrecjoin_errorstrace_acc=function|Ok_::ts->join_errorstrace_accts|Errortrace::ts->join_errors(Trace.conptrace_acctrace)ts|[]->Errortrace_accletrecjoin=function|[]->Result_syntax.return_unit|Ok()::ts->joints|Errortrace::ts->join_errorstracetsletallts=letrecauxacc=function|[]->Ok(Stdlib.List.revacc)|Okv::ts->aux(v::acc)ts|Errortrace::ts->join_errorstracetsinaux[]tsletbothab=match(a,b)with|Oka,Okb->Ok(a,b)|Errorerr,Ok_|Ok_,Errorerr->Errorerr|Errorerra,Errorerrb->Error(Trace.conperraerrb)let(and*)=bothlet(and+)=bothendmoduleLwt_traced_result_syntax=structincludeLwt_result_syntaxlet(fail[@ocaml.inline"always"])=fune->fail(Trace.makee)letjoints=letopenLwt_syntaxinlet+ps=alltsinTraced_result_syntax.joinpsletallts=letopenLwt_syntaxinlet+ps=alltsinTraced_result_syntax.allpsletbothab=letopenLwt_syntaxinlet+a,b=bothabinTraced_result_syntax.bothablet(and*)=bothlet(and+)=bothendend