package osnap

  1. Overview
  2. Docs

Module Osnap.SpecSource

include module type of Spec
Sourcetype 'a gen = 'a QCheck.Gen.t

'a gen is used to generate random values inside spec. QCheck combinators are available using Spec.Gen.

Sourcetype 'a printer = 'a -> string

'a printer is used to store randomly generated values

Sourcetype 'a encoding = 'a Data_encoding.t

'a encoding is used to encode values in memory

Sourcetype 'a spec = {
  1. gen : 'a gen;
  2. printer : 'a printer option;
  3. encoding : 'a Data_encoding.t option;
}

'a spec combines an 'a gen and a printer

Sourcemodule Result : sig ... end
Sourcetype ('fn, 'r) t =
  1. | Result : 'r Result.t -> ('r, 'r) t
  2. | Arrow : 'a spec * ('fn, 'r) t -> ('a -> 'fn, 'r) t

t is the specification type, describing a function. Thus t declaration must end with (^>>).

Sourceval default_printer : ('a -> string) option -> 'a -> string

default_printer printer creates a default printer if printer is absent

Sourceval build : ?printer:'a printer -> ?encoding:'a encoding -> 'a gen -> 'a spec

build ?printer ?encoding gen builds an 'a spec with optional fields

Sourceval of_gen : 'a gen -> 'a spec

of_gen gen creates an 'a spec with no printer

Sourceval unit : unit spec

unit specification

Sourceval bool : bool spec

bool specification

Sourceval float : float spec

float specification

Sourceval int : int spec

int specification

Sourceval char : char spec

char specification

Sourceval string : string spec

string specification

Sourceval option : 'a spec -> 'a option spec

option spec creates an option spec for spec

Sourceval array : 'a spec -> 'a array spec

array spec creates an array spec for spec

Sourceval list : 'a spec -> 'a list spec

list spec creates a list spec for spec

Sourceval (^>) : 'a spec -> ('b, 'c) t -> ('a -> 'b, 'c) t

(^>) x y combines spec x and y to create x -> y

Sourceval (^>>) : 'a spec -> 'b Result.t -> ('a -> 'b, 'b) t

(^>>) x res combines a specification and printer for the result type

Sourceval can_encode : ('fn, 'r) t -> bool

can_encode spec returns true if every spec in spec can be encoded

OCaml

Innovation. Community. Security.