text
stringlengths
12
786k
type ' a pattern = | Pany | Por of ' a pattern * ' a pattern | Pconstr of ' a * ' a pattern list
module type SIG = sig type tag val compare : tag -> tag -> int val arity : tag -> int val is_complete : tag list -> bool val not_in : tag list -> tag type pattern_ast val inject : pattern_ast -> tag pattern val eject : tag pattern -> pattern_ast end
module PATTERN_CHECKER = functor ( S : SIG ) -> struct module SSet = Set . Make ( struct type t = S . tag let compare = S . compare end ) let uniq l = SSet . elements ( List . fold_right SSet . add l SSet . empty ) let is_complete sigma = S . is_complete ( uniq sigma ) let not_in...
let header_in_file = let open Zconfig in " The Zelus compiler , version " ^ version ^ " " - ^ subversion ^ " \ n \ ( " ^ date ^ " ) "
module S = Set . Make ( struct type t = string let compare = compare end )
module Env = Map . Make ( struct type t = string let compare = compare end )
let default_used_modules = ref [ name_of_stdlib_module ]
let load_path = ref ( [ standard_lib ] )
let set_stdlib p = load_path := [ p ]
let locate_stdlib ( ) = Printf . printf " % s \ n " standard_lib
let show_version ( ) = let open Zconfig in Printf . printf " The Zelus compiler , version % s -% s ( % s ) \ n " version subversion date ; Printf . printf " Std lib : " ; locate_stdlib ( ) ; Printf . printf " \ n " ; ( )
let simulation_node = ref None
let set_simulation_node ( n : string ) = simulation_node := Some ( n )
let outname = ref None
let set_outname ( n : string ) = outname := Some ( n )
let node_outname = ref None
let set_node_outname ( n : string ) = node_outname := Some ( n )
let number_of_checks = ref 0
let set_check ( n : int ) = number_of_checks := n
let sampling_period = ref 0 . 0
let set_sampling_period p = sampling_period := p
let inlining_level = ref 10
let set_inlining_level l = inlining_level := l
let inline_all = ref false
let dzero = ref false
let verbose = ref false
let vverbose = ref false
let print_types = ref false
let print_causality_types = ref false
let print_initialization_types = ref false
let typeonly = ref false
let use_gtk = ref false
let no_stdlib = ref false
let no_causality = ref false
let no_initialisation = ref false
let no_opt = ref false
let no_deadcode = ref false
let no_simplify_causality_type = ref false
let no_reduce = ref false
let no_warning = ref false
let zsign = ref false
let with_copy = ref false
let use_rif = ref false
let build_deps = ref false
let lmm_nodes = ref S . empty
let set_lmm_nodes ( n : string ) = lmm_nodes := S . add n ! lmm_nodes object val mutable counter = 0 method name = counter <- counter + 1 ; counter method reset = counter <- 0 method init i = counter <- i end
let symbol = new name_generator object val mutable counter = 0 val mutable assoc_table : ( int * string ) list = [ ] method name var = try List . assq var assoc_table with not_found -> let n = f counter in counter <- counter + 1 ; assoc_table <- ( var , n ) :: assoc_table ; n method re...
let int_to_letter bound i = if i < 26 then String . make 1 ( Char . chr ( i + bound ) ) else String . make 1 ( Char . chr ( ( i mod 26 ) + bound ) ) ^ string_of_int ( i / 26 )
let int_to_alpha i = int_to_letter 97 i
let binding_level = ref 0
let top_binding_level ( ) = ! binding_level = 0
let push_binding_level ( ) = binding_level := ! binding_level + 1
let pop_binding_level ( ) = binding_level := ! binding_level - 1 ; assert ( ! binding_level > generic )
let reset_binding_level ( ) = binding_level := 0
let optional f acc = function | None -> acc | Some x -> f acc x
let optional_unit f acc = function | None -> ( ) | Some x -> f acc x
let optional_map f = function | None -> None | Some ( x ) -> Some ( f x )
let optional_with_map f acc = function | None -> None , acc | Some ( x ) -> let x , acc = f acc x in Some ( x ) , acc
let optional_get = function | Some x -> x | None -> assert false
let rec iter f = function | [ ] -> [ ] | x :: l -> let y = f x in y :: iter f l
let fold f l = List . rev ( List . fold_left f [ ] l )
let from i = let rec fromrec acc i = match i with | 0 -> acc | _ -> fromrec ( i :: acc ) ( i - 1 ) in fromrec [ ] i
let map_fold f acc l = let rec maprec acc = function | [ ] -> [ ] , acc | x :: l -> let y , acc = f acc x in let l , acc = maprec acc l in y :: l , acc in maprec acc l
let rec firsts = function | [ ] -> assert false | [ p ] -> [ ] , p | p :: l -> let head , tail = firsts l in p :: head , tail
module State = struct type ' a t = | Empty | Cons of ' a * ' a t | Par of ' a t * ' a t let singleton x = Cons ( x , Empty ) let cons x s = Cons ( x , s ) let seq s1 s2 = match s1 , s2 with | ( Empty , s ) | ( s , Empty ) -> s | _ -> Seq ( s1 , s2 ) let par s1 s...
let internal_error message printer input = Format . eprintf " [ @ Internal error ( % s ) . @ % a . ] " @@ message printer input ; raise Error
module Context = struct type t external create : unit -> t = " caml_zmq_new " external terminate : t -> unit = " caml_zmq_term " type int_option = | ZMQ_IO_THREADS | ZMQ_MAX_SOCKETS | ZMQ_IPV6 external set_int_option : t -> int_option -> int -> unit = " caml_zmq_ctx_set_int_option " external...
module Msg = struct open Bigarray type t type bigstring = ( char , int8_unsigned_elt , c_layout ) c_layout Array1 . t external native_init_data : bigstring -> int -> int -> t = " caml_zmq_msg_init_data " let init_data ( ? offset = 0 ) 0 ? length buf = let length = let max_possible = Arra...
module Socket = struct open Stdint type + ' a t type ' a kind = int let pair = 0 let pub = 1 let sub = 2 let req = 3 let rep = 4 let dealer = 5 let router = 6 let pull = 7 let push = 8 let xpub = 9 let xsub = 10 let stream = 11 external create : Context . t -> ' a kind -> ' a t = " ...
module Proxy = struct external zmq_proxy2 : ' a Socket . t -> ' b Socket . t -> unit = " caml_zmq_proxy2 " external zmq_proxy3 : ' a Socket . t -> ' b Socket . t -> ' c Socket . t -> unit = " caml_zmq_proxy3 " let create ? capture frontend backend = match capture with | Some capture -> z...
module Poll = struct type t type poll_event = In | Out | In_out type ' a poll_mask = ( ' a Socket . t * poll_event ) poll_event let mask_in_out t = ( t :> [ ` Pair ` | Pub ` | Sub ` | Req ` | Rep ` | Dealer ` | Router ` | Pull ` | Push ` | Xsub ` | Xpub ` | Stream ] Stream Socket . t ...
module Monitor = struct type t = string type address = string type error_no = int type error_text = string type event = | Connected of address * Unix . file_descr | Connect_delayed of address | Connect_retried of address * int | Listening of address * Unix . file_descr | Bind_failed of address * error_...
module Z85 = struct external encode : string -> string = " caml_z85_encode " external decode : string -> string = " caml_z85_decode " end
module Curve = struct external keypair : unit -> string * string = " caml_curve_keypair " end
let zmq_raise e str func_name = let exn = match e with | I_ENOTSUP -> Unix ( . Unix_error ( EOPNOTSUPP , func_name , ) ) " " | I_EPROTONOSUPPORT -> Unix ( . Unix_error ( EPROTONOSUPPORT , func_name , ) ) " " | I_ENOBUFS -> Unix ( . Unix_error ( ENOBUFS , func_name , ) ...
let ( ) = Callback . register " Zmq . zmq_raise " zmq_raise
let debug fmt = Printf . ksprintf ( fun s -> print_endline s ; flush stdout ) stdout fmt
let sleep t = ignore ( ignoreUnix . select [ ] [ ] [ ] ( ( float t ) t . / 1000 . 0 ) 0 ) 0
let dump_events l = let f = function | None -> " None " | Some In -> " In " | Some Out -> " Out " | Some In_out -> " In / Out " in let l = Array . to_list ( Array . map f l ) l in [ " " | ^ ( String . concat " ; " l ) l ^ ] " " |
let test_ctx_options ( ) = let ctx = Context . create ( ) in let test_set_get_int msg setter getter ctx v = let default = getter ctx in setter ctx v ; assert_equal ~ msg ~ printer : string_of_int v ( getter ctx ) ctx ; setter ctx default ; assert_equal ~ msg default ( getter ctx ) ctx ; ...
let test_socket_options ( ) = let ctx = Context . create ( ) in let socket = create ctx push in let test_set_get_int msg setter getter socket v = let default = getter socket in setter socket v ; assert_equal ~ msg ~ printer : string_of_int v ( getter socket ) socket ; setter socket default ; ...
let test_monitor ( ) = let endpoint = " ipc :// monitor_socket " in let expect_handshake = match Zmq . version ( ) with | ( 4 , n , _ ) _ when n < 3 -> false | ( 3 , _ , _ ) _ -> failwith " Only zmq version 4 or higher is supported " | _ -> true in let assert_event ...
let test_proxy ( ) = let ctx = Zmq . Context . create ( ) in let pull_endpoint = " inproc :// pull " in let pub_endpoint = " inproc :// pub " in let pull = Zmq . Socket . create ctx pull in let pub = Zmq . Socket . create ctx pub in let proxy ( pull , pub ) pub = Zmq . Socket . bind p...
let test_unix_exceptions = bracket ( fun ( ) -> let ctx = Zmq . Context . create ( ) in let s = Zmq . Socket . create ctx pull in ( ctx , s ) s ) ( fun ( _ , s ) s -> let mask = Zmq . Poll . of_masks [ | s , Zmq . Poll . In ] | in Sys ( . set_signal sigalrm ( Signal_ha...
let test_zmq_exception = bracket ( fun ( ) -> let ctx = Zmq . Context . create ( ) in let socket = Zmq . Socket . create ctx req in ( ctx , socket ) socket ) ( fun ( _ , socket ) socket -> assert_raises ( Zmq . ZMQ_exception ( ZMQ_exceptionZmq . EFSM , " Operation cannot be...
let test_socket_gc ( ) = let sock = let ctx = Zmq . Context . create ( ) in Zmq . Socket . create ctx Zmq . Socket . req in Gc . compact ( ) ; Zmq . Socket . close sock ; Gc . compact ( )
let test_context_gc ( ) = let ctx = let ctx = Zmq . Context . create ( ) in let sock = Zmq . Socket . create ctx Zmq . Socket . pair in Zmq . Socket . connect sock " ipc :// context_gc_socket " ; Zmq . Socket . send sock " test " ; ctx in Gc . compact ( ) ; Zmq . Context . terminate ct...
let test_z85 ( ) = let binary = " \ xBB \ x88 \ x47 \ x1D \ x65 \ xE2 \ x65 \ x9B " ^ " \ x30 \ xC5 \ x5A \ x53 \ x21 \ xCE \ xBB \ x5A " ^ " \ xAB \ x2B \ x70 \ xA3 \ x98 \ x64 \ x5C \ x26 " ^ " \ xDC \ xA2 \ xB2 \ xFC \ xB4 \ x3F \ xC5 \ x18 " in let ascii = " Yne ...
let suite = " zmq test " >::: [ " request reply " >:: ( bracket ( fun ( ) -> let ctx = Zmq . Context . create ( ) in let req = create ctx req in let rep = create ctx rep in ctx , req , rep ) ( fun ( _ , req , rep ) rep -> let endpoint = " inproc :// endpoint " in bi...
module type ZN = sig type t include S . B58_DATA with type t := t include S . ENCODER with type t := t val zero : t val one : t val n : Z . t val ( + ) : t -> t -> t val ( * ) : t -> t -> t val ( - ) : t -> t -> t val ( = ) : t -> t -> bool val of_int : int -> t val of_Z :...
module type INT = sig val n : Z . t end
module MakeZn ( N : INT ) ( B : sig val b58_prefix : string end ) : ZN = struct type t = Z . t let n = N . n let max_char_length = 2 * Z . numbits n let zero = Z . zero let one = Z . one let of_Z r = Z . ( erem r n ) let to_Z a = a let of_int u = u |> Z . of_int |> of_Z let to...
module Stable = struct module Full_data = struct module V1 = struct module Index = struct type t = int let next = Int . succ let prev = Int . pred let before_first_transition = - 1 let to_external t = max 0 t let of_external ( _ : t ) = - 1 include Binable . Of_binable_without_uuid [ @ ale...
let sexp_of_t t = Sexp . Atom t . name
let likely_machine_zones = ref [ " America / New_York " ; " Europe / London " ; " Asia / Hong_Kong " ; " America / Chicago " ] ; ;
let utc = of_utc_offset ~ hours : 0
let name zone = zone . name
let reset_transition_cache t = t . last_regime_index <- Index . before_first_transition
let get_regime_exn t index = if index < 0 then t . default_local_time_type else t . transitions . ( index ) . new_regime ; ;
module Mode = struct type t = | Absolute | Date_and_ofday end