@@ -44,8 +44,8 @@ instance Arbitrary Pattern where
4444 ]
4545 where sizedPats = do
4646 len <- choose (0,n)
47− let m = n `div` len in
48− vectorOf len $ pat m
47+ let m = n `div` (len + 1)
48+ vectorOf len $ pat m
4949
5050 shrink pat = case pat of
5151 PAnything -> []
@@ -64,22 +64,28 @@ instance Arbitrary Type where
6464 where tipe :: Int -> Gen Type
6565 tipe n = oneof [ Lambda <$> depthTipe <*> depthTipe
6666 , Var <$> lowVar
67− --, Data <$> capVar <*> listOf depthTipe
68− --, Record <$> listOf1 field <*> (Just <$> lowVar)
69− --, Record <$> listOf field <*> pure Nothing
67+ , Data <$> capVar <*> depthTipes
68+ , Record <$> fields <*> pure Nothing
69+ , Record <$> fields1 <*> (Just <$> lowVar)
7070 ]
71− where depthTipe :: Gen Type
72− depthTipe = do
73− m <- choose (0,n)
74− tipe m
75− field :: Gen (String, Type)
71+ where depthTipe = choose (0,n) >>= tipe
72+ depthTipes = do
73+ len <- choose (0,n)
74+ let m = n `div` (len + 1)
75+ vectorOf len $ tipe m
76+
7677 field = (,) <$> lowVar <*> depthTipe
77−
78+ fields = do
79+ len <- choose (0,n)
80+ let m = n `div` (len + 1)
81+ vectorOf len $ (,) <$> lowVar <*> tipe m
82+ fields1 = (:) <$> field <*> fields
83+
7884 shrink tipe = case tipe of
7985 Lambda s t -> s : t : (Lambda <$> shrink s <*> shrink t)
8086 Var _ -> []
81− Data n ts -> Data <$> shrinkWHead n <*> shrink ts
82− Record fs t -> case t of
87+ Data n ts -> ts ++ (Data <$> shrinkWHead n <*> shrink ts)
88+ Record fs t -> map snd fs ++ case t of
8389 Nothing -> Record <$> shrinkList shrinkField fs <*> pure Nothing
8490 Just _ ->
8591 do