record Gen : Type -> Type Generates random values of type `a`
Totality: total
Visibility: public export
Constructor: MkGen : (Size -> StdGen -> Cotree a) -> Gen a
Projection: .unGen : Gen a -> Size -> StdGen -> Cotree a
Hints:
Applicative Gen Functor Gen Monad Gen
.unGen : Gen a -> Size -> StdGen -> Cotree a- Totality: total
Visibility: public export unGen : Gen a -> Size -> StdGen -> Cotree a- Totality: total
Visibility: public export runGen : Size -> StdGen -> Gen a -> Cotree a- Totality: total
Visibility: public export mapGen : (Cotree a -> Cotree b) -> Gen a -> Gen b- Totality: total
Visibility: public export fromTree : Cotree a -> Gen a Lift a predefined shrink tree in to a generator, ignoring the seed and the
size.
Totality: total
Visibility: public exporttoTree : Gen a -> Gen (Cotree a) Observe a generator's shrink tree.
Totality: total
Visibility: public exportgenerate : (Size -> StdGen -> a) -> Gen a- Totality: total
Visibility: public export shrink : (a -> Colist a) -> Gen a -> Gen a- Totality: total
Visibility: public export prune : Gen a -> Gen a- Totality: total
Visibility: public export sized : (Size -> Gen a) -> Gen a Construct a generator that depends on the size parameter.
Totality: total
Visibility: public exportscale : (Size -> Size) -> Gen a -> Gen a Adjust the size parameter by transforming it with the given function.
Totality: total
Visibility: public exportresize : Size -> Gen a -> Gen a Override the size parameter. Returns a generator which uses the given size
instead of the runtime-size parameter.
Totality: total
Visibility: public exportgolden : Size -> Size Scale a size using the golden ratio.
> golden x = x / φ
> golden x = x / 1.61803..
Totality: total
Visibility: public exportsmall : Gen a -> Gen a Make a generator smaller by scaling its size parameter.
Totality: total
Visibility: public exportintegral_ : ToInteger a => Range a -> Gen a Generates a random integral number in the [inclusive,inclusive] range.
This generator does not shrink.
Totality: total
Visibility: public exportintegral : ToInteger a => Range a -> Gen a Generates a random integral number in the given @[inclusive,inclusive]@ range.
When the generator tries to shrink, it will shrink towards the
'Range.origin' of the specified 'Range'.
For example, the following generator will produce a number between @1970@
and @2100@, but will shrink towards @2000@:
```
integral (Range.'Range.constantFrom' 2000 1970 2100) :: 'Gen' 'Int'
```
Some sample outputs from this generator might look like:
> === Outcome ===
> 1973
> === Shrinks ===
> 2000
> 1987
> 1980
> 1976
> 1974
> === Outcome ===
> 2061
> === Shrinks ===
> 2000
> 2031
> 2046
> 2054
> 2058
> 2060
Totality: total
Visibility: public exportint : Range Int -> Gen Int Generates a random machine integer in the given range.
This is a specialization of `integral`, offered for convenience.
Totality: total
Visibility: public exportint8 : Range Int8 -> Gen Int8 Generates a random 8-bit integer in the given range.
This is a specialization of `integral`, offered for convenience.
Totality: total
Visibility: public exportanyInt8 : Gen Int8 Generates a random 8-bit integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportint16 : Range Int16 -> Gen Int16 Generates a random 16-bit integer in the given range.
This is a specialization of `integral`, offered for convenience.
Totality: total
Visibility: public exportanyInt16 : Gen Int16 Generates a random 16-bit integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportint32 : Range Int32 -> Gen Int32 Generates a random 32-bit integer in the given range.
This is a specialization of `integral`, offered for convenience.
Totality: total
Visibility: public exportanyInt32 : Gen Int32 Generates a random 32-bit integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportint64 : Range Int64 -> Gen Int64 Generates a random 64-bit integer in the given range.
This is a specialization of `integral`, offered for convenience.
Totality: total
Visibility: public exportanyInt64 : Gen Int64 Generates a random 64-bit integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportbits8 : Range Bits8 -> Gen Bits8 Generates a random 8-bit integer in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportanyBits8 : Gen Bits8 Generates a random 8-bit signed integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportbits16 : Range Bits16 -> Gen Bits16 Generates a random 16-bit integer in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportanyBits16 : Gen Bits16 Generates a random 16-bit signed integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportbits32 : Range Bits32 -> Gen Bits32 Generates a random 32-bit integer in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportanyBits32 : Gen Bits32 Generates a random 32-bit signed integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportbits64 : Range Bits64 -> Gen Bits64 Generates a random 64-bit integer in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportanyBits64 : Gen Bits64 Generates a random 64-bit signed integer in the full available range.
This shrinks exponentially towards 0.
Totality: total
Visibility: public exportinteger : Range Integer -> Gen Integer Generates a random Integer in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportnat : Range Nat -> Gen Nat Generates a random Nat in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportsize : Range Size -> Gen Size Generates a random Size in the given range.
This is a specialization of 'integral', offered for convenience.
Totality: total
Visibility: public exportfin : Range (Fin n) -> Gen (Fin n) Generates a random (Fin n) in the given range.
Totality: total
Visibility: public exportdouble_ : Range Double -> Gen Double Generates a random fractional number in the [inclusive,exclusive) range.
This generator does not shrink.
Totality: total
Visibility: exportdouble : Range Double -> Gen Double Generates a random floating-point number in the given range.
This generator works the same as 'integral', but for floating point numbers.
Totality: total
Visibility: exportconstant : a -> Gen a Trivial generator that always produces the same element.
This is another name for `pure`.
Totality: total
Visibility: public exportelement : Vect (S k) a -> Gen a Randomly selects one of the elements in the vector.
This generator shrinks towards the first element in the vector.
Totality: total
Visibility: public exportelement_ : Vect (S k) a -> Gen a Randomly selects one of the elements in the vector.
This generator does not shrink.
Totality: total
Visibility: public exportchoice : Vect (S k) (Gen a) -> Gen a Randomly selects one of the generators in the vector.
This generator shrinks towards the first generator in the vector.
Totality: total
Visibility: public exportchoice_ : Vect (S k) (Gen a) -> Gen a Randomly selects one of the generators in the vector.
This generator does not shrink towards a particular
generator in the vector
Totality: total
Visibility: public exportfrequency : Vect (S k) (Nat, Gen a) -> Gen a Uses a weighted distribution to randomly select one of the generators in
the vector.
This generator shrinks towards the first generator in the vector.
Note that if the given frequencies sum up to 0, the first element
of the vector
Totality: total
Visibility: public exportbool : Gen Bool Generates a random boolean.
This generator shrinks to `False`.
Totality: total
Visibility: public exportunit : Gen () Generates constant values of type `Unit"
Totality: total
Visibility: exportchar : Range Char -> Gen Char Generates a character in the given `Range`.
Shrinks towards the origin of the range.
Totality: total
Visibility: exportcharc : Char -> Char -> Gen Char Generates a character in the interval [lower,uppper].
Shrinks towards the lower value.
Totality: total
Visibility: exportbinit : Gen Char Generates an ASCII binit: `'0'..'1'`
Totality: total
Visibility: exportoctit : Gen Char Generates an ASCII octit: `'0'..'7'`
Totality: total
Visibility: exportdigit : Gen Char Generates an ASCII digit: `'0'..'9'`
Totality: total
Visibility: exporthexit : Gen Char Generates an ASCII hexit: `'0'..'9', 'a'..'f', 'A'..'F'`
Totality: total
Visibility: exportlower : Gen Char Generates an ASCII lowercase letter: `'a'..'z'`
Totality: total
Visibility: exportupper : Gen Char Generates an ASCII uppercase letter: `'A'..'Z'`
Totality: total
Visibility: exportalpha : Gen Char Generates an ASCII letter: `'a'..'z', 'A'..'Z'`
Totality: total
Visibility: exportalphaNum : Gen Char Generates an ASCII letter or digit: `'a'..'z', 'A'..'Z', '0'..'9'`
Totality: total
Visibility: exportascii : Gen Char Generates an ASCII character: `'\0'..'\127'`
Totality: total
Visibility: exportprintableAscii : Gen Char Generates an printable ASCII character: `'\32'..'\126'`
Note: This includes the space character but no
line breaks or tabs
Totality: total
Visibility: exportlatin : Gen Char Generates a latin character: `'\0'..'\255'`
Totality: total
Visibility: exportprintableLatin : Gen Char Generates a printable latin character: `'\32'..'\126'` and `'\160'..'\255'`
Totality: total
Visibility: exportunicode : Gen Char Generates a Unicode character, excluding noncharacters
and invalid standalone surrogates:
`'\0'..'\1114111'` (excluding '\55296'..'\57343', '\65534', '\65535')`
Totality: total
Visibility: exportprintableUnicode : Gen Char Generates a printable Unicode character, excluding noncharacters
and invalid standalone surrogates:
`'\0'..'\1114111'` (excluding '\0' .. '\31', '\127' .. '\159',
'\55296'..'\57343', and '\65534', '\65535')`
Totality: total
Visibility: exportunicodeAll : Gen Char Generates a Unicode character, including noncharacters
but excluding invalid standalone surrogates: `0000..10FFFF`
(excluding D800..DFFFF)
Totality: total
Visibility: exportmaybe : Gen a -> Gen (Maybe a) Generates a 'Nothing' some of the time.
Totality: total
Visibility: exporteither : Gen a -> Gen b -> Gen (Either a b) Generates either an 'a' or a 'b'.
As the size grows, this generator generates @Right@s more often than @Left@s.
Totality: total
Visibility: exporteither_ : Gen a -> Gen b -> Gen (Either a b) Generates either an 'a' or a 'b', without bias.
This generator generates as many @Right@s as it does @Left@s.
Totality: total
Visibility: exportvect : (n : Nat) -> Gen a -> Gen (Vect n a) Generates a list using a 'Range' to determine the length.
Totality: total
Visibility: exportlist : Range Nat -> Gen a -> Gen (List a) Generates a list using a 'Range' to determine the length.
Totality: total
Visibility: exportlist1 : Range Nat -> Gen a -> Gen (List1 a) Generates a non-empty list using a `Range` to determine the length.
Totality: total
Visibility: exportstring : Range Nat -> Gen Char -> Gen String Generates a string using 'Range' to determine the length.
Totality: total
Visibility: exporthlist : All Gen ts -> Gen (HList ts) Generates an heterogeneous list being provided a generator for each element
Totality: total
Visibility: exporthvect : All Gen ts -> Gen (HVect ts) Generates an heterogeneous vect being provided a generator for each element
Totality: total
Visibility: exportnp : NP Gen ts -> Gen (NP I ts) Turns an n-ary product of generators into a generator
of n-ary products of the same type.
Totality: total
Visibility: exportns : NP Gen ts -> {auto 0 _ : NonEmpty ts} -> Gen (NS I ts) Turns an n-ary product of generators into a generator
of n-ary sums of the same type. This is a generalisation
of choice and shrinks towards the first sum type
in the list.
Totality: total
Visibility: exportns_ : NP Gen ts -> {auto 0 _ : NonEmpty ts} -> Gen (NS I ts) Turns an n-ary product of generators into a generator
of n-ary sums of the same type. This is a generalisation
of `choice_` and does not shrink towards a particular
sum type.
Totality: total
Visibility: exportsop : POP Gen tss -> {auto 0 _ : NonEmpty tss} -> Gen (SOP I tss)- Totality: total
Visibility: export printWith : (HasIO io, Show a) => Size -> StdGen -> Gen a -> io () Print the value produced by a generator, and the first level of shrinks,
for the given size and seed.
Use 'print' to generate a value from a random seed.
Totality: total
Visibility: exportprint : Show a => HasIO io => Gen a -> io () Run a generator with a random seed and print the outcome, and the first
level of shrinks.
@
Gen.print (Gen.'enum' \'a\' \'f\')
@
> === Outcome ===
> 'd'
> === Shrinks ===
> 'a'
> 'b'
> 'c'
Totality: total
Visibility: exportsample : HasIO io => Gen a -> io a Generate a sample from a generator.
Totality: total
Visibility: exportrenderTree : Show a => Nat -> Nat -> Size -> StdGen -> Gen a -> String Render the shrink tree produced by a generator, for the given size and
seed up to the given depth and width.
Totality: total
Visibility: exportprintTreeWith : Show a => HasIO io => Nat -> Nat -> Size -> StdGen -> Gen a -> io () Print the shrink tree produced by a generator, for the given size and
seed.
Use 'printTree' to generate a value from a random seed.
Totality: total
Visibility: exportprintTree : Show a => HasIO io => Nat -> Nat -> Gen a -> io () Run a generator with a random seed and print the resulting shrink tree.
@
Gen.printTree (Gen.'enum' \'a\' \'f\')
@
> 'd'
> ├╼'a'
> ├╼'b'
> │ └╼'a'
> └╼'c'
> ├╼'a'
> └╼'b'
> └╼'a'
/This may not terminate when the tree is very large./
Totality: total
Visibility: export