Page
Library
Module
Module type
Parameter
Class
Class type
Source
Popper.Sample
SourceA 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
.
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.
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
.
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.
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.
log_key_value key value
is a sample that when run logs the given key
and value
pair without consuming any input.
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.
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.