Comments (5)
Indeed, the choice not to have IO in Gen
, or support a general transformer API in Gen
, is quite deliberate, as you already point out. In principle we have more leeway with Property'
, although we do have to be a bit careful.
However, I agree with you that a separation is the way to go here; this is the route taken for example by libraries such as quickcheck-state-machine, quickcheck-dynamic/quickcheck-lockstep, and others.
I don't think it would be that hard actually, because Property
and its infrastructure is already quite general. Here's where I would start experimenting. In the tasty driver, we have
data Test = Test TestOptions (Property' String ())
We can add another
data TestIO = TestIO TestOptions (Property' String (IO ()))
alongside, with correspoinding
testPropertyIO :: TestName -> Property' String (IO ()) -> TestTree
(Perhaps it would even make sense to generalize the existing Test
datatype rather than define a second one, not 100% sure.) The IsTest
instance for this would do what the existing one does and share most of its code, but would perform one additional step for the test to pass: the returned IO
action should run without exceptions. I think this would achieve the separation you mention, and would then also open the door to more full-fledged state modelling infrastructure (I'd love to see something like quickcheck-lockstep
in falsify
at some point).
What do you think? If you'd like to give it a go and get stuck somewhere, let me know and I'll try to think along.
from falsify.
Thank you for the encouragement and guidance. I'll try to look into it some more in the next days 🙂
from falsify.
+1 from me on this feature. I have some serialization code that is "morally pure" but allocates and fills buffers in IO during encoding, and I would love to be able to drop my unsafePerformIO
!
from falsify.
Related Issues (19)
- Think about generation of functions HOT 1
- Memoization HOT 3
- Figure out why the `StringToBool` test is so slow HOT 2
- Improve separation of concerns between `Function` and `Perturb` HOT 1
- Make precision of `fraction` configurable
- Improve performance of `list` by using `bst`
- example of how to use Test.Falsify.Predicate.at? HOT 5
- Indexed Arbitrary typeclass HOT 6
- Test database a la Hypothesis? HOT 3
- `Gen.enum` is unusable: no way to construct a `Range` for an enumerable (but not integral) type
- A generator for Text HOT 1
- Consider the use of `Ratio` instead of `Double` for fractions
- Support progress reporting in tasty HOT 1
- Feature Request: Pure interface for Gen HOT 1
- Release for GenDefault typeclass HOT 2
- Introduce a uniform `signedFraction` generator
- Feature request: Don't generate unused values (a la LazySmallcheck2012) HOT 1
- Add to Stackage? HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from falsify.