How can I QuickCheck Arbitary functions

Viewed 94

I am quite new on Haskell and I was trying to chek a fuction of mine. The funktion is in type of

treeValidate :: forall a. Ord a => BST a -> Bool

How could I validate this? I tried quickChekc treeValidate but I get this error: • No instance for (Arbitrary (BST a0)) arising from a use of ‘quickCheck’

edit fixed a typo on the error message

2 Answers

@WillemVanOnsem said you need an Arbitrary instance. You responded "Yes, but how is it typed on the quickCheck?".

I don't understand your response question. The fact is, you must write:

instance Arbitrary a => Arbitrary (BST a) where
    arbitrary = -- your code here

Where your code here is the definition of arbitrary you write to generate arbitrary (random) values of type BST a.

Related