Hedgehog.ShrinkSourcePure shrinking strategies.
These functions produce lists of shrunk alternatives from a value. They are used by generators to build shrink trees.
towards destination x shrinks x by edging towards destination.
towards 0 100 = [0; 50; 75; 88; 94; 97; 99]
towards 500 1000 = [500; 750; 875; ...]The destination is always tried first, as that is the optimal shrink.
towards_float destination x shrinks a float towards destination.
towards_int64 destination x shrinks an int64 towards destination, using binary-search halving. Same algorithm as towards but with Int64 arithmetic.
Progressive halving of an integral.
halves 15 = [ 15; 7; 3; 1 ] halves 100 = [ 100; 50; 25; 12; 6; 3; 1 ]Shrink a list by edging towards the empty list.
list [ 1; 2; 3 ] = [ []; [ 2; 3 ]; [ 1; 3 ]; [ 1; 2 ] ]removes k xs produces all permutations of removing k elements from xs.
removes 2 [ 'a'; 'b'; 'c'; 'd'; 'e'; 'f' ]
= [ [ 'c'; 'd'; 'e'; 'f' ]; [ 'a'; 'b'; 'e'; 'f' ]; [ 'a'; 'b'; 'c'; 'd' ] ]cons_nub x ys prepends x to ys unless x equals the head of ys.