text
stringlengths
12
786k
module Testbench = struct let write chan a b c = let b = Verilog . Testbench . write a b c in output_string chan ( Buffer . contents b ) end
module Hierarchy = struct open Signal . Types let vwrite = write let inst_name = function | Signal_inst ( _ , _ , i ) -> i . inst_name | _ -> failwith " expecting instantiation " let rec write ( ? transforms [ ] ) = database path circ = let name = Circuit . name circ in let f = ...
let qualified_name m name = Conflict . qualified_name m . mod_namespace name
let pp_lwt_return fmt = function | Some lwt_module -> fprintf fmt " % s . return " lwt_module | _ -> assert false
type from_require_import = { import_from : string ; import_module : string }
let pp_from_require_import fmt fri = fprintf fmt " From % s Require Import % s . " fri . import_from fri . import_module
type from_require_export = { export_from : string ; export_module : string }
let pp_from_require_export fmt fre = fprintf fmt " From % s Require Export % s . " fre . export_from fre . export_module
type require = { require_module : string }
let pp_require fmt req = fprintf fmt " Require % s . " req . require_module
type constructor = { constructor_name : coq_name ; constructor_prototype : Repr . prototype_repr ; }
let pp_constructor fmt c = fprintf fmt " | [ @< hov 2 [ >@< hov 2 >% a % a % a % a % a ] @@ : % a ] " @ pp_coq_name c . constructor_name ( pp_if_not_empty pp_print_space ) c . constructor_prototype . prototype_type_args pp_type_args_list c . constructor_prototype . prototype_typ...
type inductive = { inductive_name : coq_name ; inductive_type_args : string list ; inductive_type : Repr . type_repr ; inductive_constructors : constructor list ; }
let pp_inductive fmt = function | [ ] -> ( ) | lind -> let pp_inductive_aux fmt ind = fprintf fmt " % a % a % a @ : % a ] :=@@ % a " pp_coq_name ind . inductive_name ( pp_if_not_empty pp_print_space ) ind . inductive_type_args pp_type_args_list ind . inductive_type_args pp_type_rep...
type field = { field_name : coq_name ; field_type : mono_type_repr }
type record = { record_name : coq_name ; record_type_args : string list ; record_fields : field list ; }
let pp_record fmt r = let pp_field fmt f = fprintf fmt " % a : % a " pp_coq_name f . field_name pp_mono_type_repr f . field_type in fprintf fmt " [ @< hov 2 > Record % a % a % a :=@ [ @< hov { >@ % a @ } . ] ] " @@ pp_coq_name r . record_name ( pp_if_not_empty ( fun fmt ...
type definition = { def_name : coq_name ; def_typeclass_args : string list ; def_prototype : Repr . prototype_repr ; def_body : Format . formatter -> unit -> unit ; }
let pp_definition fmt def = fprintf fmt " [ @< hov 2 [ >@< hov 2 > Definition % a % a % a % a % a % a ] @ :@ % a :=@ % a . ] " @ pp_coq_name def . def_name ( pp_list ~ pp_prefix ( : fun fmt _ -> pp_print_string fmt " ` { " ) ~ pp_suffix ( : fun fmt _ -> pp_print...
type typeclass = { class_name : coq_name ; class_typeclass_args : string list ; class_args : ( string * Repr . type_repr ) list ; class_type : Repr . type_repr ; class_members : ( coq_name * Repr . type_repr ) list ; }
let pp_typeclass fmt cls = fprintf fmt " [ @< hov 2 [ >@< hov 2 > Class % a % a % a % a % a ] @ :@ % a :=@ [ @< v { > % a @ ] } . ] " @@ pp_coq_name cls . class_name ( pp_if_not_empty pp_print_space ) cls . class_typeclass_args ( pp_print_list ~ pp_sep : pp_print_sp...
type instance = { instance_name : coq_name ; instance_typeclass_args : string list ; instance_type : Repr . type_repr ; instance_members : ( coq_name * string ) list ; }
let pp_instance fmt inst = fprintf fmt " [ @< hov 2 > Instance % a % a @ : % a :=@ [ @< v { > % a @ } . ] ] " @@ pp_coq_name inst . instance_name ( pp_list ~ pp_prefix ( : fun fmt _ -> pp_print_string fmt " ` { " ) ~ pp_suffix ( : fun fmt _ -> pp_print_string f...
type axiom = { axiom_name : coq_name ; axiom_typeclass_args : string list ; axiom_type : Repr . type_repr ; }
let pp_axiom fmt ax = fprintf fmt " [ @< hov 2 > Axiom % a @ : % a % a . ] " @ pp_coq_name ax . axiom_name ( pp_list ~ pp_prefix ( : fun fmt _ -> pp_print_text fmt " forall ` { " ) ~ pp_suffix ( : fun fmt _ -> pp_print_text fmt " } , " ) ~ pp_sep ( : fun fmt _...
type extract_constant = { constant_qualid : coq_name ; constant_type_vars : string list ; constant_target : string ; }
let pp_extract_constant fmt extr = let print_args_prod fmt = function | [ ] -> ( ) | [ x ] -> fprintf fmt " ' % s " x | args -> fprintf fmt " ( % a ) " ( pp_print_list ~ pp_sep ( : fun fmt _ -> pp_print_text fmt " , " ) ( fun fmt -> fprintf fmt " ' % s " ) ...
type extract_inductive = { inductive_qualid : coq_name ; inductive_target : string ; inductive_variants_target : string list ; }
let pp_extract_inductive fmt ind = fprintf fmt " [ @< hov 2 > Extract Inductive % a =>@ " \% s " \@ [ [ @< hov 2 >% a ] ] . ] " @@ pp_coq_name ind . inductive_qualid ind . inductive_target ( pp_list ~ pp_sep : pp_print_space ~ pp_prefix : pp_print_space ~ pp_suffix : pp_pri...
type coq_module = { coqmod_name : coq_name ; coqmod_content : t } | Section of string | Subsection of string | Comment of string | Block of t Lazylist . t | CompactedBlock of t Lazylist . t | CoqModule of coq_module | ConfigPrologue | FromRequireImport of from_require_import | FromRequireExport of...
let exn_t = TParam ( CName " exn " , [ ] )
let monadic_may_raise_t may_raise t = if may_raise then map_codomain ( function | TParam ( m , [ t ] ) -> TParam ( m , [ TParam ( CName " sum " , [ t ; exn_t ] ) ] ) | _ -> assert false ) t else t
let may_raise_t may_raise t = if may_raise then map_codomain ( fun t -> TParam ( CName " sum " , [ t ; exn_t ] ) ) t else t
let rec pp_vernac fmt = function | Block l -> fprintf fmt " [ @< v >% a ] " @ ( pp_print_lazylist ~ pp_sep ( : fun fmt _ -> fprintf fmt " @ @ " ) pp_vernac ) l | CompactedBlock l -> fprintf fmt " [ @< v >% a ] " @ ( pp_print_lazylist ~ pp_sep : pp_print_space pp_vernac )...
let block_of_list l = Block ( of_list l )
let compacted_block_of_list l = CompactedBlock ( of_list l )
let empty = function [ ] -> true | _ -> false
let ( @? ) cond f = if cond then f else fun x -> x
let proto_vars proto = List . map ( fun ( l , _ ) -> asprintf " % a " pp_arg_name l ) proto . prototype_args
let call_vars proto = List . map ( fun ( l , _ ) -> asprintf " % a " pp_arg_call l ) proto . prototype_args
let instance_member_body proto name = let tvars = proto . prototype_type_args in let vars = proto_vars proto in if 0 < List . length tvars then asprintf " [ @< h 2 > fun % a % a @ => % a % a ] " @ ( pp_list ~ pp_prefix ( : fun fmt _ -> pp_print_text fmt " " ) ~ pp_sep ( : fu...
let requires_vernac features models = let requires_freespec = Lazylist . push ( FromRequireImport { import_from = " FreeSpec . Core " ; import_module = " Core " } ) in let requires_io = Lazylist . push ( FromRequireImport { import_from = " SimpleIO " ; import_module = " IO_Mon...
let functions_vernac ~ rev_namespace conflicts m = let to_def f = let func_type = may_raise_t f . func_may_raise f . func_type in let func_name = Conflict . get_coq_value rev_namespace conflicts ~ value : f . func_name in match f . func_model with | Some model -> Definition { def_name = func_name ...
let variant_entry_to_constructor ~ rev_namespace conflicts owner v = { constructor_name = Conflict . get_coq_constructor rev_namespace conflicts ~ owner ~ cstr : v . variant_name ; constructor_prototype = v . variant_prototype ; }
let field_entry_to_field ~ rev_namespace owner conflicts ( r : field_entry ) = let field_name = Conflict . get_coq_field rev_namespace conflicts ~ owner ~ field : r . field_name in { field_name ; field_type = r . field_type }
let ind_type = let rec aux pos arity = if arity == 0 then type_sort_mono else TLambda { argtype = { position = pos ; kind = PositionedArg } ; domain = type_sort_mono ; codomain = aux ( pos + 1 ) ( arity - 1 ) ; } in aux 0
let type_entry_to_vernac ~ rev_namespace conflicts features t = let transparent = is_enabled features TransparentTypes in let type_name = Conflict . get_coq_type rev_namespace conflicts ~ ty : t . type_name in match ( t . type_value , t . type_model , transparent ) with | Variant l , None , t...
let io_primitives_vernac ~ rev_namespace conflicts m = let io_axiom_name name = Conflict . get_coq_helper rev_namespace conflicts name Name . io_helper in let to_axiom prim = let axiom_type = type_lift " IO " ( may_raise_t prim . prim_may_raise prim . prim_type ) in let axiom_name = io_axiom_name ...
let interface_constructor_name rev_namespace conflicts name = Conflict . get_coq_helper rev_namespace conflicts ~ owner ( : List . hd rev_namespace ) name Name . interface_cstr
let interface_vernac ~ rev_namespace conflicts mod_name interface_name class_name instance_name all_prims vernacs = let interface_name = Conflict . get_coq_helper rev_namespace conflicts ~ owner : mod_name mod_name interface_name in let hof ( i , p ) = Repr . higher_order_monadic ( CPlaceholder i ) ...
let lwt_primitives_vernac ~ rev_namespace conflicts lwt_module m vernacs = let to_lwt t = TParam ( CName " Lwt . t " , [ t ] ) in let axiom_name prim = let owner = prim . prim_name in Conflict . get_coq_helper rev_namespace conflicts owner Name . lwt_sync_helper in let to_axiom prim = Axiom ...
let semantics_vernac ~ rev_namespace conflicts m vernacs = let axiom_name owner = Conflict . get_coq_helper rev_namespace conflicts owner Name . semantics_helper in let target_name value = Conflict . get_ocaml_value rev_namespace conflicts ~ value in let mod_name = String . uppercase_ascii m . mod_name ...
let exceptions_vernac ~ rev_namespace conflicts m vernacs = let exception_vernac v e = let exn_name = e . exception_name in let exn_type = TParam ( CName " exn " , [ ] ) in let proxy_name = Conflict . get_coq_helper rev_namespace conflicts exn_name Name . exn_proxy_type in let proxy_constructo...
let monad_vernac ~ rev_namespace conflicts mod_name prims = let prim_to_members prim = let prim_type = may_raise_t prim . prim_may_raise prim . prim_type in let prim_name = Conflict . get_coq_value rev_namespace conflicts ~ value : prim . prim_name in ( prim_name , type_lift " m " prim_type ) i...
let primitives_vernac ~ rev_namespace conflicts lwt_module features m vernacs = let prims = List . map ( fun p -> let t = p . prim_type in let i = Repr . fresh_placeholder t in let p = { p with prim_type = Repr . map_codomain ( fun x -> TParam ( CPlaceholder i , [ x ] ) ) t ; } in...
let lwt_vernac ~ rev_namespace conflicts features m vernacs = let lwt_t = " Lwt . t " in let to_prim lwt = ( lwt . lwt_placeholder , { prim_name = lwt . lwt_name ; prim_type = lwt . lwt_type ; prim_may_raise = false ; prim_loc = lwt . lwt_loc ; } ) in let prims = List . map to...
let rec module_vernac ~ rev_namespace conflicts lwt_module features models m vernac = let rev_namespace = m . mod_name :: rev_namespace in vernac |> ( not ( empty m . mod_intro ) ) @? intros_vernac ~ rev_namespace conflicts lwt_module features models m |> ( not ( empty m . mod_exceptions ) )...
let of_mod lwt_module features models conflicts m = Block ( of_list [ Comment " This file has been generated by coqffi . " ; ConfigPrologue ] |> requires_vernac features models |> module_vernac ~ rev_namespace [ ] : conflicts lwt_module features models m |+ Comment " The generated file ends he...
type choice ' a ' b = [ Left of ' a | Right of ' b ] ; match x with | Some x -> Some ( f x ) | None -> None end ; Some x -> x ] ; Left x -> x ] ; Left _ -> failwith ( " choice : " ^ symbol ) ] ; Sys . ocaml_version ; ( loc ) with Location . loc_ghost = True...
let params = List . map ( fun ( os , va ) -> match os with [ None -> ( ocaml_mktyp loc Ptyp_any , convert_camlp5_variance va ) | Some s -> ( ocaml_mktyp loc ( Ptyp_var s ) , convert_camlp5_variance va ) ] ) params in { ptyext_path = mkloc loc pathlid ; ptyext_params = params ;...
type additional_info = Dev | RC of int | Release
let string_of_additional_info = function | Dev -> " + dev " | RC n -> " ~ rc " ^ string_of_int n | Release -> " "
type t = { major : int ; minor : int ; additional_info : additional_info }
let pp f { major ; minor ; additional_info } = Format . fprintf f " % i . % i % s " major minor ( string_of_additional_info additional_info )
let to_string x = Format . asprintf " % a " pp x
let current = { major = 12 ; minor = 0 ; additional_info = Dev }
let current_string = to_string current
module Version_error = struct type t = { payload : Csexp . t option ; message : string } let payload t = t . payload let message t = t . message let create ? payload ~ message ( ) = { payload ; message } exception E of t let to_response_error { payload ; message } = Response . Er...
module Staged = struct type ( ' req , ' resp ) request = { encode_req : ' req -> Call . t ; decode_resp : Csexp . t -> ( ' resp , Response . Error . t ) result } type ' payload notification = { encode : ' payload -> Call . t } end
module Make ( Fiber : Fiber ) = struct module Handler = struct type ' state t = { menu : Menu . t ; handle_request : Menu . t -> ' state -> Types . Request . t -> Response . t Fiber . t ; handle_notification : Menu . t -> ' state -> Call . t -> ( unit , Response . Erro...
module type S = sig type data module Lang : sig val register : Syntax . t -> data -> unit module Instance : sig type t = { syntax : Syntax . t ; data : data ; version : Syntax . Version . t } end val get_exn : string -> Instance . t end val load_exn : Path . t -> f ( : Lang . Inst...
module Make ( Data : sig type t struct module Lang = struct type t = { syntax : Syntax . t ; data : Data . t } module Instance = struct type t = { syntax : Syntax . t ; data : Data . t ; version : Syntax . Version . t } end let langs = Table . create ( module String ) 32 le...
let no_more_lang = let open Decoder in let + ( _ : _ list ) = multi_field " lang " ( let + loc = loc and + _ = repeat raw in User_error . raise ~ loc [ Pp . text " The ( lang . . ) line cannot appear more than once . " ] ) in ( )
module Versioned_direct_stream_writer = struct module Direct_stream_writer = Pipe_rpc . Direct_stream_writer type ' input t = | T : { convert : ( ' input -> ' output ) ; writer : ' output Direct_stream_writer . t } -> ' input t let create ~ convert ~ writer = T { convert ; writer...
let failed_conversion x = Error . create " type conversion failure " x [ % sexp_of : [ ` Msg | ` Query | ` Response | ` Error | ` State | ` Update ] * [ ` Rpc of string ] * [ ` Version of int ] * exn ]
let multiple_registrations x = Error . create " multiple rpc registrations " x [ % sexp_of : [ ` Rpc of string ] * [ ` Version of int ] ]
let unknown_version x = Error . create " unknown rpc version " x [ % sexp_of : string * int ]
module Callee_converts = struct module Rpc = struct module Simple = struct type ( ' query , ' response ) adapter = { adapt : ' state . ( ' state -> ' query -> ' response Deferred . t ) -> ' state Implementation . t } type ( ' query , ' response ) t = { name : stri...
module Menu = struct module Model = struct let name = " __Versioned_rpc . Menu " type query = unit type response = Description . t list end include Callee_converts . Rpc . Make ( Model ) let rpc_name = Model . name module V1 = struct module T = struct let version = 1 type query = unit [ ...
module Connection_with_menu = struct type t = { connection : Connection . t ; menu : Menu . t } [ @@ deriving fields ] let create connection = let open Deferred . Or_error . Monad_infix in Menu . request connection >>| fun menu -> { connection ; menu } let create_directly connection me...
module Caller_converts = struct let most_recent_common_version ~ rpc_name ~ caller_versions ~ callee_versions ~ callee_menu = match Set . max_elt ( Set . inter callee_versions caller_versions ) with | Some version -> Ok version | None -> error_s [ % message " caller and callee share no common ver...
module Both_convert = struct module Plain = struct module type S = sig type caller_query type callee_query type caller_response type callee_response val dispatch_multi : Connection_with_menu . t -> caller_query -> caller_response Or_error . t Deferred . t val implement_multi : ? log_not_previously_seen_ve...
let from_just op msg = match op with | Some x -> x | None -> failwith @@ msg " ^: Expected Some . Got None . "
module Serialization ( S : sig type t val t : t Irmin . Type . t end ) = struct open S let pp = Irmin . Type . pp_json ~ minify : false t let of_string s = let decoder = Jsonm . decoder ( ` String s ) in let res = try Irmin . Type . decode_json t decoder with Invalid_argument s -> ( ...
module MakeVersionedDS ( Config : CONFIG ) ( OM : MERGEABLE ) ( AO_value : Irmin . Contents . Conv with type t = OM . t ) = struct module S = Irmin_git . AO ( Git_unix . FS ) ( AO_value ) include AO_value type adt = OM . t let create config = let level = Irmin . Private . Co...
module Make ( Config : CONFIG ) = struct module IWarehouse : IRMIN_DATA_STRUCTURE with type adt = Tpcc . Warehouse . t = struct module OM = Tpcc . Warehouse module AO_value : Irmin . Contents . Conv with type t = OM . t = struct type adt = OM . t type t = OM . t let t = let open Irmin . ...
type _ witnesses = . .
type _ migration = . .
type _ migration += Undefined : _ migration
type ' a migration_info = { mutable next_version : ' a migration ; mutable previous_version : ' a migration ; }
module type Ast = sig module Parsetree : sig type structure type signature type toplevel_phrase type core_type type expression type pattern type case type type_declaration type type_extension type extension_constructor end module Config : sig val ast_impl_magic_number : string val ast_intf_magic_number : string en...
type ' a _types = ' a constraint ' a = < structure : _ ; signature : _ ; toplevel_phrase : _ ; core_type : _ ; expression : _ ; pattern : _ ; case : _ ; type_declaration : _ ; type_extension : _ ; extension_constructor : _ ; > ; ;
type ' a get_structure = ' x constraint ' a _types = < structure : ' x ; . . >
type ' a get_signature = ' x constraint ' a _types = < signature : ' x ; . . >
type ' a get_toplevel_phrase = ' x constraint ' a _types = < toplevel_phrase : ' x ; . . >
type ' a get_core_type = ' x constraint ' a _types = < core_type : ' x ; . . >
type ' a get_expression = ' x constraint ' a _types = < expression : ' x ; . . >
type ' a get_pattern = ' x constraint ' a _types = < pattern : ' x ; . . >
type ' a get_case = ' x constraint ' a _types = < case : ' x ; . . >
type ' a get_type_declaration = ' x constraint ' a _types = < type_declaration : ' x ; . . >