text stringlengths 12 786k |
|---|
let crypto_random_bytes n = let ic = Pervasives . open_in_bin " / dev / urandom " in let s = Pervasives . really_input_string ic n in close_in ic ; Cstruct . of_string s |
let generate_private_key ( ) = Noise . Dh . len noise_dh |> crypto_random_bytes |> Noise . Private_key . of_bytes |
let write_handshake oc sock nego msg id = let % lwt _ = Lwt_io . eprintf " # % s write_handshake \ n " id in match Noise_socket . write_handshake sock nego msg padded_len with | Ok hmsg -> let hmsg_len = Cstruct . len hmsg in let hmsg_b = Cstruct . to_bytes hmsg in let % lwt _ = Lwt_io . epr... |
let write_msg oc sock msg id = let % lwt _ = Lwt_io . eprintf " # % s write_msg \ n " id in match Noise_socket . write_msg sock msg padded_len with | Ok tmsg -> let tmsg_len = Cstruct . len tmsg in let tmsg_b = Cstruct . to_bytes tmsg in let % lwt _ = Lwt_io . eprintf " # % s write_msg ... |
let read_handshake ic sock id = let % lwt _ = Lwt_io . eprintf " # % s read_handshake \ n " id in let % lwt ( uncons , res ) = Angstrom_lwt_unix . parse Noise_socket . Parser . handshake_msg ic in let % lwt _ = Lwt_io . eprintf " # % s read_handshake : unconsumed = % d / % d / ... |
let read_msg ic sock id = let % lwt _ = Lwt_io . eprintf " # % s read_msg \ n " id in let % lwt ( uncons , res ) = Angstrom_lwt_unix . parse Noise_socket . Parser . transport_msg ic in let % lwt _ = Lwt_io . eprintf " # % s read_msg : unconsumed = % d / % d / % d \ n " id (... |
let initiator ~ s ~ rs ? psk ~ pre_pub_keys ic oc = let e = generate_private_key ( ) in let sock = init ~ is_initiator : true ~ s : ( Some s ) ~ rs : ( Some rs ) ~ e : ( Some e ) ~ psk ~ pre_pub_keys in let % lwt _ = write_handshake oc sock in_nego Cstruct . empty " IN " in let... |
let responder ~ s ? psk ~ pre_pub_keys ic oc = let e = generate_private_key ( ) in let sock = init ~ is_initiator : false ~ s : ( Some s ) ~ rs : None ~ e : ( Some e ) ~ psk ~ pre_pub_keys in let % lwt ( nego , msg ) = read_handshake ic sock " RE " in let % lwt _ = Lwt_io . ... |
let main = let in_s = generate_private_key ( ) in let re_s = generate_private_key ( ) in let re_s_pub = Noise . Dh_25519 . public_key re_s in let pre_pub_keys = [ re_s_pub ] in let ( in_read , re_write ) = Lwt_io . pipe ( ) in let ( re_read , in_write ) = Lwt_io . pipe ( ) ... |
let ( ) = Lwt_main . run main |
type t = int [ @@ deriving_inline sexp_grammar ] let _ = fun ( _ : t ) -> ( ) let ( t_sexp_grammar : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . t ) = let ( _the_generic_group : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . generic_group ) = { implicit_vars ... |
type nonrec t = t [ @@ deriving_inline sexp_grammar ] |
let _ = fun ( _ : t ) -> ( ) |
let ( t_sexp_grammar : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . t ) = let ( _the_generic_group : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . generic_group ) = { implicit_vars = [ " t " ] ; ggid = " \ 146e \ 023 \ 249 \ 235eE \ 139c \ 132W \ 195 ... |
let _ = t_sexp_grammar [ @@@ end ] |
module Int = struct type t = int let compare = compare let hash = Hashtbl . hash let equal = ( ) = let default = 0 end |
module Dominator = Dominator . Make ( G ) |
let g = G . create ( ) |
let ( ) = G . add_edge g 1 11 ; G . add_edge g 1 2 ; G . add_edge g 1 9 ; G . add_edge g 2 3 ; G . add_edge g 2 9 ; G . add_edge g 2 10 ; G . add_edge g 3 4 ; G . add_edge g 3 5 ; G . add_edge g 4 5 ; G . add_edge g 5 6 ; G . add_edge g 6 8 ; G . ... |
let pp_comma p ( ) = Format . ( pp_print_char p ' , ' ; pp_print_space p ( ) ) |
let pp_set pf s = Format . ( fprintf pf " [ @< hv 4 { >% a } ] " @ ( pp_print_list ~ pp_sep : pp_comma pp_print_int ) ( Dominator . S . elements s ) ) |
let ( ) = let idom = Dominator . compute_idom g 1 in let domtree = Dominator . idom_to_dom_tree g idom in let s1 = Dominator . S . of_list ( Dominator . dom_tree_to_nontrivial_dom 1 domtree ) in let s2 = Dominator . dom_tree_to_snontrivial_dom 1 domtree in Format . ( printf " [ @< v... |
let comment = Str . regexp " . " ^#* |
let part = Str . regexp " @ Part [ Part ^ 1 ] 1 . " * |
let part1 = Str . regexp " @ Part1 . " * |
let blank = Str . regexp [ " \ t ] t " + |
let semicolon = Str . regexp " ; " |
let parse_column c = let ss = Str . split blank c in let ns = List . map ( fun s -> int_of_string ( " 0x " ^ s ) s ) s ss in let us = List . map ( fun n -> uchar_of_int n ) n ns in let s = UText . init ( List . length us ) us ( List . nth us ) us in s |
let parse_line line = let cs = Str . split semicolon line in Array . init 5 ( fun i -> parse_column ( List . nth cs i ) i ) i |
module C = struct type t = uchar let compare u1 u2 = ( int_of_uchar u1 ) u1 - ( int_of_uchar u2 ) u2 end |
module S = Set . Make ( C ) C |
let uset = ref S . empty |
let eq t1 t2 = if UText . length t1 <> UText . length t2 then false else let rec loop i = if i >= UText . length t1 then true else if UText . get t1 i = UText . get t2 i then loop ( i + 1 ) 1 else false in loop 0 |
let print_char u = sprintf " % 04X " ( int_of_uchar u ) u |
let print_text t = let buf = Buffer . create ( 5 * UText . length t ) t in UText . iter ( fun u -> Buffer . add_string buf ( print_char u ) u ) u t ; Buffer . contents buf |
module NF = UNF . Make ( ( UText : UnicodeString . Type with type t = UText . t ) t ) t |
let _ = read_file ( input_filename testfile ) testfile ( fun c -> let is_part1 = ref false in try while true do let line = input_line c in if Str . string_match comment line 0 then ( ) else if Str . string_match part line 0 then is_part1 := false else if Str . string_match part1 line 0 then is_par... |
let _ = let cat = general_category in for i = 0 to 1 lsl 21 - 1 do let u = uchar_of_int i in match cat u with ` Co | ` Cn -> ( ) | _ -> if S . mem u ! uset then ( ) else let s = UText . init 1 ( fun _ -> u ) u in let nfc = NF . nfc s in let nfd = NF . nfd s in let nfkc = NF . ... |
let _ = random_test ~ desc " : NFD ?= NFD ( NFDNFC ) NFDNFC " ~ log " : test - normalform - nfd " ~ data ( : fun size -> Array . init size ( fun _ -> uchar_of_int ( Random . int 0x8000000 ) 0x8000000 ) 0x8000000 ) 0x8000000 ~ body ( : fun a -> expect_pass ~ body ( : fun... |
let _ = random_test ~ desc " : NFKD ?= NFKD ( NFKDNFKC ) NFKDNFKC " ~ log " : test - normalform - nfd " ~ data ( : fun size -> Array . init size ( fun _ -> uchar_of_int ( Random . int 0x8000000 ) 0x8000000 ) 0x8000000 ) 0x8000000 ~ body ( : fun a -> expect_pass ~ body ( ... |
let handle_error ~ view = function let err = Jv . Error . message e in let msg = El . p [ El . txt Jstr . ( v " An error occured : " + err ) ] in El . set_children view [ msg ] |
let notif_options ( ) = let j = Jstr . v in let hot = Notification . Action . v ~ action ( : j " hot " ) ~ title ( : j " Hot " ) ( ) in let cold = Notification . Action . v ~ action ( : j " cold " ) ~ title ( : j " Cold " ) ( ) in Notification . opts ... |
let show_notification ( ) = let c = Service_worker . Container . of_navigator G . navigator in let * r = Service_worker . Container . register c ( Jstr . v " test_notification . js " ) in let t = Jstr . v " Brr " ! and opts = notif_options ( ) in let * ( ) = Service_work... |
let notify_me view ( ) = ignore @@ Fut . map ( handle_error ~ view ) @@ let * perm = Notification . request_permission ( ) in El . set_children view [ El . p [ El . txt Jstr . ( v " Permission : " + perm ) ] ] ; if Jstr . equal perm Notification . Permission . gra... |
let button ? at onclick label = let but = El . button ? at [ El . txt ( Jstr . v label ) ] in Ev . listen Ev . click ( fun _e -> onclick ( ) ) ( El . as_target but ) ; but |
let page_main ( ) = let h1 = El . h1 [ El . txt ' " Notification test " ] in let info = El . p [ El . strong [ El . txt ' " Note . " ] ; El . txt ' " Doesn ' t work over the file :// protocol . " ] in let view = El . p [ ] in let notify_me = button ( n... |
let ( ) = if Worker . ami ( ) then ( ) else page_main ( ) |
type t16 = A : _ abs -> t16 [ @@ ocaml . unboxed ] ; ; [ %% expect { | |
type t16 = A : ' a abs -> t16 [ @@ unboxed ] } ] ; ; | |
type t18 = A : _ list abs -> t18 [ @@ ocaml . unboxed ] ; ; [ %% expect { | |
type t18 = A : ' a list abs -> t18 [ @@ unboxed ] } ] ; ; | |
type ' a s = S : ' a -> ' a s [ @@ unboxed ] ; ; |
type t = T : _ s -> t [ @@ unboxed ] ; ; [ %% expect { | |
type ' a s = S : ' a -> ' a s [ @@ unboxed ] |
type t = T : ' a s -> t [ @@ unboxed ] } ] ; ; | |
type ' a s = S : ' a -> ' a option s [ @@ unboxed ] ; ; |
type t = T : _ s -> t [ @@ unboxed ] ; ; [ %% expect { | |
type ' a s = S : ' a -> ' a option s [ @@ unboxed ] |
type t = T : ' a s -> t [ @@ unboxed ] } ] ; ; | |
module M : sig type ' a r constraint ' a = unit -> ' b val inj : ' b -> ( unit -> ' b ) r type ' a r = ' b constraint ' a = unit -> ' b let inj x = x end ; ; [ %% expect { | |
module M : sig type ' a r constraint ' a = unit -> ' b val inj : ' b -> ( unit -> ' b ) r end } ] ; ; | |
type t = T : ( unit -> _ ) M . r -> t [ @@ unboxed ] ; ; [ %% expect { | |
type t = T : ( unit -> ' a ) M . r -> t [ @@ unboxed ] } ] ; ; | |
type ' a s = S : ( unit -> ' a ) M . r -> ' a option s [ @@ unboxed ] ; ; [ %% expect { | |
type ' a s = S : ( unit -> ' a ) M . r -> ' a option s [ @@ unboxed ] } ] ; ; | |
type t = T : _ s -> t [ @@ unboxed ] ; ; [ %% expect { | |
type t = T : ' a s -> t [ @@ unboxed ] } ] ; ; | |
type ' a t = T : ' a s -> ' a t [ @@ unboxed ] ; ; [ %% expect { | |
type ' a t = T : ' a s -> ' a t [ @@ unboxed ] } ] ; ; | |
type _ s = S : ' a t -> _ s [ @@ unboxed ] and _ t = T : ' a -> ' a s t ; ; [ %% expect { | |
type _ s = S : ' a t -> ' b s [ @@ unboxed ] } ] ; ; | |
type ' a s = S : ' a -> ' a s [ @@ unboxed ] ; ; |
type t = T : _ s -> t [ @@ unboxed ] ; ; [ %% expect { | |
type ' a s = S : ' a -> ' a s [ @@ unboxed ] |
type t = T : ' a s -> t [ @@ unboxed ] } ] ; ; | |
type ' a s = S : ' a -> ' a option s [ @@ unboxed ] ; ; |
type t = T : _ s -> t [ @@ unboxed ] ; ; [ %% expect { | |
type ' a s = S : ' a -> ' a option s [ @@ unboxed ] |
type t = T : ' a s -> t [ @@ unboxed ] } ] ; ; | |
module M : sig type ' a r constraint ' a = unit -> ' b val inj : ' b -> ( unit -> ' b ) r type ' a r = ' b constraint ' a = unit -> ' b let inj x = x end ; ; [ %% expect { | |
module M : sig type ' a r constraint ' a = unit -> ' b val inj : ' b -> ( unit -> ' b ) r end } ] ; ; | |
type t = T : ( unit -> _ ) M . r -> t [ @@ unboxed ] ; ; [ %% expect { | |
type t = T : ( unit -> ' a ) M . r -> t [ @@ unboxed ] } ] ; ; | |
type ' a s = S : ( unit -> ' a ) M . r -> ' a option s [ @@ unboxed ] ; ; [ %% expect { | |
type ' a s = S : ( unit -> ' a ) M . r -> ' a option s [ @@ unboxed ] } ] ; ; | |
type t = T : _ s -> t [ @@ unboxed ] ; ; [ %% expect { | |
type t = T : ' a s -> t [ @@ unboxed ] } ] ; ; | |
type ' a t = T : ' a s -> ' a t [ @@ unboxed ] ; ; [ %% expect { | |
type ' a t = T : ' a s -> ' a t [ @@ unboxed ] } ] ; ; | |
type _ s = S : ' a t -> _ s [ @@ unboxed ] and _ t = T : ' a -> ' a s t ; ; [ %% expect { | |
type _ s = S : ' a t -> ' b s [ @@ unboxed ] } ] ; ; | |
Ratio ( ratio_of_string " 7 / 4 " ) ) ; ; Ratio ( ratio_of_string " 7 / 4 " ) ) ; ; Int 4 ) ; ; Ratio ( ratio_of_string " 7 / 4 " ) ) ; ; Ratio ( ratio_of_string " 17 / 12 " ) ) ; ; Int ( - ( pred biggest_int ) ) ) ; ; Big_int ( ... |
let compat_ge400 = let n , _ , _ = Config . sundials_version in n >= 4 |
let compat_ge500 = let n , _ , _ = Config . sundials_version in n >= 5 |
let compat_ge540 = let n , m , _ = Config . sundials_version in ( n = 5 && m >= 4 ) || n >= 6 |
let compat_ge570 = let n , m , _ = Config . sundials_version in ( n = 5 && m >= 7 ) || n >= 6 |
let compat_ge600 = let n , _ , _ = Config . sundials_version in n >= 6 |
let compat_neq600 = match Config . sundials_version with | 6 , 0 , 0 -> false | _ -> true |
let print_passed s = if compat_ge400 then Printf . printf " PASSED test -- % s \ n " s else Printf . printf " PASSED test -- % s \ n " s |
module type NVECTOR_OPS_EXT = sig include Nvector . NVECTOR_OPS type contents val get_id : t -> Nvector . nvector_id val getarray : t -> contents val get : contents -> int -> float val set : contents -> int -> float -> unit val max_time : t -> float -> float val sync_device : unit -> unit end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.