123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Nomadic Labs, <contact@nomadic-labs.com> *)(* Copyright (c) 2023 Functori, <contact@functori.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. *)(* *)(*****************************************************************************)(** See documentation of the interface below in the mli file. *)type('state,'a)t='state->'state*'atype('state,'pass,'fail)check=('state,[`Passof'pass|`Failof'fail])tmoduletypeS=sigvalbind:('state,'a)t->('a->('state,'b)t)->('state,'b)tvalget:('state->'a)->('a->('state,'b)t)->('state,'b)tvalreturn:'a->('state,'a)tvalcheck:('state,'pass,'fail)check->('pass->('state,'fail)t)->('state,'fail)tvalreturn_pass:'pass->('state,'pass,'fail)checkvalreturn_fail:'fail->('state,'pass,'fail)checkmoduleSyntax:sigval(let*):('state,'a)t->('a->('state,'b)t)->('state,'b)tval(let*?):('state,'pass,'fail)check->('pass->('state,'fail)t)->('state,'fail)tval(let*!):('state->'a)->('a->('state,'b)t)->('state,'b)tvalreturn:'a->('state,'a)tvalpass:'pass->('state,'pass,'fail)checkvalunit:('state,unit,'fail)checkvalfail:'fail->('state,'a,'fail)checkendendmoduleM:S=structletbindmfstate=letstate,res=mstateinfresstateletgetpfstate=letres=pstateinfresstateletreturnxstate=(state,x)letcheckcf=bindc(function`Passres->fres|`Failoutput->returnoutput)letreturn_passx=`Passx|>returnletreturn_failx=`Failx|>returnmoduleSyntax=structlet(let*)=bindlet(let*?)=checklet(let*!)=getletreturn=returnletpass=return_passletunitstate=pass()stateletfail=return_failendend