[Haskell-cafe] how do i use quickcheck in the IO monad?

Don Stewart dons at galois.com
Mon Sep 22 17:10:39 EDT 2008

> If i have functions in the IO monad, is there a way to use quickcheck
> to test them?  I have a bunch of C bindings that unfortunately are not
> "safe".  But i would like to be able to use QuickCheck to test them.

Typically, via unsafePerformIO, and check the invariants that need to
hold for that to be safe by hand.


prop_foo x = unsafePerformIO $ do
                writeFile "f" x
                y <- readFile "f"
                return (x == y)

-- Don

More information about the Haskell-Cafe mailing list