Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file standard.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214(**************************************************************************)(* *)(* OCaml *)(* *)(* Simon Cruanes *)(* *)(* Copyright 2017 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)moduleMake2(Mon:Sigs2.MONAD2):Sigs2.SEQMON2TRAVERSORSwithtype('a,'e)mon:=('a,'e)Mon.twithtype('a,'e)callermon:=('a,'e)Mon.twithtype('a,'e)t:='aStdlib.Seq.t=structletreturn=Mon.returnlet(let*)=Mon.bindletrecequaleqxsys=(* TODO: support ( and* ) with Beeg.join *)letxs=xs()inletys=ys()inmatchxs,yswith|Stdlib.Seq.Nil,Stdlib.Seq.Nil->returntrue|Cons(x,xs),Cons(y,ys)->let*e=eqxyinifethenequaleqxsyselsereturnfalse|Nil,Cons(_,_)|Cons(_,_),Nil->returnfalseletreccomparecmpxsys=letxs=xs()inletys=ys()inmatchxs,yswith|Stdlib.Seq.Nil,Stdlib.Seq.Nil->return0|Cons(x,xs),Cons(y,ys)->let*c=cmpxyinifc<>0thenreturncelsecomparecmpxsys|Nil,Cons(_,_)->return(-1)|Cons(_,_),Nil->return(+1)letrecfold_leftfaccseq=letn=seq()inmatchnwith|Stdlib.Seq.Nil->returnacc|Cons(x,next)->let*acc=faccxinfold_leftfaccnextletreciterfseq=letn=seq()inmatchnwith|Stdlib.Seq.Nil->return()|Cons(x,next)->let*()=fxiniterfnextletreciteri_auxfixs=letn=xs()inmatchnwith|Stdlib.Seq.Nil->return()|Cons(x,xs)->let*()=fixiniteri_auxf(i+1)xslet[@inline]iterifxs=iteri_auxf0xsletrecfold_lefti_auxfaccuixs=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returnaccu|Cons(x,xs)->let*accu=faccuixinfold_lefti_auxfaccu(i+1)xslet[@inline]fold_leftifaccuxs=fold_lefti_auxfaccu0xsletrecfor_allpxs=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returntrue|Cons(x,xs)->let*b=pxinifbthenfor_allpxselsereturnfalseletrecexistspxs=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returnfalse|Cons(x,xs)->let*b=pxinifbthenreturntrueelseexistspxsletrecfindpxs=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returnNone|Cons(x,xs)->let*b=pxinifbthenreturn(Somex)elsefindpxsletrecfind_mapfxs=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returnNone|Cons(x,xs)->let*o=fxinmatchowith|None->find_mapfxs|Some_asresult->returnresultletreciter2fxsys=letn=xs()inmatchnwith|Stdlib.Seq.Nil->return()|Cons(x,xs)->letn=ys()inmatchnwith|Stdlib.Seq.Nil->return()|Cons(y,ys)->let*()=fxyiniter2fxsysletrecfold_left2faccuxsys=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returnaccu|Cons(x,xs)->letn=ys()inmatchnwith|Stdlib.Seq.Nil->returnaccu|Cons(y,ys)->let*accu=faccuxyinfold_left2faccuxsysletrecfor_all2fxsys=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returntrue|Cons(x,xs)->letn=ys()inmatchnwith|Stdlib.Seq.Nil->returntrue|Cons(y,ys)->let*b=fxyinifbthenfor_all2fxsyselsereturnfalseletrecexists2fxsys=letn=xs()inmatchnwith|Stdlib.Seq.Nil->returnfalse|Cons(x,xs)->letn=ys()inmatchnwith|Stdlib.Seq.Nil->returnfalse|Cons(y,ys)->let*b=fxyinifbthenreturntrueelseexists2fxsysendmoduleMake1(Mon:Sigs1.MONAD1):Sigs1.SEQMON1TRAVERSORSwithtype'amon:='aMon.twithtype'acallermon:='aMon.twithtype'at:='aStdlib.Seq.t=Make2(structtype('a,'e)t='aMon.tletreturn=Mon.returnletbind=Mon.bindend)