text stringlengths 0 601k |
|---|
module Operation = struct module T = struct type t = | Set | Let | Unlet | Makunbound | Defvaralias [ @@ deriving enumerate , sexp_of ] end include T let type_ = Value . Type . enum [ % message " variable - change - operation " ] ( module T ) ( ( function | Set -> " set " | Let -> " let " | Unlet -> " unlet " | Makunbo... |
module Event = struct type t = { local_to_buffer : Buffer . t option ; new_value : Value . t ; operation : Operation . t ; variable_changed : Symbol . t } [ @@ deriving sexp_of ] end |
let build_function here f = Defun . lambda here ( Returns Value . Type . unit ) ( let % map_open . Defun ( ) = return ( ) and symbol = required " symbol " Symbol . type_ and newval = required " newval " Value . Type . value and operation = required " operation " Operation . type_ and where = required " where " ( Value ... |
type t = { symbol : Symbol . t ; watcher : Function . t } |
let add_variable_watcher = Funcall . Wrap . ( " add - variable - watcher " <: Symbol . type_ @-> Function . type_ @-> return nil ) ; ; |
let add here var ~ f = let watcher = build_function here f in add_variable_watcher ( Var . symbol var ) watcher ; { symbol = Var . symbol var ; watcher } ; ; |
let remove_variable_watcher = Funcall . Wrap . ( " remove - variable - watcher " <: Symbol . type_ @-> Function . type_ @-> return nil ) ; ; |
let remove { symbol ; watcher } = remove_variable_watcher symbol watcher |
let test_check_variance context = let assert_type_errors = assert_type_errors ~ context in assert_type_errors { | def narnia ( ) : pass def foo ( ) -> None : [ narnia ( ) ] + [ 2 ] } | [ " Missing return annotation [ 3 ] : Returning ` None ` but no return type is specified . " ] ; assert_type_errors { | import typing d... |
let test_check_literal_variance context = let assert_type_errors = assert_type_errors ~ context in assert_type_errors { | import typing x : typing . List [ float ] = [ ] x = [ 1 ] } | [ ] ; assert_type_errors { | import typing x : typing . List [ float ] = [ ] x = [ y for y in [ 1 , 2 , 3 , 4 ] ] } | [ ] ; assert_type_... |
let ( ) = " variance " >::: [ " check_variance " >:: test_check_variance ; " check_literal_variance " >:: test_check_literal_variance ; ] |> Test . run |
module rec X : sig type t = int * bool type t = A | B let f = function A | B -> 0 end ; ; [ %% expect { | Modules do not match : sig type t = X . t = A | B val f : t -> int end is not included in sig type t = int * bool end Type declarations do not match : type t = X . t = A | B is not included in type t = int * bool }... |
module Make ( X : sig val f : [ ` A ] -> unit end ) = struct let make f1 f2 arg = match arg with ` A -> f1 arg ; f2 arg let f = make X . f ( fun _ -> ( ) ) end ; ; [ %% expect { | |
module Make : functor ( X : sig val f : [ ` A ] -> unit end ) -> sig val make : ( ( [ < ` A ] as ' a ) -> ' b ) -> ( ' a -> ' c ) -> ' a -> ' c val f : [ ` A ] -> unit end } ] | |
type ( ' a , ' b ) def = X of int constraint ' b = [ > ` A ] |
type arity = ( int , [ ` A ] ) def = X of int ; ; [ %% expect { | |
type ( ' a , ' b ) def = X of int constraint ' b = [ > ` A ] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ( int , [ ` A ] ) def They have different arities . } ] | |
type ( ' a , ' b ) ct = ( int , ' b ) def = X of int ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ( int , [ > ` A ] ) def Their constraints differ . } ] | |
type ( ' a , ' b ) kind = ( ' a , ' b ) def = { a : int } constraint ' b = [ > ` A ] ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ( ' a , [ > ` A ] ) def Their kinds differ . } ] | |
type d = X of int | Y of int |
type missing = d = X of int [ %% expect { | |
type d = X of int | Y of int ^^^^^^^^^^^^^^^^^^^^^^^^^^^ The constructor Y is only present in the original definition . } ] | |
type wrong_type = d = X of float [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Constructors do not match : X of int is not compatible with : X of float The types are not equal . } ] | |
type unboxed = d = X of float [ @@ unboxed ] [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Their internal representations differ : this definition uses unboxed representation . } ] | |
type perm = d = Y of int | X of int [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Constructors number 1 have different names , X and Y . } ] | |
module M : sig type t = Foo of int type t = Foo : int -> t end ; ; [ %% expect { | Modules do not match : sig type t = Foo : int -> t end is not included in sig type t = Foo of int end Type declarations do not match : type t = Foo : int -> t is not included in type t = Foo of int Constructors do not match : Foo : int -... |
type ' a u = [ < ` a of int | ` b of bool & int & string > ` a ] as ' a |
type ' a u1 = [ > ` a of int ] as ' a |
type u2 = [ ` a of int ] |
type ' a u3 = [ < ` b | ` a of & int & bool ] as ' a |
type ' a u4 = [ < ` b | ` a of int & bool ] as ' a |
module M1 : sig type t = | Foo of int * int type t = | Foo of float * int end ; ; [ %% expect { | Modules do not match : sig type t = Foo of float * int end is not included in sig type t = Foo of int * int end Type declarations do not match : type t = Foo of float * int is not included in type t = Foo of int * int Cons... |
module M2 : sig type t = | Foo of int * int type t = | Foo of float end ; ; [ %% expect { | Modules do not match : sig type t = Foo of float end is not included in sig type t = Foo of int * int end Type declarations do not match : type t = Foo of float is not included in type t = Foo of int * int Constructors do not ma... |
module M3 : sig type t = | Foo of { x : int ; y : int } type t = | Foo of { x : float ; y : int } end ; ; [ %% expect { | Modules do not match : sig type t = Foo of { x : float ; y : int ; } end is not included in sig type t = Foo of { x : int ; y : int ; } end Type declarations do not match : type t = Foo of { x : flo... |
module M4 : sig type t = | Foo of { x : int ; y : int } type t = | Foo of float end ; ; [ %% expect { | Modules do not match : sig type t = Foo of float end is not included in sig type t = Foo of { x : int ; y : int ; } end Type declarations do not match : type t = Foo of float is not included in type t = Foo of { x : ... |
module M5 : sig type ' a t = | Foo : int -> int t type ' a t = | Foo of ' a end ; ; [ %% expect { | Modules do not match : sig type ' a t = Foo of ' a end is not included in sig type ' a t = Foo : int -> int t end Type declarations do not match : type ' a t = Foo of ' a is not included in type ' a t = Foo : int -> int ... |
module M : sig type ( ' a , ' b ) t = A of ' a type ( ' a , ' b ) t = A of ' b end ; ; Modules do not match : sig type ( ' a , ' b ) t = A of ' b end is not included in sig type ( ' a , ' b ) t = A of ' a end Type declarations do not match : type ( ' a , ' b ) t = A of ' b is not included in type ( ' a , ' b ) t = A of... |
module M : sig type ( ' a , ' b ) t = A of ' a type ( ' b , ' a ) t = A of ' a end ; ; Modules do not match : sig type ( ' b , ' a ) t = A of ' a end is not included in sig type ( ' a , ' b ) t = A of ' a end Type declarations do not match : type ( ' b , ' a ) t = A of ' a is not included in type ( ' a , ' b ) t = A of... |
module M ( X : sig type ' a t end ) = struct module Tag_internal = struct type ( ' variant , ' args ) create = | Args of ( ' args -> ' variant ) | Const of ' variant type ( ' variant , ' args ) t = { label : string ; rep : ' args X . t ; arity : int ; args_labels : string list ; index : int ; ocaml_repr : int ; tyid : ... |
module type S = sig type ' a t include module type of M ( struct type ' a rep = ' a t type ' a t = ' a rep end ) end |
let decvarint ( s : string ) string : int64 = let dec = D . of_string s in D . int64_as_varint dec |
let encvarint ( i : int64 ) int64 : string = let enc = E . create ( create ) create in E . int64_as_varint i enc ; E . to_string enc |
let str_to_l s = let l = ref [ ] in String . iter ( fun x -> l := x :: ! l ) l s ; List . rev ! l |
let str_to_il s = str_to_l s |> List . map Char . code |
let ( ) = let s = encvarint 12L in assert ( str_to_il s = [ 12 ] 12 ) 12 ; assert ( decvarint s = 12L ) 12L |
let ( ) = let s = encvarint 0L in assert ( str_to_il s = [ 0 ] 0 ) 0 ; assert ( decvarint s = 0L ) 0L |
let ( ) = let s = encvarint 127L in assert ( str_to_il s = [ 127 ] 127 ) 127 ; assert ( decvarint s = 127L ) 127L |
let ( ) = let s = encvarint 128L in assert ( str_to_il s = [ 128 ; 1 ] 1 ) 1 ; assert ( decvarint s = 128L ) 128L |
let ( ) = let s = encvarint 300L in assert ( str_to_il s = [ 0b1010_1100 ; 0b0000_0010 ] 0b0000_0010 ) 0b0000_0010 ; assert ( decvarint s = 300L ) 300L |
let ( ) = let s = encvarint 150L in assert ( str_to_il s = [ 0x96 ; 1 ] 1 ) 1 ; assert ( decvarint s = 150L ) 150L |
let ( ) = let s = encvarint 178282982111149L in assert ( str_to_il s = [ 173 ; 239 ; 197 ; 238 ; 219 ; 196 ; 40 ] 40 ) 40 ; assert ( decvarint s = 178282982111149L ) 178282982111149L |
let setupMethod = ref pointer |
let derefMethod = ref drawarray |
let setupPointers ( ) = let vertices = Bigarray . Array1 . of_array Bigarray . float32 Bigarray . c_layout [ | 25 . ; 25 . ; 100 . ; 325 . ; 175 . ; 25 . ; 175 . ; 325 . ; 250 . ; 25 . ; 325 . ; 325 . ; ] | and colors = Bigarray . Array1 . of_array Bigarray . float32 Bigarray . c_layout [ | 1 . 0 ; 0 . 2 ; 0 . 2 ; 0 . ... |
let setupInterleave ( ) = let intertwined = Bigarray . Array1 . of_array Bigarray . float32 Bigarray . c_layout [ | 1 . 0 ; 0 . 2 ; 1 . 0 ; 100 . 0 ; 100 . 0 ; 0 . 0 ; 1 . 0 ; 0 . 2 ; 0 . 2 ; 0 . 0 ; 200 . 0 ; 0 . 0 ; 1 . 0 ; 1 . 0 ; 0 . 2 ; 100 . 0 ; 300 . 0 ; 0 . 0 ; 0 . 2 ; 1 . 0 ; 0 . 2 ; 200 . 0 ; 300 . 0 ; 0 . 0 ... |
let init ( ) = glClearColor 0 . 0 0 . 0 0 . 0 0 . 0 ; glShadeModel GL_SMOOTH ; setupPointers ( ) ; ; ; |
let display ( ) = glClear [ GL_COLOR_BUFFER_BIT ] ; if ( ! derefMethod = drawarray ) then glDrawArrays GL_TRIANGLES 0 6 else if ( ! derefMethod = arrayelement ) then begin glBegin GL_TRIANGLES ; glArrayElement 2 ; glArrayElement 3 ; glArrayElement 5 ; glEnd ( ) ; end else if ( ! derefMethod = drawelements ) then begin ... |
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluOrtho2D 0 . 0 ( float w ) 0 . 0 ( float h ) ; ; ; |
let mouse ~ button ~ state ~ x ~ y = match button , state with | GLUT_LEFT_BUTTON , GLUT_DOWN -> if ( ! setupMethod = pointer ) then begin setupMethod := interleaved ; setupInterleave ( ) ; end else if ( ! setupMethod = interleaved ) then begin setupMethod := pointer ; setupPointers ( ) ; end ; glutPostRedisplay ( ) ; ... |
let keyboard ~ key ~ x ~ y = match key with | ' \ 027 ' -> exit 0 ; | _ -> ( ) ; ; |
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_SINGLE ; GLUT_RGB ] ; glutInitWindowSize 350 350 ; glutInitWindowPosition 100 100 ; ignore ( glutCreateWindow Sys . argv . ( 0 ) ) ; let gl_version = glGetString GL_VERSION in if gl_version < " 1 . 1 " then begin Printf . eprintf " This program demon... |
let names bounded env = Env . fold ( fun n _ bounded -> S . add n bounded ) env bounded |
let rec fv_pat bounded acc p = match p . p_desc with | Ewildpat | Econstr0pat _ | Econstpat _ -> acc | Evarpat ( x ) -> if ( S . mem x acc ) || ( S . mem x bounded ) then acc else S . add x acc | Econstr1pat ( _ , pat_list ) | Etuplepat ( pat_list ) -> List . fold_left ( fv_pat bounded ) acc pat_list | Erecordpat ( lab... |
let fv_block fv_local fv_body bounded acc { b_env = b_env ; b_locals = l_list ; b_body = body ; b_write = defnames } = let bounded = names bounded b_env in let bounded , acc = List . fold_left fv_local ( bounded , acc ) l_list in bounded , fv_body bounded acc body |
let fv_match_handler fv_body m_h_list bounded acc = List . fold_left ( fun acc { m_pat = pat ; m_body = b ; m_env = env } -> fv_body ( names bounded env ) acc b ) acc m_h_list |
let rec size acc { desc = desc } = match desc with | Sconst _ | Sglobal _ -> acc | Sname ( n ) -> S . add n acc | Sop ( _ , s1 , s2 ) -> size ( size acc s1 ) s2 |
let operator acc = function | Efby | Eunarypre | Eifthenelse | Etest | Eminusgreater | Eup | Einitial | Edisc | Ehorizon | Eaccess | Eupdate | Econcat | Eatomic -> acc | Eslice ( s1 , s2 ) -> size ( size acc s1 ) s2 |
let rec fv bounded ( last_acc , acc ) e = match e . e_desc with | Eop ( op , e_list ) -> let last_acc , acc = List . fold_left ( fv bounded ) ( last_acc , acc ) e_list in last_acc , operator acc op | Econstr1 ( _ , e_list ) | Etuple ( e_list ) -> List . fold_left ( fv bounded ) ( last_acc , acc ) e_list | Eapp ( _ , e ... |
let fve acc e = let acc_last , acc = fv S . empty ( S . empty , acc ) e in S . union acc_last acc |
let empty_vcf = " ## fileformat = VCFv4 . 1 ## source = VarScan2 ## FORMAT =< ID = GT , Number = 1 , Type = String , Description " =\ Genotype " \> # CHROM \ tPOS \ tID \ tREF \ tALT \ tQUAL \ tFILTER \ tINFO \ tFORMAT \ tNORMAL \ tTUMOR " |
let somatic_on_region ~ run_with ? adjust_mapq ~ normal ~ tumor ~ result_prefix region = let open KEDSL in let name = Filename . basename result_prefix in let result_file suffix = result_prefix ^ suffix in let varscan_tool = Machine . get_tool run_with Machine . Tool . Default . varscan in let snp_output = result_file ... |
let somatic_map_reduce ( ? more_edges = [ ] ) ~ run_with ? adjust_mapq ~ normal ~ tumor ~ result_prefix ( ) = let run_on_region region = let result_prefix = result_prefix ^ " " - ^ Region . to_filename region in somatic_on_region ~ run_with ? adjust_mapq ~ normal ~ tumor ~ result_prefix region in let reference = Machin... |
type t = private [ > ] ; ; |
type u = private [ > ] ~ [ t ] ; ; |
type v = [ t | u ] ; ; |
let f x = ( x : t :> v ) ; ; |
module Mix ( X : sig type t = private [ > ] end ) ( Y : sig type t = private [ > ] end ) = struct type t = [ X . t | Y . t ] end ; ; |
module Mix ( X : sig type t = private [ > ` A of int ] end ) ( Y : sig type t = private [ > ` A of bool ] ~ [ X . t ] end ) = struct type t = [ X . t | Y . t ] end ; ; |
module Mix ( X : sig type t = private [ > ` A of int ] end ) ( Y : sig type t = private [ > ` A of int ] ~ [ X . t ] end ) = struct type t = [ X . t | Y . t ] end ; ; |
module Mix ( X : sig type t = private [ > ` A of int ] end ) ( Y : sig type t = private [ > ` B of bool ] ~ [ X . t ] end ) = struct type t = [ X . t | Y . t ] end ; ; |
type ' a t = private [ > ` L of ' a ] ~ [ ` L ] ; ; |
module Mix ( X : sig type t = private [ > ` A of int ] ~ [ ` B ] end ) ( Y : sig type t = private [ > ` B of bool ] ~ [ X . t ] end ) = struct type t = [ X . t | Y . t ] let is_t = function # t -> true | _ -> false end ; ; |
module Mix ( X : sig type t = private [ > ` A of int ] ~ [ ` B ] end ) ( Y : sig type t = private [ > ` B of bool ] ~ [ X . t ] end ) = struct type t = [ X . t | Y . t ] let which = function # X . t -> ` X | # Y . t -> ` Y end ; ; |
module Mix ( I : sig type t = private [ > ] ~ [ ` A ; ` B ] end ) ( X : sig type t = private [ > I . t | ` A of int ] ~ [ ` B ] end ) ( Y : sig type t = private [ > I . t | ` B of bool ] ~ [ X . t ] end ) = struct type t = [ X . t | Y . t ] let which = function # X . t -> ` X | # Y . t -> ` Y end ; ; |
module M = Mix ( struct type t = [ ` C of char ] end ) ( struct type t = [ ` A of int | ` C of char ] end ) ( struct type t = [ ` B of bool | ` C of char ] end ) ; ; |
module M = Mix ( struct type t = [ ` B of bool ] end ) ( struct type t = [ ` A of int | ` B of bool ] end ) ( struct type t = [ ` B of bool | ` C of char ] end ) ; ; |
module M1 = struct type t = [ ` A of int | ` C of char ] end |
module M2 = struct type t = [ ` B of bool | ` C of char ] end |
module I = struct type t = [ ` C of char ] end |
module M = Mix ( I ) ( M1 ) ( M2 ) ; ; |
let c = ( ` C ' c ' : M . t ) ; ; |
module M ( X : sig type t = private [ > ` A ] end ) = struct let f ( # X . t as x ) = x end ; ; |
type t = private [ > ` A ] ~ [ ` B ] ; ; |
module M : sig type t = private [ > ` A of int | ` B ] ~ [ ` C ] end = struct type t = [ ` A of int | ` B | ` D of bool ] end ; ; |
let f = function ( ` C | # M . t ) -> 1 + 1 ; ; |
let f = function ( ` A _ | ` B # M . t ) -> 1 + 1 ; ; |
module Mix ( X : sig type t = private [ > ] val show : t -> string end ) ( Y : sig type t = private [ > ] ~ [ X . t ] val show : t -> string end ) = struct type t = [ X . t | Y . t ] let show : t -> string = function # X . t as x -> X . show x | # Y . t as y -> Y . show y end ; ; |
module EStr = struct type t = [ ` Str of string ] let show ( ` Str s ) = s end |
module EInt = struct type t = [ ` Int of int ] let show ( ` Int i ) = string_of_int i end |
module type T = sig type t = private [ > ] val show : t -> string end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.