I am trying to write property based test with Tasty library and SmallCheck. But I need IO in the property check function and also I need I/O resource. So, I turned existing test into:
myTests :: IO Cfg -> TestTree
myTests getResource = testGroup "My Group"
[
testProperty "MyProperty" $
-- HOW TO CALL getResource here, but not in
-- function, so to avoid multiple acquisition
-- Some{..} <- getResource
\(x::X) -> monadic $ do -- HERE I WILL DO I/O...
]
So, question is: how to call getResource once? So, not in the \(x::X) -> ...
body but before it. Is it possible?