Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file applicative.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159open!ImportincludeApplicative_intf(** This module serves mostly as a partial check that [S2] and [S] are in sync, but
actually calling it is occasionally useful. *)moduleS_to_S2(X:S):(S2withtype('a,'e)t='aX.t)=structtype('a,'e)t='aX.tinclude(X:Swithtype'at:='aX.t)endmoduleS2_to_S(X:S2):(Swithtype'at=('a,unit)X.t)=structtype'at=('a,unit)X.tinclude(X:S2withtype('a,'e)t:=('a,'e)X.t)endmoduleArgs_to_Args2(X:Args):(Args2withtype('a,'e)arg='aX.argwithtype('f,'r,'e)t=('f,'r)X.t)=structtype('a,'e)arg='aX.argtype('f,'r,'e)t=('f,'r)X.tinclude(X:Argswithtype'aarg:='aX.argandtype('f,'r)t:=('f,'r)X.t)end[@@warning"-3"]moduleMake2(X:Basic2):S2withtype('a,'e)t:=('a,'e)X.t=structincludeXlet(<*>)=applyletderived_mapt~f=returnf<*>tletmap=matchX.mapwith|`Define_using_apply->derived_map|`Customx->xlet(>>|)tf=mapt~fletmap2tatb~f=map~fta<*>tbletmap3tatbtc~f=map~fta<*>tb<*>tcletallts=List.fold_rightts~init:(return[])~f:(map2~f:(funxxs->x::xs))letbothtatb=map2tatb~f:(funab->(a,b))let(*>)uv=return(fun()y->y)<*>u<*>vlet(<*)uv=return(funx()->x)<*>u<*>vletall_unitts=List.foldts~init:(return())~f:(*>)letall_ignore=all_unitmoduleApplicative_infix=structlet(<*>)=(<*>)let(*>)=(*>)let(<*)=(<*)let(>>|)=(>>|)endendmoduleMake(X:Basic):Swithtype'at:='aX.t=Make2(structtype('a,'e)t='aX.tinclude(X:Basicwithtype'at:='aX.t)end)moduleMake_let_syntax(X:For_let_syntax)(Intf:sigmoduletypeSend)(Impl:Intf.S)=structmoduleLet_syntax=structincludeXmoduleLet_syntax=structincludeXmoduleOpen_on_rhs=ImplendendendmoduleMake2_using_map2(X:Basic2_using_map2)=Make2(structincludeXletapplytftx=map2tftx~f:(funfx->fx)letmap=matchmapwith|`Custommap->`Custommap|`Define_using_map2->`Define_using_applyend)moduleMake_using_map2(X:Basic_using_map2):Swithtype'at:='aX.t=Make2_using_map2(structtype('a,'e)t='aX.tinclude(X:Basic_using_map2withtype'at:='aX.t)end)moduleMake_args'(X:S2)=structopenXtype('f,'r,'e)t_={applyN:('f,'e)X.t->('r,'e)X.t}letnil={applyN=Fn.id}letconsargt={applyN=fund->t.applyN(applydarg)}letstept~f={applyN=fund->t.applyN(map~fd)}let(@>)=consletapplyNargt=t.applyNargletmapN~ft=applyN(returnf)tendmoduleMake_args(X:S):Argswithtype'aarg:='aX.t=structincludeMake_args'(structtype('a,'e)t='aX.tinclude(X:Swithtype'at:='aX.t)end)type('f,'r)t=('f,'r,unit)t_end[@@warning"-3"]moduleMake_args2(X:S2):Args2withtype('a,'e)arg:=('a,'e)X.t=structincludeMake_args'(X)type('f,'r,'e)t=('f,'r,'e)t_end[@@warning"-3"]moduleOf_monad(M:Monad.S):Swithtype'at:='aM.t=Make(structtype'at='aM.tletreturn=M.returnletapplymfmx=M.bindmf~f:(funf->M.mapmx~f)letmap=`CustomM.mapend)moduleCompose(F:S)(G:S):Swithtype'at='aF.tG.t=structtype'at='aF.tG.tincludeMake(structtypenonrec'at='atletreturna=G.return(F.returna)letapplytftx=G.apply(G.map~f:F.applytf)txletcustom_mapt~f=G.map~f:(F.map~f)tletmap=`Customcustom_mapend)endmodulePair(F:S)(G:S):Swithtype'at='aF.t*'aG.t=structtype'at='aF.t*'aG.tincludeMake(structtypenonrec'at='atletreturna=(F.returna,G.returna)letapplytftx=(F.apply(fsttf)(fsttx),G.apply(sndtf)(sndtx))letcustom_mapt~f=(F.map~f(fstt),G.map~f(sndt))letmap=`Customcustom_mapend)end