
Dear all, I'm trying to work out how to use QuickCheck 2 (installed via apt-get from the Ubuntu repositories) and in the process keep managing to get the quickCheck function (called under GHCi 6.10.4) to enter what appears to be an infinite loop. Evidently, I'm doing something wrong ... Here's the problem: I have a module for types, and it exports a datatype called "Type". I make this an instance of Arbitrary, like so: instance (Eq a, Arbitrary a) => Arbitrary (Type a) where arbitrary = oneof [ liftM tyVar arbitrary, liftM2 tyCon arbitrary arbitrary] Here, tyVar and tyCon are two functions injecting into Types. I then write two silly properties to test whether this works. The first property: prop_InjectTypeVarFreeVar var = (freeTypeVars . tyVar) var == [tyVar var] Works fine. A call to quickCheck gives me the familiar "100 tests passed" message. The second property: prop_InjectTypeConFreeVars args = (freeTypeVars . (tyCon "Fun")) args == (concatMap freeTypeVars args) Sends quickCheck into an infinite loop of some sort. It manages to get through 5-6 tests before GHCi is brought to its knees. Before I go crazy, can anybody explain what I'm doing wrong? Many thanks in advance, Dominic

On Thu, Jan 21, 2010 at 10:05:20PM +0000, Dominic Mulligan wrote:
The second property:
prop_InjectTypeConFreeVars args = (freeTypeVars . (tyCon "Fun")) args == (concatMap freeTypeVars args)
Sends quickCheck into an infinite loop of some sort. It manages to get through 5-6 tests before GHCi is brought to its knees. Before I go crazy, can anybody explain what I'm doing wrong?
What type is 'args'? Sounds to me more like a combinatorial explosion of some sort rather than an actual infinite loop. -Brent
participants (2)
-
Brent Yorgey
-
Dominic Mulligan