text stringlengths 0 601k |
|---|
let to_int64_array t = Array . init ( words t ) ~ f ( : fun i -> unsafe_get_int64 t i ) |
let to_z ~ signedness t = let module Z = Zarith . Z in let words = words t in let rec f word z = if word < 0 then z else ( let w = unsafe_get_int64 t word in let a = Int64 . ( w lsr 32 ) in let z = Z . ( logor ( shift_left z 32 ) ( of_int64 a ) ) in let a = Int64 . ( w land 0xFFFF_FFFFL ) in let z = Z . ( logor ( shift... |
let to_hex_string ~ signedness t = let rec of_binary ( ~ signedness : Signedness . t ) s = let hex_of_bin s = match s with | " 0000 " -> " 0 " | " 0001 " -> " 1 " | " 0010 " -> " 2 " | " 0011 " -> " 3 " | " 0100 " -> " 4 " | " 0101 " -> " 5 " | " 0110 " -> " 6 " | " 0111 " -> " 7 " | " 1000 " -> " 8 " | " 1001 " -> " 9... |
let of_hum x = String . filter x ~ f ( : fun c -> not Char . ( c = ' _ ' ) ) |
let of_binary_string b = if String . length b = 0 then raise_s [ % message " [ Constant . of_binary_string ] input string is empty " ] else ( let width = String . length b in let rec to_int8 b acc offset count = if count = 0 then Char . of_int_exn acc else ( let char = b . [ offset ] in if Char . ( char = ' 0 ' || char... |
let of_binary_string_hum b = of_binary_string ( of_hum b ) |
let of_int64 ~ width i = let sign_extend_value = if Int64 . ( i < 0L ) then - 1L else 0L in init_int64 ~ width ~ f ( : function | 0 -> i | _ -> sign_extend_value ) ; ; |
let of_int ~ width i = of_int64 ~ width ( Int64 . of_int i ) |
let of_int32 ~ width i = of_int64 ~ width ( Int64 . of_int32 i ) |
let of_int64_array ~ width a = let array_width = Array . length a lsl log_bits_per_word in if array_width > Int . round_up ~ to_multiple_of : bits_per_word width then raise_s [ % message " [ of_int64_array ] array to large for given [ width ] " ( array_width : int ) ( width : int ) ] ; init_int64 ~ width ~ f ( : fun i ... |
let z32mask = Zarith . Z . of_int64 0xFFFF_FFFFL |
let of_z ~ width z = let module Z = Zarith . Z in let t = create width in let rec f i z width = if width <= 0 || Z . ( equal z zero ) then ( ) else ( let a = Z . ( to_int64 ( logand z z32mask ) ) in let z = Z . shift_right z 32 in let b = Z . ( to_int64 ( logand z z32mask ) ) in let z = Z . shift_right z 32 in let a = ... |
let of_pow2_string ( ~ signedness : Signedness . t ) ~ width ~ pow2 h = let to_binary t = let len = String . length t in let len_pow = len * pow2 in let rec make_string = function | 0 -> " " | i -> let c = t . [ i - 1 ] in let digit = match c with | ' 0 ' . . ' 9 ' -> Char . to_int c - char_zero | ' A ' . . ' Z ' -> Ch... |
let of_hex_string ~ signedness ~ width h = of_pow2_string ~ signedness ~ width ~ pow2 : 4 h |
let of_octal_string ~ signedness ~ width h = of_pow2_string ~ signedness ~ width ~ pow2 : 3 h |
module type Bit = sig type t val vdd : t val gnd : t val equal : t -> t -> bool end |
module Make_bit_list ( Bit : Bit ) = struct let to_constant bits = List . map bits ~ f ( : fun bit -> if Bit . equal bit Bit . vdd then ' 1 ' else ' 0 ' ) |> String . of_char_list |> of_binary_string ; ; let of_constant t = to_binary_string t |> String . to_list |> List . map ~ f ( : function | ' 0 ' -> Bit . gnd | _ -... |
module Bits = Make_bit_list ( struct type t = int let vdd = 1 let gnd = 0 let equal = Int . equal end ) |
let pp fmt t = Caml . Format . fprintf fmt " % s " ( to_binary_string_hum t ) |
module _ = Pretty_printer . Register ( struct type nonrec t = t let module_name = " Hardcaml . Constant " let to_string t = to_binary_string_hum t end ) |
let options = [ ( " auto . offset . reset " , " earliest " ) ] |
let main ( brokers , ( topic , topics ) , group_id ) = let open Deferred . Result . Let_syntax in Log . Global . debug " Starting " ; let options = ( " metadata . broker . list " , brokers ) :: ( " group . id " , group_id ) :: options in let % bind consumer = Deferred . return @@ Kafka_async . new_consumer options in L... |
let main_or_error opts = match % bind main opts with | Ok _ as v -> return v | Error ( _ , msg ) -> return @@ Error ( Error . of_string msg ) |
let ( ) = let open Command . Let_syntax in Command . async_or_error ~ summary " : Consume messages on Kafka topic " [ % map_open let _ = Log . Global . set_level_via_param ( ) and topics = flag " topic " ( one_or_more string ) ~ doc " : NAME Which topics to consume from " and group_id = flag " group - id " ( optional_w... |
module Pair ( A : Thing ) ( B : Thing ) : Thing with type t = A . t * B . t = struct type t = A . t * B . t let compare ( a1 , b1 ) ( a2 , b2 ) = let c = A . compare a1 a2 in if c <> 0 then c else B . compare b1 b2 let hash ( a , b ) = Hashtbl . hash ( A . hash a , B . hash b ) let equal ( a1 , b1 ) ( a2 , b2 ) = A . e... |
module Make_map ( T : Thing ) ( Set : Set_plus_stdlib with type elt = T . t ) = struct include Map . Make [ @ inlined hint ] ( T ) module Set = Set let of_list l = List . fold_left ( fun map ( id , v ) -> add id v map ) empty l let disjoint_union ? eq ? print m1 m2 = ignore print ; union ( fun _id v1 v2 -> let ok = mat... |
module Make_set ( T : Thing_no_hash ) = struct include Set . Make [ @ inlined hint ] ( T ) let [ @ ocamlformat " disable " ] print ppf s = let elts ppf s = iter ( fun e -> Format . fprintf ppf " @ % a " T . print e ) s in Format . fprintf ppf " [ @< 1 { [ >@% a @ ] } ] " @@ elts s let to_string s = Format . asprintf " ... |
module Make ( T : Thing ) = struct module T = T include T module Set = Make_set ( T ) module Map = Make_map ( T ) ( Set ) end |
module Make_pair ( T1 : S ) ( T2 : S ) = struct module Pair = Pair ( T1 . T ) ( T2 . T ) include Make ( Pair ) let create_from_cross_product t1_set t2_set = T1 . Set . fold ( fun t1 result -> T2 . Set . fold ( fun t2 result -> Set . add ( t1 , t2 ) result ) t2_set result ) t1_set Set . empty end |
module type Thing_no_hash = sig type t include Map . OrderedType with type t := t val print : Format . formatter -> t -> unit end |
module type Thing = sig type t include Hashtbl . HashedType with type t := t include Map . OrderedType with type t := t val print : Format . formatter -> t -> unit end |
module type Set = sig type elt type t val empty : t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val disjoint : t -> t -> bool val diff : t -> t -> t val compare : t -> t -> int val equal :... |
module type Map = sig type key module Set : Set with type elt = key type ' +! a t val empty : ' a t val is_empty : ' a t -> bool val mem : key -> ' a t -> bool val add : key -> ' a -> ' a t -> ' a t val update : key -> ( ' a option -> ' a option ) -> ' a t -> ' a t val singleton : key -> ' a -> ' a t val remove : key -... |
module type S = sig type t module T : Thing with type t = t include Thing with type t := T . t module Set : Set with type elt = t module Map : Map with type key = t and module Set = Set end |
module type Set_plus_stdlib = sig include Set include Stdlib . Set . S with type elt := elt and type t := t end |
module type Map_plus_stdlib = sig include Map include Stdlib . Map . S with type key := key and type ' a t := ' a t end |
module type S_plus_stdlib = sig type t module T : Thing with type t = t include Thing with type t := T . t module Set : Set_plus_stdlib with type elt = t module Map : Map_plus_stdlib with type key = t and module Set = Set end |
type t = { memory_limit_in_mb : int ; function_name : string ; function_version : string ; invoked_function_arn : string ; aws_request_id : string ; xray_trace_id : string option ; log_stream_name : string ; log_group_name : string ; client_context : Client . client_context option ; identity : Client . cognito_identity... |
let make ~ invoked_function_arn ~ aws_request_id ~ xray_trace_id ~ client_context ~ identity ~ deadline settings = { memory_limit_in_mb = settings . Config . memory_size ; function_name = settings . function_name ; function_version = settings . version ; log_stream_name = settings . log_stream ; log_group_name = settin... |
let skip_user_input ( b : bool ) : json_spel = Json_spel . assoc [ Context . skip_user_input_lbl , Json_spel . bool b ] |
let set_skip_user_input ( ctx : json_spel ) ( b : bool ) : json_spel = Json_spel . set ctx Context . skip_user_input_lbl ( ` Bool b ) |
let take_skip_user_input ( ctx : json_spel ) : json_spel * bool = begin match Json_spel . take ctx Context . skip_user_input_lbl with | ctx , Some ( ` Bool b ) -> ctx , b | _ -> ctx , false end |
let actions ( acts : action list ) : json_spel = Json_spel . assoc [ Context . actions_lbl , Json_spel . list ( List . map Wcs . json_spel_of_action acts ) ] |
let actions_def ( acts : action_def list ) : json_spel = Json_spel . assoc [ Context . actions_lbl , Json_spel . list ( List . map Wcs . json_spel_of_action_def acts ) ] |
let json_spel_of_action ( act : action ) : json_spel = let json = Wcs . json_of_action act in let json_spel = Json_spel . of_json json in json_spel |
let action_of_json_spel ( act : json_spel ) : action = Wcs_j . action_of_string ( Yojson . Basic . to_string ( Json_spel . to_json act ) ) |
let set_actions ctx ( acts : action list ) : json_spel = let js_acts = List . map json_spel_of_action acts in Json_spel . set ctx Context . actions_lbl ( ` List js_acts ) |
let take_actions ( ctx : json_spel ) : json_spel * action list option = begin match Json_spel . take ctx Context . actions_lbl with | ctx ' , Some ( ` List acts ) -> begin try ctx ' , Some ( List . map action_of_json_spel acts ) with _ -> Log . warning " Context_spel " ( Format . sprintf " illed formed actions :\ n % s... |
let push_action ( ctx : json_spel ) ( act : action ) : json_spel = begin match take_actions ctx with | ctx , None -> set_actions ctx [ act ] | ctx , Some acts -> set_actions ctx ( acts @ [ act ] ) end |
let pop_action ( ctx : json_spel ) : json_spel * action option = begin match take_actions ctx with | ctx ' , Some ( act :: acts ) -> set_actions ctx ' acts , Some act | _ -> ctx , None end |
let set_continuation ( ctx : json_spel ) ( k : action ) : json_spel = Json_spel . set ctx Context . continuation_lbl ( json_spel_of_action k ) |
let take_continuation ( ctx : json_spel ) : json_spel * action option = begin match Json_spel . take ctx Context . continuation_lbl with | ctx ' , Some act -> begin try ctx ' , Some ( action_of_json_spel act ) with _ -> Log . warning " Context_spel " ( Format . sprintf " illed formed continuation :\ n % s . " @ ( Yojso... |
let get_continuation ( ctx : json_spel ) : action option = let _ , act = take_continuation ctx in act |
let return ( v : json_spel ) : json_spel = Json_spel . assoc [ Context . return_lbl , v ] |
let set_return ( ctx : json_spel ) ( x : json_spel ) : json_spel = Json_spel . set ctx Context . return_lbl x |
let get_return ( ctx : json_spel ) : json_spel option = Json_spel . get ctx Context . return_lbl |
let next_stamp = let next_stamp = ref 0 in fun ( ) -> incr next_stamp ; ! next_stamp |
module Sort = struct type t = | Normal_or_exn | Return | Define_root_symbol | Toplevel_return let to_string t = match t with | Normal_or_exn -> " Normal_or_exn " | Return -> " Return " | Define_root_symbol -> " Define_root_symbol " | Toplevel_return -> " Toplevel_return " let print ppf t = Format . pp_print_string ppf ... |
module Data = struct type t = { compilation_unit : Compilation_unit . t ; previous_compilation_units : Compilation_unit . t list ; name : string ; name_stamp : int ; sort : Sort . t } let flags = continuation_flags let [ @ ocamlformat " disable " ] print ppf { compilation_unit ; name ; name_stamp ; sort ; previous_comp... |
module Table = Table_by_int_id . Make ( Data ) |
let grand_table_of_continuations = ref ( Table . create ( ) ) |
let initialise ( ) = grand_table_of_continuations := Table . create ( ) |
let reset ( ) = initialise ( ) |
let create ? sort ? name ( ) : t = let sort = Option . value sort ~ default : Sort . Normal_or_exn in let name = Option . value name ~ default " : k " in let compilation_unit = Compilation_unit . get_current_exn ( ) in let previous_compilation_units = [ ] in let name_stamp = next_stamp ( ) in let data : Data . t = { co... |
let find_data t = Table . find ! grand_table_of_continuations t |
let rename t = let { Data . name ; sort ; name_stamp = _ ; compilation_unit = _ ; previous_compilation_units = _ } = find_data t in create ~ sort ~ name ( ) |
let name t = ( find_data t ) . name |
let name_stamp t = ( find_data t ) . name_stamp |
let sort t = ( find_data t ) . sort type nonrec t = t let compare t1 t2 = Id . compare t1 t2 let equal t1 t2 = Id . equal t1 t2 let hash t = Hashtbl . hash t let print ppf t = Format . fprintf ppf " @< 0 >% s " ( Flambda_colours . continuation ( ) ) ; if String . equal ( name t ) " k " then Format . fprintf ppf " k % d... |
module Tree = Patricia_tree . Make ( struct let print = print end ) |
let export t = find_data t |
let import data = Table . add ! grand_table_of_continuations data |
let map_compilation_unit f ( data : Data . t ) : Data . t = let new_compilation_unit = f data . compilation_unit in if Compilation_unit . equal new_compilation_unit data . compilation_unit then data else { data with compilation_unit = new_compilation_unit ; previous_compilation_units = data . compilation_unit :: data .... |
module Extra_arg = struct type t = | Already_in_scope of Simple . t | New_let_binding of Variable . t * Flambda_primitive . t | New_let_binding_with_named_args of Variable . t * ( Simple . t list -> Flambda_primitive . t ) let [ @ ocamlformat " disable " ] print ppf t = match t with | Already_in_scope simple -> Format ... |
type t = { extra_params : Bound_parameters . t ; extra_args : Extra_arg . t list Apply_cont_rewrite_id . Map . t } |
let [ @ ocamlformat " disable " ] print ppf { extra_params ; extra_args ; } = Format . fprintf ppf " [ @< hov 1 ( >\ [ @< hov 1 ( > extra_params @ % a ) ] @@ \ [ @< hov 1 ( > extra_args @ % a ) ] @\ ) ] " @ Bound_parameters . print extra_params ( Apply_cont_rewrite_id . Map . print Extra_arg . List . print ) extra_args |
let empty = { extra_params = Bound_parameters . empty ; extra_args = Apply_cont_rewrite_id . Map . empty } |
let is_empty t = if Bound_parameters . is_empty t . extra_params then ( assert ( Apply_cont_rewrite_id . Map . is_empty t . extra_args ) ; true ) else false |
let add t ~ extra_param ~ extra_args = let extra_args = if Apply_cont_rewrite_id . Map . is_empty t . extra_args then Apply_cont_rewrite_id . Map . map ( fun extra_args -> [ extra_args ] ) extra_args else Apply_cont_rewrite_id . Map . merge ( fun id already_extra_args extra_args -> match already_extra_args , extra_args... |
let concat t1 t2 = if is_empty t2 then t1 else if is_empty t1 then t2 else let extra_args = Apply_cont_rewrite_id . Map . merge ( fun id extra_args1 extra_args2 -> match extra_args1 , extra_args2 with | None , None -> None | Some _ , None | None , Some _ -> Misc . fatal_errorf " concat : mismatching domains on id % a "... |
let extra_params t = t . extra_params |
type t = | Linearly_used_and_inlinable of { params : Bound_parameters . t ; handler : Rebuilt_expr . t ; free_names_of_handler : Name_occurrences . t ; cost_metrics_of_handler : Cost_metrics . t } | Non_inlinable_zero_arity of { handler : Rebuilt_expr . t Or_unknown . t } | Non_inlinable_non_zero_arity of { arity : Fla... |
let [ @ ocamlformat " disable " ] print are_rebuilding_terms ppf t = match t with | Linearly_used_and_inlinable { params ; handler ; free_names_of_handler ; cost_metrics_of_handler } -> Format . fprintf ppf " [ @< hov 1 ( > Linearly_used_and_inlinable @ \ [ @< hov 1 ( > params @ % a ) ] @@ \ [ @< hov 1 ( > handler @ % ... |
let arity t = match t with | Linearly_used_and_inlinable { params ; handler = _ ; free_names_of_handler = _ ; cost_metrics_of_handler = _ } -> Bound_parameters . arity_with_subkinds params | Non_inlinable_zero_arity _ -> Flambda_arity . With_subkinds . nullary | Non_inlinable_non_zero_arity { arity } | Toplevel_or_func... |
type t = { continuation : Continuation . t ; arity : Flambda_arity . t ; uses : U . t list } |
let create continuation arity = { continuation ; arity ; uses = [ ] } |
let [ @ ocamlformat " disable " ] print ppf { continuation ; arity ; uses ; } = Format . fprintf ppf " [ @< hov 1 ( >\ [ @< hov 1 ( > continuation @ % a ) ] @@ \ [ @< hov 1 ( > arity @ % a ) ] @@ \ [ @< hov 1 ( > uses @ % a ) ] @\ ) ] " @ Continuation . print continuation Flambda_arity . print arity ( Format . pp_print... |
let add_use t kind ~ env_at_use id ~ arg_types = try let arity = T . arity_of_list arg_types in if not ( Flambda_arity . equal arity t . arity ) then Misc . fatal_errorf " Arity of use ( % a ) doesn ' t match continuation ' s arity ( % a ) " Flambda_arity . print arity Flambda_arity . print t . arity ; let use = U . cr... |
let union t1 t2 = assert ( Continuation . equal t1 . continuation t2 . continuation ) ; assert ( Flambda_arity . equal t1 . arity t2 . arity ) ; { continuation = t1 . continuation ; arity = t1 . arity ; uses = t1 . uses @ t2 . uses } |
let number_of_uses t = List . length t . uses |
let arity t = t . arity |
let get_uses t = t . uses |
let get_arg_types_by_use_id t = List . fold_left ( fun args use -> List . map2 ( fun arg_map arg_type -> let env_at_use = U . env_at_use use in let typing_env = DE . typing_env env_at_use in let arg_at_use : Continuation_env_and_param_types . arg_at_use = { arg_type ; typing_env } in Apply_cont_rewrite_id . Map . add (... |
let get_typing_env_no_more_than_one_use t = match t . uses with | [ ] -> None | [ use ] -> Some ( DE . typing_env ( U . env_at_use use ) ) | _ :: _ -> Misc . fatal_errorf " Only zero or one continuation use ( s ) expected :@ % a " print t |
type t = { continuation_uses : Continuation_uses . t Continuation . Map . t } |
let [ @ ocamlformat " disable " ] print ppf { continuation_uses ; } = Format . fprintf ppf " [ @< hov 1 ( >\ [ @< hov 1 ( > continuation_uses @ % a ) ] @\ ) ] " @ ( Continuation . Map . print Continuation_uses . print ) continuation_uses |
let empty = { continuation_uses = Continuation . Map . empty } |
let record_continuation_use t cont kind ~ env_at_use ~ arg_types = let id = Apply_cont_rewrite_id . create ( ) in let continuation_uses = Continuation . Map . update cont ( function | None -> let arity = T . arity_of_list arg_types in let uses = Continuation_uses . create cont arity in Some ( Continuation_uses . add_us... |
let get_typing_env_no_more_than_one_use t k = match Continuation . Map . find k t . continuation_uses with | exception Not_found -> None | cont_uses -> Continuation_uses . get_typing_env_no_more_than_one_use cont_uses |
let get_continuation_uses t cont = match Continuation . Map . find cont t . continuation_uses with | exception Not_found -> None | uses -> Some uses |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.