I have 

data Tweet = Tweet {
    user :: String,
    text :: String,
    retweets :: Double
    } deriving (Show)

data TweetSet = NoTweets | SomeTweets Tweet TweetSet TweetSet

and trying to create some generators for testing, with

instance Arbitrary Tweet where
  arbitrary = liftM3 Tweet arbitrary arbitrary arbitrary 
  
instance Arbitrary TweetSet where
  arbitrary = sized set'
    where set' 0 = return NoTweets
          set' n | n>0 = oneof[return NoTweets, liftM3 SomeTweets
          arbitrary subTweets subTweets]
            where subTweets = set' (n `div` 2) 

but wondering how I would go about generating a random TweetSet that
contains a known random Tweet I later have reference to and I would also
assume the known Tweet to be placed randomly.

Then I could test a contains function.

Thanks

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to