hedgehog-0.5.2: Hedgehog will eat all your bugs.

Safe HaskellSafe
LanguageHaskell98

Hedgehog.Internal.Shrink

Synopsis

Documentation

towards :: Integral a => a -> a -> [a] Source #

Shrink an integral number by edging towards a destination.

>>> towards 0 100
[0,50,75,88,94,97,99]
>>> towards 500 1000
[500,750,875,938,969,985,993,997,999]
>>> towards (-50) (-26)
[-50,-38,-32,-29,-27]

Note we always try the destination first, as that is the optimal shrink.

towardsFloat :: RealFloat a => a -> a -> [a] Source #

Shrink a floating-point number by edging towards a destination.

>>> take 7 (towardsFloat 0.0 100)
[0.0,50.0,75.0,87.5,93.75,96.875,98.4375]
>>> take 7 (towardsFloat 1.0 0.5)
[1.0,0.75,0.625,0.5625,0.53125,0.515625,0.5078125]

Note we always try the destination first, as that is the optimal shrink.

list :: [a] -> [[a]] Source #

Shrink a list by edging towards the empty list.

>>> list [1,2,3]
[[],[2,3],[1,3],[1,2]]
>>> list "abcd"
["","cd","ab","bcd","acd","abd","abc"]

Note we always try the empty list first, as that is the optimal shrink.

halves :: Integral a => a -> [a] Source #

Produce a list containing the progressive halving of an integral.

>>> halves 15
[15,7,3,1]
>>> halves 100
[100,50,25,12,6,3,1]
>>> halves (-26)
[-26,-13,-6,-3,-1]

removes :: Int -> [a] -> [[a]] Source #

Produce all permutations of removing k elements from a list.

>>> removes 2 "abcdef"
["cdef","abef","abcd"]

consNub :: Eq a => a -> [a] -> [a] Source #

Cons an element on to the front of a list unless it is already there.