Module QCheck2.Observable
An observable is a random function argument.
val make : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> 'a Print.t -> 'a t
make ?eq ?hash print
creates an observable of'a
.If
eq
isNone
, uses the standard polymorphic(=)
function.If
hash
isNone
, uses a default hashing function.
val equal : 'a t -> 'a -> 'a -> bool
equal o
returns the equality function ofo
.
val hash : 'a t -> 'a -> int
hash o
returns the hashing function ofo
.
val unit : unit t
unit
is an observable ofunit
.
val bool : bool t
bool
is an observable ofbool
.
val int : int t
int
is an observable ofint
.
val float : float t
float
is an observable offloat
.
val string : string t
string
is an observable ofstring
.
val char : char t
char
is an observable ofchar
.
val contramap : ('b -> 'a) -> 'a t -> 'b t
contramap f o
maps the functionf
on observableo
.Note the reverse order of types in
f
which may be conter-intuitive: indeed a function that consumes values of type'b
can be obtained by transforming a value of type'b
to'a
usingf
, and then by consuming this value of type'a
usingo
.
val option : 'a t -> 'a option t
option o
wraps the observableo
of'a
into an observable of'a option
.