@@ -237,38 +237,50 @@ constructWithFromIndicesM op len =
237237applicativeOps
238238 :: Applicative (t IO)
239239 => ([Int] -> t IO Int)
240+ -> String
240241 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
241242 -> (t IO (Int, Int) -> SerialT IO (Int, Int))
242− -> ([Int], [Int])
243− -> Property
244−applicativeOps constr eq t (a, b) = withMaxSuccess maxTestCount $
245− monadicIO $ do
246− stream <- run ((S.toList . t) ((,) <$> constr a <*> constr b))
247− let list = (,) <$> a <*> b
248− listEquals eq stream list
249−
250− stream1 <- run ((S.toList . t) (liftA2 (,) (constr a) (constr b)))
251− listEquals eq stream1 list
243+ -> Spec
244+applicativeOps constr desc eq t = do
245+ prop (desc <> " <*>") $
246+ transformFromList2
247+ constr
248+ eq
249+ (\a b -> (,) <$> a <*> b)
250+ (\a b -> t ((,) <$> a <*> b))
251+ prop (desc <> " liftA2") $
252+ transformFromList2 constr eq (liftA2 (,)) (\a b -> t $ liftA2 (,) a b)
252253
253254-- XXX we can combine this with applicativeOps by making the type sufficiently
254255-- polymorphic.
255256applicativeOps1
256257 :: Applicative (t IO)
257258 => ([Int] -> t IO Int)
259+ -> String
258260 -> ([Int] -> [Int] -> Bool)
259261 -> (t IO Int -> SerialT IO Int)
260− -> ([Int], [Int])
261− -> Property
262−applicativeOps1 constr eq t (a, b) = withMaxSuccess maxTestCount $
262+ -> Spec
263+applicativeOps1 constr desc eq t = do
264+ prop (desc <> " *>") $
265+ transformFromList2 constr eq (*>) (\a b -> t (a *> b))
266+ prop (desc <> " <*") $
267+ transformFromList2 constr eq (<*) (\a b -> t (a <* b))
268+
269+transformFromList2
270+ :: (Eq c, Show c)
271+ => ([a] -> t IO a)
272+ -> ([c] -> [c] -> Bool)
273+ -> ([a] -> [a] -> [c])
274+ -> (t IO a -> t IO a -> SerialT IO c)
275+ -> ([a], [a])
276+ -> Property
277+transformFromList2 constr eq listOp op (a, b) =
278+ withMaxSuccess maxTestCount $
263279 monadicIO $ do
264− stream <- run ((S.toList . t) (constr a *> constr b))
265− let list = a *> b
280+ stream <- run (S.toList $ op (constr a) (constr b))
281+ let list = listOp a b
266282 listEquals eq stream list
267283
268− stream1 <- run ((S.toList . t) (constr a <* constr b))
269− let list1 = a <* b
270− listEquals eq stream1 list1
271−
272284-------------------------------------------------------------------------------
273285-- Elimination operations
274286-------------------------------------------------------------------------------
@@ -432,7 +444,7 @@ eliminationOpsWord8 constr desc t = do
432444-------------------------------------------------------------------------------
433445
434446functorOps
435− :: Functor (t IO)
447+ :: (Functor (t IO), Semigroup (t IO Int))
436448 => ([Int] -> t IO Int)
437449 -> String
438450 -> ([Int] -> [Int] -> Bool)