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

Michał Pałka michal.palka at poczta.fm
Tue Sep 23 06:16:56 EDT 2008


On Mon, 2008-09-22 at 12:35 -0700, Anatoly Yakovenko wrote:
> 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.

Hi Anatoly,

If you want to test some sequential properties then you might use
QuickCheck to generate sequences of actions that the library will
perform and check if the outcomes are correct. If there is no easy way
to verify the results then you may create a model of your library and
compare the results.

This approach is demonstrated in this talk:
http://ulf.wiger.net/weblog/2008/02/29/john-hughes-testing-with-quickcheck/
where John Hughes tests fread()/fwrite()/fseek() unix functions. He uses
the Erlang version of QuickCheck, but using a Haskell one should allow
you to do the same thing in the IO monad.

There are probably some papers that deal with what you want to do as
well, like this one:
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19.9275
(I haven't read it though).

Best,
Michał



More information about the Haskell-Cafe mailing list