Gen
Monad #
This monad is used to formulate randomized computations with a parameter to specify the desired size of the result. This is a port of the Haskell QuickCheck library.
Main definitions #
Gen
monad
Tags #
random testing
References #
- https://hackage.haskell.org/package/QuickCheck
Monad to generate random examples to test properties with.
It has a Nat
parameter so that the caller can decide on the
size of the examples.
Equations
- SlimCheck.Gen α = ReaderT (ULift.{u, 0} ℕ) Rand α
Instances For
Lift BoundedRandom.randomR
to the Gen
monad.
Equations
- SlimCheck.Gen.choose α lo hi h x = Random.randBound α lo hi h
Instances For
Get access to the size parameter of the Gen
monad.
Equations
- SlimCheck.Gen.getSize = do let __do_lift ← read pure __do_lift.down
Instances For
Apply a function to the size parameter.
Equations
- SlimCheck.Gen.resize f x = withReader (ULift.up ∘ f ∘ ULift.down) x
Instances For
Create a List
of examples using x
. The size is controlled
by the size parameter of Gen
.
Equations
- SlimCheck.Gen.listOf x = SlimCheck.Gen.arrayOf x >>= pure ∘ Array.toList
Instances For
Given a list of example generators, choose one to create an example.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a list of examples, choose one to create an example.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Generate a random permutation of a given list.
Equations
- One or more equations did not get rendered due to their size.
- SlimCheck.Gen.permutationOf [] = pure { val := [], property := (_ : List.Perm [] []) }
Instances For
Given two generators produces a tuple consisting out of the result of both
Equations
- One or more equations did not get rendered due to their size.
Instances For
Execute a Gen
inside the IO
monad using size
as the example size
Equations
- SlimCheck.Gen.run x size = IO.runRand (liftM (ReaderT.run x { down := size }))