text stringlengths 0 601k |
|---|
let quote s = str " ` % s ' " s |
let alts_str ( ? quoted = true ) alts = let quote = if quoted then quote else ( fun s -> s ) in match alts with | [ ] -> invalid_arg err_empty_list | [ a ] -> ( quote a ) | [ a ; b ] -> str " either % s or % s " ( quote a ) ( quote b ) | alts -> let rev_alts = List . rev alts in str " one of % s or % s " ( String . con... |
let pr_white_str spaces ppf s = let left = ref 0 and right = ref 0 and len = String . length s in let flush ( ) = Format . pp_print_string ppf ( String . sub s ! left ( ! right - ! left ) ) ; incr right ; left := ! right ; in while ( ! right <> len ) do if s . [ ! right ] = ' \ n ' then ( flush ( ) ; Format . pp_force_... |
let pr_text = pr_white_str true |
let pr_lines = pr_white_str false |
let pr_to_temp_file pr v = try let exec = Filename . basename Sys . argv . ( 0 ) in let file , oc = Filename . open_temp_file exec " out " in let ppf = Format . formatter_of_out_channel oc in pr ppf v ; Format . pp_print_flush ppf ( ) ; close_out oc ; at_exit ( fun ( ) -> try Sys . remove file with Sys_error e -> ( ) )... |
let levenshtein_distance s t = let minimum a b c = min a ( min b c ) in let m = String . length s in let n = String . length t in let d = Array . make_matrix ( m + 1 ) ( n + 1 ) 0 in for i = 0 to m do d . ( i ) . ( 0 ) <- i done ; for j = 0 to n do d . ( 0 ) . ( j ) <- j done ; for j = 1 to n do for i = 1 to m do if s ... |
let suggest s candidates = let add ( min , acc ) name = let d = levenshtein_distance s name in if d = min then min , ( name :: acc ) else if d < min then d , [ name ] else min , acc in let dist , suggs = List . fold_left add ( max_int , [ ] ) candidates in if dist < 3 then suggs else [ ] |
module Trie : sig type ' a t val empty : ' a t val is_empty : ' a t -> bool val add : ' a t -> string -> ' a -> ' a t val find : ' a t -> string -> [ ` Ok of ' a | ` Ambiguous | ` Not_found ] val ambiguities : ' a t -> string -> string list val of_list : ( string * ' a ) list -> ' a t module Cmap = Map . Make ( Char ) ... |
type env_info = { env_var : string ; env_doc : string ; env_docs : string ; } |
type absence = | Error | Val of string Lazy . t |
type opt_kind = | Flag | Opt | Opt_vopt of string |
type pos_kind = | All | Nth of bool * int | Left of bool * int | Right of bool * int |
type arg_info = { id : int ; absent : absence ; env_info : env_info option ; doc : string ; docv : string ; docs : string ; p_kind : pos_kind ; o_kind : opt_kind ; o_names : string list ; o_all : bool ; } |
let arg_id = let c = ref 0 in fun ( ) -> let id = ! c in incr c ; if id > ! c then assert false else id |
let is_opt a = a . o_names <> [ ] |
let is_pos a = a . o_names = [ ] |
module Amap = Map . Make ( struct type t = arg_info let compare a a ' = compare a . id a ' . id end ) |
type arg = | O of ( int * string * ( string option ) ) list | P of string list |
type cmdline = arg Amap . t |
type man_block = [ | ` S of string | ` P of string | ` Pre of string | ` I of string * string | ` Noblank ] |
type term_info = { name : string ; version : string option ; tdoc : string ; tdocs : string ; sdocs : string ; man : man_block list ; } |
type eval_info = { term : term_info * arg_info list ; main : term_info * arg_info list ; choices : ( term_info * arg_info list ) list ; env : string -> string option } |
let eval_kind ei = if ei . choices = [ ] then ` Simple else if ( fst ei . term ) == ( fst ei . main ) then ` M_main else ` M_choice |
module Manpage = struct type title = string * int * string * string * string type block = man_block type t = title * block list let p_indent = 7 let l_indent = 4 let escape subst esc buf s = let subst s = let len = String . length s in if not ( len > 1 && s . [ 1 ] = ' , ' ) then ( subst s ) else if len = 2 then " " el... |
module Help = struct let invocation ( ? sep = ' ' ) ei = match eval_kind ei with | ` Simple | ` M_main -> ( fst ei . main ) . name | ` M_choice -> str " % s % c % s " ( fst ei . main ) . name sep ( fst ei . term ) . name let title ei = let prog = String . capitalize ( fst ei . main ) . name in let name = String . upper... |
module Err = struct let invalid kind s exp = str " invalid % s % s , % s " kind ( quote s ) exp let invalid_val = invalid " value " let no kind s = str " no % s % s " ( quote s ) kind let not_dir s = str " % s is not a directory " ( quote s ) let is_dir s = str " % s is a directory " ( quote s ) let element kind s exp ... |
module Cmdline : sig exception Error of string val choose_term : term_info -> ( term_info * ' a ) list -> string list -> term_info * string list val create : ? peek_opts : bool -> arg_info list -> string list -> cmdline val opt_arg : cmdline -> arg_info -> ( int * string * ( string option ) ) list val pos_arg : cmdline... |
module Arg = struct type ' a parser = string -> [ ` Ok of ' a | ` Error of string ] type ' a printer = Format . formatter -> ' a -> unit type ' a converter = ' a parser * ' a printer type env = env_info type ' a arg_converter = ( eval_info -> cmdline -> ' a ) type ' a t = arg_info list * ' a arg_converter type info = a... |
module Term = struct type info = term_info type ' + a t = arg_info list * ( eval_info -> cmdline -> ' a ) type ' a result = [ | ` Ok of ' a | ` Error of [ ` Parse | ` Term | ` Exn ] | ` Version | ` Help ] exception Term of [ ` Help of [ ` Pager | ` Plain | ` Groff ] * string option | ` Error of bool * string ] let info... |
module List = struct include List let map f l = List . rev_map f l |> List . rev let rev_split l = let rec inner xs ys = function | ( x , y ) :: xys -> inner ( x :: xs ) ( y :: ys ) xys | [ ] -> ( xs , ys ) in inner [ ] [ ] l let split l = rev_split ( List . rev l ) end |
type wrap = [ | ` Wrap_atoms | ` Always_wrap | ` Never_wrap | ` Force_breaks | ` Force_breaks_rec | ` No_breaks ] |
type label_break = [ | ` Auto | ` Always | ` Always_rec | ` Never ] |
type style = { tag_open : string ; tag_close : string } |
type atom_param = { atom_style : style_name option ; } |
let atom = { atom_style = None } |
type list_param = { space_after_opening : bool ; space_after_separator : bool ; space_before_separator : bool ; separators_stick_left : bool ; space_before_closing : bool ; stick_to_label : bool ; align_closing : bool ; wrap_body : wrap ; indent_body : int ; list_style : style_name option ; opening_style : style_name o... |
let list = { space_after_opening = true ; space_after_separator = true ; space_before_separator = false ; separators_stick_left = true ; space_before_closing = true ; stick_to_label = true ; align_closing = true ; wrap_body = ` Wrap_atoms ; indent_body = 2 ; list_style = None ; opening_style = None ; body_style = None ... |
type label_param = { label_break : label_break ; space_after_label : bool ; indent_after_label : int ; label_style : style_name option ; } |
let label = { label_break = ` Auto ; space_after_label = true ; indent_after_label = 2 ; label_style = None ; } |
type t = Atom of string * atom_param | List of ( string * string * string * list_param ) * t list | Label of ( t * label_param ) * t | Custom of ( formatter -> unit ) |
type escape = [ ` None | ` Escape of ( ( string -> int -> int -> unit ) -> string -> int -> int -> unit ) | ` Escape_string of ( string -> string ) ] |
type styles = ( style_name * style ) list |
let propagate_from_leaf_to_root ~ init_acc ~ merge_acc ~ map_node x = let rec aux x = match x with | Atom _ -> let acc = init_acc x in map_node x acc | List ( param , children ) -> let new_children , accs = List . rev_split ( List . rev_map aux children ) in let acc = List . fold_left merge_acc ( init_acc x ) accs in m... |
let propagate_forced_breaks x = let init_acc = function | List ( ( _ , _ , _ , { wrap_body = ` Force_breaks_rec } ) , _ ) | Label ( ( _ , { label_break = ` Always_rec } ) , _ ) -> true | Atom _ | Label _ | Custom _ | List _ -> false in let merge_acc force_breaks1 force_breaks2 = force_breaks1 || force_breaks2 in let ma... |
module Pretty = struct let rewrite x = propagate_forced_breaks x let set_escape fmt escape = let print0 , flush0 = pp_get_formatter_output_functions fmt ( ) in let tagf0 = ( pp_get_formatter_tag_functions [ @ warning " - 3 " ] ) fmt ( ) in let is_tag = ref false in let mot tag = is_tag := true ; tagf0 . mark_open_tag t... |
module Compact = struct open Printf let rec fprint_t buf = function Atom ( s , _ ) -> Buffer . add_string buf s | List ( param , l ) -> fprint_list buf param l | Label ( label , x ) -> fprint_pair buf label x | Custom f -> let fmt = formatter_of_buffer buf in f fmt ; pp_print_flush fmt ( ) and fprint_list buf ( op , se... |
module Param = struct let list_true = { space_after_opening = true ; space_after_separator = true ; space_before_separator = true ; separators_stick_left = true ; space_before_closing = true ; stick_to_label = true ; align_closing = true ; wrap_body = ` Wrap_atoms ; indent_body = 2 ; list_style = None ; opening_style =... |
module Prop = struct module Boolean = Boolean include Option include Set end |
let f t = [ 1 ] @ t |
let f t = 1 :: [ ] @ t |
let f ( t : int * int ) = fst t + snd t |
let dounit ( ) = ( ) |
let f ( ) = if x then ( if x then x else y ) else y |
let f ( ) = if x then ( if x then x else let z = 3 in dounit ( ) ; ( if z = 2 then x else y ) ) else y |
let f ( ) = let l = [ ] in begin match l with | [ ] -> begin match l with | [ ] -> let z = [ ] in begin match z with | _ -> true end | _ -> false end | _ -> true end |
let z = if x then 1 else if y then 2 else if x & y then 3 else 4 |
let z = if x then 1 else if y then 2 else if x & y then 3 else if z = 4 then 3 else 9 |
let z = ( x = TConstr 3 || x = TConstr 4 ) |
let z = ( x = [ 12 ] || x = [ 50 ] ) |
let z = ( x = 5 || x = 6 ) |
let z = ( x = TConstr 3 && x = TConstr 4 ) |
let z = ( x = [ 12 ] && x = [ 50 ] ) |
let z = ( x = 5 && x = 6 ) |
let z = ( x = TConstr 3 || not ( x = TConstr 3 ) ) |
let z = ( x = [ ] || x = [ ] ) |
let z = ( x = None || x = None ) |
let z = ( x = 5 || x = 5 ) |
let z = ( x = TConstr 3 || x = TConstr 3 ) |
let z = ( x = TConstr 3 || x = TConstr 3 || x = TConstr 4 ) |
let z = ( x = TConstr 3 || x = TConstr 4 || x = TConstr 3 ) |
let z = ( x = [ ] && x = [ ] ) |
let z = ( x = None && x = None ) |
let z = ( x = 5 && x = 5 ) |
let z = ( x = TConstr 3 && x = TConstr 3 ) |
let z = ( x = TConstr 3 && x = TConstr 3 && x = TConstr 4 ) |
let z = ( x = TConstr 3 && x = TConstr 4 && x = TConstr 3 ) |
let ( ) = Alcotest . run ~ verbose : true __FILE__ [ ( " alpha " , [ Alcotest . test_case " 0 newlines " ` Quick ( fun ( ) -> Format . printf " Print inside alpha " ) ; ] ) ; ( " beta " , [ Alcotest . test_case " 1 newline " ` Quick ( fun ( ) -> Format . printf " Print inside beta \ n " ) ; ] ) ; ( " gamma " , [ Alcote... |
val mutable x : int = x method x = x val mutable y : int = y method y = y val mutable width = w method width = width method draw = fill_rect x y width width method private contains x ' y ' = x <= x ' && x ' <= x + width && y <= y ' && y ' <= y + width method on_click ? start ? stop f = on_click ? start ? stop ( fun ev ... |
module Verifier_index_json = struct module Lookup = struct type lookups_used = Kimchi_types . VerifierIndex . Lookup . lookups_used = | Single | Joint [ @@ deriving yojson ] yojson type ' polyComm t = ' polyComm Kimchi_types . VerifierIndex . Lookup . t = { lookup_used : lookups_used ; lookup_table : ' polyComm array ;... |
module Data = struct [ %% versioned module Stable = struct module V1 = struct type t = { constraints : int } [ @@ deriving yojson ] yojson let to_latest = Fn . id end end ] end end |
module Repr = struct [ %% versioned module Stable = struct module V2 = struct type t = { commitments : Backend . Tock . Curve . Affine . Stable . V1 . t Plonk_verification_key_evals . Stable . V2 . t ; step_domains : Domains . Stable . V2 . t array ; data : Data . Stable . V1 . t } [ @@ deriving to_yojson ] to_yojson l... |
module Stable = struct module V2 = struct type t = { commitments : Backend . Tock . Curve . Affine . t Plonk_verification_key_evals . t ; step_domains : Domains . t array ; index : ( Impls . Wrap . Verification_key . t [ @ to_yojson Verifier_index_json . to_yojson Backend . Tock . Field . to_yojson Backend . Tick . Fie... |
let dummy_commitments g = let open Plonk_types in { Plonk_verification_key_evals . sigma_comm = Vector . init Permuts . n ~ f ( : fun _ -> g ) g ; coefficients_comm = Vector . init Columns . n ~ f ( : fun _ -> g ) g ; generic_comm = g ; psm_comm = g ; complete_add_comm = g ; mul_comm = g ; emul_comm = g ; endomul_scala... |
let dummy = lazy ( let rows = Domain . size ( Common . wrap_domains ~ proofs_verified : 2 ) 2 . h in let g = Backend . Tock . Curve ( . to_affine_exn one ) one in { Repr . commitments = dummy_commitments g ; step_domains = [ ] || ; data = { constraints = rows } } |> Stable . Latest . of_repr ( Kimchi_bindings . Protoco... |
module Base = struct module type S = sig type t type ledger_proof type invalid = [ ` Invalid_keys of Signature_lib . Public_key . Compressed . t list | ` Invalid_signature of Signature_lib . Public_key . Compressed . t list | ` Invalid_proof | ` Missing_verification_key of Signature_lib . Public_key . Compressed . t li... |
module type S = sig include Base . S val create : logger : Logger . t -> proof_level : Genesis_constants . Proof_level . t -> constraint_constants : Genesis_constants . Constraint_constants . t -> pids : Child_processes . Termination . t -> conf_dir : string option -> t Deferred . t end |
let extract_sources sources = let erl = List . hd sources in let ml = List . hd ( List . tl sources ) in ( erl , ml ) |
let compare_parsetree a b = if a = b then Ok ( ) else Error ` not_equal |
let remove_locations parsetree = let open Ast_mapper in let open Parsetree in let map_structure_item sub { pstr_loc = loc ; pstr_desc = desc } = let open Ast_helper . Str in let loc = sub . location sub loc in match desc with | Pstr_value ( _r , vbs ) -> value ~ loc Recursive ( List . map ( sub . value_binding sub ) vb... |
let verify sources = let erl , ml = extract_sources sources in let ml_parsetree = Ocaml . parse_implementation ~ dump_ast : false ~ source_file : ml |> remove_locations in Printast . structure 0 Format . std_formatter ml_parsetree ; Format . fprintf Format . std_formatter " \ n \ n " ; %! let erl_parsetree = Erlang_as_... |
let ( . <> ) f g x = f ( g x ) |
module Scheduler = Carton . Make ( Fiber ) |
module SHA1 = struct include Digestif . SHA1 let feed ctx ? off ? len bs = feed_bigstring ctx ? off ? len bs let null = digest_string " " let length = digest_size let compare a b = String . compare ( to_raw_string a ) ( to_raw_string b ) end |
module Verify = Carton . Dec . Verify ( SHA1 ) ( Scheduler ) ( Fiber ) |
module First_pass = Carton . Dec . Fp ( SHA1 ) |
let sched = let open Scheduler in { Carton . bind = ( fun x f -> inj ( bind ( prj x ) ( fun x -> prj ( f x ) ) ) ) ; return = ( fun x -> inj ( return x ) ) ; } |
let z = De . bigstring_create De . io_buffer_size |
let allocate bits = De . make_window ~ bits |
let replace hashtbl k v = try let v ' = Hashtbl . find hashtbl k in if v < v ' then Hashtbl . replace hashtbl k v ' with _ -> Hashtbl . add hashtbl k v |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.