text stringlengths 0 601k |
|---|
let rec get_to_bottom_of_aliases f = function | ( _alias1 , type1 ) type1 :: ( _alias2 , type2 ) type2 :: rest -> begin match get_to_bottom_of_aliases f rest with | false -> f ( type1 , type2 ) type2 | true -> true end | _ -> false |
let state_escape_scope = get_to_bottom_of_aliases ( function | ( { desc = Tconstr ( p , _ , _ ) _ } _ , { desc = Tvar _ ; level } level ) level when level < Path . binding_time p -> true | _ -> false ) |
let is_array_wanted_reactElement = get_to_bottom_of_aliases ( function | ( { desc = Tconstr ( path1 , _ , _ ) _ } _ , { desc = Tconstr ( path2 , _ , _ ) _ } _ ) _ when Path . last path1 = " array " && Path . last path2 = " reactElement " -> true | _ -> false ) end |
let report_error env ppf = function | Typecore . Polymorphic_label lid -> fprintf ppf [ " @ The record field % a is polymorphic . @ % s ] " @ longident lid " You cannot instantiate it in a pattern . " | Constructor_arity_mismatch ( Constructor_arity_mismatchlid , expected , provided ) provided -> fprintf ppf [ " @ This... |
let report_error env ppf err = Printtyp . wrap_printing_env env ( fun ( ) -> report_error env ppf err ) err |
let setup ( ) = Location . register_error_of_exn ( function | Typecore . Error ( loc , env , err ) err -> Some ( Super_location . error_of_printer loc ( report_error env ) env err ) err | Typecore . Error_forward err -> Some err | _ -> None ) end |
let pp_component_type_not_generalizable_pre ppf = fprintf ppf [ " @< v >\ [ { @@< info > Is this a ReasonReact reducerComponent or component with retained props } ?@@ \ If so , this error will disappear after ] , :@@\ [ @- Defining the component ' s ` make ` function ] , @@\ [ @- Using the state once or annotating it w... |
let pp_component_type_not_generalizable_post ppf ( ) = fprintf ppf [ " @ This happens when the type system senses there ' s a mutation / side - effect , in combination with a polymorphic value . , @\ Using or annotating that value usually solves it . @ \ More info :@ https :// realworldocaml . org / v1 / en / html / im... |
let report_error ppf = Typemod ( . function Cannot_apply mty -> fprintf ppf [ " @ This module is not a functor ; it has type @ % a ] " @ modtype mty | Not_included errs -> fprintf ppf [ " @< v > Signature mismatch :@ % a ] " @ Includemod . report_error errs | Cannot_eliminate_dependency mty -> fprintf ppf [ " @ This fu... |
let report_error env ppf err = Printtyp . wrap_printing_env env ( fun ( ) -> report_error ppf err ) err |
let setup ( ) = Location . register_error_of_exn ( function | Typemod . Error ( loc , env , err ) err -> Some ( Super_location . error_of_printer loc ( report_error env ) env err ) err | Typemod . Error_forward err -> Some err | _ -> None ) end |
let spellcheck ppf fold env lid = let cutoff = match String . length ( Longident . last lid ) lid with | 1 | 2 -> 0 | 3 | 4 -> 1 | 5 | 6 -> 2 | _ -> 3 in let compare target head acc = let ( best_choice , best_dist ) best_dist = acc in match Misc . edit_distance target head cutoff with | None -> ( best_choice , best_dis... |
let spellcheck ppf fold = spellcheck ppf ( fun f -> fold ( fun s _ _ x -> f s x ) x ) x |
let report_error env ppf = function | Typetexp . Unbound_type_variable name -> fprintf ppf " Unbound type parameter % s . " @ name | Unbound_type_constructor lid -> fprintf ppf " This type constructor ' s parameter , ` % a ` , can ' t be found . Is it a typo " ? longident lid ; spellcheck ppf Env . fold_types env lid ;... |
let setup ( ) = Location . register_error_of_exn ( function | Typetexp . Error ( loc , env , err ) err -> Some ( Super_location . error_of_printer loc ( report_error env ) env err ) err | _ -> None ) end |
let setup ( ) = Super_location . setup ( ) ; Super_typetexp . setup ( ) ; Super_typemod . setup ( ) ; Super_typecore . setup ( ) ; Super_env . setup ( ) ; Super_pparse . setup ( ) ; end |
let rec drill_through_tlink_and_tsubst t = match t . desc with | Tlink t | Tsubst t -> drill_through_tlink_and_tsubst t | _ -> t |
let is_weak_type_after_drilling t = match drill_through_tlink_and_tsubst t with | { desc = Tvar _ } _ -> true | _ -> false |
let component_spec_weak_type_variables t = match drill_through_tlink_and_tsubst t with | { desc = Tconstr ( Pdot ( ( Pident { name = " ReasonReact } ) " , " componentSpec " , _ ) _ , [ state ; _initial_state ; retained_props ; _initial_retained_props ; action ] action , _ ) } -> ( state |> is_weak_type_after_drilling ,... |
let component_spec_weak_type_variables_in_module_type ( mty : Types . module_type ) module_type = match mty with | Mty_signature signature_values -> signature_values |> List . map ( function | Sig_value ( _id , value_desc ) value_desc -> let typ = value_desc . val_type in component_spec_weak_type_variables typ | _ -> (... |
let check_each_trace_chunk_bottom_up f = fun t -> let t_flipped = List . rev t in let rec check f = function | ( _alias2 , type2 ) type2 :: ( _alias1 , type1 ) type1 :: rest -> if f ( type1 , type2 ) type2 then true else check f rest | _ -> false in check f t_flipped |
let state_escape_scope = check_each_trace_chunk_bottom_up ( function | ( { desc = Tconstr ( p , _ , _ ) _ } _ , { desc = Tvar _ ; level } level ) level when level < Path . binding_time p -> true | _ -> false ) |
let trace_both_component_spec = check_each_trace_chunk_bottom_up ( function | ( { desc = Tconstr ( ( Pdot ( ( Pident { name = " ReasonReact } ) " , " componentSpec " , _ ) _ ) _ , ( [ state1 ; _ ; _ ; _ ; action1 ] action1 | [ state1 ; _ ; action1 ] action1 ) action1 , _ ) } , { desc = Tconstr ( ( Pdot ( ( Pident { nam... |
let is_array_wanted_react_element = check_each_trace_chunk_bottom_up ( function | ( { desc = Tconstr ( path1 , _ , _ ) _ } _ , { desc = Tconstr ( ( Pdot ( ( Pident { name = " ReasonReact } ) " , " reactElement " , _ ) _ ) _ , _ , _ ) } ) when Path . last path1 = " array " -> true | _ -> false ) |
let is_component_spec_wanted_react_element = check_each_trace_chunk_bottom_up ( function | ( { desc = Tconstr ( ( Pdot ( ( Pident { name = " ReasonReact } ) " , " componentSpec " , _ ) _ ) _ , ( [ state1 ; _ ; _ ; _ ; action1 ] action1 | [ state1 ; _ ; action1 ] action1 ) action1 , _ ) } , { desc = Tconstr ( ( Pdot ( (... |
let tagged tag fn ppf arg = Format . pp_open_tag ppf tag ; fn ppf arg ; Format . pp_close_tag ppf ( ) |
let rec bottom_aliases = function | ( _ , one ) one :: ( _ , two ) two :: rest -> begin match bottom_aliases rest with | Some types -> Some types | None -> Some ( one , two ) two end | _ -> None |
let simple_conversions = [ ( ( " float " , " int ) " , " int_of_float ) " ; ( ( " int " , " float ) " , " float_of_int ) " ; ( ( " int " , " string ) " , " string_of_int ) " ; ( ( " float " , " string ) " , " string_of_float ) " ; ] |
let print_simple_conversion ppf ( actual , expected ) expected = try ( let converter = List . assoc ( actual , expected ) expected simple_conversions in Format . pp_print_newline ppf ( ) ; Format . pp_print_newline ppf ( ) ; fprintf ppf " You can convert a { @< info >% s } @ to a { @< info >% s } @ with { @< info >% s ... |
let print_simple_message ppf = function | ( " float " , " int ) " -> fprintf ppf " If this is a literal , you want a number without a trailing dot ( e . g . { @< info > 20 } ) . ; " @@ | ( " int " , " float ) " -> fprintf ppf " If this is a literal , you want a number with a trailing dot ( e . g . { @< info > 20 } ) . ... |
let show_extra_help ppf env trace = begin match bottom_aliases trace with | Some ( { desc = Tconstr ( actualPath , actualArgs , _ ) _ } _ , { desc = Tconstr ( expectedPath , expextedArgs , _ ) _ } _ ) _ -> begin match ( actualPath , actualArgs , expectedPath , expextedArgs ) expextedArgs with | ( Pident { name = actual... |
let rec collect_missing_arguments env type1 type2 = match type1 with | { desc = Tarrow ( label , argtype , typ , _ ) _ } _ when Ctype . matches env typ type2 -> Some [ ( label , argtype ) argtype ] argtype | { desc = Tarrow ( label , argtype , typ , _ ) _ } _ -> begin match collect_missing_arguments env typ type2 with ... |
let check_bs_arity_mismatch ppf trace = let arity t = match t . desc with | Tvariant { row_fields = [ ( label , _ ) _ ] _ } -> let label_len = String . length label in let arity_str = " Arity_ " in let arity_len = String . length arity_str in if arity_len < label_len && String . sub label 0 arity_len = arity_str then t... |
let print_expr_type_clash env trace ppf = if Super_reason_react . state_escape_scope trace && Super_reason_react . trace_both_component_spec trace then fprintf ppf [ " @< v >\ [ { @@< info > Is this a ReasonReact reducerComponent or component with retained props } ?@@ \ If so , is the type for state , retained props or... |
let report_error env ppf = function | Typecore . Polymorphic_label lid -> fprintf ppf [ " @ The record field % a is polymorphic . @ % s ] " @ longident lid " You cannot instantiate it in a pattern . " | Constructor_arity_mismatch ( Constructor_arity_mismatchlid , expected , provided ) provided -> fprintf ppf [ " @ This... |
let report_error env ppf err = Printtyp . wrap_printing_env env ( fun ( ) -> report_error env ppf err ) err |
let setup ( ) = Location . register_error_of_exn ( function | Typecore . Error ( loc , env , err ) err -> Some ( Super_location . error_of_printer loc ( report_error env ) env err ) err | Typecore . Error_forward err -> Some err | _ -> None ) |
let non_generalizable_msg ppf ~ result ~ is_module print_fallback_msg = let contain_vs_be = if is_module then " This module seems to contain " else " This seems to be " in match result with | ( _ , true , _ ) _ :: _ -> fprintf ppf [ " @< v >\ { @< info >% s a ReasonReact reducerComponentWithRetainedProps } ?@@ \ The re... |
let report_error ppf = Typemod ( . function Cannot_apply mty -> fprintf ppf [ " @ This module is not a functor ; it has type @ % a ] " @ modtype mty | Not_included errs -> fprintf ppf [ " @< v > Signature mismatch :@ % a ] " @ Includemod . report_error errs | Cannot_eliminate_dependency mty -> fprintf ppf [ " @ This fu... |
let report_error env ppf err = Printtyp . wrap_printing_env env ( fun ( ) -> report_error ppf err ) err |
let setup ( ) = Location . register_error_of_exn ( function | Typemod . Error ( loc , env , err ) err -> Some ( Super_location . error_of_printer loc ( report_error env ) env err ) err | Typemod . Error_forward err -> Some err | _ -> None ) |
let spellcheck ppf fold env lid = let cutoff = match String . length ( Longident . last lid ) lid with | 1 | 2 -> 0 | 3 | 4 -> 1 | 5 | 6 -> 2 | _ -> 3 in let compare target head acc = let ( best_choice , best_dist ) best_dist = acc in match Misc . edit_distance target head cutoff with | None -> ( best_choice , best_dis... |
let spellcheck ppf fold = spellcheck ppf ( fun f -> fold ( fun s _ _ x -> f s x ) x ) x |
let report_error env ppf = function | Typetexp . Unbound_type_variable name -> fprintf ppf " Unbound type parameter % s . " @ name | Unbound_type_constructor lid -> fprintf ppf " This type constructor ' s parameter , ` % a ` , can ' t be found . Is it a typo " ? longident lid ; spellcheck ppf Env . fold_types env lid ;... |
let setup ( ) = Location . register_error_of_exn ( function | Typetexp . Error ( loc , env , err ) err -> Some ( Super_location . error_of_printer loc ( report_error env ) env err ) err | _ -> None ) |
let ( ) = Random . init 100 |
type bid = { action : buy_or_sell ; price : int ; volume : int ; } and buy_or_sell = Buy | Sell |
let generate_auction_data ( ) = List . map3_exn ( [ Buy ; Sell ] |> sample ~ size : 100 ) ( List . range 1 100 ~ stop ` : inclusive |> sample ~ size : 100 ) ( List . range 1 10 ~ stop ` : inclusive |> sample ~ size : 100 ) ~ f ( : fun action price volume -> { action ; price ; volume } ) |
let asks , bids = let group_by_price = group_by ~ f ( : fun q -> q . price ) in let group_by_action = group_by ~ f ( : fun q -> q . action ) in let flat_map l ~ f = List . bind l ~ f in let aggregate bids = List . reduce_exn bids ~ f ( : fun b1 b2 -> { b1 with volume = b1 . volume + b2 . volume } ) in generate_auction_... |
let ( ) = let aggregate bids = begin match bids with | [ ] | [ _ ] as x -> x | bid :: bids -> scan bids ~ init : bid ~ f ( : fun b1 b2 -> { b1 with price = b2 . price ; volume = b1 . volume + b2 . volume } ) end |> List . map ~ f ( : fun b -> Caml . float b . volume , Caml . float b . price ) in let gp = Gp . create ( ... |
module Specification = struct type t = | UnreachCall of string | NoDataRace | NoOverflow let of_string s = let s = String . strip s in let regexp = Str . regexp " CHECK ( init ( main ( ) ) , LTL ( G ! ( . ) ) \\*\\ ) " in if Str . string_match regexp s 0 then let global_not = Str . matched_group 1 s in if global_not = ... |
module type Task = sig val file : Cil . file val specification : Specification . t module Cfg : MyCFG . CfgBidir end |
let task : ( module Task ) option ref = ref None |
let is_error_function f = let module Task = ( val ( Option . get ! task ) ) in match Task . specification with | UnreachCall f_spec -> f . vname = f_spec | _ -> false |
let is_special_function f = let loc = f . vdecl in let is_svcomp = String . ends_with loc . file " sv - comp . c " in let is_verifier = match f . vname with | fname when String . starts_with fname " __VERIFIER " -> true | fname -> let module Task = ( val ( Option . get ! task ) ) in match Task . specification with | Un... |
module Result = struct type t = | True | False of Specification . t option | Unknown let to_string = function | True -> " true " | False None -> " false " | False ( Some spec ) -> let result_spec = match spec with | UnreachCall _ -> " unreach - call " | NoOverflow -> " no - overflow " | NoDataRace -> " no - data - race... |
module type TaskResult = sig module Arg : MyARG . S val result : Result . t val invariant : Arg . Node . t -> Invariant . t val is_violation : Arg . Node . t -> bool val is_sink : Arg . Node . t -> bool end |
module StackTaskResult ( Cfg : MyCFG . CfgForward ) ( TaskResult : TaskResult ) = struct module Arg = MyARG . Stack ( Cfg ) ( TaskResult . Arg ) let result = TaskResult . result let invariant nl = TaskResult . invariant ( List . hd nl ) let is_violation nl = TaskResult . is_violation ( List . hd nl ) let is_sink nl = T... |
type command = | Move_to of float * float | Curve_to of float * float * float * float * float * float |
type color = float * float * float |
type element = | Path of command list * color option * color option | Ellipse of float * float * float * float * color option * color option | Polygon of ( float * float ) list * color option * color option | Text of float * float * string * string * float * color option * color option |
let w = truncate ( ( width . * float h . / height ) . + 0 . 5 ) |
let s = Cairo . image_surface_create Cairo . FORMAT_ARGB32 w h |
let perform_draw ctx fill stroke = ( match fill with | Some ( r , g , b ) -> Cairo . set_source_rgb ctx r g b ; if stroke <> None then Cairo . fill_preserve ctx else Cairo . fill ctx | None -> ( ) ) ; match stroke with | Some ( r , g , b ) -> Cairo . set_source_rgb ctx r g b ; Cairo . stroke ctx | None -> ( ) |
let pi = 4 . . * atan 1 . |
let draw_element ctx e = match e with | Path ( cmd , fill , stroke ) -> List . iter ( fun c -> match c with | Move_to ( x , y ) -> Cairo . move_to ctx x y | Curve_to ( x1 , y1 , x2 , y2 , x3 , y3 ) -> Cairo . curve_to ctx x1 y1 x2 y2 x3 y3 ) cmd ; perform_draw ctx fill stroke | Ellipse ( cx , cy , rx , ry , fill , stro... |
let path_extent ctx fill stroke = if stroke <> None then Cairo . stroke_extents ctx else Cairo . fill_extents ctx |
let compute_extent ctx e = Cairo . new_path ctx ; match e with | Path ( cmd , fill , stroke ) -> List . iter ( fun c -> match c with | Move_to ( x , y ) -> Cairo . move_to ctx x y | Curve_to ( x1 , y1 , x2 , y2 , x3 , y3 ) -> Cairo . curve_to ctx x1 y1 x2 y2 x3 y3 ) cmd ; path_extent ctx fill stroke | Ellipse ( cx , cy... |
let ctx = Cairo . create s |
let scale = float h . / height |
let _ = Cairo . scale ctx scale scale ; Cairo . translate ctx 364 . 22443 . |
let convert ( r , g , b ) = let c i = float i . / 255 . 99 in c r , c g , c b |
let named_colors = let colors = Hashtbl . create 101 in List . iter ( fun ( nm , v ) -> Hashtbl . add colors nm ( convert v ) ) [ " aliceblue " , ( 240 , 248 , 255 ) ; " antiquewhite " , ( 250 , 235 , 215 ) ; " aqua " , ( 0 , 255 , 255 ) ; " aquamarine " , ( 127 , 255 , 212 ) ; " azure " , ( 240 , 255 , 255 ) ; " beige... |
let svg_name nm = " http :// www . w3 . org / 2000 / svg " , nm |
let d_attr = " " , " d " |
let x_attr = " " , " x " |
let y_attr = " " , " y " |
let cx_attr = " " , " cx " |
let cy_attr = " " , " cy " |
let rx_attr = " " , " rx " |
let ry_attr = " " , " ry " |
let points_attr = " " , " points " |
let taxt_anchor_attr = " " , " text - anchor " |
let font_family_attr = " " , " font - family " |
let font_size_attr = " " , " font - size " |
let fill_attr = " " , " fill " |
let stroke_attr = " " , " stroke " |
let stack = ref [ ] |
let push e = stack := e :: ! stack |
let skip_whitespace i = match Xmlm . peek i with | ` Data s -> ignore ( Xmlm . input i ) | _ -> ( ) |
let end_tag i = let e = Xmlm . input i in assert ( e = ` El_end ) |
let rec empty_tag i = match Xmlm . input i with | ` Data s -> empty_tag i | ` El_end -> ( ) | _ -> assert false |
let rec text_tag i = match Xmlm . input i with | ` Data s -> empty_tag i ; s | ` El_end -> " " | _ -> assert false |
let comma_wsp = Str . regexp " [ \ x20 \ x09 \ x0D \ x0A , ] " + |
let cmd = Str . regexp " [ a - zA - Z ] " |
let rec parse_curve_to args rem = match args with | [ ] -> rem | x1 :: y1 :: x2 :: y2 :: x3 :: z3 :: r -> Curve_to ( x1 , y1 , x2 , y2 , x3 , z3 ) :: parse_curve_to r rem | _ -> assert false |
let rec parse_cmds l = match l with | Str . Delim cmd :: Str . Text args :: rem -> ( let args = List . map float_of_string ( Str . split comma_wsp args ) in let rem = parse_cmds rem in match cmd , args with | " M " , [ x ; y ] -> Move_to ( x , y ) :: rem | " C " , ( _ :: _ as args ) -> parse_curve_to args rem | _ -> as... |
let parse_path s = let l = Str . full_split cmd s in parse_cmds l |
let parse_color c = if c = " none " then None else if String . length c = 7 && c . [ 0 ] = ' ' # then let conv s = int_of_string ( " 0x " ^ s ) in let c = conv ( String . sub c 1 2 ) , conv ( String . sub c 3 2 ) , conv ( String . sub c 5 2 ) in Some ( convert c ) else Some ( try Hashtbl . find named_colors c with Not_... |
let read_path attrs i = let d = List . assoc d_attr attrs in let cmd = parse_path d in let fill = parse_color ( List . assoc fill_attr attrs ) in let stroke = parse_color ( List . assoc stroke_attr attrs ) in let e = Path ( cmd , fill , stroke ) in push e ; empty_tag i |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.