Gen
Monad #
This monad is used to formulate randomized computations with a parameter to specify the desired size of the result.
Main definitions #
Gen
monad
References #
@[reducible, inline]
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
- Plausible.Gen α = ReaderT (ULift Nat) Plausible.Rand α
Instances For
@[inline]
Equations
- x.up = do let size ← read liftM (Plausible.Rand.up (ReaderT.run x { down := size.down }))
Instances For
@[inline]
Equations
- x.down = do let size ← read liftM (Plausible.Rand.down (ReaderT.run x { down := size.down }))
Instances For
Lift BoundedRandom.randomR
to the Gen
monad.
Equations
- Plausible.Gen.choose α lo hi h x✝ = Plausible.Random.randBound α lo hi h
Instances For
Apply a function to the size parameter.
Equations
- Plausible.Gen.resize f x = withReader (ULift.up ∘ f ∘ ULift.down) x
Instances For
Choose a Nat
between 0
and getSize
.
Equations
- Plausible.Gen.chooseNat = do let __do_lift ← Plausible.Gen.getSize let a ← Plausible.Gen.choose Nat 0 __do_lift ⋯ pure a.val
Instances For
Given a list of example generators, choose one to create an example.
Equations
Instances For
Given a list of examples, choose one to create an example.
Equations
Instances For
Given two generators produces a tuple consisting out of the result of both
Equations
Instances For
Execute a Gen
inside the IO
monad using size
as the example size
Equations
- x.run size = Plausible.runRand (liftM (ReaderT.run x { down := size }))