123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116openModule_typesmoduletypeSIG_MIN=sigtype_tvalreturn:'a->'atval(>>=):'at->('a->'bt)->'btendmoduletypeSIG_WITH_MAP=sigincludeSIG_MINvalmap:('a->'b)->'at->'btendmoduletypeRESULT=sigincludeMONADtypeerrorvalthrow:error->'atvalcatch:'at->(error->'at)->'atvalcontinue:'at->('a->'z)->(error->'z)->'zendmoduleOf_sig_with_map(M:SIG_WITH_MAP):MONADwithtype'at='aM.t=structincludeMlet(>=>)fga=fa>>=glet(<*>)mfm=mf>>=funf->mapfmletjoinmm=mm>>=funm->mendmoduleOf_sig_min(M:SIG_MIN):MONADwithtype'at='aM.t=structincludeMlet(>=>)fga=fa>>=gletmap(f:'a->'b)(m:'at):'bt=m>>=funa->return(fa)let(<*>)mfm=mf>>=funf->mapfmletjoinmm=mm>>=funm->mendmoduleIdentity=structincludeOf_sig_min(structtype'at='aletreturn(a:'a):'at=alet(>>=)(m:'at)(f:'a->'bt):'bt=fmend)leteval(m:'at):'a=mendmoduleResult(E:ANY)=structtypeerror=E.tincludeOf_sig_min(structtype'at=('a,error)resultletreturn(a:'a):'at=Okalet(>>=)(m:'at)(f:'a->'bt):'bt=matchmwith|Oka->fa|Errore->Erroreend)letthrow(e:error):'at=Erroreletcatch(m:'at)(f:error->'at):'at=matchmwith|Ok_->m|Errore->feletcontinue(m:'at)(f1:'a->'r)(f2:error->'r):'r=matchmwith|Oka->f1a|Errore->f2eend(* Result *)