text stringlengths 0 601k |
|---|
let ( ) = let csv1 = [ [ " a " ; " b " ; " c " ; " " ; " " ] ; [ " f " ; " g " ; " h " ; " i " ; " " ] ; [ " " ] ; [ ] ] in let csv2 = [ [ " a " ; " b " ; " c " ; " d " ; " " ] ; [ " f " ; " g " ; " h " ; " i " ; " " ] ; [ " " ] ; [ ] ] in assert ( Csv . compare csv1 csv2 < 0 ) 0 |
let ( ) = let csv1 = [ [ " a " ; " b " ; " c " ; " " ; " " ] ; [ " f " ; " g " ; " h " ; " i " ; " " ] ; [ " " ] ; [ ] ] in let csv2 = [ [ " A " ; " B " ; " C " ; " " ; " " ] ; [ " F " ; " G " ; " H " ; " I " ; " " ] ; [ " " ] ; [ ] ] in assert ( Csv . map ~ f : String . capitalize_ascii csv1 = csv2 ) csv2 |
let ( ) = print_endline IF_LWT ( IF_LWT " All conformity tests succeeded ( Csv_lwt ) Csv_lwt . " , " All conformity tests succeeded ( Csv ) Csv ) . " |
type ' l t = R | W | L of string | S of string | B of ( int -> int -> int ) * string | E | C of int | J of ' l | JT of ' l | JF of ' l object inherit [ int , unit , string , unit , string , ' extra ] class_t method c_R ( ) = " R " method c_W ( ) = " W " method c_L ( ) x = " L " ^ x method c_S ( ) x = " S " ^ x method c... |
let resolve p = let symbols = ref [ ] in let p = Array . mapi ( fun i ( s , c ) -> if s != " " then symbols := ( s , i ) :: ! symbols ; c ) p in Array . map ( fun i -> transform ( t ) ( fun _ i -> List . assoc i ! symbols ) ( new resolve ) ( ) i ) p |
let toString i = transform ( t ) ( fun _ i -> string_of_int i ) ( new toString ) ( ) i |
type env = int list * ( string -> int ) * int list * int list * int object inherit [ int , env , int , env , env option ] class_t method c_R ( s , m , x :: i , o , p ) _ = Some ( x :: s , m , i , o , p + 1 ) method c_W ( x :: s , m , i , o , p ) _ = Some ( s , m , i , x :: o , p + 1 ) method c_L ( s , m , i , o , p ) _... |
let interpret ii p i = let rec inner ( ( _ , _ , _ , o , i ) as conf ) = match transform ( t ) ( fun _ i -> i ) ii conf p . ( i ) with | None -> List . rev o | Some conf -> inner conf in inner ( [ ] , ( fun x -> invalid_arg ( Printf . sprintf " Variable % s undefined " x ) ) , i , [ ] , 0 ) |
let sum = [ | R ; R ; B ( ( ) , + " " ) ; + W ; E ] | |
let sumN = [ | R ; S " n " ; C 0 ; S " s " ; L " n " ; JF 15 ; L " n " ; C 1 ; B ( ( ) , - " " ) ; - S " n " ; R ; L " s " ; B ( ( ) , + " " ) ; + S " s " ; J 4 ; L " s " ; W ; E ] | |
let sumS = [ " " , | R ; " " , R ; " " , B ( ( ) , + " " ) ; + " " , W ; " " , E ] | |
let sumNS = [ | " " , R ; " " , S " n " ; " " , C 0 ; " " , S " s " ; " cont " , L " n " ; " " , JF " end " ; " " , L " n " ; " " , C 1 ; " " , B ( ( ) , - " " ) ; - " " , S " n " ; " " , R ; " " , L " s " ; " " , B ( ( ) , + " " ) ; + " " , S " s " ; " " , J " cont " ; " end " , L " s " ; " " , W ; " " , E ] | |
let _ = let ii = new interpret in let dd = new debug ( fun i ( _ , _ , _ , _ , p ) -> Printf . printf " % s @ % d \ n " ( toString ~: i ) p ) in let main name xx p i = Printf . printf " % s :\ n " name ; List . iter ( fun x -> Printf . printf " % d \ n " x ) ( interpret xx p i ) in main " sum " ii sum [ 2 ; 3 ] ; main ... |
module PV : sig @ type a = [ ` A of b | ` C of GT . int ] with show and b = [ ` B of a | ` D of GT . string ] with show @ type a = [ ` A of b | ` C of GT . int ] with show and b = [ ` B of a | ` D of GT . string ] with show end |
module Show2 = struct open PV class [ ' self ] show_b_t_stub2 ( for_a , for_b ) = object inherit [ ' self ] show_b_t_stub ( for_a , for_b ) method c_C ( ) ( _ : b ) a = Printf . sprintf " new C ( % s ) " ( for_a ( ) a ) method c_D ( ) _ s = Printf . sprintf " new D % s " s end let showa0 a = Printf . printf " new !\ n ... |
module ShowC = struct open PV class [ ' extra ] show_c_stub2 make_clas = let show_a2 , show_b2 = Show2 . ( fix_a showa0 ( fun _ -> ( ( make_clas ( ) ) ) ) ) in object inherit [ unit , ' extra , string ] c_t inherit [ ' extra ] show_b_t_stub ( show_a2 , show_b2 ) method ! c_B ( ) _ a = sprintf " new ` B ( % s ) " ( show... |
let rec to_string = function |
let gensym = let n = ref 0 in fun ( ) -> incr n ; " _ " ^ string_of_int ! n ; ; inherit [ ( string * ' v ) list , ' self , ' v ] @ var constraint ' self = [ > var ] method c_Var s _ name = try List . assoc name s with Not_found -> ` Var name end inherit [ ( string * ' self ) list , ' self , ' self , ( string * ' self )... |
let rec eval1 s e = GT . transform ( lambda ) ( new lambda_eval eval1 ) s e ; ; inherit [ ( string * ' self ) list , ' self , ' self , ( string * ' self ) list , ' self , ' self ] @ var_expr inherit [ ' self , ' self ] var_eval constraint ' self = [ > ' self var_expr ] method c_Num _ _ i = ` Num i method c_Add env _ x ... |
let rec eval2 s e = GT . transform ( var_expr ) ( new var_expr_eval eval2 ) s e ; ; inherit [ ( string * ' self ) list , ' a , ' self , ( string * ' self ) list , ' self , ' self ] @ expr inherit [ ' self ] lambda_eval fself fself inherit [ ' self ] var_expr_eval fself fself constraint ' self = [ > ' a var_expr | ' a l... |
let eval3 s e = GT . transform ( expr ) ( new expr_eval ) s e |
let _ = Printf . printf " % s \ n " @@ to_string ( eval3 [ " x " , ` Num 5 ; " y " , ` Num 6 ] ( ` Add ( ` Var " x " , ` Mult ( ` Num 2 , ` Var " y " ) ) ) ) |
let decode_ref_data ( ) = T . ( { p1 = { first_name = " John " ; last_name = " Doe " ; date_of_birth = 19820429l ; tel_number = None ; employment = Employed_by " Google " ; marital_status = None ; gender = Some Male ; } ; p2 = { first_name = " Marie " ; last_name = " Dupont " ; date_of_birth = 19820306l ; tel_number = ... |
let ( ) = Printf . printf " Show is working : % s \ n " @@ T . show_couple ( decode_ref_data ( ) ) |
let ( ) = let mode = Test_util . parse_args ( ) in match mode with | Test_util . Decode -> Test_util . decode " test01 . c2ml . data " Pb . decode_couple Pp . pp_couple ( decode_ref_data ( ) ) | Test_util . Encode -> Test_util . encode " test01 . ml2c . data " Pb . encode_couple ( decode_ref_data ( ) ) |
let ( ) = let expected_default_person = T . ( { first_name = " Max " ; last_name = " Ransan " ; date_of_birth = 19820429l ; tel_number = None ; employment = Self_employed 0l ; marital_status = None ; gender = None ; } ) in assert ( expected_default_person = T . default_person ( ) ) |
module AL : sig @ type ( ' a , ' b ) alist = [ ] [ @ name " nil " ] | ( ) :: of ' a * ' b [ @ name " cons " ] with show , foldl , gmap @ type ( ' a , ' b ) alist = [ ] [ @ name " nil " ] | ( ) :: of ' a * ' b [ @ name " cons " ] with show , foldl , gmap end |
let ( ) = let open AL in let sh xs = GT . show alist Fun . id Fun . id xs in Printf . printf " % s \ n " %! ( sh @@ " aaa " :: " bbb " ) ; ( ) |
module L : sig @ type ' a list = ( ' a , ' a list ) AL . alist with show , gmap , foldl @ type ' a list = ( ' a , ' a list ) AL . alist with show , gmap , foldl end |
let ( ) = let open L in let sh x = GT . show list Fun . id x in Printf . printf " % s \ n " %! ( sh @@ " aaa " :: " bbb " :: [ ] ) |
module Lo : sig @ type ' a logic = Var of GT . int | Value of ' a with show , gmap , foldl @ type ' a logic = Var of GT . int | Value of ' a with show , gmap , foldl end |
let ( ) = let open Lo in let sh x = GT . show logic Fun . id x in Printf . printf " % s \ t % s \ n " %! ( sh @@ Var 5 ) ( sh @@ Value " asdf " ) |
module LList : sig @ type ' a llist = ( ' a , ' a llist ) AL . alist Lo . logic with show , gmap , foldl @ type ' a llist = ( ' a , ' a llist ) AL . alist Lo . logic with show , gmap , foldl end |
let ( ) = let sh x = GT . show LList . llist Fun . id x in Printf . printf " % s \ n " %! ( sh @@ Value ( " aaa " :: Value ( " bbb " :: Var 15 ) ) ) |
module Lo2 = struct include Lo class [ ' a , ' self ] my_show fa fself = object inherit [ ' a , ' self ] Lo . show_logic_t fa fself method c_Value ( ) _ x = fa ( ) x end let logic = { Lo . logic with GT . plugins = object method show fa xs = GT . transform ( Lo . logic ) ( new my_show ( GT . lift fa ) ) ( ) xs method g... |
let ( ) = let open Lo2 in let sh x = GT . show logic Fun . id x in Printf . printf " Modified implementation :\ n " ; %! Printf . printf " \ t % s \ n " %! ( sh @@ Var 5 ) ; Printf . printf " \ t % s \ n " %! ( sh @@ Value " asdf " ) ; ( ) |
module ReworkedLList : sig @ type ' a llist = ( ' a , ' a llist ) AL . alist Lo2 . logic with show , gmap , foldl @ type ' a llist = ( ' a , ' a llist ) AL . alist Lo2 . logic with show , gmap , foldl end |
let ( ) = let sh x = GT . show ReworkedLList . llist Fun . id x in Printf . printf " Printing of modified logic list \ n " ; Printf . printf " % s \ n " %! ( sh @@ Value ( " aaa " :: ( Value ( " bbb " :: ( Var 15 ) ) ) ) ) |
let id x = x |
module PV : sig @ type ( ' a , ' b ) pv = [ ` A of ' a | ` B of ' b ] with show , gmap @ type ( ' a , ' b ) pv = [ ` A of ' a | ` B of ' b ] with show , gmap end |
let _ = let open PV in Printf . printf " Original PV : % s \ nMapped PV : % s \ n " ( GT . show pv id id ( ` A " 1 " ) ) ( GT . show pv ( GT . show GT . int ) id @@ GT . gmap pv int_of_string id ( ` A " 1 " ) ) |
module PVExt : sig @ type ( ' a , ' b ) pv_ext = [ ( ' a , ' b ) PV . pv | ` C of ' a ] with show , gmap @ type ( ' a , ' b ) pv_ext = [ ( ' a , ' b ) PV . pv | ` C of ' a ] with show , gmap end |
let _ = let open PV in let open PVExt in Printf . printf " ****************************\ n " ; %! Printf . printf " Original pv : % s \ n " @@ GT . show pv id id ( ` A " 1 " ) ; Printf . printf " Mapped pv and showed as a pv_ext : % s \ n " @@ GT . show pv_ext ( GT . show GT . int ) id @@ ( ( GT . gmap pv int_of_string... |
module PVExt2 : sig @ type ( ' a , ' b ) pv_ext2 = [ ( ' a , ' b ) PVExt . pv_ext | ` D of ' a ] with show , gmap @ type ( ' a , ' b ) pv_ext2 = [ ( ' a , ' b ) PVExt . pv_ext | ` D of ' a ] with show , gmap end |
let ( ) = let open PVExt in let open PVExt2 in Printf . printf " ****************************\ n " ; %! Printf . printf " Original pv_ext : % s \ n " @@ GT . show pv_ext2 id id ( ` C " 1 " ) ; Printf . printf " Mapped pv_ext and showed as a pv_ext2 : % s \ n " @@ GT . show pv_ext2 ( GT . show GT . int ) id @@ ( ( GT . ... |
module PVExt3 : sig @ type ( ' a , ' b , ' c ) pv_ext3 = [ ( ' a , ' b ) PVExt2 . pv_ext2 | ` E of ' c ] with show , gmap @ type ( ' a , ' b , ' c ) pv_ext3 = [ ( ' a , ' b ) PVExt2 . pv_ext2 | ` E of ' c ] with show , gmap end |
let ( ) = let open PVExt2 in let open PVExt3 in Printf . printf " ****************************\ n " ; %! Printf . printf " Original pv_ext2 : % s \ n " @@ GT . show pv_ext2 id id ( ` D " 1 " ) ; Printf . printf " Mapped pv_ext2 and showed as a pv_ext3 : % s \ n " @@ GT . show pv_ext3 ( GT . show GT . int ) id id @@ ( (... |
module PVSum = struct @ type ( ' a , ' b ) s = [ ( ' a , ' b ) PV . pv | ( ' a , ' b ) PVExt . pv_ext ] with show , gmap end |
module XXX = struct @ type ' a xxx = [ ` XXX of ' a ] with show , gmap end |
module YYY = struct @ type ' a yyy = [ ' a XXX . xxx | ( ' a , ' a ) PV . pv ] with show , gmap end |
module T : sig @ type t2 = GT . int * GT . string with show , gmap , foldl , eq , compare , eval , stateful , html ; ; @ type ' a t3 = GT . int * ' a * GT . string with show , gmap , html , foldl , eq , compare , eval , stateful ; ; @ type ' a t1 = ' a with show , gmap , html , foldl , eq , compare , eval , stateful ; ... |
module M = Map . Make ( String ) object val i = 0 val m = M . empty method add name = { < i = i + 1 ; m = M . add name i m } , > i method lookup name = M . find name m end |
let lookup env name = ( env , env # lookup name ) |
let unused _ _ = failwith " *** Using the unused " *** |
let rec fix f x = f ( fix f ) x |
let ith m n = fix ( fun me i -> function | [ ] -> raise Not_found | x :: _ when x = n -> i | _ :: tl -> me ( i + 1 ) tl ) 0 m |
module Abs = struct @ type ( ' name , ' term ) t = [ ` Abs of ' name * ' term ] with show , eval , stateful class [ ' term , ' term2 , ' extra , ' syn ] de_bruijn ft = object inherit [ string , unit , ' term , ' term2 , ' extra , ' syn , ' env ] @ t [ eval ] ( fun _ _ -> ( ) ) ft unused constraint ' env = string list c... |
module Lam = struct @ type ( ' name , ' lam ) t = [ ` App of ' lam * ' lam | ` Var of ' name ] with show , eval , stateful end |
module M = Map . Make ( String ) object val i = 0 val m = M . empty method add name = { < i = i + 1 ; m = M . add name i m } , > i method lookup name = M . find name m end |
let lookup env name = ( env , env # lookup name ) |
let unused _ _ = failwith " *** Using the unused " *** |
let rec fix f x = f ( fix f ) x |
let ith m n = fix ( fun me i -> function | [ ] -> raise Not_found | x :: _ when x = n -> i | _ :: tl -> me ( i + 1 ) tl ) 0 m |
module Lam = struct @ type ( ' name , ' lam ) t = [ ` App of ' lam * ' lam | ` Var of ' name ] with show class [ ' lam , ' nameless ] lam_to_nameless ( flam : string list -> ' lam -> ' nameless ) = object inherit [ string list , string , int , string list , ' lam , ' nameless , string list , ' lam , ' nameless ] t_t me... |
module Abs = struct @ type ( ' name , ' term ) t = [ ` Abs of ' name * ' term ] with show class [ ' lam , ' nameless ] abs_to_nameless ( flam : string list -> ' lam -> ' nameless ) = object inherit [ string list , string , int , string list , ' lam , ' nameless , string list , ' lam , ' nameless ] t_t method c_Abs env ... |
let to_nameless lam = GT . transform ( named ) ( fun fself -> new to_nameless fself ) [ ] lam |
let _ = let l = ` App ( ` Abs ( " x " , ` Var " x " ) , ` Abs ( " y " , ` Var " y " ) ) in Printf . printf " Original : % s \ n " ( GT . show ( named ) l ) ; Printf . printf " Converted : % s \ n " ( GT . show ( nameless ) @@ to_nameless l ) |
type ' a prodcons = { buffer : ' a array ; lock : Mutex . t ; mutable readpos : int ; mutable writepos : int ; notempty : Condition . t ; notfull : Condition . t } |
let create size init = { buffer = Array . create size init ; lock = Mutex . create ( ) ; readpos = 0 ; writepos = 0 ; notempty = Condition . create ( ) ; notfull = Condition . create ( ) } |
let put p data = Mutex . lock p . lock ; while ( p . writepos + 1 ) mod Array . length p . buffer = p . readpos do Condition . wait p . notfull p . lock done ; p . buffer . ( p . writepos ) <- data ; p . writepos <- ( p . writepos + 1 ) mod Array . length p . buffer ; Condition . signal p . notempty ; Mutex . unlock p ... |
let get p = Mutex . lock p . lock ; while p . writepos = p . readpos do Condition . wait p . notempty p . lock done ; let data = p . buffer . ( p . readpos ) in p . readpos <- ( p . readpos + 1 ) mod Array . length p . buffer ; Condition . signal p . notfull ; Mutex . unlock p . lock ; data |
let buff = create 20 0 |
let rec produce n = print_int n ; print_string " " ; --> print_newline ( ) ; put buff n ; if n < 10000 then produce ( n + 1 ) |
let rec consume ( ) = let n = get buff in print_string " " ; --> print_int n ; print_newline ( ) ; if n < 10000 then consume ( ) |
let t1 = Thread . create produce 0 |
let _ = consume ( ) ; ; |
let ( ) = Printexc . record_backtrace true ; try if Dynlink . is_native then begin Dynlink . loadfile " test10_plugin . cmxs " end else begin Dynlink . loadfile " test10_plugin . cmo " end with | Dynlink . Error ( Dynlink . Library ' s_module_initializers_failed exn ) -> Printf . eprintf " Error : % s \ n " %! ( Printe... |
let create_ref_data n = let rec loop l = function | 0 -> l | n -> let couple = { T . p1 = { T . first_name = " John " ; T . last_name = " Doe " ; T . date_of_birth = ( Int32 . of_int n ) ; T . tel_number = None ; T . employment = T . Employed_by " Google " ; T . marital_status = None ; } ; T . p2 = { T . first_name = "... |
let ( ) = let mode = Test_util . parse_args ( ) in match mode with | Test_util . Decode -> Test_util . decode " test11 . c2ml . data " ~ notest ( ) : Pb . decode_couples Pp . pp_couples ( create_ref_data 100000 ) | Test_util . Encode -> Test_util . encode " test11 . ml2c . data " Pb . encode_couples ( create_ref_data 1... |
let decode_ref_data ( ) = T . ( { string_to_string = ( " one " , " two " ) ( " :: three " , " four " ) [ ] ; :: string_to_int = ( " one " , 1l ) ( " :: three " , 3l ) [ ] ; :: int_to_int = ( 1 , 2 ) ( :: 3 , 4 ) [ ] ; :: int_to_message_value = ( 1l , { mv_field = " one " } ) ( :: 2l , { mv_field = " two " } ) [ ] ; :: ... |
let mode = Test_util . parse_args ( ) |
let sort_by_string_key l = let cmp : string -> string -> int = compare in let cmp ( lhs , _ ) ( rhs , _ ) = cmp lhs rhs in List . stable_sort cmp l |
let sort_by_int_key l = let cmp : int -> int -> int = compare in let cmp ( lhs , _ ) ( rhs , _ ) = cmp lhs rhs in List . stable_sort cmp l |
let sort_by_int32_key l = let cmp : int32 -> int32 -> int = compare in let cmp ( lhs , _ ) ( rhs , _ ) = cmp lhs rhs in List . stable_sort cmp l |
let decode_maps decoder = let maps = Pb . decode_maps decoder in let { T . string_to_string ; T . string_to_int ; T . int_to_int ; T . int_to_message_value ; T . int_to_enum_value ; T . int_to_oneof_value ; } = maps in { T . string_to_string = sort_by_string_key string_to_string ; T . string_to_int = sort_by_string_key... |
let ( ) = match mode with | Test_util . Decode -> Test_util . decode " test18 . c2ml . data " decode_maps Pp . pp_maps ( decode_ref_data ( ) ) | Test_util . Encode -> Test_util . encode " test18 . ml2c . data " Pb . encode_maps ( decode_ref_data ( ) ) |
let f x = x + 1 [ @@ inline never ] |
let ( ) = try if Dynlink . is_native then begin Dynlink . loadfile " test1_plugin . cmxs " end else begin Dynlink . loadfile " test1_plugin . cmo " end ; assert false with | Dynlink . Error ( Dynlink . Linking_error ( _ , Dynlink . Uninitialized_global " Test1_inited_second " ) ) -> ( ) |
type ( ' aa , ' bb ) poly = ( ' aa , ' bb ) Test . poly |
type poly_int2 = ( int , int ) poly |
type test2 = { test0 : poly_int2 ; test1 : ( int , string option ) poly } |
type poly_int_string = ( int , string ) poly |
let write_untagged_poly _aa_tag write_untagged__aa write__aa _bb_tag write_untagged__bb write__bb = ( Test . write_untagged_poly _aa_tag write_untagged__aa write__aa _bb_tag write_untagged__bb write__bb ) |
let write_poly _aa_tag write_untagged__aa write__aa _bb_tag write_untagged__bb write__bb ob x = Bi_io . write_tag ob Test . poly_tag ; write_untagged_poly _aa_tag write_untagged__aa write__aa _bb_tag write_untagged__bb write__bb ob x |
let string_of_poly _aa_tag write_untagged__aa write__aa _bb_tag write_untagged__bb write__bb ( ? len = 1024 ) x = let ob = Bi_outbuf . create len in write_poly _aa_tag write_untagged__aa write__aa _bb_tag write_untagged__bb write__bb ob x ; Bi_outbuf . contents ob |
let get_poly_reader get__aa_reader read__aa get__bb_reader read__bb = ( Test . get_poly_reader get__aa_reader read__aa get__bb_reader read__bb ) |
let read_poly get__aa_reader read__aa get__bb_reader read__bb = ( Test . read_poly get__aa_reader read__aa get__bb_reader read__bb ) |
let poly_of_string get__aa_reader read__aa get__bb_reader read__bb ? pos s = read_poly get__aa_reader read__aa get__bb_reader read__bb ( Bi_inbuf . from_string ? pos s ) |
let write_untagged__1 = ( write_untagged_poly Bi_io . svint_tag Bi_io . write_untagged_svint Bi_io . write_svint Bi_io . svint_tag Bi_io . write_untagged_svint Bi_io . write_svint ) |
let write__1 ob x = Bi_io . write_tag ob Test . poly_tag ; write_untagged__1 ob x |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.