Closed jwaldmann closed 5 years ago
@jwaldmann This is definitely a bug. Thank you for reporting. I'll have a new minor version of LeanCheck (v0.9.1) released on Hackage with the fix at the latest in a couple days.
You are right about the cause of the bug: an application of addWeight
or delay
is missing in at least one place in Test.LeanCheck.Generic
:
instance Listable c => Listable' (K1 i c) where
tiers' = mapT K1 tiers
should be
instance Listable c => Listable' (K1 i c) where
tiers' = delay $ mapT K1 tiers
There may be a couple other places where I should add delay
. I'll add some tests first :-) with a few different recursive types to make sure I'm not missing anything. My test files for the generic derivation are missing recursive types!
I'll probably want to try to make the genericTiers
enumeration the same as the one produced by TH
for consistency.
Hi, thanks for the quick response.
I'll probably want to try to make the genericTiers enumeration the same as the one produced by TH for consistency.
Yes that would be ideal. And you could easily test it automatically.
@jwaldmann The bug is fixed:
$ cabal update
$ cabal install leancheck
Resolving dependencies...
Downloading leancheck-0.9.1
Downloaded leancheck-0.9.1
Starting leancheck-0.9.1
Building leancheck-0.9.1
Completed leancheck-0.9.1
$ ghci -XDeriveGeneric
> import GHC.Generics
> import Test.LeanCheck
> import Test.LeanCheck.Generic
> data P = Q | R P deriving (Show, Generic)
> instance Listable P where tiers = genericTiers
> take 6 $ tiers :: [[P]]
[[Q],[R Q],[R (R Q)],[R (R (R Q))],[R (R (R (R Q)))],[R (R (R (R (R Q))))]]
I have released leancheck-0.9.1 with the fix, commits: a5ec90fa2dfddeae85bbf082cd13a212068a4e28 and a9e126a11db8c3d16a5fa9f740b398c195ed4c2a.
In addition to the fix, I have added a few automated tests using recursive types (5756b48f5b7e195fec19f6f272b2f225a985080d) and automated tests of consistency between deriveTiers
and genericTiers
(ce850e2e9d122c98dfbcfaaf658bad6f861aa321).
@jwaldmann Thanks again for the bug report.
This does not work (there is no output)
I guess that
addWeight
is missing somewhere. But where exactly?This variant is OK (where we get the extra weight by going through
Maybe
on recursion)