简体   繁体   中英

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

您需要为您的类型编写一个Aribtrary实例

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM