1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192(* This file is free software, part of containers. See file "license" for more details. *)(** {1 Basic Functions} *)(* import standard implementations, if any *)includeSysincludeStdlibincludeFunlet[@inline]and_predfgx=fx&&gxlet[@inline]or_predfgx=fx||gxlet[@inline]composefgx=g(fx)let[@inline]compose_binopfgxy=g(fx)(fy)let[@inline]curryfxy=f(x,y)let[@inline]uncurryf(x,y)=fxylet[@inline]tapfx=ignore(fx);xletlexicographicf1f2xy=letc=f1xyinifc<>0thencelsef2xyletfinally~h~f=tryletx=f()inignore(h());xwithe->ignore(h());raiseeletfinally1~hfx=tryletres=fxinignore(h());reswithe->ignore(h());raiseeletfinally2~hfxy=tryletres=fxyinignore(h());reswithe->ignore(h());raiseeletreciteratenfx=ifn<0theninvalid_arg"CCFun.iterate"elseifn=0thenxelseiterate(n-1)f(fx)let[@inline]with_return(typeret)f:ret=letexceptionEofretinletreturnx=raise_notrace(Ex)inmatchfreturnwith|res->res|exceptionEres->resmoduleInfix=struct(* default implem for some operators *)let(%>)=composelet[@inline](%)fgx=f(gx)let(let@)=(@@)let(||>)(a,b)f=fablet(|||>)(a,b,c)f=fabcendincludeInfixmoduleMonad(X:sigtypetend)=structtype'at=X.t->'alet[@inline]returnx_=xlet[@inline](>|=)fgx=g(fx)let[@inline](>>=)fgx=g(fx)xend[@@inline]