I want to generate values, so that i have some arbitrary object, which has a certain set of signals, and each set of signals has a certain set of sensor value pairs, were the values are arbitrary.
However to demonstrate my problem I have an easy example, were I want to generate an instance of
data QCExample = QCExample Int Int
deriving Show
and the second value should always be the double of the first. So I tried this:
instance Arbitrary QCExample where
arbitrary =
let i1 = arbitrary
i2 = fmap (* 2) i1
in liftM2 QCExample i1 i2
but showing some of the generated test cases in ghci does not give me what I expected:
let gen :: Gen (QCExample) = arbitrary
Test.QuickCheck.Gen.sample gen
> QCExample (-2) 0
> QCExample (-4) (-6)
> QCExample 3 30
> ...
I know that I can filter, but this would be to inefficient.
Jürgen