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 #
Error thrown on generation failure, e.g. because you've run out of resources.
Instances For
Equations
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. It allows failure to generate via the ExceptT
transformer
Equations
- Plausible.Gen α = Plausible.RandT (ReaderT (ULift Nat) (Except Plausible.GenError)) α
Instances For
Equations
- Plausible.instMonadLiftGen = { monadLift := fun {α : Type ?u.20} (m_1 : Plausible.RandGT StdGen m α) => liftM ∘ StateT.run m_1 }
Equations
Equations
- Plausible.Gen.genFailure (Plausible.GenError.genError mes) = IO.userError (toString "generation failure: " ++ toString mes)
Instances For
Lift BoundedRandom.randomR
to the Gen
monad.
Equations
- Plausible.Gen.choose α lo hi h = liftM (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
until it actually produces an output. May diverge for bad generators!
Equations
- Plausible.Gen.runUntil attempts x size = (Plausible.Gen.runUntil.repeatGen attempts x).run size
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.