Library
Module
Module type
Parameter
Class
Class type
A value of type 'a t
is a parser that when run with an Input.t
value, produces some output containing a value of type 'a
.
map f s
creates a sample that when run maps its output value using the function f
.
val return : 'a -> 'a t
return x
is a sample that does not read any input and always produces a value containing x
.
bind s f
is a sample that when run, first executes s
on the given input, then applies its output value to f
in order to produe a new sample that is run on the remaining input. This is the monadic operator for sequencing sample operations.
both s1 s2
is a sample that when run executes s1
followed by s2
and combines their result.
val size : int t
size
returns the current max-size
argument.
sized f
lifts the function f
that depend on a size argument to a sample.
resize n s
creates a sample that when run fixes the size parameter to n
.
one_of ss
is a sample that selects on of the given sample from the list ss
.
val one_value_of : 'a list -> 'a t
one_vlaue_of xs
same as one_of
but lifts all values to samples using return
.
choose fss
chooses one sample from the list with a probability corresponding to the relative weight, as specified by the weight and sample pairs in fss
.
delayed f
is sample that delays the production of the sample using f
until run
sequence ss
is a sample that runs each sample in ss
and combines their results in a list.
val unit : unit t
unit
is a sample that produce a unit value without consuming any input.
val int : int t
int
is a sample that produces int
values.
val int32 : int32 t
int32
is a sample that produces int32
values.
val int64 : int64 t
int64
is a sample that produces int64
values.
val char : char t
char
is a sample that produces char
values.
val float : float t
float
is a sample that produces float
values.
val bool : bool t
bool
is a sample that produces bool
values.
val string : string t
char
is a sample that produces char
values.
option s
is a sample that either produces a value None
or a value of Some
using s
.
result ~ok ~error
is a sample that produces a result value, either using the ok
sample, or an error using the error
sample.
list s
is a sample that produces a list using the give s
. The size of the list is not determined but is influenced by the implicit size
parameter.
val log_key_value : string -> string -> unit t
log_key_value key value
is a sample that when run logs the given key
and value
pair without consuming any input.
val with_log : string -> (Format.formatter -> 'a -> unit) -> 'a t -> 'a t
with_log key pp s
enhances the given sample s
so as to also log its result using the key
and printer pp
for producing a string value.
val with_consumed : 'a t -> ('a * Consumed.t) t
with_consumed s
is a sample produces a pair of a value using s
and its consumed data. This would only be used for debugging purposes.
tag_name name s
is a sample that when run, applies s
but tags its consumed input with the given name
. Mostly useful for debuggin.
module Syntax : sig ... end
module Int : sig ... end
module Float : sig ... end
module List : sig ... end
module Array : sig ... end
module String : sig ... end
module Tuple : sig ... end