smallcheck series forever bug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}

-- The below code displays a long (possibly infinite) list of a,b pair trees, deeper and deeper
-- but what I was expecting was that the "list 1" would only go one deep. (and indeed I think an
-- older version of smallcheck was behaving that way for me)
-- This is with smallcheck 1.0.1

import Test.SmallCheck.Series

import Control.Monad.Identity

import GHC.Generics

data Foo = A | B | Pair Foo Foo deriving Show

deriving instance Generic Foo
instance (Monad m) => Serial m Foo


main = do
  putStrLn "test"
  let a = list 1 (series :: Series Identity Foo)
  print a

-- the smallcheck-0.6.1 version which gives [A,B] as output is:
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PackageImports #-}

import Test.SmallCheck.Series

import Control.Monad.Identity

import GHC.Generics

data Foo = A | B | Pair Foo Foo deriving Show

deriving instance Generic Foo
instance Serial Foo


main = do
  putStrLn "test"
  let a = (series :: Series Foo) 1
  print a

-- and this can be compiled with
--   ghc -package smallcheck-0.6.1 smallchecktest-0.6.hs