[Haskell-cafe] Quickcheck generator help

Graham Berks graham at fatlazycat.com
Mon Nov 11 22:31:48 UTC 2013

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 ?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131111/c7dc43b7/attachment.html>

More information about the Haskell-Cafe mailing list