Giter Site home page Giter Site logo

IO in Propertys about falsify HOT 5 OPEN

well-typed avatar well-typed commented on August 12, 2024
IO in Propertys

from falsify.

Comments (5)

edsko avatar edsko commented on August 12, 2024 2

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.

voidus avatar voidus commented on August 12, 2024

Thank you for the encouragement and guidance. I'll try to look into it some more in the next days 🙂

from falsify.

ejconlon avatar ejconlon commented on August 12, 2024

+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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.