123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(* This file is free software, part of containers. See file "license" for more details. *)(** {1 Basic Functions} *)(* import standard implementations, if any *)includeSysincludeStdlibincludeFunlet[@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@)=(@@)endincludeInfixmoduleMonad(X:sigtypetend)=structtype'at=X.t->'alet[@inline]returnx_=xlet[@inline](>|=)fgx=g(fx)let[@inline](>>=)fgx=g(fx)xend[@@inline]