package boltzgen

  1. Overview
  2. Docs

Boltzgen runtime library entry point

type nat = int
type natp = int
type bits = int
type small_nat = int
type simple_string = string
type simple_spaced_string = string
type id_string = string
module Type : sig ... end
val compute_boltzman : ?silent:bool -> Type.compo_type -> float -> float * float * float

Main generation function

compute_boltzman fd z Evaluates the Boltzmann generating function for function signature fd using Boltzmann parameter z

val gen_string_of_compo : Type.compo_type -> string

Generates the to_string function for a type

val gen_from_compo : Random.State.t -> int -> Type.compo_type -> float -> Type.hidden_type * int

Generates a value for a type

val print_from_compo : Type.compo_type -> Format.formatter -> Type.hidden_type -> unit

Prints a value given its type

val parse_string : string -> Type.def_type list * Type.func option

Parsing and type generation

val evaluate : Type.def_type -> unit

Builds the type and adds it to the type library

val eval_typedef : string -> unit

eval_typedef s parses and evaluates an OCaml type definition

Parameters of generation

val set_max_size : int -> unit
val set_boltzmann_size : float -> unit
val boltzmann_size : float ref
val send_warning : bool ref
type random_fun_table = (Type.compo_type list * Type.compo_type, char) Hashtbl.t
val gen_random_fun_def : Format.formatter -> Type.def_type list -> random_fun_table -> Type.func -> unit

Generates and prints random functions with memoization

val random_state : unit -> Random.State.t

Initializes a random generator state

val call_random : ?tsrange:(int * int) -> ?max_iter:int -> random_fun_table -> Random.State.t -> int -> float -> Type.func -> string

Generates and prints a call for a function

Convenient functions for runtime value generation

val stagfun_struct : Format.formatter_stag_functions
val nb_test : int ref
val nb_fail : int ref
val print_value : Format.formatter -> string -> 'a -> unit

HIGHLY UNSAFE: Given a type description and a value, prints it on the formatter. Undefined behavior if types do not match. See print_from_compo for a safe version

val rand_value : ?seed:int -> ?size:float -> ?silent:bool -> string -> 'a

rand_value ~seed ~size type returns a value of type type. seed is a seed for the random generator; if omitted, Random.bits is used. size controls the size of the value, overriding set_boltzmann_size. See gen_from_compo for a safer version

val rand_fun : ?size:float -> ?silent:bool -> string -> int -> 'a -> 'b

rand_fun ~size ~silent type arg is a pure generic function; it generates a value of type type. arg is a parameter for the value, similar to rand_value but makes the type checker happy

val rand_fun_alea : ?seed:int -> ?size:float -> ?silent:bool -> string -> 'a -> 'b

rand_fun_alea ~seed ~size ~silent type arg is a pure generic function; it generates a value of type type. seed and arg are parameters for the value, similar to rand_value but makes the type checker happy

Functions for runtime equality checking

val assert_equal : ?throw:bool -> ?err:bool -> ('a -> string) -> ('b -> string) -> string -> (unit -> 'a) -> (unit -> 'b) -> unit
val assert_equal_arg : ?throw:bool -> ?err:bool -> ('a -> string) -> ('b -> string) -> ('c -> string) -> ('c -> 'a) -> ('c -> 'b) -> 'c -> unit
val assert_equal_string : ?err:bool -> string -> (unit -> string) -> (unit -> string) -> unit
OCaml

Innovation. Community. Security.