mitch
09/23/2021, 11:35 AMEmil Kantis
09/23/2021, 11:37 AMmitch
09/23/2021, 11:37 AMEmil Kantis
09/23/2021, 11:37 AMmitch
09/23/2021, 11:42 AM#. value shrinks
arb1 -> v 5 3 1 0
arb2 -> v. v v v v (that has no shrinks)
arb3 -> v. a b b b (2 shrinks pad last entry)
arb4 -> v. 0 0 0 0 (1 shrink, pad last entry)
that’ll reduce the space and computational complexity from exponential O(n^k) to linear O(n)
now i’m quite sure that is correct, but let me look into some references first[].flatMap [a, b, c] --> []
/** Shrink instance of 4-tuple */
implicit def shrinkTuple4[
T1:Shrink, T2:Shrink, T3:Shrink, T4:Shrink
]: Shrink[(T1,T2,T3,T4)] =
Shrink { case (t1,t2,t3,t4) =>
shrink(t1).map((_, t2, t3, t4)) append
shrink(t2).map((t1, _, t3, t4)) append
shrink(t3).map((t1, t2, _, t4)) append
shrink(t4).map((t1, t2, t3, _))
}
#. value shrinks
arb1 -> v1 5 3 1 0
arb2 -> v2 (no shrinks)
arb3 -> v3 a b
arb4 -> v4 0
you’d get 4 lists of shrinks
#1
[
bindFn(5, v2, v3, v4),
bindFn(3, v2, v3, v4),
bindFn(1, v2, v3, v4),
bindFn(0, v2, v3, v4)
]
#2
[] // empty because of emptyList<>.map(...) == emptylist
#3
[
bindFn(v1, a, v3, v4),
bindFn(v1, b, v3, v4),
]
#4
[
bindFn(v1, v2, v3, 0)
]
finalShrinks = shrinks1 + shrinks2 + shrinks3 + shrinks4
sam
09/23/2021, 12:12 PMmitch
09/23/2021, 12:14 PM// shrinking one by one is the not the most comprehensive
// but allows a reasonable number of entries in the shrink
sam
09/23/2021, 12:15 PMEmil Kantis
09/23/2021, 9:38 PMmitch
09/24/2021, 3:31 AMsam
09/24/2021, 3:39 AM