File tree Expand file tree Collapse file tree 5 files changed +25
-20
lines changed
Expand file tree Collapse file tree 5 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,6 @@ instance Arbitrary a => Arbitrary (Bot a) where
2727 , (4 , Bot <$> arbitrary)
2828 ]
2929
30- instance CoArbitrary a => CoArbitrary (Bot a ) where
31- coarbitrary (Bot x) = coarbitrary x
32-
33- instance Function a => Function (Bot a ) where
34- function = functionMap (\ (Bot x) -> x) Bot
35-
3630{- -------------------------------------------------------------------
3731 Lazy functions
3832--------------------------------------------------------------------}
Original file line number Diff line number Diff line change @@ -1701,16 +1701,24 @@ prop_keysSet keys =
17011701prop_fromSet :: [Int ] -> Fun Int A -> Property
17021702prop_fromSet keys funF =
17031703 let f = apply funF
1704- in fromSet f (IntSet. fromList keys) === fromList (fmap (id &&& f) keys)
1704+ m = fromSet f (IntSet. fromList keys)
1705+ in
1706+ valid m .&&.
1707+ m === fromList (fmap (id &&& f) keys)
17051708
17061709prop_fromSetA_action_order :: [Int ] -> Fun Int A -> Property
17071710prop_fromSetA_action_order keys funF =
1708- let iSet = IntSet. fromList keys
1711+ let set = IntSet. fromList keys
1712+ setList = IntSet. toList set
17091713 f = apply funF
17101714 action = \ k ->
17111715 let v = f k
17121716 in tell [v] $> v
1713- in execWriter (fromSetA action iSet) === List. map f (IntSet. toList iSet)
1717+ (writtenMap, writtenOutput) = runWriter (fromSetA action set)
1718+ in
1719+ valid writtenMap .&&.
1720+ writtenOutput === List. map f setList .&&.
1721+ toList writtenMap === fmap (id &&& f) setList
17141722
17151723newtype Identity a = Identity a
17161724 deriving (Eq , Show )
Original file line number Diff line number Diff line change @@ -1723,16 +1723,24 @@ prop_argSet xs =
17231723prop_fromSet :: [OrdA ] -> Fun OrdA B -> Property
17241724prop_fromSet keys funF =
17251725 let f = apply funF
1726- in fromSet f (Set. fromList keys) === fromList (fmap (id &&& f) keys)
1726+ m = fromSet f (Set. fromList keys)
1727+ in
1728+ valid m .&&.
1729+ m === fromList (fmap (id &&& f) keys)
17271730
17281731prop_fromSetA_action_order :: [OrdA ] -> Fun OrdA B -> Property
17291732prop_fromSetA_action_order keys funF =
1730- let iSet = Set. fromList keys
1733+ let set = Set. fromList keys
1734+ setList = Set. toList set
17311735 f = apply funF
17321736 action = \ k ->
17331737 let v = f k
17341738 in tell [v] $> v
1735- in execWriter (fromSetA action iSet) === List. map f (Set. toList iSet)
1739+ (writtenMap, writtenOutput) = runWriter (fromSetA action set)
1740+ in
1741+ valid writtenMap .&&.
1742+ writtenOutput === List. map f setList .&&.
1743+ toList writtenMap === fmap (id &&& f) setList
17361744
17371745prop_fromArgSet :: [(OrdA , B )] -> Property
17381746prop_fromArgSet ys =
Original file line number Diff line number Diff line change @@ -3551,10 +3551,7 @@ fromSet f = runIdentity . fromSetA (pure . f)
35513551fromSetA :: Applicative f => (k -> f a ) -> Set. Set k -> f (Map k a )
35523552fromSetA _ Set. Tip = pure Tip
35533553fromSetA f (Set. Bin sz x l r) =
3554- flip (Bin sz x)
3555- <$> fromSetA f l
3556- <*> f x
3557- <*> fromSetA f r
3554+ liftA3 (flip (Bin sz x)) (fromSetA f l) (f x) (fromSetA f r)
35583555#if __GLASGOW_HASKELL__
35593556{-# INLINABLE fromSetA #-}
35603557#else
Original file line number Diff line number Diff line change @@ -1482,10 +1482,8 @@ fromSet f = runIdentity . fromSetA (pure . f)
14821482fromSetA :: Applicative f => (k -> f a ) -> Set. Set k -> f (Map k a )
14831483fromSetA _ Set. Tip = pure Tip
14841484fromSetA f (Set. Bin sz x l r) =
1485- flip (Bin sz x $! )
1486- <$> fromSetA f l
1487- <*> f x
1488- <*> fromSetA f r
1485+ liftA3 (flip (Bin sz x $! )) (fromSetA f l) (f x) (fromSetA f r)
1486+
14891487#if __GLASGOW_HASKELL__
14901488{-# INLINABLE fromSetA #-}
14911489#else
You can’t perform that action at this time.
0 commit comments