[Haskell-cafe] QuickChecking IO

Twan van Laarhoven twanvl at gmail.com
Thu May 25 11:28:46 EDT 2006


Mike Gunter wrote:
 > I'd like to use QuickCheck on IO code.  For instance, I'd like to
 > check a property of type String -> IO Bool.
 >
 > Using unsafePerformIO seems straightforward (though I haven't written
 > the code, so I may be wrong about that) and it might be possible to
 > make a solution involving unsafeInterleaveIO work.  Short of rewriting
 > QuickCheck, is there any way to check IO code "safely"?

To use QuickCheck on IO you would need an instance of Arbitrary that can 
generate arbitrary states of the world :) If you ignore that you could, 
for example, make tests that depends on some files existing outside the 
program. To me that sounds like a bad idea, or at least outside the 
realm of QuickCheck.

Twan


More information about the Haskell-Cafe mailing list