[Haskell-cafe] Help using QuickCheck

Benjamin Franksen benjamin.franksen at bessy.de
Fri Oct 21 13:58:10 EDT 2005

Hello All,

I am asking help with using QuickCheck. I tried everything I could think 
of, but invariably as soon as I start invoking the quickCheck function 
on my property it fails with

Top level:
    No instance for (Show (IO ()))
      arising from use of `print' at Top level
    Probable fix: add an instance declaration for (Show (IO ()))
    In a 'do' expression: print it

    No instances for (Arbitrary (OrdSeq Int), Show (OrdSeq Int))
      arising from use of `quickCheck' at <interactive>:1:0-20
    Probable fix:
      add an instance declaration for (Arbitrary (OrdSeq Int), Show 
(OrdSeq Int))
    In the definition of `it': it = quickCheck prop_DeleteInsert

The property is quite a simple one:

prop_DeleteInsert x xs = delete x (insert x xs) == xs
  where types = xs :: OrdSeq Int

My code compiles just fine with ghc. I tried some examples from the 
QuickCheck manual and these seem to work; at least I get the expected 
"OK, passed 100 tests.".

What am I doing wrong?

Besides, there are some really non-obvious quirks with QuickCheck. For 
instance, the following one caused me some headache:

I downloaded the haskell script 'quickCheck' and modified the line where 
ghci is executed like this:

system ("/usr/bin/ghci -cpp -package QuickCheck "++options opts'++" 

(I am using ghc 6.4.1, btw). Running 'quickCheck 
Data/FingerSearchTreeUtil.hs' gives me:

    Failed to load interface for `QuickCheck':
        Could not find module `QuickCheck':
          it is a member of package util-1.0, which is hidden

Strange. Replacing 'ChickCheck' with 'util' gives me the above error 
message about "No instance for (Show (IO ()))..."


More information about the Haskell-Cafe mailing list