package monolith

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The submodule Gen offers facilities for generating values of many common types. It draws data from the file whose name is supplied on the command line. (If no file name is supplied, it draws random data from OCaml's Random module.)

type 'a gen = unit -> 'a

A generator is a function of unit to a value of some desired type 'a. It is permitted for a generator to fail by calling reject or guard. This failure is not fatal; it causes the engine to backtrack (to an unspecified point) and retry.

val reject : 'a gen

reject generates nothing. It always fails.

val guard : bool -> unit

guard b fails if b is false.

val byte : int gen

byte generates a byte. A byte is viewed as an unsigned integer.

val bits : int gen

bits generates a signed integer.

val bool : bool gen

bool generates a Boolean.

val int : int -> int gen

int n generates an integer in the semi-open interval [0..n). If this interval is empty, the generator fails.

val interval : int -> int -> int gen

interval i j generates an integer in the semi-open interval [i, j). If this interval is empty, the generator fails.

val interval_ : int -> int -> int gen

interval_ i j generates an integer in the closed interval [i, j]. If this interval is empty, the generator fails.

val lt : int -> int gen

lt j is synonymous with int j and with interval 0 j.

val le : int -> int gen

le j is synonymous with interval_ 0 j.

val sequential : unit -> int gen

sequential() produces a fresh stateful sequential generator of integers. This generator is deterministic. Every time this generator is invoked, it produces a new integer, counting from 0 and up.

val choose : 'a list -> 'a gen

choose xs picks an element in the list xs. If this list is empty, the generator fails.

val option : 'a gen -> 'a option gen

An option generator. If element is an element generator, then option element is a generator of optional elements.

val list : int gen -> 'a gen -> 'a list gen

A list generator. If element is an element generator and if n is a length generator (where a length is a nonnegative integer), then list n element is a list generator.

val array : int gen -> 'a gen -> 'a array gen

An array generator. If element is an element generator and if n is a length generator (where a length is a nonnegative integer), then array n element is a array generator.

OCaml

Innovation. Community. Security.