package osnap

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of Spec
type 'a gen = 'a QCheck.Gen.t

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

type 'a printer = 'a -> string

'a printer is used to store randomly generated values

type 'a encoding = 'a Data_encoding.t

'a encoding is used to encode values in memory

type '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

module Result : sig ... end
type ('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 (^>>).

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

default_printer printer creates a default printer if printer is absent

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

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

val of_gen : 'a gen -> 'a spec

of_gen gen creates an 'a spec with no printer

val unit : unit spec

unit specification

val bool : bool spec

bool specification

val float : float spec

float specification

val int : int spec

int specification

val char : char spec

char specification

val string : string spec

string specification

val option : 'a spec -> 'a option spec

option spec creates an option spec for spec

val array : 'a spec -> 'a array spec

array spec creates an array spec for spec

val list : 'a spec -> 'a list spec

list spec creates a list spec for spec

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

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

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

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

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

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