@@ -68,19 +68,20 @@ import Test.QuickCheck
6868 , Function (.. )
6969 , Property
7070 , Testable
71+ , arbitrarySizedIntegral
7172 , checkCoverage
7273 , choose
7374 , coarbitraryIntegral
7475 , coarbitraryShow
7576 , frequency
7677 , functionIntegral
78+ , functionMap
7779 , functionShow
7880 , listOf
7981 , scale
82+ , shrinkIntegral
8083 , shrinkMapBy
8184 )
82- import Test.QuickCheck.Instances.Natural
83- ()
8485
8586import qualified Data.MonoidMap as MonoidMap
8687import qualified Data.Text as Text
@@ -98,6 +99,26 @@ instance (Arbitrary k, Ord k, Arbitrary v, MonoidNull v) =>
9899 shrink =
99100 shrinkMapBy MonoidMap. fromMap MonoidMap. toMap shrink
100101
102+ instance (CoArbitrary k , CoArbitrary v ) =>
103+ CoArbitrary (MonoidMap k v )
104+ where
105+ coarbitrary = coarbitrary . MonoidMap. toMap
106+
107+ instance (Function k , Function v , Ord k , MonoidNull v ) =>
108+ Function (MonoidMap k v )
109+ where
110+ function = functionMap MonoidMap. toMap MonoidMap. fromMap
111+
112+ instance Arbitrary Natural where
113+ arbitrary = arbitrarySizedIntegral
114+ shrink = shrinkIntegral
115+
116+ instance CoArbitrary Natural where
117+ coarbitrary = coarbitraryIntegral
118+
119+ instance Function Natural where
120+ function = functionIntegral
121+
101122instance Arbitrary Text where
102123 arbitrary = Text. pack <$> listOf genChar
103124 where
@@ -177,11 +198,14 @@ testValueTypesAll =
177198 , TestValueType (Proxy @ (Text ))
178199 , TestValueType (Proxy @ [Int ])
179200 , TestValueType (Proxy @ [Natural ])
201+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Int )))
202+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
180203 ]
181204
182205testValueTypesGroup :: [TestValueType Group ]
183206testValueTypesGroup =
184207 [ TestValueType (Proxy @ (Sum Int ))
208+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Int )))
185209 ]
186210
187211testValueTypesMonus :: [TestValueType Monus ]
@@ -190,6 +214,7 @@ testValueTypesMonus =
190214 , TestValueType (Proxy @ (Set Int ))
191215 , TestValueType (Proxy @ (Set Natural ))
192216 , TestValueType (Proxy @ (Sum Natural ))
217+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
193218 ]
194219
195220testValueTypesLeftReductive :: [TestValueType LeftReductive ]
@@ -206,6 +231,7 @@ testValueTypesLeftReductive =
206231 , TestValueType (Proxy @ (Text ))
207232 , TestValueType (Proxy @ [Int ])
208233 , TestValueType (Proxy @ [Natural ])
234+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
209235 ]
210236
211237testValueTypesRightReductive :: [TestValueType RightReductive ]
@@ -222,6 +248,7 @@ testValueTypesRightReductive =
222248 , TestValueType (Proxy @ (Text ))
223249 , TestValueType (Proxy @ [Int ])
224250 , TestValueType (Proxy @ [Natural ])
251+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
225252 ]
226253
227254testValueTypesReductive :: [TestValueType Reductive ]
@@ -232,6 +259,7 @@ testValueTypesReductive =
232259 , TestValueType (Proxy @ (Set Natural ))
233260 , TestValueType (Proxy @ (Sum Int ))
234261 , TestValueType (Proxy @ (Sum Natural ))
262+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
235263 ]
236264
237265testValueTypesLeftGCDMonoid :: [TestValueType LeftGCDMonoid ]
@@ -242,6 +270,7 @@ testValueTypesLeftGCDMonoid =
242270 , TestValueType (Proxy @ (Set Natural ))
243271 , TestValueType (Proxy @ (Sum Natural ))
244272 , TestValueType (Proxy @ (Text ))
273+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
245274 ]
246275
247276testValueTypesRightGCDMonoid :: [TestValueType RightGCDMonoid ]
@@ -252,6 +281,7 @@ testValueTypesRightGCDMonoid =
252281 , TestValueType (Proxy @ (Set Natural ))
253282 , TestValueType (Proxy @ (Sum Natural ))
254283 , TestValueType (Proxy @ (Text ))
284+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
255285 ]
256286
257287testValueTypesOverlappingGCDMonoid :: [TestValueType OverlappingGCDMonoid ]
@@ -262,6 +292,7 @@ testValueTypesOverlappingGCDMonoid =
262292 , TestValueType (Proxy @ (Set Natural ))
263293 , TestValueType (Proxy @ (Sum Natural ))
264294 , TestValueType (Proxy @ (Text ))
295+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
265296 ]
266297
267298testValueTypesGCDMonoid :: [TestValueType GCDMonoid ]
@@ -270,6 +301,7 @@ testValueTypesGCDMonoid =
270301 , TestValueType (Proxy @ (Set Int ))
271302 , TestValueType (Proxy @ (Set Natural ))
272303 , TestValueType (Proxy @ (Sum Natural ))
304+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
273305 ]
274306
275307testValueTypesLCMMonoid :: [TestValueType LCMMonoid ]
@@ -278,6 +310,7 @@ testValueTypesLCMMonoid =
278310 , TestValueType (Proxy @ (Set Int ))
279311 , TestValueType (Proxy @ (Set Natural ))
280312 , TestValueType (Proxy @ (Sum Natural ))
313+ , TestValueType (Proxy @ (MonoidMap Ordering (Sum Natural )))
281314 ]
282315
283316--------------------------------------------------------------------------------
0 commit comments