123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289moduleO=BatOrdexceptionInvalid_boundstype'abound_t=[`oof'a|`cof'a|`u]type('a,'b)bounding_f=bounds:('abound_t*'abound_t)->'a->'bletret_somex=Somexletret_none_=Noneletconsta_=aexternalidentity:'a->'a="%identity"letbounding_of_ord~default_low~default_highconvord=fun~(bounds:'abound_t*'abound_t)->matchboundswith|`cl,`cu->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_->default_low|_,O.Gt->default_high|O.Eq,_|_,O.Eq|O.Gt,_->convxend|`u,`cu->beginfunx->matchordxuwith|O.Gt->default_high|O.Eq|O.Lt->convxend|`cl,`u->beginfunx->matchordxlwith|O.Lt->default_low|O.Gt|O.Eq->convxend|`u,`u->conv|`ol,`ou->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_|O.Eq,_->default_low|_,O.Gt|_,O.Eq->default_high|O.Gt,_->convxend|`u,`ou->beginfunx->matchordxuwith|O.Gt|O.Eq->default_high|O.Lt->convxend|`ol,`u->beginfunx->matchordxlwith|O.Lt|O.Eq->default_low|O.Gt->convxend|`cl,`ou->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_->default_low|_,O.Gt|_,O.Eq->default_high|O.Eq,_|O.Gt,_->convxend|`ol,`cu->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_|O.Eq,_->default_low|_,O.Gt->default_high|_,O.Eq|O.Gt,_->convxend(*$T bounding_of_ord
bounding_of_ord ~default_low:None ~default_high:None (fun x -> Some x) BatInt.ord ~bounds:(`u, `u) 0 = Some 0
bounding_of_ord ~default_low:None ~default_high:None (fun x -> Some x) BatInt.ord ~bounds:(`c 0, `u) 0 = Some 0
bounding_of_ord ~default_low:None ~default_high:None (fun x -> Some x) BatInt.ord ~bounds:(`o 0, `u) 0 = None
bounding_of_ord ~default_low:None ~default_high:None (fun x -> Some x) BatInt.ord ~bounds:(`u, `c 0) 0 = Some 0
bounding_of_ord ~default_low:None ~default_high:None (fun x -> Some x) BatInt.ord ~bounds:(`u, `o 0) 0 = None
bounding_of_ord ~default_low:(Some ~-10) ~default_high:(Some 10) (fun x -> Some x) BatInt.ord ~bounds:(`u, `u) 0 = Some 0
bounding_of_ord ~default_low:(Some ~-10) ~default_high:(Some 10) (fun x -> Some x) BatInt.ord ~bounds:(`c 0, `u) 0 = Some 0
bounding_of_ord ~default_low:(Some ~-10) ~default_high:(Some 10) (fun x -> Some x) BatInt.ord ~bounds:(`o 0, `u) 0 = Some ~-10
bounding_of_ord ~default_low:(Some ~-10) ~default_high:(Some 10) (fun x -> Some x) BatInt.ord ~bounds:(`u, `c 0) 0 = Some 0
bounding_of_ord ~default_low:(Some ~-10) ~default_high:(Some 10) (fun x -> Some x) BatInt.ord ~bounds:(`u, `o 0) 0 = Some 10
*)letbounding_of_ord_chain~low~highconvord=fun~(bounds:'abound_t*'abound_t)->matchboundswith(* Closed bounds (inclusive) *)|`cl,`cu->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_->lowx|_,O.Gt->highx|O.Eq,_|_,O.Eq|O.Gt,_->convxend|`u,`cu->beginfunx->matchordxuwith|O.Gt->highx|O.Eq|O.Lt->convxend|`cl,`u->beginfunx->matchordxlwith|O.Lt->lowx|O.Gt|O.Eq->convxend(* Open bounds (exclusive) *)|`ol,`ou->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_|O.Eq,_->lowx|_,O.Gt|_,O.Eq->highx|O.Gt,_->convxend|`u,`ou->beginfunx->matchordxuwith|O.Gt|O.Eq->highx|O.Lt->convxend|`ol,`u->beginfunx->matchordxlwith|O.Lt|O.Eq->lowx|O.Gt->convxend(* Mixed open and closed bounds *)|`cl,`ou->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_->lowx|_,O.Gt|_,O.Eq->highx|O.Eq,_|O.Gt,_->convxend|`ol,`cu->beginifordlu=O.GtthenraiseInvalid_bounds;funx->matchordxl,ordxuwith|O.Lt,_|O.Eq,_->lowx|_,O.Gt->highx|_,O.Eq|O.Gt,_->convxend|`u,`u->conv(*$T bounding_of_ord_chain as f
f (fun x -> Some x) BatInt.ord ~low:(const None) ~high:(const None) ~bounds:(`u, `u) 0 = Some 0
f (fun x -> Some x) BatInt.ord ~low:(const None) ~high:(const None) ~bounds:(`c 0, `u) 0 = Some 0
f (fun x -> Some x) BatInt.ord ~low:(const None) ~high:(const None) ~bounds:(`o 0, `u) 0 = None
f (fun x -> Some x) BatInt.ord ~low:(const None) ~high:(const None) ~bounds:(`u, `c 0) 0 = Some 0
f (fun x -> Some x) BatInt.ord ~low:(const None) ~high:(const None) ~bounds:(`u, `o 0) 0 = None
f (fun x -> Some x) ~low:(fun _x -> Some ~-10) ~high:(fun _x -> Some 10) BatInt.ord ~bounds:(`u, `u) 0 = Some 0
f (fun x -> Some x) ~low:(fun _x -> Some ~-10) ~high:(fun _x -> Some 10) BatInt.ord ~bounds:(`c 0, `u) 0 = Some 0
f (fun x -> Some x) ~low:(fun _x -> Some ~-10) ~high:(fun _x -> Some 10) BatInt.ord ~bounds:(`o 0, `u) 0 = Some ~-10
f (fun x -> Some x) ~low:(fun _x -> Some ~-10) ~high:(fun _x -> Some 10) BatInt.ord ~bounds:(`u, `c 0) 0 = Some 0
f (fun x -> Some x) ~low:(fun _x -> Some ~-10) ~high:(fun _x -> Some 10) BatInt.ord ~bounds:(`u, `o 0) 0 = Some 10
*)letsaturate_of_ord~(bounds:'abound_t*'abound_t)ord=matchboundswith|`ol,`oh|`cl,`ch|`ol,`ch|`cl,`oh->bounding_of_ord_chain~low:(constl)~high:(consth)identityord~bounds|`u,`oh|`u,`ch->bounding_of_ord_chain~low:identity~high:(consth)identityord~bounds|`ol,`u|`cl,`u->bounding_of_ord_chain~low:(constl)~high:identityidentityord~bounds|`u,`u->bounding_of_ord_chain~low:identity~high:identityidentityord~boundsletopt_of_ord~(bounds:'abound_t*'abound_t)ord=bounding_of_ord_chain~low:ret_none~high:ret_noneret_someord~boundsmoduletypeBoundedType=sigtypebase_ttypetvalbounds:base_tbound_t*base_tbound_tvalbounded:(base_t,t)bounding_fvalbase_of_t:t->base_toptionvalbase_of_t_exn:t->base_tendmoduletypeBoundedNumericType=sigincludeBoundedTypemoduleInfix:BatNumber.Infixwithtypebat__infix_t:=base_tendmoduletypeS=sigtypebase_utypeutypet=privateuvalbounds:base_ubound_t*base_ubound_tvalmake:base_u->texternalextract:t->u="%identity"valmap:(base_u->base_u)->t->toptionvalmap2:(base_u->base_u->base_u)->t->t->toptionvalmap_exn:(base_u->base_u)->t->tvalmap2_exn:(base_u->base_u->base_u)->t->t->tendmoduletypeNumericSig=sigincludeSval(+):t->base_u->tval(-):t->base_u->tval(*):t->base_u->tval(/):t->base_u->tval(+:):t->t->tval(-:):t->t->tval(*:):t->t->tval(/:):t->t->tendmoduleMake(M:BoundedType):(Swithtypebase_u=M.base_twithtypeu=M.twithtypet=privateM.t)=structincludeMtypebase_u=base_ttypeu=tletmake=bounded~boundsexternalextract:t->u="%identity"letmapfx=BatOption.mapmake(BatOption.mapf(base_of_tx))letmap2fxy=matchbase_of_tx,base_of_tywith|Somebx,Someby->Some(make(fbxby))|None,Some_|Some_,None|None,None->Noneletmap_exnfx=make(f(base_of_t_exnx))letmap2_exnfxy=letbx=base_of_t_exnxinletby=base_of_t_exnyinmake(fbxby)endmoduleMakeNumeric(M:BoundedNumericType)=structincludeMake(M)moduleI=M.Infixlet(+)ab=map_exn(I.(+)b)alet(-)ab=map_exn(I.(-)b)alet(*)ab=map_exn(I.(*)b)alet(/)ab=map_exn(I.(/)b)alet(+:)=map2_exnI.(+)let(-:)=map2_exnI.(-)let(*:)=map2_exnI.(*)let(/:)=map2_exnI.(/)end