text
stringlengths
12
786k
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 ' a Constructors do not match : A of ' a is not compatible with : A of ' a The types are not equal . } ] ; ; |
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 : ' args Typename . t ; create : ( ' variant , ' args ) create } end module Tag : sig type ( ' variant , ' args ) create = | Args of ( ' args -> ' variant ) | Const of ' variant type ( ' variant , ' args ) t val label : ( _ , _ ) t -> string val arity : ( _ , _ ) t -> int val args_labels : ( _ , _ ) t -> string list | B | C of int | D of char | E of { x : int } ] } ) * val index : ( _ , _ ) t -> int print_int ( Obj . magic ' foo ) Standards variants : ------------------- [ ocaml_repr ] is the tag corresponding to the constructor within the type . the way it works in the ocaml runtime is by partitioning the constructors regarding if they have some arguments or not , preserving the order , then assign increasing index withing each partition . Example : { [ type t = | A | B of int | C | D of ( float * string ) | E | F | G of string | H of { x : int } ] } ) * val ocaml_repr : ( _ , _ ) t -> int val create : ( ' variant , ' args ) t -> ( ' variant , ' args ) create val tyid : ( _ , ' args ) t -> ' args Typename . t val traverse : ( _ , ' args ) t -> ' args X . t val internal_use_only : ( ' a , ' b ) Tag_internal . t -> ( ' a , ' b ) t end = struct include Tag_internal let label t = t . label let arity t = t . arity let args_labels t = t . args_labels let index t = t . index let ocaml_repr t = t . ocaml_repr let create t = t . create let tyid t = t . tyid let traverse t = t . rep let internal_use_only t = t end module Variant_internal = struct type _ tag = Tag : ( ' variant , ' a ) Tag . t -> ' variant tag type _ value = Value : ( ' variant , ' a ) Tag . t * ' a -> ' variant value type ' a t = { typename : ' a Typename . t ; tags : ' a tag array ; polymorphic : bool ; value : ' a -> ' a value } end module Variant : sig type _ tag = Tag : ( ' variant , ' args ) Tag . t -> ' variant tag type _ value = Value : ( ' variant , ' args ) Tag . t * ' args -> ' variant value type ' a t val typename_of_t : ' a t -> ' a Typename . t val length : ' a t -> int val tag : ' a t -> int -> ' a tag val is_polymorphic : _ t -> bool val value : ' a t -> ' a -> ' a value val fold : ' a t -> init ' : acc -> f ( ' : acc -> ' a tag -> ' acc ) -> ' acc val internal_use_only : ' a Variant_internal . t -> ' a t end = struct include Variant_internal let typename_of_t t = t . typename let length t = Array . length t . tags let tag t index = t . tags . ( index ) let is_polymorphic t = t . polymorphic let value t = t . value let fold t ~ init ~ f = Array . fold_left f init t . tags let internal_use_only t = t end module Field_internal = struct type ( ' record , ' field ) t = { label : string ; rep : ' field X . t ; index : int ; tyid : ' field Typename . t ; get : ' record -> ' field ; is_mutable : bool } end module Field : sig type ( ' record , ' field ) t foo : string ; bar : float ; } ] } ) * val label : ( _ , _ ) t -> string foo : string ; bar : string ; } ] } ) * val index : ( _ , _ ) t -> int val get : ( ' record , ' field ) t -> ' record -> ' field val is_mutable : ( _ , _ ) t -> bool val tyid : ( _ , ' field ) t -> ' field Typename . t val traverse : ( _ , ' field ) t -> ' field X . t val internal_use_only : ( ' a , ' b ) Field_internal . t -> ( ' a , ' b ) t end = struct include Field_internal let label t = t . label let index t = t . index let get t = t . get let is_mutable t = t . is_mutable let tyid t = t . tyid let traverse t = t . rep let internal_use_only t = t end module Record_internal = struct type _ field = Field : ( ' record , ' a ) Field . t -> ' record field type ' record fields = { get : ' field . ( ' record , ' field ) Field . t -> ' field } type ' a t = { typename : ' a Typename . t ; fields : ' a field array ; has_double_array_tag : bool ; create : ' a fields -> ' a } end module Record : sig type _ field = Field : ( ' record , ' a ) Field . t -> ' record field type ' record fields = { get : ' field . ( ' record , ' field ) Field . t -> ' field } type ' a t val typename_of_t : ' a t -> ' a Typename . t val length : ' a t -> int val field : ' a t -> int -> ' a field val has_double_array_tag : _ t -> bool val create : ' a t -> ' a fields -> ' a val fold : ' a t -> init ' : acc -> f ( ' : acc -> ' a field -> ' acc ) -> ' acc val internal_use_only : ' a Record_internal . t -> ' a t end = struct include Record_internal let typename_of_t t = t . typename let length t = Array . length t . fields let field t index = t . fields . ( index ) let has_double_array_tag t = t . has_double_array_tag let create t = t . create let fold t ~ init ~ f = Array . fold_left f init t . fields let internal_use_only t = t end end
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 . 2 ; 0 . 2 ; 1 . 0 ; 0 . 8 ; 1 . 0 ; 0 . 2 ; 0 . 75 ; 0 . 75 ; 0 . 75 ; 0 . 35 ; 0 . 35 ; 0 . 35 ; 0 . 5 ; 0 . 5 ; 0 . 5 ; ] | in glEnableClientState GL_VERTEX_ARRAY ; glEnableClientState GL_COLOR_ARRAY ; glVertexPointer 2 Coord . GL_FLOAT 0 vertices ; glColorPointer 3 Color . GL_FLOAT 0 colors ; ; ;
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 ; 0 . 2 ; 1 . 0 ; 1 . 0 ; 300 . 0 ; 200 . 0 ; 0 . 0 ; 0 . 2 ; 0 . 2 ; 1 . 0 ; 200 . 0 ; 100 . 0 ; 0 . 0 ; ] | in glInterleavedArrays GL_C3F_V3F 0 intertwined ; ; ;
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 indices = Bigarray . Array1 . of_array Bigarray . nativeint Bigarray . c_layout [ | 0n ; 1n ; 3n ; 4n ] | in glDrawElements GL_POLYGON 4 Elem . GL_UNSIGNED_INT indices ; end ; glFlush ( ) ; ; ;
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 ( ) ; | GLUT_MIDDLE_BUTTON , GLUT_DOWN | GLUT_RIGHT_BUTTON , GLUT_DOWN -> if ( ! derefMethod = drawarray ) then derefMethod := arrayelement else if ( ! derefMethod = arrayelement ) then derefMethod := drawelements else if ( ! derefMethod = drawelements ) then derefMethod := drawarray ; 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 demonstrates a feature which is not in OpenGL Version 1 . 0 . \ n \ If your implementation of OpenGL Version 1 . 0 has the right extensions , \ n \ you may be able to modify this program to make it run . \ n " ; %! exit 1 ; end ; init ( ) ; glutDisplayFunc ~ display ; glutReshapeFunc ~ reshape ; glutMouseFunc ~ mouse ; glutKeyboardFunc ~ keyboard ; glutMainLoop ( ) ; ; ;
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 ( label_pat_list ) -> List . fold_left ( fun acc ( _ , p ) -> fv_pat bounded acc p ) acc label_pat_list | Ealiaspat ( p , name ) -> let acc = fv_pat bounded acc p | Eorpat ( p1 , _ ) -> fv_pat bounded acc p1 | Etypeconstraintpat ( p , _ ) -> fv_pat bounded acc p
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 , e_list ) -> List . fold_left ( fv bounded ) ( fv bounded ( last_acc , acc ) e ) e_list | Elocal ( n ) -> last_acc , if ( S . mem n acc ) || ( S . mem n bounded ) then acc else S . add n acc | Elast ( n ) -> ( if ( S . mem n last_acc ) || ( S . mem n bounded ) then last_acc else S . add n last_acc ) , acc | Erecord_access ( e , _ ) | Etypeconstraint ( e , _ ) -> fv bounded ( last_acc , acc ) e | Erecord ( f_e_list ) -> List . fold_left ( fun acc ( _ , e ) -> fv bounded acc e ) ( last_acc , acc ) f_e_list | Erecord_with ( e , f_e_list ) -> let last_acc , acc = fv bounded ( last_acc , acc ) e in List . fold_left ( fun acc ( _ , e ) -> fv bounded acc e ) ( last_acc , acc ) f_e_list | Elet ( local , e ) -> let bounded , acc = fv_local ( bounded , ( last_acc , acc ) ) local in fv bounded acc e | Eblock ( b , e ) -> let acc = fv_block_eq_list bounded ( last_acc , acc ) b in fv bounded acc e | Eseq ( e1 , e2 ) -> fv bounded ( fv bounded ( last_acc , acc ) e1 ) e2 | Econst _ | Econstr0 _ | Eglobal _ | Eperiod _ -> last_acc , acc | Epresent _ | Ematch _ -> assert false match desc with | EQeq ( _ , e ) | EQinit ( _ , e ) | EQpluseq ( _ , e ) -> | EQmatch ( _ , e , m_h_list ) -> fv_match_handler fv_block_eq_list m_h_list bounded | EQreset ( eq_list , r ) -> fv bounded ( fv_eq_list bounded ( last_acc , acc ) eq_list ) r | EQder ( _ , e , None , [ ] ) -> fv bounded ( last_acc , acc ) e | EQblock ( b ) -> fv_block_eq_list bounded ( last_acc , acc ) b | EQand ( eq_list ) | EQbefore ( eq_list ) -> fv_eq_list bounded ( last_acc , acc ) eq_list | EQforall { for_index = i_list ; for_init = init_list ; let index ( last_acc , acc ) { desc = desc } = match desc with | Einput ( _ , e ) -> fv bounded ( last_acc , acc ) e | Eindex ( _ , e1 , e2 ) -> | Eoutput _ -> last_acc , acc in let init ( bounded , last_acc , acc ) { desc = desc } = match desc with | Einit_last ( x , e ) -> let last_acc , acc = List . fold_left index ( last_acc , acc ) i_list in let bounded , last_acc , acc = List . fold_left init ( bounded , last_acc , acc ) init_list in fv_block_eq_list bounded ( last_acc , acc ) b_eq_list | EQder _ | EQemit _ | EQpresent _ | EQautomaton _ | EQnext _ -> assert false let bounded = names bounded l_env in let acc = List . fold_left ( fv_eq bounded ) acc eq_list in ( bounded , acc ) let _ , acc = fv_block fv_local fv_eq_list bounded acc b in acc
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 " - snp . vcf " in let indel_output = result_file " - indel . vcf " in let normal_pileup = Samtools . mpileup ~ run_with ~ region ? adjust_mapq normal in let tumor_pileup = Samtools . mpileup ~ run_with ~ region ? adjust_mapq tumor in let host = Machine . as_host run_with in let tags = [ Target_tags . variant_caller ; " varscan " ] in let varscan_somatic = let name = " somatic " - ^ name in let make = let big_one_liner = " if [ - s " ^ normal_pileup # product # path ^ " ] && [ - s " ^ tumor_pileup # product # path ^ " ] ; then " ^ sprintf " java - jar $ VARSCAN_JAR somatic % s % s \ -- output - snp % s \ -- output - indel % s \ -- output - vcf 1 ; " normal_pileup # product # path tumor_pileup # product # path snp_output indel_output ^ " else " ^ " echo ' " ^ empty_vcf ^ " ' > " ^ snp_output ^ " ; " ^ " echo ' " ^ empty_vcf ^ " ' > " ^ indel_output ^ " ; " ^ " fi " in Program . ( Machine . Tool . init varscan_tool && sh big_one_liner ) |> Machine . run_big_program run_with ~ name ~ processors : 1 ~ self_ids [ " : varscan " ; " somatic " ] in workflow_node ~ name ~ make ( single_file snp_output ~ host ) ~ tags ~ edges [ : depends_on ( Machine . Tool . ensure varscan_tool ) ; depends_on normal_pileup ; depends_on tumor_pileup ; on_failure_activate ( Remove . file ~ run_with snp_output ) ; on_failure_activate ( Remove . file ~ run_with indel_output ) ; ] in let snp_filtered = result_file " - snpfiltered . vcf " in let indel_filtered = result_file " - indelfiltered . vcf " in let varscan_filter = let name = " filter " - ^ name in let make = Program . ( Machine . Tool . init varscan_tool && shf " java - jar $ VARSCAN_JAR somaticFilter % s \ -- indel - file % s \ -- output - file % s " snp_output indel_output snp_filtered && shf " java - jar $ VARSCAN_JAR processSomatic % s " snp_filtered && shf " java - jar $ VARSCAN_JAR processSomatic % s " indel_output ) |> Machine . run_big_program run_with ~ name ~ processors : 1 ~ self_ids [ " : varscan " ; " somaticfilter " ] in workflow_node ~ name ~ make ~ tags ( vcf_file snp_filtered ~ reference_build : normal # product # reference_build ~ host ) ~ edges [ : depends_on varscan_somatic ; on_failure_activate ( Remove . file ~ run_with snp_filtered ) ; on_failure_activate ( Remove . file ~ run_with indel_filtered ) ; ] in varscan_filter
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 = Machine . get_reference_genome run_with normal # product # reference_build in let targets = List . map ( Reference_genome . major_contigs reference ) ~ f : run_on_region in let final_vcf = result_prefix ^ " - merged . vcf " in Vcftools . vcf_concat ~ run_with targets ~ final_vcf ~ more_edges
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
module Mix ( X : T ) ( Y : T with type t = private [ > ] ~ [ X . t ] ) : T with type t = [ X . t | Y . t ] = struct type t = [ X . t | Y . t ] let show = function # X . t as x -> X . show x | # Y . t as y -> Y . show y end ; ;
module M : sig type t = private [ > ` A ] end = struct type t = [ ` A ] end
module M ' : sig type t = private [ > ] end = struct type t = [ M . t | ` A ] end ; ;
type t = private [ > ]
type u = private [ > ` A of int ] ~ [ t ] ; ;
type t = private [ > ` A of int ]
type u = private [ > ` A of int ] ~ [ t ] ; ;
module F ( X : sig type t = private [ > ] ~ [ ` A ; ` B ; ` C ; ` D ] type u = private [ > ` A ` | B ` | C ] ~ [ t ; ` D ] open X let f = function # u -> 1 | # t -> 2 | ` D -> 3 let g = function # u |# t ` | D -> 2 type v = [ t | u ` | D ] end
module M = struct type t = private [ > ` A ] end ; ;
module M ' : sig type t = private [ > ] ~ [ ` A ] end = M ; ;
module type T = sig type t = private [ > ] ~ [ ` A ] end ; ;
module type T ' = T with type t = private [ > ` A ] ; ;
type t = private [ > ] ~ [ ` A ]
let f = function ` A x -> x | # t -> 0
type t ' = private [ < ` A of int | t ] ; ;
module F ( X : sig end ) : sig type t = private [ > ] type u = private [ > ] ~ [ t ] end = struct type t = [ ` A ] type u = [ ` B ] end
let f = function # M . t -> 1 | # M . u -> 2
let f = function # M . t -> 1 | _ -> 2
type t = [ M . t | M . u ]
let f = function # t -> 1 | _ -> 2 ; ;
module G ( X : sig type t = private [ > ] type u = private [ > ] ~ [ t ] end ) = struct let f = function # X . t -> 1 | _ -> 2 end ; ;
module M1 = G ( struct module N = F ( String ) type t = N . t type u = N . u end ) ; ;
module M1 = G ( struct type t = M . t type u = M . u end ) ; ;
let f = function # F ( String ) . t -> 1 | _ -> 2 ; ;
type t = [ F ( String ) . t | M . u ]
let f = function # t -> 1 | _ -> 2 ; ;
module N : sig type t = private [ > ] end = struct type t = [ F ( String ) . t | M . u ] end ; ;
type a = [ ` A of int | ` B ]
type b = [ ` A of bool | ` B ]
type c = private [ > ] ~ [ a ; b ]
let f = function # c -> 1 | ` A x -> truncate x
type d = private [ > ] ~ [ a ]
let g = function # d -> 1 | ` A x -> truncate x ; ;
type num = [ ` Num of int ]
module type Exp = sig type t = private [ > num ] val eval : t -> t val show : t -> string end
module Num ( X : Exp ) = struct type t = num let eval ( ` Num _ as x ) : X . t = x let show ( ` Num n ) = string_of_int n end
type ' a add = [ ` Add of ' a * ' a ]