Hello all
I have a   data type
data Index = Index {indexSize::Float, indexIds::[Int], indexDown::(IntMap.IntMap Index)}
  | IndexLeaf {indexSize::Float, indexIds::[Int]}
  | IndexEmpty {indexSize::Float}
  deriving ( Show , Eq ) 
I derived some thing like this for QuickCheck testing
instance Arbitrary a => Arbitrary ( IntMap a )  where
    arbitrary = liftM IntMap.fromList  arbitrary

instance Arbitrary Index where
    arbitrary =
      oneof [ liftM3 Index arbitrary arbitrary arbitrary , liftM2 IndexLeaf arbitrary arbitrary , liftM IndexEmpty arbitrary ]
but its generating infinite list of data. After reading the paper QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs
i tried to write above one using sized  but i am not sure how to write this .

instance Arbitrary a => Arbitrary ( IntMap a )  where
    arbitrary = liftM IntMap.fromList  arbitrary

instance  Arbitrary Index where
    arbitrary = sized arbIndex

arbIndex 0 = liftM IndexEmpty arbitrary
arbIndex 1 = liftM2 IndexLeaf arbitrary arbitrary
arbIndex n = frequency [ ( 1 , liftM IndexEmpty arbitrary ) , ( 1 ,  liftM2 IndexLeaf arbitrary arbitrary ) , ( 2 , liftM2 Index arbitrary arbitrary ( arbIndex $ div n 2 )   ) ]

but from this type i can see arbIndex $ div n 2 will return Gen Index not Gen ( IntMap Index )  and i am getting compiler error . Could some one please tell me , how to write arbIndex n in terms of smaller n like in the paper
arbTree 0 = liftM Leaf arbitrary
arbTree n = frequency[   ( 1 , liftM Leaf arbitrary ) , ( 4 , liftM2 Branch ( arbTree $ div n 2 ) ( arbTree $ div n 2 ) ) ]


Thank You
Mukesh Tiwari