-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi,
First of all, thank you for your great library and great expositions! This library is really cool indeed.
Feature Request: Pure interface for Gen
Currently, there is an impure interface to sample a value from Gen:
sample :: Gen a -> IO aIt would also be nice to have a pure analogue for this. The most straightforward one could be:
sampleFrom :: SMGen -> Gen a -> aUnfortunately, this leaks the implementation detail. So perhaps it could be something like this:
data GenSource -- opaque (could be just a newtype wrapper around SMGen or SampleTree)
mkGenSource :: Word64 -> GenSource
sampleFrom :: GenSource -> Gen a -> aBackground
Recently, I use falsify to test the validity of transformations on propositional formulae.
The test worked well, and I eventually have several valid implementations with different performance characteristics. So I decided to take some benchmarks on them.
To do that, I have to generate some random formula of a specific size. Surely, we can do this with sample :: Gen a -> IO a. One downside of sample function is the lack of reproducibility - as sample initialises SMGen from the air on every invocation, we don't have any access to the seed it used.
Once we have sampled some formulae from Gen, we must save them on a disk. This becomes tedious when one needs multiple formulae. If we can sample a value from specified seed, then we can just hard-code the seed instead.