I have an arbExample function to generate a random Example data type, which depends on the number of functions.
I'm trying to test properties by running quickCheck prop_example , the problem is that I don't know how to define an Arbitrary instance for Example that uses arbExample .
I like to run quickCheck prop_example when specifying the Gens data structure that arbExample uses.
data Example = Example { myInt :: Int , myList :: [String] } deriving (Show) data Gens = Gens { gen1 :: Gen Int , gen2 :: Gen String } arbExample :: Gens -> Gen Example arbExample gens = do i <- gen1 gens xs <- vectorOf i (gen2 gens) return Example{myInt=i, myList=xs} prop_example :: Example -> Property prop_example example = do let len = length (myList example) monadicIO $ do -- result of running some program successful <- run $ (\e -> return False) example case successful of True -> return () False -> fail "failure " instance Arbitrary Example where arbitrary = arbExample _ {- ??? -}
source share