text
stringlengths
12
786k
let is_pkg_system project pkg = Hashtbl . find project . project_dep_data pkg = System
let get_internal_library_deps project target = let internalDeps = Dag . getChildren project . project_targets_dag target . target_name in list_filter_map ( fun name -> match name with | Name . Lib lname -> Some lname | _ -> None ) internalDeps
let initializeSystemStdlib ocamlCfg = let ocaml_ver = Hashtbl . find ( Prog . getOcamlConfig ( ) ) " version " in let stdlibPath = fp ( get_ocaml_config_key_hashtbl " standard_library " ocamlCfg ) in let stdlibLibs = Filesystem . list_dir_pred_map ( fun n -> let ext = Filetype . of_f...
let readOcamlMkConfig filename = let lines = Utils . read_file_with ( function " " -> None | s when s . [ 0 ] = ' ' # -> None | s -> Some s ) ( filename ^ " / Makefile . config " ) in let h = Hashtbl . create 32 in List . iter ( fun l -> let ( k , v ) = Utils . ...
let prepare projFile user_flags = verbose Verbose " analyzing project \ n " ; %! let ocamlCfg = Prog . getOcamlConfig ( ) in let ocamlMkCfg = readOcamlMkConfig ( Hashtbl . find ocamlCfg " standard_library " ) in let depsTable = Hashtbl . create 16 in let cpkgsTable = Hashtbl . create 1...
module _ = struct let x = 13 , 37 end
module rec A : sig type t = B . t type t = A . t val x : int * int type t = B . t let x = 4 , 2 end type t type t let x = " foo " , " bar " end
let f ( module _ : S ) = ( )
type re = { mutable cell : string ; }
let s = { cell = " " }
module _ = struct let ( ) = s . cell <- " Hello World " ! end
let drop _ = ( )
let ( ) = drop s . cell
let malformed_string s = Format . kasprintf invalid_arg " Terminal . Ansi : malformed UTF - 8 string : % S " s
module Length_counter = struct type t = { mutable acc : int ; mutable state : [ ` Normal | ` Parsing_ansi_sequence | ` Ansi_parameter_bytes ] } let empty ( ) = { acc = 0 ; state = ` Normal } let is_initial_ansi_byte c = Char . equal c ' \ x1b ' let is_final_ansi_byte c = l...
let guess_printed_width s = let count = Length_counter . empty ( ) in Uutf . String . fold_utf_8 ( fun ( ) _ -> function | ` Malformed _ -> malformed_string s | ` Uchar c -> Length_counter . add count c ) ( ) s ; Length_counter . count count
let uchar_size u = match Uchar . to_int u with | u when u < 0 -> assert false | u when u <= 0x007F -> 1 | u when u <= 0x07FF -> 2 | u when u <= 0xFFFF -> 3 | u when u <= 0x10FFFF -> 4 | _ -> assert false
let string_equal : string -> string -> bool = ( = )
let truncate_to_width width s = if width < 0 then Format . kasprintf invalid_arg " Terminal . truncate_to_width : negative width % d requested " width ; let count = Length_counter . empty ( ) in try Uutf . String . fold_utf_8 ( fun ( ) i -> function | ` Malformed _ -> malformed_str...
let move_up ppf = function 0 -> ( ) | n -> Format . fprintf ppf " \ x1b [ % dA " n
let move_down ppf = function 0 -> ( ) | n -> Format . fprintf ppf " \ x1b [ % dB " n
let apigw_response = ( module struct type t = Http . api_gateway_proxy_response let pp formatter t = Format . pp_print_text formatter ( t |> Http . API_gateway_response . to_yojson |> Lwt_main . run |> Yojson . Safe . pretty_to_string ) let equal = ( = ) end : Alcotest . TESTABLE with...
module Http_runtime = struct include Http type event = Http . API_gateway_request . t type response = Http . API_gateway_response . t end
let request = Test_common . make_test_request ( module Http . API_gateway_request ) " apigw_real "
let test_fixture = Test_common . test_fixture ( module Http . API_gateway_request )
let test_runtime = test_runtime_generic ( module Http_runtime ) ~ lift : Lwt . return request
let test_async_runtime = test_runtime_generic ( module Http_runtime ) ~ lift : id request
let response = Http . { status_code = 200 ; headers = StringMap . empty ; body = " Hello " ; is_base64_encoded = false }
let suite = [ " deserialize ( mock ) API Gateway Proxy Request " , ` Quick , test_fixture " apigw " ; ( " deserialize ( real world ) API Gateway Proxy Request " , ` Quick , test_fixture " apigw_real_trimmed " ) ; ( " successful handler invocation " , ` Quick , ...
module Model = struct type t = unit [ @@ deriving sexp ] let init ( ) = ( ) let cutoff _ _ = true end
module Action = struct type t = unit [ @@ deriving sexp ] let should_log _ = true end
module State = struct type t = unit end
let apply_action _ _ _ ~ schedule_action : _ = ( )
let on_startup ~ schedule_action : _ _ = Async_kernel . return ( )
let view_resize_observer = let widget_id = Type_equal . Id . create ~ name " : my widget type " ( fun ( _ : ResizeObserver . resizeObserver Js . t * Dom_html . element Js . t ) -> Sexp . Atom " < resize - observer - widget " ) > in Vdom . Node . widget ~ id : widget_id ~...
let view_colorize_button = let widget_id = Type_equal . Id . create ~ name " : my widget type " ( fun _ -> Sexp . Atom " < my widget type " ) > in Vdom . Node . widget ~ id : widget_id ~ init ( : fun ( ) -> let button = Dom_html . document ## createElement ( " button " ...
let raw_html = Vdom . Node . inner_html ~ tag " : div " ~ attr : Vdom . Attr . empty ~ this_html_is_sanitized_and_is_totally_safe_trust_me " :< b > bold </ b " > ; ;
let view _ ~ inject : _ = Incr . return ( Vdom . Node . div [ view_colorize_button ; view_resize_observer ; raw_html ] ) ; ;
let create model ~ old_model : _ ~ inject = let open Incr . Let_syntax in let % map apply_action = let % map model = model in apply_action model and view = view model ~ inject and model = model in Component . create ~ apply_action model view ; ;
type t = { k : Continuation . t ; args : Simple . t list ; trap_action : Trap_action . Option . t ; dbg : Debuginfo . t }
let print_or_elide_debuginfo ppf dbg = if Debuginfo . is_none dbg then Format . pp_print_string ppf " " else begin Format . pp_print_string ppf " " ; Debuginfo . print_compact ppf dbg end type nonrec t = t let [ @ ocamlformat " disable " ] print ppf { k ; args ; trap_action ; dbg ; ...
let create ? trap_action k ~ args ~ dbg = { k ; args ; trap_action ; dbg }
let goto k = { k ; args = [ ] ; trap_action = None ; dbg = Debuginfo . none }
let continuation t = t . k
let args t = t . args
let trap_action t = t . trap_action
let debuginfo t = t . dbg
let free_names { k ; args ; trap_action ; dbg = _ } = let default = Simple . List . free_names args in match trap_action with | None -> Name_occurrences . add_continuation default k ~ has_traps : false | Some trap_action -> Name_occurrences . add_continuation ( Name_occurrences . union d...
let apply_renaming ( { k ; args ; trap_action ; dbg } as t ) perm = let k ' = Renaming . apply_continuation perm k in let args ' = Simple . List . apply_renaming args perm in let trap_action ' = Trap_action . Option . apply_renaming trap_action perm in if k == k ' && args == args ...
let all_ids_for_export { k ; args ; trap_action ; dbg = _ } = List . fold_left ( fun ids arg -> Ids_for_export . add_simple ids arg ) ( Ids_for_export . add_continuation ( Trap_action . Option . all_ids_for_export trap_action ) k ) args
let update_continuation t continuation = { t with k = continuation }
let update_continuation_and_args t cont ~ args = if Continuation . equal t . k cont && args == t . args then t else { t with k = cont ; args }
let update_args t ~ args = if args == t . args then t else { t with args }
let with_debuginfo t ~ dbg = if dbg == t . dbg then t else { t with dbg }
let no_args t = match args t with [ ] -> true | _ :: _ -> false
let is_goto t = no_args t && Option . is_none ( trap_action t )
let is_goto_to t k = Continuation . equal ( continuation t ) k && is_goto t
let to_goto t = if no_args t && Option . is_none ( trap_action t ) then Some ( continuation t ) else None
let is_raise t = match t . trap_action with | Some ( Pop { exn_handler ; _ } ) -> Continuation . equal t . k exn_handler | Some ( Push _ ) | None -> false
let clear_trap_action t = { t with trap_action = None }
let to_one_arg_without_trap_action t = match t . trap_action with | Some _ -> None | None -> ( match t . args with [ arg ] -> Some arg | [ ] | _ :: _ :: _ -> None )
type used = | Used | Unused
type t = { original_params : Bound_parameters . t ; used_params : BP . Set . t ; used_extra_params : Bound_parameters . t ; extra_args : ( EA . t * used ) list Id . Map . t }
let print_used ppf = function | Used -> ( ) | Unused -> Format . fprintf ppf " @ unused "
let print_ea_used ppf t = Format . fprintf ppf " ( % a ) " ( Format . pp_print_list ~ pp_sep : Format . pp_print_space ( fun ppf ( ea , used ) -> Format . fprintf ppf " % a % a " EA . print ea print_used used ) ) t
let [ @ ocamlformat " disable " ] print ppf { original_params ; used_params ; used_extra_params ; extra_args ; } = Format . fprintf ppf " [ @< hov 1 ( >\ [ @< hov 1 ( > original_params @ ( % a ) ) ] @@ \ [ @< hov 1 ( > used_params @ % a ) ] @@ \ [ @<...
let does_nothing t = Bound_parameters . cardinal t . original_params = BP . Set . cardinal t . used_params && Id . Map . is_empty t . extra_args
let create ~ original_params ~ used_params ~ extra_params ~ extra_args ~ used_extra_params = Bound_parameters . check_no_duplicates original_params ; Bound_parameters . check_no_duplicates extra_params ; if Bound_parameters . cardinal original_params < BP . Set . cardinal used_params then Misc . ...
let original_params t = t . original_params
let used_params t = t . used_params
let used_extra_params t = t . used_extra_params
let extra_args t id = match Id . Map . find id t . extra_args with | exception Not_found -> if not ( Bound_parameters . is_empty t . used_extra_params ) then Misc . fatal_errorf " This [ Apply_cont_rewrite ] does not have any @ extra arguments for use \ ID % a , but it has @ >= 1 extra ...
let original_params_arity t = Bound_parameters . arity_with_subkinds ( original_params t )
module type Model = sig type t val cutoff : t -> t -> bool end
module type Action = sig type t [ @@ deriving sexp_of ] end
module type State = sig type t end
module type S = sig module Model : Model module Action : Action module State : State val on_startup : schedule_action ( : Action . t -> unit ) -> Model . t -> State . t Deferred . t Component . create ~ apply_action model view ; ; ] } The full code for this example can be found in exampl...
module Private = struct type ( ' state , ' model , ' action ) snapshot = { view : Vdom . Node . t ; apply_action : ' state -> schedule_event ( : unit Ui_effect . t -> unit ) -> ' model -> ' action -> ' model ; update_visibility : ' model -> schedule_event ( : unit ...
type t = { size : Dwarf_int . t ; values : Dwarf_value . t list }
let create ~ start_of_code_symbol ~ end_of_code_symbol ~ debug_info_label = let module V = Dwarf_value in let values = [ V . int16 ~ comment " : section version number " ( Int16 . of_int_exn 2 ) ; V . offset_into_debug_info ~ comment " : offset to compilation unit header " debug_info_la...
let size t = t . size
let emit ~ asm_directives t = Initial_length . emit ~ asm_directives ( Initial_length . create t . size ) ; List . iter ( fun v -> Dwarf_value . emit ~ asm_directives v ) t . values
let pic_code = ref true
let command_line_options = [ " - fPIC " , Arg . Set pic_code , " Generate position - independent machine code ( default ) " ; " - fno - PIC " , Arg . Clear pic_code , " Generate position - dependent machine code " ]
type specific_operation = Imultaddf | Imultsubf
type addressing_mode = | Iindexed of int | Iindexed2 of int
let identity_addressing = Iindexed 0
let offset_addressing addr delta = match addr with | Iindexed n -> Iindexed ( n + delta ) | Iindexed2 n -> Iindexed2 ( n + delta )
let num_args_addressing = function | Iindexed _ -> 1 | Iindexed2 _ -> 2
let print_addressing printreg addr ppf arg = match addr with | Iindexed n -> let idx = if n <> 0 then Printf . sprintf " + % i " n else " " in fprintf ppf " % a % s " printreg arg . ( 0 ) idx | Iindexed2 n -> let idx = if n <> 0 then Printf . sprintf " + % i " n else " " ...
let print_specific_operation printreg op ppf arg = match op with | Imultaddf -> fprintf ppf " % a * f % a + f % a " printreg arg . ( 0 ) printreg arg . ( 1 ) printreg arg . ( 2 ) | Imultsubf -> fprintf ppf " % a * f % a - f % a " printreg arg . ( 0 ) printreg arg . (...
let operation_is_pure _ = true
let operation_can_raise _ = false
type anon_fun = ( string -> unit )
type spec = | Unit of ( unit -> unit ) | Bool of ( bool -> unit ) | Set of bool ref | Clear of bool ref | String of ( string -> unit ) | Set_string of string ref | Int of ( int -> unit ) | Set_int of int ref | Float of ( float -> unit ) | Set_float of float ref | Tuple of spec list ...
type error = | Unknown of string | Wrong of string * string * string | Missing of string | Message of string
let rec assoc3 x l = match l with | [ ] -> raise Not_found | ( y1 , y2 , _ ) :: _ when y1 = x -> y2 | _ :: t -> assoc3 x t
let split s = let i = String . index s ' ' = in let len = String . length s in String . sub s 0 i , String . sub s ( i + 1 ) ( len ( - i + 1 ) )
let make_symlist prefix sep suffix l = match l with | [ ] -> " < none " > | h :: t -> ( List . fold_left ( fun x y -> x ^ sep ^ y ) ( prefix ^ h ) t ) ^ suffix
let print_spec buf ( key , spec , doc ) = if String . length doc > 0 then match spec with | Symbol ( l , _ ) -> bprintf buf " % s % s % s \ n " key ( make_symlist " { " " " | " } " l ) doc | _ -> bprintf buf " % s % s \ n " key doc