[Haskell-beginners] `coarbitrary' is not a (visible) method of class `Arbitrary'

Amy de Buitléir amy at nualeargais.ie
Sat Dec 19 08:20:43 EST 2009


I'm trying to follow the instructions in
http://haskell.org/haskellwiki/How_to_write_a_Haskell_program. I'm at
the step where we've just written a QuickCheck test:

amy at localhost ~/forbairt/haq $ cat Tests.hs
import Char
import List
import Test.QuickCheck
import Text.Printf

main  = mapM_ (\(s,a) -> printf "%-25s: " s >> a) tests

instance Arbitrary Char where
    arbitrary     = choose ('\0', '\128')
    coarbitrary c = variant (ord c `rem` 4)

-- reversing twice a finite list, is the same as identity
prop_reversereverse s = (reverse . reverse) s == id s
    where _ = s :: [Int]

-- and add this to the tests list
tests  = [("reverse.reverse/id", test prop_reversereverse)]


But when I try to run it, I get the following errors:

amy at localhost ~/forbairt/haq $ runhaskell Tests.hs

Tests.hs:10:4:
    `coarbitrary' is not a (visible) method of class `Arbitrary'

Tests.hs:17:33: Not in scope: `test'


I think this has something to do with the changes between QuickCheck
v1 and v2. Can someone tell me what I need to do to make this example
work? Thank you in advance!

Amy


More information about the Beginners mailing list