12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485(* 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)moduleInfix=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]