Jupi
Jupi

Reputation: 35

How can I QuickCheck Arbitary functions

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

Upvotes: 2

Views: 143

Answers (2)

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

@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.

Upvotes: 2

luqui
luqui

Reputation: 60463

You need to write an Aribtrary instance for your type.

Upvotes: 3

Related Questions