module Test.QuickCheck.DynamicLogic.SmartShrinking (shrinkSmart) where
import Test.QuickCheck
shrinkSmart :: (a -> [a]) -> Smart a -> [Smart a]
shrinkSmart :: forall a. (a -> [a]) -> Smart a -> [Smart a]
shrinkSmart a -> [a]
shr (Smart Int
i a
x) = forall a. Int -> [a] -> [a]
take Int
i' [Smart a]
ys forall {a}. [a] -> [a] -> [a]
`ilv` forall a. Int -> [a] -> [a]
drop Int
i' [Smart a]
ys
where
ys :: [Smart a]
ys = [forall a. Int -> a -> Smart a
Smart Int
j a
y | (Int
j, a
y) <- [Int
0 ..] forall a b. [a] -> [b] -> [(a, b)]
`zip` a -> [a]
shr a
x]
i' :: Int
i' = Int
0 forall a. Ord a => a -> a -> a
`max` (Int
i forall a. Num a => a -> a -> a
- Int
2)
[] ilv :: [a] -> [a] -> [a]
`ilv` [a]
bs = [a]
bs
[a]
as `ilv` [] = [a]
as
(a
a : [a]
as) `ilv` (a
b : [a]
bs) = a
a forall a. a -> [a] -> [a]
: a
b forall a. a -> [a] -> [a]
: ([a]
as [a] -> [a] -> [a]
`ilv` [a]
bs)