text stringlengths 0 601k |
|---|
module MN : sig type foo = M . foo = { x : int ; y : int ; } type bar = N . bar = { x : int ; y : int ; } end |
module NM : sig type bar = N . bar = { x : int ; y : int ; } type foo = M . foo = { x : int ; y : int ; } end } ] | |
let r = { MN . x = 3 ; NM . y = 4 } ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^ but is mixed here with fields of type MN . bar = N . bar } ] | |
module M = struct type foo = { x : int ; y : int } type bar = { x : int ; y : int ; z : int } end ; ; [ %% expect { | |
module M : sig type foo = { x : int ; y : int ; } type bar = { x : int ; y : int ; z : int ; } end } ] | |
module F5 = struct open M let f r = ignore ( r : foo ) ; { r with x = 2 ; z = 3 } end ; ; [ %% expect { | ^ ^ The field z does not belong to type M . foo } ] | |
module M = struct include M type other = { a : int ; b : int } end ; ; [ %% expect { | |
module M : sig type foo = M . foo = { x : int ; y : int ; } type bar = M . bar = { x : int ; y : int ; z : int ; } type other = { a : int ; b : int ; } end } ] | |
module F6 = struct open M let f r = ignore ( r : foo ) ; { r with x = 3 ; a = 4 } end ; ; [ %% expect { | ^ ^ The field a does not belong to type M . foo } ] | |
module F7 = struct open M let r = { x = 1 ; y = 2 } let r : other = { x = 1 ; y = 2 } end ; ; [ %% expect { | ^ ^ ^ The field x does not belong to type M . other } ] | |
module A = struct type t = { x : int } end |
module B = struct type t = { x : int } end ; ; [ %% expect { | |
module A : sig type t = { x : int ; } end |
module B : sig type t = { x : int ; } end } ] | |
let f ( r : B . t ) = r . A . x ; ; [ %% expect { | ^^^ but a field was expected belonging to the record type B . t } ] | |
module F8 = struct type t = { x : int ; yyy : int } let a : t = { x = 1 ; yyz = 2 } end ; ; [ %% expect { | ^^^ The field yyz does not belong to type t } ] | |
type s = A [ %% expect { | |
type s = A } ] | [ %% expect { | ^ } ] | [ %% expect { | ^ ^ ^ ^ ^ } ] | |
module Shadow1 = struct type t = { x : int } module M = struct type s = { x : string } end open M let y : t = { x = 0 } end ; ; [ %% expect { | ^ ^^^^^^ |
module Shadow1 : sig type t = { x : int ; } module M : sig type s = { x : string ; } end val y : t end } ] | |
module Shadow2 = struct type t = { x : int } module M = struct type s = { x : string } end open M let y = { x = " " } end ; ; [ %% expect { | ^^^^^^ ^^^^^^^^ |
module Shadow2 : sig type t = { x : int ; } module M : sig type s = { x : string ; } end val y : M . s end } ] | |
module P6235 = struct type t = { loc : string ; } type v = { loc : string ; x : int ; } type u = [ ` Key of t ] let f ( u : u ) = match u with ` Key { loc } -> loc end ; ; [ %% expect { | ^^^ |
module P6235 : sig type t = { loc : string ; } type v = { loc : string ; x : int ; } type u = [ ` Key of t ] val f : u -> string end } ] | |
module P6235 ' = struct type t = { loc : string ; } type v = { loc : string ; x : int ; } type u = [ ` Key of t ] let f = function | ( _ : u ) when false -> " " ` | Key { loc } -> loc end ; ; [ %% expect { | ^^^ |
module P6235 ' : sig type t = { loc : string ; } type v = { loc : string ; x : int ; } type u = [ ` Key of t ] val f : u -> string end ^^^^^ ^^^^^ x ^^^^^^^^^^ but a pattern was expected which matches values of type u Types for tag ` Key are incompatible } ] | |
module M1 : sig type t = { f0 : unit * unit * unit * int * unit * unit * unit ; f1 : unit * unit * unit * int * unit * unit * unit } type t = { f0 : unit * unit * unit * float * unit * unit * unit ; f1 : unit * unit * unit * string * unit * unit * unit } end ; ; [ %% expect { | Modules do not match : sig type t = { f0 ... |
module M2 : sig type t = { mutable f0 : unit * unit * unit * int * unit * unit * unit ; f1 : unit * unit * unit * int * unit * unit * unit } type t = { f0 : unit * unit * unit * float * unit * unit * unit ; f1 : unit * unit * unit * string * unit * unit * unit } end ; ; [ %% expect { | Modules do not match : sig type t... |
module M3 : sig type t = { f0 : unit } type t = { f1 : unit } end ; ; [ %% expect { | Modules do not match : sig type t = { f1 : unit ; } end is not included in sig type t = { f0 : unit ; } end Type declarations do not match : type t = { f1 : unit ; } is not included in type t = { f0 : unit ; } Fields number 1 have dif... |
module M4 : sig type t = { f0 : unit ; f1 : unit } type t = { f0 : unit } end ; ; [ %% expect { | Modules do not match : sig type t = { f0 : unit ; } end is not included in sig type t = { f0 : unit ; f1 : unit ; } end Type declarations do not match : type t = { f0 : unit ; } is not included in type t = { f0 : unit ; f1... |
let find_name ( attr : Parsetree . attribute ) = match attr with | { attr_name = { txt = " bs . as " | " as " } ; attr_payload = PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( s , _ , _ ) ) } , _ ) ; } ; ] ; } -> Some s | _ -> None |
let find_name_with_loc ( attr : Parsetree . attribute ) : string Asttypes . loc option = match attr with | { attr_name = { txt = " bs . as " | " as " ; loc } ; attr_payload = PStr [ { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_constant ( Pconst_string ( s , _ , _ ) ) } , _ ) ; } ; ] ; } -> Some { txt = s ; loc } | _ ->... |
let fld_record ( lbl : label ) = Lambda . Fld_record { name = Ext_list . find_def lbl . lbl_attributes find_name lbl . lbl_name ; mutable_flag = lbl . Types . lbl_mut ; } |
let fld_record_set ( lbl : label ) = Lambda . Fld_record_set ( Ext_list . find_def lbl . lbl_attributes find_name lbl . lbl_name ) |
let blk_record fields = let all_labels_info = Ext_array . map fields ( fun ( ( lbl : label ) , _ ) -> Ext_list . find_def lbl . Types . lbl_attributes find_name lbl . lbl_name ) in Lambda . Blk_record all_labels_info |
let check_bs_attributes_inclusion ( attrs1 : Parsetree . attributes ) ( attrs2 : Parsetree . attributes ) lbl_name = let a = Ext_list . find_def attrs1 find_name lbl_name in let b = Ext_list . find_def attrs2 find_name lbl_name in if a = b then None else Some ( a , b ) |
let rec check_duplicated_labels_aux ( lbls : Parsetree . label_declaration list ) ( coll : Set_string . t ) = match lbls with | [ ] -> None | { pld_name = { txt } as pld_name ; pld_attributes } :: rest -> ( if Set_string . mem coll txt then Some pld_name else let coll_with_lbl = Set_string . add coll txt in match Ext_l... |
let check_duplicated_labels lbls = check_duplicated_labels_aux lbls Set_string . empty |
type t = { a : int option ; b : y } xx : int ; yy : int } |
let ( ) = Belt . Debug . setupChromeDebugger ( ) |
let v = { a = Some 3 ; b = { xx = 2 ; yy = 3 } 3 } 3 |
let u = { v with a = Some 2 } 2 |
type u += B of int * int |
let v0 = A 3 |
let v1 = B ( 3 , 2 ) 2 |
let v2 = ` C 2 |
let v3 = ` C ( 2 , 3 ) 3 |
module N = struct let a = 0 let b = 1 external f : int -> int = " % identity " end |
module N0 : sig val a : int val b : int val f : int -> int let a = 0 let b = 1 external f : int -> int = " % identity " end |
let fmt , a , c = Format . std_formatter , ( 1 , 2 , 2 , 4 , 3 ) 3 , [ | 1 ; 2 ; 3 ; 4 ; 5 ] | |
type r = { a : unit ; b : int ; c : char ; d : float ; } |
let r1 = { c = ( print_endline " c1 " ; ' c ' ) ; a = print_endline " a1 " ; d = ( print_endline " d1 " ; 1 . ) ; b = ( print_endline " b1 " ; 2 ) ; } |
let r2 = { b = ( print_endline " b2 " ; 2 ) ; d = ( print_endline " d2 " ; 1 . ) ; a = print_endline " a2 " ; c = ( print_endline " c2 " ; ' c ' ) ; } |
let r3 = { ( print_endline " default " ; r1 ) with d = ( print_endline " d3 " ; 1 . ) ; c = ( print_endline " c3 " ; ' c ' ) ; a = print_endline " a3 " ; } |
let ( ) = print_endline " " |
type r2 = { x1 : unit ; x2 : unit ; x3 : unit ; x4 : unit ; x5 : unit ; x6 : unit ; x7 : unit ; x8 : unit ; x9 : unit ; } |
let a = { x5 = print_endline " x5 " ; x6 = print_endline " x6 " ; x1 = print_endline " x1 " ; x3 = print_endline " x3 " ; x4 = print_endline " x4 " ; x9 = print_endline " x9 " ; x7 = print_endline " x7 " ; x8 = print_endline " x8 " ; x2 = print_endline " x2 " ; } |
let ( ) = print_endline " " |
let b = { a with x7 = print_endline " x7 " ; x2 = print_endline " x2 " ; } |
let ( ) = print_endline " " |
let c = { a with x2 = print_endline " x2 " ; x7 = print_endline " x7 " ; } |
let ( ) = print_endline " " |
let c = { a with x2 = print_endline " x2 " ; x7 = print_endline " x7 " ; x5 = print_endline " x5 " ; } |
let ( ) = print_endline " " |
let d = { a with x5 = print_endline " x5 " ; x7 = print_endline " x7 " ; x2 = print_endline " x2 " ; } |
module Aliases = struct module L = Info . Linguistic module H = Ast_helper module Exp = H . Exp module Pat = H . Pat module P = Parsetree module C = Common end |
let stype = ident ' " stype__generated " |
let pnext = ident ' " pnext__generated " |
let name root_name = L . ( root_name " // eXt " ) |
let def ( typename , exts ) = let name = typestr @@ name typename in let ty t = typ t in let ext e = H . Te . decl ~ args ( : Pcstr_tuple [ ty e ] ) ( nloc @@ mkconstr e ) in let exts = H . Te . decl ( nloc " No_extension " ) :: List . map ext exts in let te = H . Te . mk ( nlid name ) exts in let extend = item ( H . S... |
let constr = let n = nlid % mkconstr in let p x var = Pat . construct ( n x ) ( Some var ) and e x var = Exp . construct ( n x ) ( Some var ) in { e ; p } |
let flag x = qn ( Utils . tymod ( " ~: Structure_type " ) ) ( mkconstr x ) |
let str = ident % flag |
let strp x = Pat . construct ( nloc @@ flag x ) None |
let typext = ident % typename |
let split _tag ptr ( name , exts ) input = let v = ident ' " x " in let case x = Exp . case ( constr . p x v . p ) [ % expr [ % e str x ] , [ % e C . coerce ~ from ( : C . ptr @@ typext x ) ~ to ' : C . ( ptr void ) ( C . addr v . e ) ] ] in let noext_case = let null = if Inspect . is_option ( snd ptr ) then [ % expr N... |
let merge ( name , exts ) ~ tag ~ data = let case ext = Exp . case ( strp ext ) C . ( constr . e ext @@ ( ) !@ @@ coerce ~ from ( : ptr void ) ~ to ' ( : ptr @@ typext ext ) data ) in let noext = Exp . case ( strp name ) [ % expr No_extension ] in let exn = Exp . case [ % pat ? _ ] [ % expr raise Unknown_record_extensi... |
let check_hash_differently ~ hash ~ sexp_of_t a b = if hash a = hash b then failwithf " ! fail : expect values to hash differently : { % sexp : t } -- { % sexp : t } " a b ( ) |
let check_hash_same ~ hash ~ sexp_of_t a b = if not ( hash a = hash b ) then failwithf " ! fail : expect values to hash the same : { % sexp : t } -- { % sexp : t } " a b ( ) |
module No_string_field = struct type t = { i : int ; } [ @@ deriving hash , sexp_of ] let v1 = { i = 42 } end |
module Immutable = struct type t = { s : string ; i : int } [ @@ deriving hash , sexp_of ] let v1 = { s = " hey " ; i = 42 } let v2 = { s = " ho " ; i = 42 } let % test_unit _ = check_hash_differently ~ hash ~ sexp_of_t v1 v2 end |
module Immutable_hash_dot_ignore = struct type t = { s : string [ @ hash . ignore ] ; i : int } [ @@ deriving hash , sexp_of ] let v1 = { s = " hey " ; i = 42 } let v2 = { s = " ho " ; i = 42 } let % test_unit _ = check_hash_same ~ hash ~ sexp_of_t v1 v2 let % test_unit _ = [ % test_eq : int ] ( hash v1 ) No_string_fie... |
module Mutable_hash_dot_ignore = struct type t = { mutable s : string [ @ hash . ignore ] ; i : int } [ @@ deriving hash , sexp_of ] let v1 = { s = " hey " ; i = 42 } let v2 = { s = " ho " ; i = 42 } let % test_unit _ = check_hash_same ~ hash ~ sexp_of_t v1 v2 let % test_unit _ = [ % test_eq : int ] ( hash v1 ) No_stri... |
module Immutable_compare_ignore = struct type t = { s : string [ @ compare . ignore ] ; i : int } [ @@ deriving hash , sexp_of ] let v1 = { s = " hey " ; i = 42 } let v2 = { s = " ho " ; i = 42 } let % test_unit _ = check_hash_same ~ hash ~ sexp_of_t v1 v2 let % test_unit _ = [ % test_eq : int ] ( hash v1 ) No_string_f... |
module type S = sig module G : GRAMMAR type item = G . lr1 * G . production * int type recovery = G . lr1 -> int * ( G . lr1 option * item list ) list val recover : recovery val report : Format . formatter -> unit end |
module Make ( G : GRAMMAR ) ( S : Synthesis . S with module G = G ) : S with module G = G = struct module G = G open G type item = lr1 * production * int type recovery = lr1 -> int * ( lr1 option * item list ) list type trace = Trace of float * item list module Trace = struct type t = trace let min = arg_min_float ( fu... |
module type RECOVERY = sig module G : GRAMMAR type item = G . lr1 * G . production * int type recovery = { prefix : int ; cases : ( G . lr1 option * item list ) list } val recover : G . lr1 -> recovery val report : Format . formatter -> unit end |
module Recover ( G : GRAMMAR ) ( S : SYNTHESIZER with module G := G ) : RECOVERY with module G := G = struct open G open Utils type item = lr1 * production * int type recovery = { prefix : int ; cases : ( G . lr1 option * item list ) list } type trace = { cost : Cost . t ; items : item list } module Trace = struct type... |
module type S = sig module G : Cmly_api . GRAMMAR val cost_of_prod : G . production -> float val penalty_of_item : G . production * int -> float val cost_of_symbol : G . symbol -> float val default_prelude : Format . formatter -> unit val default_terminal : G . terminal -> string option val default_nonterminal : G . no... |
module Make ( G : Cmly_api . GRAMMAR ) : S with module G = G = struct module G = G open G let cost_of_attributes prj attrs = List . fold_left ( fun total attr -> if Attribute . has_label " cost " attr then total . + float_of_string ( Attribute . payload attr ) else total ) 0 . ( prj attrs ) let cost_of_symbol = let mea... |
let run rule_group : bool list = Rectypes . rectypes rule_group |> List . map snd |
let create_token s = { name = s ; is_inlined = false ; description = Constant s ; } |
let create_rule name body : rule = { name ; body ; is_rec = true ; is_inlined_rule = false ; is_inlined_type = false ; } |
let test_no_cycle ( ) = let rule = create_rule " a " ( Seq [ Symbol " b " ; Token ( create_token " x " ) ; Blank ; Repeat ( Symbol " c " ) ; Choice [ " y " , Symbol " d " ; " z " , Token ( create_token " z " ) ] ; ] ) in assert ( run [ rule ] = [ false ] ) |
let test_simple_cycle ( ) = let rule = create_rule " a " ( Seq [ Symbol " b " ; Blank ; Token ( create_token " x " ) ; Optional ( Repeat1 ( Repeat ( Symbol " a " ) ) ) ; ] ) in assert ( run [ rule ] = [ true ] ) |
let test_cycle_and_choice ( ) = let rule = create_rule " a " ( Seq [ Symbol " b " ; Token ( create_token " x " ) ; Blank ; Repeat ( Symbol " c " ) ; Choice [ " y " , Symbol " a " ; " z " , Token ( create_token " z " ) ] ; ] ) in assert ( run [ rule ] = [ false ] ) |
let test_mutually_recursive ( ) = let rule_a = create_rule " a " ( Seq [ Symbol " b " ; Token ( create_token " x " ) ; ] ) in let rule_b = create_rule " b " ( Seq [ Symbol " a " ; Token ( create_token " x " ) ; ] ) in let rule_c = create_rule " c " ( Choice [ " a " , Symbol " a " ; " b " , Symbol " b " ; " c " , Symbol... |
let test = " Rectypes " , [ " no cycle " , ` Quick , test_no_cycle ; " simple cycle " , ` Quick , test_simple_cycle ; " cycle and choice " , ` Quick , test_cycle_and_choice ; " mutually recursive " , ` Quick , test_mutually_recursive ; ] |
module type S = sig type ( ' a , ' b ) reagent type t val create : unit -> t val acq : t -> ( unit , unit ) reagent val try_acq : t -> ( unit , bool ) reagent val rel : t -> ( unit , bool ) reagent end |
module Make ( Base : Base . S ) ( Tid : sig val get_tid : unit -> int end ) : S with type ( ' a , ' b ) reagent = ( ' a , ' b ) Base . t = struct type ( ' a , ' b ) reagent = ( ' a , ' b ) Base . t open Base type thread_id = int type count = int type status = Locked of thread_id * count | Unlocked type t = status Ref .... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.