-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IO in Propertys #57
Comments
Indeed, the choice not to have IO in 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 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 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. |
Thank you for the encouragement and guidance. I'll try to look into it some more in the next days 🙂 |
+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 |
I'm also interested in this feature! (I have an external system that I want to compare to a simpler implementation in Haskell.) Maybe I could contribute something or extend #62. On that PR, @voidus says:
We'd also probably want Would it make sense to split the types this way?
Then I suppose the Tasty adapter would take a What do you think: does this approach make sense? |
@dpercy Sorry for the slow reply, I'm swamped with work. I think that the approach you sketch is not quite what we want (though perhaps I misunderstand). With The most important consideration here is that all this would then still have a very strict phase separation: first generate the |
Heya,
I'm thinking about how to test some code that needs IO to run.
The situations I'm thinking about are more like using STM internally or something, the possibility of IO making the property unreliable is not really my focus here.
I didn't find anything in the docs, so I looked into the code. Relevant definitions:
So there's no base
IO
behindGen
(like in hedgehog) that we could expose throughMonadIO
, even if we wanted to. And we don't:This leaves the question: Is there a way to do what I'm looking for?
I've tried:
TestResultT
tom (IO (TestResult e a))
, but couldn't write the monad instance, presumably because m isn't a monad transformer.Since
TestResultT
is applied toStateT TestRun Gen
, requiring a transformer is outassert
, which is not a big surprise I guess.Right now, I can't really see a way to implement this at all (short of making
Gen
a transformer).Maybe an interesting approach is to split the Property in a generation phase (without IO, with
gen
) and an assertion phase (with IO, withoutgen
)? Seems annoying type-wise, but that would prevent the obvious footgun of depending on external input during test prep.The text was updated successfully, but these errors were encountered: