text stringlengths 0 601k |
|---|
let class_infos sub f x = { x with ci_params = List . map ( tuple2 ( sub . typ sub ) id ) x . ci_params ; ci_expr = f x . ci_expr ; } |
let module_type_declaration sub x = let mtd_type = Option . map ( sub . module_type sub ) x . mtd_type in { x with mtd_type } |
let module_declaration sub x = let md_type = sub . module_type sub x . md_type in { x with md_type } |
let module_substitution _ x = x |
let include_infos f x = { x with incl_mod = f x . incl_mod } |
let class_type_declaration sub x = class_infos sub ( sub . class_type sub ) x |
let class_declaration sub x = class_infos sub ( sub . class_expr sub ) x |
let structure_item sub { str_desc ; str_loc ; str_env } = let str_env = sub . env sub str_env in let str_desc = match str_desc with | Tstr_eval ( exp , attrs ) -> Tstr_eval ( sub . expr sub exp , attrs ) | Tstr_value ( rec_flag , list ) -> let ( rec_flag , list ) = sub . value_bindings sub ( rec_flag , list ) in Tstr_v... |
let value_description sub x = let val_desc = sub . typ sub x . val_desc in { x with val_desc } |
let label_decl sub x = let ld_type = sub . typ sub x . ld_type in { x with ld_type } |
let constructor_args sub = function | Cstr_tuple l -> Cstr_tuple ( List . map ( sub . typ sub ) l ) | Cstr_record l -> Cstr_record ( List . map ( label_decl sub ) l ) |
let constructor_decl sub cd = let cd_args = constructor_args sub cd . cd_args in let cd_res = Option . map ( sub . typ sub ) cd . cd_res in { cd with cd_args ; cd_res } |
let type_kind sub = function | Ttype_abstract -> Ttype_abstract | Ttype_variant list -> Ttype_variant ( List . map ( constructor_decl sub ) list ) | Ttype_record list -> Ttype_record ( List . map ( label_decl sub ) list ) | Ttype_open -> Ttype_open |
let type_declaration sub x = let typ_cstrs = List . map ( tuple3 ( sub . typ sub ) ( sub . typ sub ) id ) x . typ_cstrs in let typ_kind = sub . type_kind sub x . typ_kind in let typ_manifest = Option . map ( sub . typ sub ) x . typ_manifest in let typ_params = List . map ( tuple2 ( sub . typ sub ) id ) x . typ_params i... |
let type_declarations sub ( rec_flag , list ) = ( rec_flag , List . map ( sub . type_declaration sub ) list ) |
let type_extension sub x = let tyext_params = List . map ( tuple2 ( sub . typ sub ) id ) x . tyext_params in let tyext_constructors = List . map ( sub . extension_constructor sub ) x . tyext_constructors in { x with tyext_constructors ; tyext_params } |
let type_exception sub x = let tyexn_constructor = sub . extension_constructor sub x . tyexn_constructor in { x with tyexn_constructor } |
let extension_constructor sub x = let ext_kind = match x . ext_kind with Text_decl ( ctl , cto ) -> Text_decl ( constructor_args sub ctl , Option . map ( sub . typ sub ) cto ) | Text_rebind _ as d -> d in { x with ext_kind } |
let pat sub x = let extra = function | Tpat_type _ | Tpat_unpack as d -> d | Tpat_open ( path , loc , env ) -> Tpat_open ( path , loc , sub . env sub env ) | Tpat_constraint ct -> Tpat_constraint ( sub . typ sub ct ) in let pat_env = sub . env sub x . pat_env in let pat_extra = List . map ( tuple3 extra id id ) x . pat... |
let expr sub x = let extra = function | Texp_constraint cty -> Texp_constraint ( sub . typ sub cty ) | Texp_coerce ( cty1 , cty2 ) -> Texp_coerce ( Option . map ( sub . typ sub ) cty1 , sub . typ sub cty2 ) | Texp_newtype _ as d -> d | Texp_poly cto -> Texp_poly ( Option . map ( sub . typ sub ) cto ) in let exp_extra =... |
let package_type sub x = let pack_fields = List . map ( tuple2 id ( sub . typ sub ) ) x . pack_fields in { x with pack_fields } |
let binding_op sub x = { x with bop_exp = sub . expr sub x . bop_exp } |
let signature sub x = let sig_final_env = sub . env sub x . sig_final_env in let sig_items = List . map ( sub . signature_item sub ) x . sig_items in { x with sig_items ; sig_final_env } |
let signature_item sub x = let sig_env = sub . env sub x . sig_env in let sig_desc = match x . sig_desc with | Tsig_value v -> Tsig_value ( sub . value_description sub v ) | Tsig_type ( rec_flag , list ) -> let ( rec_flag , list ) = sub . type_declarations sub ( rec_flag , list ) in Tsig_type ( rec_flag , list ) | Tsig... |
let class_description sub x = class_infos sub ( sub . class_type sub ) x |
let functor_parameter sub = function | Unit -> Unit | Named ( id , s , mtype ) -> Named ( id , s , sub . module_type sub mtype ) |
let module_type sub x = let mty_env = sub . env sub x . mty_env in let mty_desc = match x . mty_desc with | Tmty_ident _ | Tmty_alias _ as d -> d | Tmty_signature sg -> Tmty_signature ( sub . signature sub sg ) | Tmty_functor ( arg , mtype2 ) -> Tmty_functor ( functor_parameter sub arg , sub . module_type sub mtype2 ) ... |
let with_constraint sub = function | Twith_type decl -> Twith_type ( sub . type_declaration sub decl ) | Twith_typesubst decl -> Twith_typesubst ( sub . type_declaration sub decl ) | Twith_module _ | Twith_modsubst _ as d -> d |
let open_description sub od = { od with open_env = sub . env sub od . open_env } |
let open_declaration sub od = { od with open_expr = sub . module_expr sub od . open_expr ; open_env = sub . env sub od . open_env } |
let module_coercion sub = function | Tcoerce_none -> Tcoerce_none | Tcoerce_functor ( c1 , c2 ) -> Tcoerce_functor ( sub . module_coercion sub c1 , sub . module_coercion sub c2 ) | Tcoerce_alias ( env , p , c1 ) -> Tcoerce_alias ( sub . env sub env , p , sub . module_coercion sub c1 ) | Tcoerce_structure ( l1 , l2 ) ->... |
let module_expr sub x = let mod_env = sub . env sub x . mod_env in let mod_desc = match x . mod_desc with | Tmod_ident _ as d -> d | Tmod_structure st -> Tmod_structure ( sub . structure sub st ) | Tmod_functor ( arg , mexpr ) -> Tmod_functor ( functor_parameter sub arg , sub . module_expr sub mexpr ) | Tmod_apply ( me... |
let module_binding sub x = let mb_expr = sub . module_expr sub x . mb_expr in { x with mb_expr } |
let class_expr sub x = let cl_env = sub . env sub x . cl_env in let cl_desc = match x . cl_desc with | Tcl_constraint ( cl , clty , vals , meths , concrs ) -> Tcl_constraint ( sub . class_expr sub cl , Option . map ( sub . class_type sub ) clty , vals , meths , concrs ) | Tcl_structure clstr -> Tcl_structure ( sub . cl... |
let class_type sub x = let cltyp_env = sub . env sub x . cltyp_env in let cltyp_desc = match x . cltyp_desc with | Tcty_signature csg -> Tcty_signature ( sub . class_signature sub csg ) | Tcty_constr ( path , lid , list ) -> Tcty_constr ( path , lid , List . map ( sub . typ sub ) list ) | Tcty_arrow ( label , ct , cl )... |
let class_signature sub x = let csig_self = sub . typ sub x . csig_self in let csig_fields = List . map ( sub . class_type_field sub ) x . csig_fields in { x with csig_self ; csig_fields } |
let class_type_field sub x = let ctf_desc = match x . ctf_desc with | Tctf_inherit ct -> Tctf_inherit ( sub . class_type sub ct ) | Tctf_val ( s , mut , virt , ct ) -> Tctf_val ( s , mut , virt , sub . typ sub ct ) | Tctf_method ( s , priv , virt , ct ) -> Tctf_method ( s , priv , virt , sub . typ sub ct ) | Tctf_const... |
let typ sub x = let ctyp_env = sub . env sub x . ctyp_env in let ctyp_desc = match x . ctyp_desc with | Ttyp_any | Ttyp_var _ as d -> d | Ttyp_arrow ( label , ct1 , ct2 ) -> Ttyp_arrow ( label , sub . typ sub ct1 , sub . typ sub ct2 ) | Ttyp_tuple list -> Ttyp_tuple ( List . map ( sub . typ sub ) list ) | Ttyp_constr (... |
let class_structure sub x = let cstr_self = sub . pat sub x . cstr_self in let cstr_fields = List . map ( sub . class_field sub ) x . cstr_fields in { x with cstr_self ; cstr_fields } |
let row_field sub x = let rf_desc = match x . rf_desc with | Ttag ( label , b , list ) -> Ttag ( label , b , List . map ( sub . typ sub ) list ) | Tinherit ct -> Tinherit ( sub . typ sub ct ) in { x with rf_desc ; } |
let object_field sub x = let of_desc = match x . of_desc with | OTtag ( label , ct ) -> OTtag ( label , ( sub . typ sub ct ) ) | OTinherit ct -> OTinherit ( sub . typ sub ct ) in { x with of_desc ; } |
let class_field_kind sub = function | Tcfk_virtual ct -> Tcfk_virtual ( sub . typ sub ct ) | Tcfk_concrete ( ovf , e ) -> Tcfk_concrete ( ovf , sub . expr sub e ) |
let class_field sub x = let cf_desc = match x . cf_desc with | Tcf_inherit ( ovf , cl , super , vals , meths ) -> Tcf_inherit ( ovf , sub . class_expr sub cl , super , vals , meths ) | Tcf_constraint ( cty , cty ' ) -> Tcf_constraint ( sub . typ sub cty , sub . typ sub cty ' ) | Tcf_val ( s , mf , id , k , b ) -> Tcf_v... |
let value_bindings sub ( rec_flag , list ) = ( rec_flag , List . map ( sub . value_binding sub ) list ) |
let cases sub l = List . map ( sub . case sub ) l |
let case sub { c_lhs ; c_guard ; c_rhs } = { c_lhs = sub . pat sub c_lhs ; c_guard = Option . map ( sub . expr sub ) c_guard ; c_rhs = sub . expr sub c_rhs ; } |
let value_binding sub x = let vb_pat = sub . pat sub x . vb_pat in let vb_expr = sub . expr sub x . vb_expr in { x with vb_pat ; vb_expr } |
let env _sub x = x |
let default = { binding_op ; case ; cases ; class_declaration ; class_description ; class_expr ; class_field ; class_signature ; class_structure ; class_type ; class_type_declaration ; class_type_field ; env ; expr ; extension_constructor ; module_binding ; module_coercion ; module_declaration ; module_substitution ; m... |
let print_variant_field fmt ld = pp fmt " % s % a :% a " ( if ld . ld_mut = Mutable then " mutable " else " " ) Ident . pp ( fst ld . ld_field ) print_ty ( snd ld . ld_field ) |
let print_rec_field fmt ld = pp fmt " % s % a :% a " ( if ld . ld_mut = Mutable then " mutable " else " " ) Ident . pp ld . ld_field . ls_name print_ty ( Stdlib . Option . get ld . ld_field . ls_value ) |
let print_label_decl_list print_field fmt fields = pp fmt " { % a } " ( list ~ sep : semi print_field ) fields |
let print_type_kind fmt = function | Pty_abstract -> ( ) | Pty_variant cpl -> let print_args cs fmt = function | [ ] -> list ~ sep : star print_ty fmt cs . ls_args | ld -> print_label_decl_list print_variant_field fmt ld in let print_constructor fmt { cd_cs ; cd_ld ; _ } = pp fmt " [ @% a of % a @\ n [ @< h 2 >% a ] ] ... |
let print_type_spec fmt { ty_ephemeral ; ty_fields ; ty_invariants ; _ } = if ( not ty_ephemeral ) && ty_fields = [ ] && ty_invariants = [ ] then ( ) else let print_ephemeral f e = if e then pp f " [ @ ephemeral ] " @ in let print_term f t = pp f " [ @% a ] " @ print_term t in let print_field f ( ls , mut ) = pp f " [ ... |
let print_type_declaration fmt td = let print_param fmt ( tv , ( v , i ) ) = pp fmt " % s % s % a " ( type_variance v ) ( type_injectivity i ) print_tv tv in let print_params fmt = function | [ ] -> ( ) | [ p ] -> pp fmt " % a " print_param p | ps -> pp fmt " ( % a ) " ( list ~ sep : comma print_param ) ps in let print... |
let print_lb_arg fmt = function | Lunit -> pp fmt " ( ) " | Lnone vs -> print_vs fmt vs | Loptional vs -> pp fmt " ?% a " print_vs vs | Lnamed vs -> pp fmt " ~% a " print_vs vs | Lghost vs -> pp fmt " [ % a : % a ] " print_vs vs print_ty vs . vs_ty |
let print_xposts f xposts = if xposts = [ ] then ( ) else let print xs f ( p , t ) = pp f " [ [ @@% a @ % a ] @ -> [ @% a ] ] " @@ print_xs xs print_pattern p print_term t in let print_xpost ( xs , tl ) = match tl with | [ ] -> pp f " @\ n [ @ raises % a ] " @ print_xs xs | tl -> list ~ first ( : newline ++ const strin... |
let print_vd_spec val_id fmt spec = let print_term f t = pp f " [ @% a ] " @ print_term t in let print_diverges f d = if not d then ( ) else pp f " @\ n [ @ diverges ] " @ in match spec with | None -> ( ) | Some vs -> pp fmt " " ( list ~ sep : comma print_lb_arg ) vs . sp_ret ( if vs . sp_ret = [ ] then " " else " " ) ... |
let print_param f p = pp f " ( % a :% a ) " Ident . pp p . vs_name print_ty p . vs_ty |
let print_function f x = let func_pred = if x . fun_ls . ls_value = None then " predicate " else " function " in let print_term f t = pp f " [ @% a ] " @ print_term t in let print_term f t = pp f " [ @% a ] " @ print_term t in let func_spec f x = pp f " % a % a % a % a " ( fun f _ -> if x . fun_coer then pp f " @\ ncoe... |
let print_extension_constructor ctxt f x = match x . ext_kind with | Pext_decl ( _ , _ , _ ) -> print_xs f x . ext_xs | Pext_rebind li -> pp f " % a % a ; ; @=@% a " Ident . pp x . ext_xs . xs_ident ( attributes ctxt ) x . ext_attributes longident_loc li |
let exception_declaration ctxt f x = pp f " [ @< hov2 > exception @ % a ] @% a " ( print_extension_constructor ctxt ) x . exn_constructor ( item_attributes ctxt ) x . exn_attributes |
let rec print_signature_item f x = let print_val f vd = let intro = if vd . vd_prim = [ ] then " val " else " external " in pp f " [ @% s @ % a @ :@ % a % a % a ] @@\ n [ @< h4 >% a ] " @ intro Ident . pp vd . vd_name core_type vd . vd_type ( fun f x -> if x . vd_prim <> [ ] then pp f " @ =@ % a " ( list constant_strin... |
module type State = sig type state end |
module type S = sig type state type b type ' a i type ' a o type reset = unit -> state type cycle = state -> b i -> state * b o * b o type task_req type t = private { vreq : task_req Lwt_mvar . t ; vresp : ( b o * b o ) Lwt_mvar . t ; children : t list ; inputs : b option i ; log : log option ; } and log = t -> unit Lw... |
module Make ( State : State ) ( B : Comb . S ) ( I : Interface . S ) ( O : Interface . S ) = struct include State open Lwt . Infix type b = B . t type ' a i = ' a I . t type ' a o = ' a O . t type reset = unit -> state type cycle = state -> b i -> state * b o * b o type task_req = | Cycle of b option I . t | Finish typ... |
let get_byte i b = 255 land ( i lsr ( 8 * b ) ) |
let get_byte32 i b = 255 land ( Int32 . to_int ( Int32 . shift_right i ( 8 * b ) ) ) |
let get_byte64 i b = 255 land ( Int64 . to_int ( Int64 . shift_right i ( 8 * b ) ) ) |
let comp_int ( b : bytes ) n = let s = ref 0l in let sb = 32 - 8 * n in for i = 0 to ( n - 1 ) do s := Int32 . logor ! s ( Int32 . shift_left ( Int32 . of_int ( int_of_char ( Bytes . get b i ) ) ) ( 8 ( * n - 1 - i ) ) ) done ; Int32 . shift_right ( Int32 . shift_left ! s sb ) sb |
let comp_int64 ( b : bytes ) n = let s = ref 0L in for i = 0 to ( n - 1 ) do s := Int64 . logor ! s ( Int64 . shift_left ( Int64 . of_int ( int_of_char ( Bytes . get b i ) ) ) ( 8 ( * n - 1 - i ) ) ) done ; ! s |
let version_1 = 0x80010000l inherit P . t trans val ibyte = Bytes . create 8 method writeBool b = ibyte . [ 0 ] <- char_of_int ( if b then 1 else 0 ) ; trans # write ibyte 0 1 method writeByte i = ibyte . [ 0 ] <- char_of_int ( get_byte i 0 ) ; trans # write ibyte 0 1 method writeI16 i = let gb = get_byte i in ibyte . ... |
type ( ' a , ' b ) t = Empty | Node of ( ' a , ' b ) t * ' a * ' b * ( ' a , ' b ) t * int |
let height = function Empty -> 0 | Node ( _ , _ , _ , _ , h ) -> h |
let create l x d r = let hl = height l and hr = height r in Node ( l , x , d , r , ( if hl >= hr then hl + 1 else hr + 1 ) ) |
let bal l x d r = let hl = height l and hr = height r in if hl > hr + 1 then match l with | Node ( ll , lv , ld , lr , _ ) when height ll >= height lr -> create ll lv ld ( create lr x d r ) | Node ( ll , lv , ld , Node ( lrl , lrv , lrd , lrr , _ ) , _ ) -> create ( create ll lv ld lrl ) lrv lrd ( create lrr x d r ) | ... |
let rec add x data = function Empty -> Node ( Empty , x , data , Empty , 1 ) | Node ( l , v , d , r , h ) -> let c = compare x v in if c = 0 then Node ( l , x , data , r , h ) else if c < 0 then bal ( add x data l ) v d r else bal l v d ( add x data r ) |
let rec find x = function Empty -> raise Not_found | Node ( l , v , d , r , _ ) -> let c = compare x v in if c = 0 then d else find x ( if c < 0 then l else r ) |
let rec mem x = function Empty -> false | Node ( l , v , d , r , _ ) -> let c = compare x v in c = 0 || mem x ( if c < 0 then l else r ) |
let rec merge t1 t2 = match ( t1 , t2 ) with ( Empty , t ) -> t | ( t , Empty ) -> t | ( Node ( l1 , v1 , d1 , r1 , h1 ) , Node ( l2 , v2 , d2 , r2 , h2 ) ) -> bal l1 v1 d1 ( bal ( merge r1 l2 ) v2 d2 r2 ) |
let rec remove x = function Empty -> Empty | Node ( l , v , d , r , h ) -> let c = compare x v in if c = 0 then merge l r else if c < 0 then bal ( remove x l ) v d r else bal l v d ( remove x r ) |
let rec iter f = function Empty -> ( ) | Node ( l , v , d , r , _ ) -> iter f l ; f v d ; iter f r |
let print print_key print_data ppf tbl = let print_tbl ppf tbl = iter ( fun k d -> fprintf ppf " [ @< 2 >% a ->@ % a ; ] @@ " print_key k print_data d ) tbl in fprintf ppf " [ @< hv 2 [ [ >% a ] ] ] " @ print_tbl tbl |
let crc_tbl = Array . init 128 ( fun i -> let rec loop j sum = if j < 0 then sum else if i land ( 1 lsl j ) j <> 0 then loop ( j - 1 ) 1 ( sum lxor ( poly lsr j ) j ) j else loop ( j - 1 ) 1 sum in loop ( 7 - 1 ) 1 0 ) 0 |
let byte3 n = n lsr 24 land 127 |
let byte2 n = n lsr 16 land 255 |
let byte1 n = n lsr 8 land 255 |
let byte0 n = n land 255 |
let ( lsl ) lsl x n = if n >= Sys . word_size then 0 else if n <= ~- Sys . word_size then 0 else if n < 0 then x lsr ( ~- n ) n else x lsl n |
type ' a tbl = ' a array array array array |
type ' a t = ' a tbl |
type ' a tagged = Tag of ' a * int |
let untag ( Tag ( a , _ ) _ ) _ = a |
let id ( Tag ( _ , n ) n ) n = n |
let get tbl n = let lev = Array . unsafe_get tbl ( byte3 n ) n in let lev = Array . unsafe_get lev ( byte2 n ) n in let lev = Array . unsafe_get lev ( byte1 n ) n in Array . unsafe_get lev ( byte0 n ) n |
module type NodeType = sig type elt type t val level : int val make : elt -> t tagged val of_map : int -> elt -> elt IMap . t -> t tagged val of_set : int -> elt -> ISet . t -> elt -> t tagged end |
module MakeNode ( Sub : NodeType ) NodeType = struct type elt = Sub . elt type node = Sub . t array type t = node let level = Sub . level + 1 module NodeHash = struct type t = node tagged let equal x y = let a = untag x in let b = untag y in let rec loop i = if i < 0 then true else if a ( . i ) i == b ( . i ) i then lo... |
module MakeTbl ( Lev0 : NodeType ) NodeType = struct module Lev1 = MakeNode ( Lev0 ) Lev0 module Lev2 = MakeNode ( Lev1 ) Lev1 module Lev3 = MakeNode ( Lev2 ) Lev2 include Lev3 let get = get let of_map def m = untag ( Lev3 . of_map 0 def m ) m end |
module ArrayLeaf ( H : Hashtbl . HashedType ) HashedType = struct type elt = H . t type t = elt array type node = t let level = 0 module NodeHash = struct type t = node tagged let equal x y = let a = untag x in let b = untag y in let rec loop i = if i >= 255 then true else if H . equal a ( . i ) i b ( . i ) i then loop... |
module type Type = sig type elt type t = elt tbl val get : elt tbl -> int -> elt val of_map : elt -> elt IMap . t -> elt tbl end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.