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
Lift Random.random
to the Gen
monad.
Equations
Lift BoundedRandom.randomR
to the Gen
monad.
Equations
- SlimCheck.Gen.choose α lo hi h x = Random.randBound α lo hi h
Get access to the size parameter of the Gen
monad.
Equations
- SlimCheck.Gen.getSize = do let __do_lift ← read pure __do_lift.down
Apply a function to the size parameter.
Equations
- SlimCheck.Gen.resize f x = withReader (ULift.up ∘ f ∘ ULift.down) x
Create an 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
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.
Given a list of examples, choose one to create an example.
Equations
- One or more equations did not get rendered due to their size.
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 := (_ : [] ~ []) }
Given two generators produces a tuple consisting out of the result of both
Equations
- SlimCheck.Gen.prodOf x y = do let __do_lift ← x let __do_lift_1 ← y pure (__do_lift, __do_lift_1)
Execute a Gen
inside the IO
monad using size
as the example size
Equations
- SlimCheck.Gen.run x size = IO.runRand (ReaderT.run x { down := size })