text stringlengths 0 601k |
|---|
type enum_mixed = | Enum_int_0 | Enum_int_1 | Enum_float_0_1 | Enum_float_1_1 | Enum_number_other of int | Enum_string_foo | Enum_string_bar | Enum_string_other of string | Enum_bool_true | Enum_bool_false |
let rec enum_mixed_of_js : Ojs . t -> enum_mixed = fun ( x40 : Ojs . t ) t -> let x41 = x40 in match Ojs . type_of x41 with | " number " -> ( match Ojs . float_of_js x41 with | 0 . 1 -> Enum_float_0_1 | 1 . 1 -> Enum_float_1_1 | _ -> ( match Ojs . int_of_js x41 with | 0 -> Enum_int_0 | 1 -> Enum_int_1 | x42 -> Enum_num... |
type enum_mixed_partial_bool = | Enum_int_0 | Enum_int_1 | Enum_float_0_1 | Enum_float_1_1 | Enum_number_other of float | Enum_string_foo | Enum_string_bar | Enum_string_other of string | Enum_bool_true |
let rec enum_mixed_partial_bool_of_js : Ojs . t -> enum_mixed_partial_bool = fun ( x47 : Ojs . t ) t -> let x48 = x47 in match Ojs . type_of x48 with | " number " -> ( match Ojs . float_of_js x48 with | 0 . 1 -> Enum_float_0_1 | 1 . 1 -> Enum_float_1_1 | x49 -> ( match Ojs . int_of_js x48 with | 0 -> Enum_int_0 | 1 -> ... |
type enum_mixed_partial_bool2 = | Enum_int_0 | Enum_int_1 | Enum_float_0_1 | Enum_float_1_1 | Enum_number_other of float | Enum_string_foo | Enum_string_bar | Enum_string_other of string | Enum_bool_true | Enum_bool_other of bool |
let rec enum_mixed_partial_bool2_of_js : Ojs . t -> enum_mixed_partial_bool2 = fun ( x55 : Ojs . t ) t -> let x56 = x55 in match Ojs . type_of x56 with | " number " -> ( match Ojs . float_of_js x56 with | 0 . 1 -> Enum_float_0_1 | 1 . 1 -> Enum_float_1_1 | x57 -> ( match Ojs . int_of_js x56 with | 0 -> Enum_int_0 | 1 -... |
let rec dummy1_of_js : Ojs . t -> dummy1 = fun ( x61 : Ojs . t ) t -> x61 |
let rec dummy2_of_js : Ojs . t -> dummy2 = fun ( x63 : Ojs . t ) t -> x63 |
let rec dummy3_of_js : Ojs . t -> dummy3 = fun ( x65 : Ojs . t ) t -> x65 |
let rec dummy4_of_js : Ojs . t -> dummy4 = fun ( x67 : Ojs . t ) t -> x67 |
let rec dummy5_of_js : Ojs . t -> dummy5 = fun ( x69 : Ojs . t ) t -> x69 |
let rec dummy6_of_js : Ojs . t -> dummy6 = fun ( x71 : Ojs . t ) t -> x71 |
type union_int = | Union_int_0 of dummy1 | Union_int_1 of dummy2 | Unknown of Ojs . t |
let rec union_int_of_js : Ojs . t -> union_int = fun ( x76 : Ojs . t ) t -> let x77 = x76 in match Ojs . type_of ( Ojs . get_prop_ascii x77 " tag ) " with | " number " -> ( match Ojs . int_of_js ( Ojs . get_prop_ascii x77 " tag ) " with | 0 -> Union_int_0 ( dummy1_of_js x77 ) x77 | 1 -> Union_int_1 ( dummy2_of_js x77 )... |
type union_float = | Union_float_0_1 of dummy1 | Union_float_1_1 of dummy2 | Unknown of Ojs . t |
let rec union_float_of_js : Ojs . t -> union_float = fun ( x82 : Ojs . t ) t -> let x83 = x82 in match Ojs . type_of ( Ojs . get_prop_ascii x83 " tag ) " with | " number " -> ( match Ojs . float_of_js ( Ojs . get_prop_ascii x83 " tag ) " with | 0 . 1 -> Union_float_0_1 ( dummy1_of_js x83 ) x83 | 1 . 1 -> Union_float_1_... |
type union_string = | Union_string_foo of dummy3 | Union_string_bar of dummy4 | Unknown of Ojs . t |
let rec union_string_of_js : Ojs . t -> union_string = fun ( x88 : Ojs . t ) t -> let x89 = x88 in match Ojs . type_of ( Ojs . get_prop_ascii x89 " tag ) " with | " number " -> Unknown x89 | " string " -> ( match Ojs . string_of_js ( Ojs . get_prop_ascii x89 " tag ) " with | " foo " -> Union_string_foo ( dummy3_of_js x... |
type union_bool = | Union_bool_true of dummy5 | Union_bool_false of dummy6 |
let rec union_bool_of_js : Ojs . t -> union_bool = fun ( x93 : Ojs . t ) t -> let x94 = x93 in match Ojs . bool_of_js ( Ojs . get_prop_ascii x94 " tag ) " with | true -> Union_bool_true ( dummy5_of_js x94 ) x94 | false -> Union_bool_false ( dummy6_of_js x94 ) x94 fun ( x90 : union_bool ) union_bool -> match x90 with | ... |
type union_bool_partial = | Union_bool_true of dummy5 |
let rec union_bool_partial_of_js : Ojs . t -> union_bool_partial = fun ( x97 : Ojs . t ) t -> let x98 = x97 in match Ojs . bool_of_js ( Ojs . get_prop_ascii x98 " tag ) " with | true -> Union_bool_true ( dummy5_of_js x98 ) x98 | _ -> assert false fun ( x95 : union_bool_partial ) union_bool_partial -> match x95 with | U... |
type union_bool_partial2 = | Union_bool_true of dummy5 | Unknown of Ojs . t |
let rec union_bool_partial2_of_js : Ojs . t -> union_bool_partial2 = fun ( x102 : Ojs . t ) t -> let x103 = x102 in match Ojs . type_of ( Ojs . get_prop_ascii x103 " tag ) " with | " number " -> Unknown x103 | " string " -> Unknown x103 | " boolean " -> ( match Ojs . bool_of_js ( Ojs . get_prop_ascii x103 " tag ) " wit... |
type union_mixed = | Union_int_0 of dummy1 | Union_int_1 of dummy2 | Union_float_0_1 of dummy1 | Union_float_1_1 of dummy2 | Union_string_foo of dummy3 | Union_string_bar of dummy4 | Union_bool_true of dummy5 | Union_bool_false of dummy6 | Unknown of Ojs . t |
let rec union_mixed_of_js : Ojs . t -> union_mixed = fun ( x114 : Ojs . t ) t -> let x115 = x114 in match Ojs . type_of ( Ojs . get_prop_ascii x115 " tag ) " with | " number " -> ( match Ojs . float_of_js ( Ojs . get_prop_ascii x115 " tag ) " with | 0 . 1 -> Union_float_0_1 ( dummy1_of_js x115 ) x115 | 1 . 1 -> Union_f... |
type union_mixed_partial_bool = | Union_int_0 of dummy1 | Union_int_1 of dummy2 | Union_float_0_1 of dummy1 | Union_float_1_1 of dummy2 | Union_string_foo of dummy3 | Union_string_bar of dummy4 | Union_bool_true of dummy5 | Unknown of Ojs . t |
let rec union_mixed_partial_bool_of_js : Ojs . t -> union_mixed_partial_bool = fun ( x125 : Ojs . t ) t -> let x126 = x125 in match Ojs . type_of ( Ojs . get_prop_ascii x126 " tag ) " with | " number " -> ( match Ojs . float_of_js ( Ojs . get_prop_ascii x126 " tag ) " with | 0 . 1 -> Union_float_0_1 ( dummy1_of_js x126... |
type uf = { link : int array ; rank : int array ; mutable rep : int -> int ; [ @ ghost ] mutable dst : int -> int ; [ @ ghost ] mutable maxd : int ; [ @ ghost ] } |
let rec find i uf = let p = uf . link . ( i ) in if p = i then i else let rep = find p uf in uf . link . ( i ) <- rep ; rep fun y -> if ( y = x ) [ @ pure ] then v else f y |
let union i j uf = let rep_i = find i uf in let rep_j = find j uf in if not ( rep_i = rep_j ) then if uf . rank . ( rep_i ) > uf . rank . ( rep_j ) then ( uf . link . ( rep_j ) <- rep_i ; uf . rep <- ( fun [ @ pure ] k -> if uf . rep k = uf . rep rep_j then rep_i else uf . rep k ) ; uf . maxd <- uf . maxd + 1 ; uf . ds... |
let test = " union_find " >::: [ " all " >:: ( fun ( ) -> let t1 = create 13 in assert ( get t1 = 13 ) ; set t1 15 ; assert ( get t1 = 15 ) ; assert ( same_class t1 t1 ) ; let t2 = create 17 in assert ( not ( same_class t1 t2 ) ) ; union t1 t2 ; assert ( same_class t1 t1 ) ; assert ( same_class t1 t2 ) ; assert ( same_... |
module MyQuery = [ % graphql { | { dogOrHuman { . . . on Dog { name barkVolume } } } } ] | |
type qt = < dogOrHuman : [ | ` Dog of < name : string ; barkVolume : float > | ` Nonexhaustive ] > |
let my_query = ( module struct type t = qt let pp formatter ( obj : qt ) = Format . fprintf formatter " < dogOrHuman = % a " > ( fun formatter -> function | ` Dog dog -> Format . fprintf formatter " ` Dog [ @<>< name = % a ; barkVolume = % a ] " >@ Format . pp_print_string dog # name Format . pp_print_float dog # barkV... |
let decodes_non_exhaustive_query ( ) = Alcotest . check my_query " result equality " ( MyQuery . parse ( Yojson . Basic . from_string { | { " dogOrHuman " : { " __typename " : " Human " , " name " : " Max " } } } ) ) | ( object method dogOrHuman = ` Nonexhaustive end ) |
let tests = [ " Decodes non - exhaustive query " , ` Quick , decodes_non_exhaustive_query ; ] |
module Make ( ArtLib : ArtLib . S ) ( Name : Name . S ) ( Elt : Data . S ) ( St : SpreadTree . S with type name = Name . t and type elt = Elt . t ) = struct module List = St . List module Set = Trie . Set . Make ( Name ) ( ArtLib ) ( Elt ) let list_unique : ( Elt . t * Elt . t ) -> List . t -> List . t = fun ( zero , o... |
let list_unique : List . Data . t -> List . Data . t = let loop = List . Art . mk_mfn ( Key . of_string " Unique # list_unique " ) ( module AdaptonTypes . Tuple3 ( Key ) ( List . Data ) ( Set ) ) ( fun loop ( nm , l , s ) -> match l with | ` Nil -> ` Nil | ` Cons ( i , l ' ) -> let nm ' , nm ' ' = Key . fork nm in let ... |
let lthunk : List . Data . t -> List . Art . t = let ident = List . Art . mk_mfn ( Key . of_string " Unique # lthunk " ) ( module List . Data ) ( fun _ l -> l ) in ident . mfn_art |
let _ = let name l = ` Name ( Key . nondet ( ) , ` Art ( lthunk l ) ) in let al_of_l ( l : int list ) : List . Data . t = OList . fold_right ( fun n a -> name ( ` Cons ( n , a ) ) ) l ` Nil in let rec l_of_al : List . Data . t -> int list = function | ` Nil -> [ ] | ` Cons ( i , l ) -> i ( :: l_of_al l ) | ` Art a -> l... |
module type Id = Id |
let rec race_free_create_loop cell make = let x = ! cell in let new_x = make x in if phys_equal ! cell x then ( cell := new_x ; x ) else race_free_create_loop cell make ; ; |
module Int ( ) = struct include Int let current = ref zero let create ( ) = race_free_create_loop current succ end |
module Int63 ( ) = struct include Int63 let current = ref zero let create ( ) = race_free_create_loop current succ end |
let test_reserved_identifiers ( ) = let u = U . init ~ reserved_identifiers [ " : y " ] ~ reserved_prefixes [ ] : ~ safe_prefix " : x_ " in Alcotest . ( check ( option string ) ) " equal " None ( U . translate_only u " a " ) ; Alcotest . ( check string ) " equal " " a " ( U . translate u " a " ) ; Alcotest . ( check st... |
let test_reserved_prefixes ( ) = ( try U . init ~ reserved_identifiers [ ] : ~ reserved_prefixes [ " " ] : ~ safe_prefix " : x_ " |> ignore ; assert false with _ -> ( ) ) ; ( try U . init ~ reserved_identifiers [ ] : ~ reserved_prefixes [ " : x " ] ~ safe_prefix " : x_ " |> ignore ; assert false with _ -> ( ) ) ; let u... |
let test_identifier_creation ( ) = let u = U . init ~ reserved_identifiers [ ] : ~ reserved_prefixes [ " : y_ " ] ~ safe_prefix " : x_ " in Alcotest . ( check string ) " equal " " y " ( U . translate u " y " ) ; Alcotest . ( check string ) " equal " " y_ " ( U . create u " y " ) ; Alcotest . ( check string ) " equal " ... |
let test : unit Alcotest . test = " Unique_name " , [ " reserved identifiers " , ` Quick , test_reserved_identifiers ; " reserved prefixes " , ` Quick , test_reserved_prefixes ; " identifier creation " , ` Quick , test_identifier_creation ; ] |
module M = struct type t = B let f : t -> t = fun B -> x end ; ; [ %% expect { | |
type t = A ^ t / 1 Line 4 , characters 2 - 12 : Definition of type t / 1 Line 1 , characters 0 - 10 : Definition of type t / 2 } ] | |
module M = struct type t = B end |
module N = struct module M = struct type t = C end let f : M . t -> M . t = fun M . C -> y end ; ; [ %% expect { | |
module M : sig type t = B end ^ M / 1 . t Lines 4 - 6 , characters 2 - 5 : Definition of module M / 1 Line 1 , characters 0 - 32 : Definition of module M / 2 } ] | |
let f : t -> t = fun D -> x ; ; [ %% expect { | |
type t = D ^ t / 1 Line 1 , characters 0 - 10 : Definition of type t / 1 Line 1 , characters 0 - 10 : Definition of type t / 2 } ] | |
type ttt = A of ttt | B of uuu [ %% expect { | |
type ttt = A of ttt | B of uuu } ] | |
type nonrec ttt = X of ttt |
let x : ttt = let rec y = A y in y ; ; [ %% expect { | |
type nonrec ttt = X of ttt ^ ttt / 1 Line 1 , characters 0 - 26 : Definition of type ttt / 1 Line 2 , characters 0 - 30 : Definition of type ttt / 2 } ] | |
let safe_ascii c = ( c >= ' a ' && c <= ' z ' ) || ( c >= ' A ' && c <= ' Z ' ) || c = ' _ ' || ( c >= ' 0 ' && c <= ' 9 ' ) |
let safe_ascii_only s = CCString . filter_map ( fun c -> if safe_ascii c then Some c else None ) s |
let safe_ascii_only_ml s = CCString . filter_map ( fun c -> if safe_ascii c || c = ' ' ' \ then Some c else None ) s |
let unsuffixed_file_name ( ) = let loc = ! Ast_helper . default_loc in let name = Filename . basename loc . Lo . loc_start . Le . pos_fname in match CCString . split_on_char ' . ' name with | [ ] -> " " | s :: _ -> safe_ascii_only s |
let make_uniq_cnt htl s = let i = match Hashtbl . find htl s with exception Not_found -> 0 | n -> n in Hashtbl . replace htl s ( succ i ) ; i |
let htl_c = Hashtbl . create 128 |
let safe_cname = let cnt = make_uniq_cnt htl_c in fun ~ prefix -> let loc = ! Ast_helper . default_loc in let name = unsuffixed_file_name ( ) in let s = safe_ascii_only prefix in let cutmax s maxlen = let len = String . length s in if len > maxlen then String . sub s 0 maxlen else s in let s = cutmax s 20 in let name =... |
let htl_ml = Hashtbl . create 128 |
let safe_mlname = let cnt = make_uniq_cnt htl_ml in fun ( ? capitalize = false ) ? prefix ( ) -> let s , p = match prefix with | None -> ( " " , " " ) | Some s -> ( safe_ascii_only_ml s , " _ " ) in let loc = ! Ast_helper . default_loc in let line = loc . Lo . loc_start . Le . pos_lnum in let pre = if capitalize then M... |
type merlin_state = { l_c : ( string * int ) list ; l_ml : ( string * int ) list ; } |
let merlin_save ( ) : merlin_state = { l_c = CCHashtbl . Poly . to_list htl_c ; l_ml = CCHashtbl . Poly . to_list htl_ml } |
let merlin_restore { l_c ; l_ml } = let f htl l = Hashtbl . clear htl ; List . iter ( fun ( a , b ) -> Hashtbl . replace htl a b ) l in f htl_c l_c ; f htl_ml l_ml |
let htl_ctypes = Hashtbl . create 64 |
type t = { mod_path : string list ; uniq_name : string ; short_name : string ; sref : string ; } |
type make_result = { id : t ; topmod_vb : structure_item ; topmod_ref : structure_item ; main_ref : expression ; } |
let attr ~ attr ~ cont = let loc = ! Ast_helper . default_loc in let x = U . mk_loc attr in let pl = PStr [ [ % stri [ % e U . str_expr cont ] ] ] in [ Ast_helper . Attr . mk x pl ] |
let vb ? constr ~ attrs n expr = let p = match constr with None -> U . mk_pat n | Some t -> U . mk_pat_pconstr t n in Str . value Nonrecursive [ Vb . mk ~ attrs p expr ] |
let make ? constr ? main_ref_attrs ~ retype mod_path short_name expr = let uniq_name = U . safe_mlname ~ prefix : short_name ( ) in let sref = String . concat " . " ( mod_path @ [ short_name ] ) in Hashtbl . add htl_ctypes sref ( ) ; let id = { mod_path ; uniq_name ; short_name ; sref } in let attrs = attr ~ cont : sre... |
let get_remove_string_exn name attr = let res = ref None in let attribs = List . filter attr ~ f ( : fun x -> if x . attr_name . txt <> name then true else match x . attr_payload with | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( s , _ , _ ) ) ; _ ; } , _ ) ; _ ; } ; ] -> res := Some ... |
let is_uniq_ctype orig = match Hashtbl . find_all htl_ctypes orig with | [ _ ] -> true | [ ] -> failwith " invalid parsetree generated " | _ -> false |
let get_final_name t = if is_uniq_ctype t . sref then t . short_name else t . uniq_name |
let replace_expr = function | { pexp_desc = Pexp_ident _ as orig ; pexp_attributes = _ :: _ as attribs ; _ } as expr when List . exists attribs ~ f ( : fun x -> x . attr_name . txt = a_reference_string ) -> let s , pexp_attributes = get_remove_string_exn a_reference_string attribs in let id_ref , single_ref = CCString ... |
let replace_stri = function | { pstr_desc = Pstr_value ( Nonrecursive , [ ( { pvb_attributes = _ :: _ as attribs ; _ } as a ) ] ) ; _ ; } as stri -> if List . exists attribs ~ f ( : fun x -> x . attr_name . txt = a_orig_name ) then let s , pvb_attributes = get_remove_string_exn a_orig_name attribs in let pvb_pat = matc... |
let clear ( ) = Hashtbl . clear htl_ctypes |
type merlin_state = string list |
let merlin_save ( ) = CCHashtbl . Poly . to_list htl_ctypes |> List . split |> fst |
let merlin_restore l = clear ( ) ; List . iter l ~ f ( : fun x -> Hashtbl . add htl_ctypes x ( ) ) |
let desc = [ ` Path " lablgtk - 1 . 00 / config . make " ; ` Path " lablgtk - 1 . 00 / lablgtktop_t " ; ` Path " lablgtk - 1 . 00 / lablgtktop " ; ` Path " lablgtk - 1 . 00 / lablgtkrun " ; ` Path " lablgtk - 1 . 00 / lablgtk " ; ` Path " unison3 / src / unison " ; ` Name " core " ; ` Path " lipe / caisse / val_parse .... |
let paths = [ " These " ; " Xduce " ; " unison " ; " unison2 " ; " unison3 " ; " tinkertype " ; " lipe " ; " icfp2000 " ; " Views " ; " sync " ; " misc " ; " lablgtk - 1 . 00 " ; " mydb " ; " yacc " ; " db - papers " ; " submissions " ; " xml " ; " profiler " ; " specs " ; " ocaml " ; " rx " ] |
let rec children p = let rec loop ch dir = try let file = Unix . readdir dir in let ch ' = if file = " . " || file = " . . " then ch else file :: ch in loop ch ' dir with End_of_file -> ch in let dir = Unix . opendir p in let result = loop [ ] dir in Unix . closedir dir ; result |
let is_dir p = try ( Unix . lstat p ) . Unix . st_kind = Unix . S_DIR with Unix . Unix_error _ -> false |
let count = ref 0 |
let hit = ref 0 |
let rec visit rx p = try ignore ( Re . exec ~ group : false rx p ) ; with Not_found -> let fp = prefix ^ p in if is_dir fp then List . iter ( fun n -> visit rx ( p ^ " " / ^ n ) ) ( children fp ) |
let _ = let rx = Re . seq [ Re . bos ; Re . alt ( List . map ( fun p -> match p with ` Path s -> Re . Glob . globx s | ` Name s -> Re . seq [ Re . no_group ( Re_posix . re " ( . ) " ) ; */? Re . Glob . globx s ] ) desc ) ; Re . eos ] in let rx = Re . compile rx in List . iter ( fun p -> visit rx p ) paths done |
let desc = [ ` Path " lablgtk - 1 . 00 / config . make " ; ` Path " lablgtk - 1 . 00 / lablgtktop_t " ; ` Path " lablgtk - 1 . 00 / lablgtktop " ; ` Path " lablgtk - 1 . 00 / lablgtkrun " ; ` Path " lablgtk - 1 . 00 / lablgtk " ; ` Path " unison3 / src / unison " ; ` Name " core " ; ` Path " lipe / caisse / val_parse .... |
let paths = [ " These " ; " Xduce " ; " unison " ; " unison2 " ; " unison3 " ; " tinkertype " ; " lipe " ; " icfp2000 " ; " Views " ; " sync " ; " misc " ; " lablgtk - 1 . 00 " ; " mydb " ; " yacc " ; " db - papers " ; " submissions " ; " xml " ; " profiler " ; " specs " ; " ocaml " ; " rx " ] |
let rec children p = let rec loop ch dir = try let file = Unix . readdir dir in let ch ' = if file = " . " || file = " . . " then ch else file :: ch in loop ch ' dir with End_of_file -> ch in let dir = Unix . opendir p in let result = loop [ ] dir in Unix . closedir dir ; result |
let is_dir p = try ( Unix . lstat p ) . Unix . st_kind = Unix . S_DIR with Unix . Unix_error _ -> false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.