promote :: Monad m => m (Gen a) -> Gen (m a)
Promotes a monadic generator to a generator of monadic values.
Unsafe combinators for the Gen monad.
Gen is only morally a monad: two generators that are supposed
to be equal will give the same probability distribution, but they
might be different as functions from random number seeds to values.
QuickCheck maintains the illusion that a Gen is a probability
distribution and does not allow you to distinguish two generators
that have the same distribution.
The functions in this module allow you to break this illusion by reusing the same random number seed twice. This is unsafe because by applying the same seed to two morally equal generators, you can see whether they are really equal or not.
promote :: Monad m => m (Gen a) -> Gen (m a)Promotes a monadic generator to a generator of monadic values.
delay :: Gen (Gen a -> a)Randomly generates a function of type , which
you can then use to evaluate generators. Mostly useful in
implementing Gen a -> apromote.
capture :: Gen CaptureA variant of delay that returns a polymorphic evaluation function.
Can be used in a pinch to generate polymorphic (rank-2) values:
genSelector :: Gen (a -> a -> a)
genSelector = elements [\x y -> x, \x y -> y]
data Selector = Selector (forall a. a -> a -> a)
genPolySelector :: Gen Selector
genPolySelector = do
Capture eval <- capture
return (Selector (eval genSelector))newtype CaptureCapture :: (forall a. Gen a -> a) -> CaptureCommunity contribution. The service has not verified this documentation. The generator reported 30 diagnostics.
Target: Linux on x86-64. Some inferred types and resolved links are not available.
Generator: aihc-haddock-aa6debbd-web-3
Metadata snapshot: f17ab6aeb2a7b6daf9fba7614097e138beeef85fa92c3fb7fdfed9ed0e49728c
Open the dependency plan · Download the documentation model