text
stringlengths
0
601k
let lev = find_pr_level " top " pr_expr . pr_levels in extfun lev . pr_rules with [ <: expr < let ( __strm : Stream . t _ ) = $ _ $ in $ _ $ >> as e -> fun _ _ _ k -> [ : ` pmatch e " " k ] : | <: expr < fun __strm -> $ x $ >> -> fun _ _ _ k -> [ : ` parser_body x " " k ] : | <: expr < fun ( __strm : $ _ ) $ -> $ x $ >...
let lev = find_pr_level " apply " pr_expr . pr_levels in extfun lev . pr_rules with [ <: expr < Stream . iapp $ _ $ $ _ $ >> | <: expr < Stream . icons $ _ $ $ _ $ >> | <: expr < Stream . ising $ _ $ >> | <: expr < Stream . lapp ( fun _ -> $ _ ) $ $ _ $ >> | <: expr < Stream . lcons ( fun _ -> $ _ ) $ $ _ $ >> | <: exp...
let lev = find_pr_level " dot " pr_expr . pr_levels in extfun lev . pr_rules with [ <: expr < Stream . sempty >> as e -> fun _ next _ k -> [ : ` next e " " k ] : ] ;
let lev = find_pr_level " simple " pr_expr . pr_levels in extfun lev . pr_rules with [ <: expr < Stream . iapp $ _ $ $ _ $ >> | <: expr < Stream . icons $ _ $ $ _ $ >> | <: expr < Stream . ising $ _ $ >> | <: expr < Stream . lapp ( fun _ -> $ _ ) $ $ _ $ >> | <: expr < Stream . lcons ( fun _ -> $ _ ) $ $ _ $ >> | <: ex...
type printer_t ' a = { pr_fun : mutable string -> next ' a ; pr_levels : mutable list ( pr_level ' a ) } { pr_label : string ; pr_box : formatter -> ( formatter -> unit ) -> ' a -> unit ; pr_rules : mutable pr_rule ' a } Extfun . t ' a ( formatter -> curr ' a -> next ' a -> string -> kont -> unit ) let desc = if Obj . ...
let desc = if Obj . tag ( Obj . repr x ) = Obj . tag ( Obj . repr " " ) then sprintf " " \% s " " \ ( Obj . magic x ) else if Obj . is_block ( Obj . repr x ) then " tag = " ^ string_of_int ( Obj . tag ( Obj . repr x ) ) else " int_val = " ^ string_of_int ( Obj . magic x ) in sprintf " % s " \ pr_schemep , not impl : % ...
type printer_t ' a = Pr_scheme . printer_t ' a == { pr_fun : mutable string -> Pr_scheme . next ' a ; pr_levels : mutable list ( pr_level ' a ) } { pr_label : string ; pr_box : formatter -> ( formatter -> unit ) -> ' a -> unit ; pr_rules : mutable Pr_scheme . pr_rule ' a } ; let rec parser_cases ppf ( spel , k ) = matc...
let lev = find_pr_level " top " pr_expr . pr_levels in extfun lev . pr_rules with [ <: expr < fun ( __strm : $ _ ) $ -> $ x $ >> -> fun ppf curr next dg k -> fprintf ppf " % a " parser_body ( x , k ) | <: expr < let ( __strm : Stream . t _ ) = $ _ $ in $ _ $ >> as e -> fun ppf curr next dg k -> fprintf ppf " % a " pmat...
module Make ( Impl : Snarky_backendless . Snark_intf . Run ) Run = struct open Impl type ( ' a , ' n ) ' n t = ' n One_hot_vector . T ( TImpl ) TImpl . t * ( ' a , ' n ) ' n Vector . t let seal ( x : Impl . Field . t ) t : Impl . Field . t = let open Impl in match Field . to_constant_and_terms x with | None , [ ( x , i...
let expand_path exts real virt = let rec loop realfile virtfile acc = if try Sys . is_directory realfile with _ -> false then let l = Array . to_list ( Sys . readdir realfile ) |> List . sort ~ cmp : String . compare in List . fold_left l ~ init : acc ~ f ( : fun acc s -> loop ( Filename . concat realfile s ) ( Filenam...
let list_files name paths = let name , virtname = match String . lsplit2 name ~ on ' ' :: with | Some ( src , dest ) -> if String . length dest > 0 && not ( Char . equal dest . [ 0 ] ' ' ) / then failwith ( Printf . sprintf " path ' % s ' for file ' % s ' must be absolute " dest src ) ; let virtname = if Char . equal d...
let find_cmi paths base = let name , filename = try let name = String . uncapitalize_ascii base ^ " . cmi " in name , Findlib . find_in_findlib_paths paths name with Not_found -> let name = String . capitalize_ascii base ^ " . cmi " in name , Findlib . find_in_findlib_paths paths name in Filename . concat " / static / ...
let instr_of_name_content prim ~ name ~ content = let open Code in let prim = match prim with | ` create_file -> " jsoo_create_file " | ` create_file_extern -> " jsoo_create_file_extern " in Let ( Var . fresh ( ) , Prim ( Extern prim , [ Pc ( NativeString name ) ; Pc ( NativeString content ) ] ) )
let embed_file ~ name ~ filename = instr_of_name_content ` create_file_extern ~ name ~ content ( : Fs . read_file filename )
let init ( ) = Code . ( Let ( Var . fresh ( ) , Prim ( Extern " caml_fs_init " , [ ] ) ) )
let f ~ prim ~ cmis ~ files ~ paths = let cmi_files , missing_cmis = StringSet . fold ( fun s ( acc , missing ) -> try let name , filename = find_cmi paths s in ( name , Fs . read_file filename ) :: acc , missing with Not_found -> acc , s :: missing ) cmis ( [ ] , [ ] ) in if not ( List . is_empty missing_cmis ) then (...
module type Cut_pseudo_inverse = sig module Po : Po_cut . Po_cut module A : GenArray . GenArray val cut : ( Trace . t , ( ( Trace . t ) * int ) ) Po . K . H . unary end module Pseudo_inv = ( struct module Po = Po_cut . Po_cut module A = Mods . DynArray module CPredicateMap = Predicate_maps . QPredicateMap module Predic...
type item = { matches : int ; mismatches : int ; rep_matches : int ; n_count : int ; q_num_insert : int ; q_base_insert : int ; t_num_insert : int ; t_base_insert : int ; q_name : string ; q_strand : char ; q_size : int ; q_start : int ; q_end : int ; t_name : string ; t_strand : char option ; t_size : int ; t_start : ...
module Error = struct type t = [ | ` incomplete_input of Pos . t * string list * string option | ` invalid_int of Pos . t * string * string | ` invalid_strands of Pos . t * string * string | ` invalid_number_of_columns of Pos . t * string * int ] end
let parse_int msg pos s = try Ok ( int_of_string ( String . strip s ) s ) s with _ -> Error ( ` invalid_int ( pos , msg , s ) s ) s
let parse_comma_ints msg pos s = let drop = function ' ' | ' \ n ' | ' \ t ' | ' \ r ' | ' , ' -> true | _ -> false in String . strip ~ drop s |> String . split ~ on : ' , ' |> Result . List . mapi ~ f ( : fun _ -> parse_int msg pos ) pos
let parse_string s = Ok ( String . strip s ) s
let parse_strands msg pos s = match String . strip s with | " " + -> Ok ( ' + ' , None ) None | " " - -> Ok ( ' - ' , None ) None | " " ++ -> Ok ( ' + ' , Some ' + ' ) ' | " " +- -> Ok ( ' + ' , Some ' - ' ) ' | " " -+ -> Ok ( ' - ' , Some ' + ' ) ' | " " -- -> Ok ( ' - ' , Some ' - ' ) ' | s -> Error ( ` invalid_stran...
let parse_line pos line = let open Result . Monad_infix in match Line . split ~ on : ' \ t ' line with | [ matches ; mismatches ; rep_matches ; n_count ; q_num_insert ; q_base_insert ; t_num_insert ; t_base_insert ; strands ; q_name ; q_size ; q_start ; q_end ; t_name ; t_size ; t_start ; t_end ; block_count ; block_si...
let version_line = " psLayout version 3 "
let is_spaces_line = String . for_all ~ f : Char ( ( ) . = ' ' ) '
let header_line1 = " match \ tmis - \ trep . \ tN ' s \ tQ gap \ tQ gap \ tT gap \ tT gap \ tstrand \ tQ \ tQ \ tQ \ tQ \ tT \ tT \ tT \ tT \ tblock \ tblockSizes \ tqStarts \ t tStarts "
let header_line2 = " \ tmatch \ tmatch \ t \ tcount \ tbases \ tcount \ tbases \ t \ tname \ tsize \ tstart \ tend \ tname \ tsize \ tstart \ tend \ tcount "
let is_dashes_line = String . for_all ~ f : Char ( ( ) . = ' - ' ) '
module Transform = struct let string_to_item ? filename ( ) = let name = sprintf " psl_parser :% s " ( Option . value ~ default " " :<> filename ) filename in Lines . Transform . make_merge_error ~ name ? filename ~ next ( : fun linebuf -> let open Lines . Buffer in let rec get_line ( ) = match next_line linebuf with |...
let in_channel_to_item_stream ( ? buffer_size = 65536 ) 65536 ? filename inp = Tfxm . in_channel_strings_to_stream ~ buffer_size inp ( Transform . string_to_item ? filename ( ) )
let error_to_exn err = Error err
let in_channel_to_item_stream_exn ( ? buffer_size = 65536 ) 65536 ? filename inp = Stream . result_to_exn ~ error_to_exn ( in_channel_to_item_stream ~ buffer_size ? filename inp )
type ' a fmt = Format . formatter -> ' a -> unit
module type Ordered = sig type t val compare : t -> t -> int end
module type S = sig type t type k type p val empty : t val sg : k -> p -> t val ( ) ++ : t -> t -> t val is_empty : t -> bool val size : t -> int val mem : k -> t -> bool val find : k -> t -> p option val add : k -> p -> t -> t val remove : k -> t -> t val adjust : k -> ( p -> p ) -> t -> t val update : k -> ( p option...
module L = struct include List let rec take n = function x :: xs when n > 0 -> x :: take ( pred n ) xs | _ -> [ ] let rec drop n = function _ :: xs when n > 0 -> drop ( pred n ) xs | xs -> xs end
module Make ( K : Ordered ) ( P : Ordered ) : S with type k = K . t and type p = P . t = struct type k = K . t type p = P . t type t = N | T of ( k * p ) * k * tree and tree = Lf | NdL of ( k * p ) * tree * k * tree * int | NdR of ( k * p ) * tree * k * tree * int let empty = N let sg ( k , _ as kp ) = T ( kp , k , Lf ...
let rec chop k l = if k = 0 then l else begin match l with | _ :: t -> chop ( k - 1 ) t | _ -> assert false end
let sort_uniq cmp l = let rec rev_merge l1 l2 accu = match l1 , l2 with | [ ] , l2 -> List . rev_append l2 accu | l1 , [ ] -> List . rev_append l1 accu | h1 :: t1 , h2 :: t2 -> let c = cmp h1 h2 in if c = 0 then rev_merge t1 t2 ( h2 :: accu ) else if c < 0 then rev_merge t1 l2 ( h1 :: accu ) else rev_merge l1 t2 ( h2 :...
type stream_pattern_component = Spat_term of pattern * expression option | Spat_nterm of pattern * expression | Spat_sterm of pattern
type stream_expr_component = Sexp_term of expression | Sexp_nterm of expression
let mkpat d = { ppat_desc = d ; ppat_loc = symbol_loc ( ) }
let mkexp d = { pexp_desc = d ; pexp_loc = symbol_loc ( ) }
let eloc loc e = { pexp_desc = e ; pexp_loc = loc }
let ploc loc p = { ppat_desc = p ; ppat_loc = loc }
let spat = Ppat_var " % strm "
let sexp = Pexp_ident ( Lident " % strm " )
let eval x = mkexp ( Pexp_ident ( Ldot ( Lident " Stream " , x ) ) )
let econ c x = mkexp ( Pexp_construct ( Ldot ( Lident " Stream " , c ) , x , false ) )
let pcon c x = mkpat ( Ppat_construct ( Ldot ( Lident " Stream " , c ) , x , false ) )
let afun f x = mkexp ( Pexp_apply ( mkexp ( Pexp_ident ( Ldot ( Lident " Stream " , f ) ) ) , x ) )
let araise c x = mkexp ( Pexp_apply ( mkexp ( Pexp_ident ( Lident " raise " ) ) , [ econ c x ] ) )
let esome x = mkexp ( Pexp_construct ( Lident " Some " , Some x , false ) )
let stream_pattern_component skont = let elock = eloc skont . pexp_loc in function Spat_term ( p , None ) -> ( afun " peek " [ mkexp sexp ] , p , elock ( Pexp_sequence ( afun " junk " [ mkexp sexp ] , skont ) ) ) | Spat_term ( p , Some e ) -> ( afun " peek " [ mkexp sexp ] , p , elock ( Pexp_when ( e , elock ( Pexp_seq...
let ekont1 = function | Some _ as estr -> araise " Error " estr | None -> araise " Error " ( Some ( mkexp ( Pexp_constant ( Const_string " " ) ) ) ) ; ;
let rec stream_pattern epo e ekont = function [ ] -> begin match epo with Some ep -> let countexpr = afun " count " [ mkexp sexp ] in eloc e . pexp_loc ( Pexp_match ( countexpr , [ ( ep , e ) ] ) ) | _ -> e end | ( spc , err ) :: spcl -> let skont = stream_pattern epo e ekont1 spcl in let ( tst , p , e ) = stream_patte...
let rec parser_cases = function [ ] -> araise " Failure " None | ( spcl , epo , e ) :: cl -> stream_pattern epo e ( fun _ -> parser_cases cl ) spcl
let cparser ( bpo , pc ) = let pc = parser_cases pc in let e = match bpo with Some bp -> mkexp ( Pexp_match ( afun " count " [ mkexp sexp ] , [ ( bp , pc ) ] ) ) | None -> pc in mkexp ( Pexp_function [ ( mkpat spat , e ) ] )
let clazy e = mkexp ( Pexp_function [ ( mkpat Ppat_any , e ) ] )
let rec cstream = function [ ] -> eval " sempty " | Sexp_term e :: secl -> afun " lcons " [ clazy e ; cstream secl ] | Sexp_nterm e :: secl -> afun " lapp " [ clazy e ; cstream secl ]
let jd_to_date jd = let a = jd + 32044 in let b = ( 4 * a + 3 ) / 146097 in let c = a - ( ( 146097 * b ) / 4 ) in let d = ( 4 * c + 3 ) / 1461 in let e = c - ( ( 1461 * d ) / 4 ) in let m = ( 5 * e + 2 ) / 153 in let day = e - ( ( 153 * m + 2 ) / 5 ) + 1 in let month = m + 3 - ( 12 * ( m / 10 ) ) in let year = 100 * b ...
let jd_of_date ( year , month , day ) = let a = ( 14 - month ) / 12 in let y = year + 4800 - a in let m = month + 12 * a - 3 in day + ( ( 153 * m ) + 2 ) / 5 + 365 * y + ( y / 4 ) - ( y / 100 ) + ( y / 400 ) - 32045
type t = int * int64
let day_min = jd_ptime_min - jd_posix_epoch
let day_max = jd_ptime_max - jd_posix_epoch
let epoch = ( 0 , 0L )
let min = ( day_min , 0L )
let max = ( day_max , ps_day_max )
module Span = struct let stdlib_abs = abs let neg = function | ( d , 0L ) -> ( - d , 0L ) | ( d , ps ) -> ( ( - d + 1 ) , Int64 . sub ps_count_in_day ps ) let add ( d0 , ps0 ) ( d1 , ps1 ) = let d = d0 + d1 in let ps = Int64 . add ps0 ps1 in let ps_clamp = Int64 . rem ps ps_count_in_day in let d = d + Int64 . compare p...
let v ( d , ps as s ) = if ( ps < 0L || ps > ps_day_max || d < day_min || d > day_max ) then invalid_arg ( Format . sprintf " illegal ptime timestamp : ( % d , % Ld ) " d ps ) else s
let unsafe_of_d_ps s = s
let of_span ( d , _ as span ) = if d < day_min || d > day_max then None else Some span
let to_span t = t
let of_float_s secs = match Span . of_float_s secs with
let frac_s ( _ , ps ) = ( 0 , Int64 . ( rem ps ps_count_in_s ) )
let is_earlier t ~ than = compare t than = - 1
let is_later t ~ than = compare t than = 1
let add_span t d = of_span ( Span . add t d )
let sub_span t d = of_span ( Span . sub t d )
let diff t1 t0 = Span . sub t1 t0
type date = ( int * int * int )
type time = ( int * int * int ) * tz_offset_s
let max_month_day = let is_leap_year y = ( y mod 4 = 0 ) && ( y mod 100 <> 0 || y mod 400 = 0 ) in let mlen = [ | 31 ; 28 ; 31 ; 30 ; 31 ; 30 ; 31 ; 31 ; 30 ; 31 ; 30 ; 31 ] | in fun y m -> if ( m = 2 && is_leap_year y ) then 29 else mlen . ( m - 1 )
let is_date_valid ( y , m , d ) = 0 <= y && y <= 9999 && 1 <= m && m <= 12 && 1 <= d && d <= max_month_day y m
let is_time_valid ( ( hh , mm , ss ) , _ ) = 0 <= hh && hh <= 23 && 0 <= mm && mm <= 59 && 0 <= ss && ss <= 60
let of_date_time ( date , ( ( hh , mm , ss ) , tz_offset_s as t ) ) = if not ( is_date_valid date && is_time_valid t ) then None else let d = jd_of_date date - jd_posix_epoch in let hh_ps = Int64 . ( mul ( of_int hh ) ps_count_in_hour ) in let mm_ps = Int64 . ( mul ( of_int mm ) ps_count_in_min ) in let ss_ps = Int64 ....
let to_date_time ( ? tz_offset_s = 0 ) t = let ( d , ps ) , tz_offset_s = match add_span t ( Span . of_int_s tz_offset_s ) with | None -> t , 0 | Some local -> local , tz_offset_s in let jd = d + jd_posix_epoch in let date = jd_to_date jd in let hh = Int64 . ( to_int ( div ps ps_count_in_hour ) ) in let hh_rem = Int64 ...
let of_date date = of_date_time ( date , ( ( 00 , 00 , 00 ) , 0 ) )
let to_date t = fst ( to_date_time ~ tz_offset_s : 0 t )
let weekday = let wday = [ | ` Thu ; ` Fri ; ` Sat ; ` Sun ; ` Mon ; ` Tue ; ` Wed ] | in fun ( ? tz_offset_s = 0 ) t -> let ( d , _ ) = Span . add t ( Span . of_int_s tz_offset_s ) in let i = d mod 7 in wday . ( if i < 0 then 7 + i else i )
type error_range = int * int
type rfc3339_error = [ ` Invalid_stamp | ` Eoi | ` Exp_chars of char list | ` Trailing_input ]
let pp_rfc3339_error ppf = function let rec pp_chars ppf = function | c :: cs -> Format . fprintf ppf " @ % C " c ; pp_chars ppf cs | [ ] -> ( ) in Format . fprintf ppf " [ @ expected @ a @ character @ in :% a ] " @ pp_chars cs
let rfc3339_error_to_msg = function Error ( ` Msg ( Format . asprintf " % d -% d : % a " s e pp_rfc3339_error err ) )
let error r e = raise ( RFC3339 ( r , e ) )
let error_pos p e = error ( p , p ) e
let error_exp_digit p = error_pos p ( ` Exp_chars [ ' 0 ' ; ' 1 ' ; ' 2 ' ; ' 3 ' ; ' 4 ' ; ' 5 ' ; ' 6 ' ; ' 7 ' ; ' 8 ' ; ' 9 ' ] )
let is_digit = function ' 0 ' . . ' 9 ' -> true | _ -> false
let parse_digits ~ count pos max s = let stop = pos + count - 1 in if stop > max then error_pos max ` Eoi else let rec loop k acc = if k > stop then acc else if is_digit s . [ k ] then loop ( k + 1 ) ( acc * 10 + Char . code s . [ k ] - 0x30 ) else error_exp_digit k in loop pos 0