text stringlengths 0 601k |
|---|
let input_closed_error = Error . of_string " input closed " |
let input_closed_in_the_middle_of_data_error = Error . of_string " input closed in the middle of data " ; ; |
let unpack_error error = Error . create " unpack error " error [ % sexp_of : Error . t ] |
module Unpack_iter_result = struct type ' a t = | Input_closed | Input_closed_in_the_middle_of_data of ' a Unpack_buffer . t | Unpack_error of Error . t [ @@ deriving sexp_of ] let to_error : _ t -> Error . t = function | Input_closed -> input_closed_error | Input_closed_in_the_middle_of_data _ -> input_closed_in_the_m... |
module Unpack_result = struct type ' a t = | Input_closed | Input_closed_in_the_middle_of_data of ' a Unpack_buffer . t | Output_closed | Unpack_error of Error . t [ @@ deriving sexp_of ] let to_error : _ t -> Error . t = function | Input_closed -> input_closed_error | Input_closed_in_the_middle_of_data _ -> input_clos... |
module Unpack_from = struct type t = | Pipe of string Pipe . Reader . t | Reader of Reader . t end |
module Unpack_to = struct type ' a t = | Iter of ( ' a -> unit ) | Pipe of ' a Pipe . Writer . t [ @@ deriving sexp_of ] end |
let unpack_all ( ~ from : Unpack_from . t ) ( ~ to_ : _ Unpack_to . t ) ~ using : unpack_buffer = let unpack_all_available = match to_ with | Iter f -> fun ( ) -> ( match Unpack_buffer . unpack_iter unpack_buffer ~ f with | Ok ( ) -> return ` Continue | Error error -> return ( ` Stop ( Unpack_result . Unpack_error erro... |
let unpack_into_pipe ~ from ~ using = let output_reader , output_writer = Pipe . create ( ) in let result = unpack_all ~ from ~ to_ ( : Pipe output_writer ) ~ using >>| fun result -> Pipe . close output_writer ; result in output_reader , result ; ; |
let unpack_iter ~ from ~ using ~ f = unpack_all ~ from ~ to_ ( : Iter f ) ~ using >>| function | Input_closed -> Unpack_iter_result . Input_closed | Input_closed_in_the_middle_of_data x -> Input_closed_in_the_middle_of_data x | Unpack_error x -> Unpack_error x | Output_closed as t -> failwiths ~ here [ :% here ] " Unpa... |
let sexps = let a x = Sexp . Atom x in let l x = Sexp . List x in [ a " " ; a " hello " ; l [ ] ; l [ a " " ] ; l [ a " " ; a " hello " ] ] ; ; |
let test ( ) = Unix . pipe ( Info . of_string " unpack_sequence_test " ) >>= fun ( ` Reader reader_fd , ` Writer writer_fd ) -> let string_writer = Writer . create writer_fd in let sexp_reader , unpack_result = Unpack_sequence . unpack_into_pipe ~ from ( : Reader ( Reader . create reader_fd ) ) ~ using ( : Unpack_buffe... |
let tests = [ " Unpack_Sequence_test " , test ] |
let display ( ) = glClear [ GL_COLOR_BUFFER_BIT ] ; glFlush ( ) ; ; ; |
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluPerspective 45 . 0 ( float w . / float h ) 1 . 0 100 . 0 ; glMatrixMode GL_MODELVIEW ; glLoadIdentity ( ) ; ; ; |
let mouse ~ button ~ state ~ x ~ y = match button with | GLUT_LEFT_BUTTON -> if state = GLUT_DOWN then begin let viewport = glGetInteger4 Get . GL_VIEWPORT in let a , b , c , d = viewport in let viewport = [ | a ; b ; c ; d ] | in let mvmatrix = glGetMatrix Get . GL_MODELVIEW_MATRIX in let projmatrix = glGetMatrix Get ... |
let keyboard ~ key ~ x ~ y = match key with | ' \ 027 ' -> exit ( 0 ) ; | _ -> ( ) ; ; |
let ( ) = let _ = glutInit Sys . argv in glutInitDisplayMode [ GLUT_SINGLE ; GLUT_RGB ] ; glutInitWindowSize 500 500 ; glutInitWindowPosition 100 100 ; let _ = glutCreateWindow Sys . argv . ( 0 ) in glutDisplayFunc ~ display ; glutReshapeFunc ~ reshape ; glutKeyboardFunc ~ keyboard ; glutMouseFunc ~ mouse ; glutMainLoo... |
module M : sig type t = private [ ` Bar of ' a | ` Foo ] as ' a val bar : t type t = [ ` Bar of ' a | ` Foo ] as ' a let bar = ` Bar ` Foo end ; ; [ %% expect { | |
module M : sig type t = private [ ` Bar of ' a | ` Foo ] as ' a val bar : t end } ] | |
let y = match ( M . bar :> [ ` Bar of ' a | ` Foo ] as ' a ) with | ` Bar x -> x | ` Foo -> assert false ; ; [ %% expect { | } ] | |
let y = match ( M . bar :> [ ` Bar of M . t | ` Foo ] ) with | ` Bar x -> x | ` Foo -> assert false ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type M . t = [ ` Bar of M . t | ` Foo ] is not a subtype of M . t } ] | |
module F ( X : sig end ) : sig type s = private [ ` Bar of ' a | ` Foo ] as ' a val from : M . t -> s val to_ : s -> M . t type s = M . t let from x = x let to_ x = x end ; ; [ %% expect { | |
module F : functor ( X : sig end ) -> sig type s = private [ ` Bar of ' a | ` Foo ] as ' a val from : M . t -> s val to_ : s -> M . t end } ] | |
module N = F ( struct end ) ; ; [ %% expect { | |
module N : sig type s = private [ ` Bar of ' a | ` Foo ] as ' a val from : M . t -> s val to_ : s -> M . t end } ] | |
let y = match ( N . from M . bar :> [ ` Bar of N . s | ` Foo ] ) with | ` Bar x -> N . to_ x | ` Foo -> assert false ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type N . s = [ ` Bar of N . s | ` Foo ] is not a subtype of N . s } ] | |
let rec exp { e_desc = desc } = match desc with | Eapp ( _ , e , e_list ) -> ( not ( Ztypes . is_combinatorial ( List . length e_list ) e . e_typ ) ) || ( exp e ) || ( List . exists exp e_list ) | Erecord_access ( e , _ ) | Etypeconstraint ( e , _ ) -> exp e | Erecord ( f_e_list ) -> List . exists ( fun ( _ , e ) -> ex... |
let rec equation { eq_desc = desc } = match desc with | EQeq ( _ , e ) | EQinit ( _ , e ) | EQder ( _ , e , None , [ ] ) | EQpluseq ( _ , e ) -> exp e | EQmatch ( _ , e , m_h_list ) -> exp e || List . exists | EQreset ( eq_list , e ) -> exp e || List . exists equation eq_list | EQand ( eq_list ) | EQbefore ( eq_list ) ... |
let ( ) = init ( ) |
module type Basics = sig type t val add : t -> t -> t val sub : t -> t -> t val mul : t -> t -> t val div : t -> t -> t val rem : t -> t -> t val max_int : t val logand : t -> t -> t val logor : t -> t -> t val logxor : t -> t -> t val shift_left : t -> int -> t val shift_right : t -> int -> t val of_int : int -> t val... |
module type Extras = sig type t val zero : t val one : t val lognot : t -> t val succ : t -> t val pred : t -> t val compare : t -> t -> int val equal : t -> t -> bool val max : t -> t -> t val min : t -> t -> t val of_string_opt : string -> t option val pp : Format . formatter -> t -> unit val pp_hex : Format . format... |
module type Infix = sig type t val ( ) + : t -> t -> t val ( ) - : t -> t -> t val ( * ) : t -> t -> t val ( ) / : t -> t -> t val ( mod ) : t -> t -> t val ( land ) : t -> t -> t val ( lor ) : t -> t -> t val ( lxor ) : t -> t -> t val ( lsl ) : t -> int -> t val ( lsr ) : t -> int -> t end |
module type S = sig include Basics include Extras with type t := t module Infix : Infix with type t := t end |
module MakeInfix ( B : Basics ) = struct open B let ( ) + = add let ( ) - = sub let ( * ) = mul let ( ) / = div let ( mod ) = rem let ( land ) = logand let ( lor ) = logor let ( lxor ) = logxor let ( lsl ) = shift_left let ( lsr ) = shift_right end |
module Extras ( Basics : Basics ) : Extras with type t := Basics . t = struct open Basics let zero = of_int 0 let one = of_int 1 let succ n = add n one let pred n = sub n one let lognot n = logxor n max_int let compare ( x : t ) ( y : t ) = Stdlib . compare x y let equal ( x : t ) ( y : t ) = Stdlib . ( ) = x y let max... |
module UInt8 : S with type t = private int = struct module B = struct type t = int let max_int = 255 let add : t -> t -> t = fun x y -> ( x + y ) land max_int let sub : t -> t -> t = fun x y -> ( x - y ) land max_int let mul : t -> t -> t = fun x y -> ( x * y ) land max_int let div : t -> t -> t = ( ) / let rem : t -> ... |
module UInt16 : S with type t = private int = struct module B = struct type t = int let max_int = 65535 let add : t -> t -> t = fun x y -> ( x + y ) land max_int let sub : t -> t -> t = fun x y -> ( x - y ) land max_int let mul : t -> t -> t = fun x y -> ( x * y ) land max_int let div : t -> t -> t = ( ) / let rem : t ... |
module UInt32 : sig include S val of_int32 : int32 -> t val to_int32 : t -> int32 struct module B = struct type t external add : t -> t -> t = " integers_uint32_add " external sub : t -> t -> t = " integers_uint32_sub " external mul : t -> t -> t = " integers_uint32_mul " external div : t -> t -> t = " integers_uint32_... |
module UInt64 : sig include S external of_uint32 : UInt32 . t -> t = " integers_uint64_of_uint32 " external to_uint32 : t -> UInt32 . t = " integers_uint32_of_uint64 " struct module B = struct type t external add : t -> t -> t = " integers_uint64_add " external sub : t -> t -> t = " integers_uint64_sub " external mul :... |
let of_byte_size : int -> ( module S ) = function | 1 -> ( module UInt8 ) | 2 -> ( module UInt16 ) | 4 -> ( module UInt32 ) | 8 -> ( module UInt64 ) | _ -> invalid_arg " Unsigned . of_byte_size " |
module Size_t : S = ( val of_byte_size ( size_t_size ( ) ) ) |
module UShort : S = ( val of_byte_size ( ushort_size ( ) ) ) |
module UInt : S = ( val of_byte_size ( uint_size ( ) ) ) |
module ULong : S = ( val of_byte_size ( ulong_size ( ) ) ) |
module ULLong : S = ( val of_byte_size ( ulonglong_size ( ) ) ) |
module type Unsigned_intf = Unsigned . S |
module Extend ( Unsigned : Unsigned . S ) S ( M : sig val length : int end ) end : S with type t = Unsigned . t = struct assert ( M . length < Field . size_in_bits - 3 ) 3 let length_in_bits = M . length module T = struct include Sexpable . Of_stringable ( Unsigned ) Unsigned type t = Unsigned . t let compare = Unsigne... |
module UInt64 = struct module M = Extend ( Unsigned . UInt64 ) UInt64 ( struct let length = 64 end ) end [ %% versioned_binable module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type t = Unsigned . UInt64 . t let to_latest = Fn . id [ %% define_locally M . ( equal , compa... |
module UInt32 = struct module M = Extend ( Unsigned . UInt32 ) UInt32 ( struct let length = 32 end ) end [ %% versioned_binable module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type t = Unsigned . UInt32 . t let to_latest = Fn . id [ %% define_locally M . ( equal , compa... |
type mapper = { attribute : mapper -> T . attribute -> attribute ; attributes : mapper -> T . attribute list -> attribute list ; binding_op : mapper -> T . binding_op -> T . pattern -> binding_op ; case : mapper -> T . case -> case ; cases : mapper -> T . case list -> case list ; class_declaration : mapper -> T . class... |
let string_is_prefix sub str = let sublen = String . length sub in String . length str >= sublen && String . sub str 0 sublen = sub |
let rec lident_of_path = function | Path . Pident id -> Longident . Lident ( Ident . name id ) | Path . Pdot ( p , s ) -> Longident . Ldot ( lident_of_path p , s ) | Path . Papply ( p1 , p2 ) -> Longident . Lapply ( lident_of_path p1 , lident_of_path p2 ) |
let map_loc sub { loc ; txt } = { loc = sub . location sub loc ; txt } |
let fresh_name s env = let rec aux i = let name = s ^ Int . to_string i in if Env . bound_value name env then aux ( i + 1 ) else name in aux 0 |
let rec extract_letop_patterns n pat = if n = 0 then pat , [ ] else begin match pat . pat_desc with | Tpat_tuple ( [ first ; rest ] ) -> let next , others = extract_letop_patterns ( n - 1 ) rest in first , next :: others | _ -> let rec anys n = if n = 0 then [ ] else { pat with pat_desc = Tpat_any } :: anys ( n - 1 ) i... |
let constant = function | Const_char c -> Pconst_char c | Const_string ( s , d ) -> Pconst_string ( s , d ) | Const_int i -> Pconst_integer ( Int . to_string i , None ) | Const_int32 i -> Pconst_integer ( Int32 . to_string i , Some ' l ' ) | Const_int64 i -> Pconst_integer ( Int64 . to_string i , Some ' L ' ) | Const_n... |
let attribute sub a = { attr_name = map_loc sub a . attr_name ; attr_payload = a . attr_payload ; attr_loc = a . attr_loc } |
let attributes sub l = List . map ( sub . attribute sub ) l |
let structure sub str = List . map ( sub . structure_item sub ) str . str_items |
let open_description sub od = let loc = sub . location sub od . open_loc in let attrs = sub . attributes sub od . open_attributes in Opn . mk ~ loc ~ attrs ~ override : od . open_override ( snd od . open_expr ) |
let open_declaration sub od = let loc = sub . location sub od . open_loc in let attrs = sub . attributes sub od . open_attributes in Opn . mk ~ loc ~ attrs ~ override : od . open_override ( sub . module_expr sub od . open_expr ) |
let structure_item sub item = let loc = sub . location sub item . str_loc in let desc = match item . str_desc with Tstr_eval ( exp , attrs ) -> Pstr_eval ( sub . expr sub exp , attrs ) | Tstr_value ( rec_flag , list ) -> Pstr_value ( rec_flag , List . map ( sub . value_binding sub ) list ) | Tstr_primitive vd -> Pstr_p... |
let value_description sub v = let loc = sub . location sub v . val_loc in let attrs = sub . attributes sub v . val_attributes in Val . mk ~ loc ~ attrs ~ prim : v . val_prim ( map_loc sub v . val_name ) ( sub . typ sub v . val_desc ) |
let module_binding sub mb = let loc = sub . location sub mb . mb_loc in let attrs = sub . attributes sub mb . mb_attributes in Mb . mk ~ loc ~ attrs ( map_loc sub mb . mb_name ) ( sub . module_expr sub mb . mb_expr ) |
let type_parameter sub ( ct , v ) = ( sub . typ sub ct , v ) |
let type_declaration sub decl = let loc = sub . location sub decl . typ_loc in let attrs = sub . attributes sub decl . typ_attributes in Type . mk ~ loc ~ attrs ~ params ( : List . map ( type_parameter sub ) decl . typ_params ) ~ cstrs ( : List . map ( fun ( ct1 , ct2 , loc ) -> ( sub . typ sub ct1 , sub . typ sub ct2 ... |
let type_kind sub tk = match tk with | Ttype_abstract -> Ptype_abstract | Ttype_variant list -> Ptype_variant ( List . map ( sub . constructor_declaration sub ) list ) | Ttype_record list -> Ptype_record ( List . map ( sub . label_declaration sub ) list ) | Ttype_open -> Ptype_open |
let constructor_arguments sub = function | Cstr_tuple l -> Pcstr_tuple ( List . map ( sub . typ sub ) l ) | Cstr_record l -> Pcstr_record ( List . map ( sub . label_declaration sub ) l ) |
let constructor_declaration sub cd = let loc = sub . location sub cd . cd_loc in let attrs = sub . attributes sub cd . cd_attributes in Type . constructor ~ loc ~ attrs ~ args ( : constructor_arguments sub cd . cd_args ) ? res ( : Option . map ( sub . typ sub ) cd . cd_res ) ( map_loc sub cd . cd_name ) |
let label_declaration sub ld = let loc = sub . location sub ld . ld_loc in let attrs = sub . attributes sub ld . ld_attributes in Type . field ~ loc ~ attrs ~ mut : ld . ld_mutable ( map_loc sub ld . ld_name ) ( sub . typ sub ld . ld_type ) |
let type_extension sub tyext = let attrs = sub . attributes sub tyext . tyext_attributes in Te . mk ~ attrs ~ params ( : List . map ( type_parameter sub ) tyext . tyext_params ) ~ priv : tyext . tyext_private ( map_loc sub tyext . tyext_txt ) ( List . map ( sub . extension_constructor sub ) tyext . tyext_constructors ) |
let type_exception sub tyexn = let attrs = sub . attributes sub tyexn . tyexn_attributes in Te . mk_exception ~ attrs ( sub . extension_constructor sub tyexn . tyexn_constructor ) |
let extension_constructor sub ext = let loc = sub . location sub ext . ext_loc in let attrs = sub . attributes sub ext . ext_attributes in Te . constructor ~ loc ~ attrs ( map_loc sub ext . ext_name ) ( match ext . ext_kind with | Text_decl ( args , ret ) -> Pext_decl ( constructor_arguments sub args , Option . map ( s... |
let pattern sub pat = let loc = sub . location sub pat . pat_loc in let attrs = sub . attributes sub pat . pat_attributes in let desc = match pat with { pat_extra [ = Tpat_unpack , loc , _attrs ] ; pat_desc = Tpat_any ; _ } -> Ppat_unpack { txt = None ; loc } | { pat_extra [ = Tpat_unpack , _ , _attrs ] ; pat_desc = Tp... |
let exp_extra sub ( extra , loc , attrs ) sexp = let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in let desc = match extra with Texp_coerce ( cty1 , cty2 ) -> Pexp_coerce ( sexp , Option . map ( sub . typ sub ) cty1 , sub . typ sub cty2 ) | Texp_constraint cty -> Pexp_constraint ( sexp , sub ... |
let cases sub l = List . map ( sub . case sub ) l |
let case sub { c_lhs ; c_guard ; c_rhs } = { pc_lhs = sub . pat sub c_lhs ; pc_guard = Option . map ( sub . expr sub ) c_guard ; pc_rhs = sub . expr sub c_rhs ; } |
let value_binding sub vb = let loc = sub . location sub vb . vb_loc in let attrs = sub . attributes sub vb . vb_attributes in Vb . mk ~ loc ~ attrs ( sub . pat sub vb . vb_pat ) ( sub . expr sub vb . vb_expr ) |
let expression sub exp = let loc = sub . location sub exp . exp_loc in let attrs = sub . attributes sub exp . exp_attributes in let desc = match exp . exp_desc with Texp_ident ( _path , lid , _ ) -> Pexp_ident ( map_loc sub lid ) | Texp_constant cst -> Pexp_constant ( constant cst ) | Texp_let ( rec_flag , list , exp )... |
let binding_op sub bop pat = let pbop_op = bop . bop_op_name in let pbop_pat = sub . pat sub pat in let pbop_exp = sub . expr sub bop . bop_exp in let pbop_loc = bop . bop_loc in { pbop_op ; pbop_pat ; pbop_exp ; pbop_loc } |
let package_type sub pack = ( map_loc sub pack . pack_txt , List . map ( fun ( s , ct ) -> ( s , sub . typ sub ct ) ) pack . pack_fields ) |
let module_type_declaration sub mtd = let loc = sub . location sub mtd . mtd_loc in let attrs = sub . attributes sub mtd . mtd_attributes in Mtd . mk ~ loc ~ attrs ? typ ( : Option . map ( sub . module_type sub ) mtd . mtd_type ) ( map_loc sub mtd . mtd_name ) |
let signature sub sg = List . map ( sub . signature_item sub ) sg . sig_items |
let signature_item sub item = let loc = sub . location sub item . sig_loc in let desc = match item . sig_desc with Tsig_value v -> Psig_value ( sub . value_description sub v ) | Tsig_type ( rec_flag , list ) -> Psig_type ( rec_flag , List . map ( sub . type_declaration sub ) list ) | Tsig_typesubst list -> Psig_typesub... |
let module_declaration sub md = let loc = sub . location sub md . md_loc in let attrs = sub . attributes sub md . md_attributes in Md . mk ~ loc ~ attrs ( map_loc sub md . md_name ) ( sub . module_type sub md . md_type ) |
let module_substitution sub ms = let loc = sub . location sub ms . ms_loc in let attrs = sub . attributes sub ms . ms_attributes in Ms . mk ~ loc ~ attrs ( map_loc sub ms . ms_name ) ( map_loc sub ms . ms_txt ) |
let include_infos f sub incl = let loc = sub . location sub incl . incl_loc in let attrs = sub . attributes sub incl . incl_attributes in Incl . mk ~ loc ~ attrs ( f sub incl . incl_mod ) |
let include_declaration sub = include_infos sub . module_expr sub |
let include_description sub = include_infos sub . module_type sub |
let class_infos f sub ci = let loc = sub . location sub ci . ci_loc in let attrs = sub . attributes sub ci . ci_attributes in Ci . mk ~ loc ~ attrs ~ virt : ci . ci_virt ~ params ( : List . map ( type_parameter sub ) ci . ci_params ) ( map_loc sub ci . ci_id_name ) ( f sub ci . ci_expr ) |
let class_declaration sub = class_infos sub . class_expr sub |
let class_description sub = class_infos sub . class_type sub |
let class_type_declaration sub = class_infos sub . class_type sub |
let functor_parameter sub : functor_parameter -> Parsetree . functor_parameter = function | Unit -> Unit | Named ( _ , name , mtype ) -> Named ( name , sub . module_type sub mtype ) |
let module_type sub mty = let loc = sub . location sub mty . mty_loc in let attrs = sub . attributes sub mty . mty_attributes in let desc = match mty . mty_desc with Tmty_ident ( _path , lid ) -> Pmty_ident ( map_loc sub lid ) | Tmty_alias ( _path , lid ) -> Pmty_alias ( map_loc sub lid ) | Tmty_signature sg -> Pmty_si... |
let with_constraint sub ( _path , lid , cstr ) = match cstr with | Twith_type decl -> Pwith_type ( map_loc sub lid , sub . type_declaration sub decl ) | Twith_module ( _path , lid2 ) -> Pwith_module ( map_loc sub lid , map_loc sub lid2 ) | Twith_typesubst decl -> Pwith_typesubst ( map_loc sub lid , sub . type_declarati... |
let module_expr sub mexpr = let loc = sub . location sub mexpr . mod_loc in let attrs = sub . attributes sub mexpr . mod_attributes in match mexpr . mod_desc with Tmod_constraint ( m , _ , Tmodtype_implicit , _ ) -> sub . module_expr sub m | _ -> let desc = match mexpr . mod_desc with Tmod_ident ( _p , lid ) -> Pmod_id... |
let class_expr sub cexpr = let loc = sub . location sub cexpr . cl_loc in let attrs = sub . attributes sub cexpr . cl_attributes in let desc = match cexpr . cl_desc with | Tcl_constraint ( { cl_desc = Tcl_ident ( _path , lid , tyl ) ; _ } , None , _ , _ , _ ) -> Pcl_constr ( map_loc sub lid , List . map ( sub . typ sub... |
let class_type sub ct = let loc = sub . location sub ct . cltyp_loc in let attrs = sub . attributes sub ct . cltyp_attributes in let desc = match ct . cltyp_desc with Tcty_signature csg -> Pcty_signature ( sub . class_signature sub csg ) | Tcty_constr ( _path , lid , list ) -> Pcty_constr ( map_loc sub lid , List . map... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.