
11 Nov
2013
11 Nov
'13
5:31 p.m.
Hi, have the following type data BinomialHeap a = EmptyHeap | Node a Int (BinomialHeap a) and wanted to create a test generator with type ‘a’ as an Int for example hence had newtype BinominalHeapInt = BinominalHeap Int deriving (Eq, Show) But struggling to get the generator correct, currently have instance Arbitrary BinominalHeapInt where arbitrary = sized heap' where heap' 0 = return EmptyHeap heap' n | n>0 = oneof [return EmptyHeap, liftM3 Node arbitrary arbitrary subnode] where subnode = heap' (n `div` 2) But it complains Expected type: Int -> Gen BinominalHeapInt Actual type: Int -> Gen (BinomialHeap a1) in sized heap’ Any pointers ? Thanks