Randomly generate a context
Just generate an appropriate random monadic context. If you are running tests, you can't stay in pure imaginary monad land, you actually have to pick a particular monad to test out. Did you pick a list monad? Randomly generate a list as the context. A state monad? Randomly generate a value of the state type for the context. Writer? Randomly generate a log.
Randomly generate an action
So what do you want to generate, exactly? If it is a monadic action, then you need to provide a way of generating monadic actions for your particular monad, based on its unique primitives. e.g. randomly generated State actions should be constructed randomly from State primitives get
and put
.
Put them together
If you use QuickCheck's capabilities to generate a function f
that produces a monadic action, and use QuickCheck to generate a context c
, then you can simply c >>= f
to put them together. Or you can simply generate the action a
directly, and do c >> a
.