MonadGenOps

trait MonadGenOps[M[_]]
class Object
trait Matchable
class Any
trait GenTOps
object Gen

Value members

Concrete methods

def discard[A](G: MonadGenT[M]): M[A]

Discards the whole generator.

Discards the whole generator.

def ensure[A](gen: M[A], p: A => Boolean)(F: Monad[M], G: MonadGenT[M]): M[A]

Discards the generator if the generated value does not satisfy the predicate.

Discards the generator if the generated value does not satisfy the predicate.

def filter[A](gen: M[A])(p: A => Boolean)(F: Monad[M], G: MonadGenT[M]): M[A]

Generates a value that satisfies a predicate.

Generates a value that satisfies a predicate.

We keep some state to avoid looping forever. If we trigger these limits then the whole generator is discarded.

def fromSome[A](gen: M[Option[A]])(F: Monad[M], G: MonadGenT[M]): M[A]

Runs a Option generator until it produces a Some.

Runs a Option generator until it produces a Some.

This is implemented using filter and has the same caveats.

def generate[A](f: (Size, Seed) => (Seed, A))(G: MonadGenT[M]): M[A]

Construct a generator that depends on the size parameter.

Construct a generator that depends on the size parameter.

def integral[A](range: Range[A], fromLong: Long => A)(`evidence$1`: Integral[A], F: MonadGenT[M]): M[A]

Generates a random integral number in the given [inclusive,inclusive] range.

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:

Gen.integral(Range.constantFrom(2000, 1970, 2100))

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
def integral_[A](range: Range[A], fromLong: Long => A)(G: MonadGenT[M], I: Integral[A]): M[A]

Generates a random integral number in the [inclusive,inclusive] range.

Generates a random integral number in the [inclusive,inclusive] range.

''This generator does not shrink.''

def list[A](gen: M[A], range: Range[Int])(F: Monad[M], G: MonadGenT[M]): M[List[A]]

Generates a list using a 'Range' to determine the length.

Generates a list using a 'Range' to determine the length.

def sized[A](f: Size => M[A])(F: Monad[M], G: MonadGenT[M]): M[A]

Construct a generator that depends on the size parameter.

Construct a generator that depends on the size parameter.