mitch
09/11/2021, 1:51 PMsam
09/11/2021, 2:15 PMGavin Ray
09/11/2021, 4:02 PMmitch
09/15/2021, 12:05 AMsam
09/15/2021, 12:06 AMsam
09/15/2021, 12:06 AMmitch
09/15/2021, 12:07 AMmitch
09/15/2021, 12:10 AM// from this
fun <T> arbitrary(fn: (RandomSource) -> T): Arb<T>
// to this
fun <T> arbitrary(fn: suspend ArbitraryBuilderSyntax.(RandomSource) -> T): Arb<T>
and that’ll generate a different function
class BuildersKt {
static Arb<T> arbitrary(Continuation, ArbitraryBuilderSyntax, RandomSource -> T) ...
}
mitch
09/15/2021, 12:10 AMsam
09/15/2021, 12:10 AMmitch
09/15/2021, 12:10 AMsam
09/15/2021, 12:12 AMfun <T> fix(fn: suspend ArbitraryBuilderSyntax.(RandomSource) -> T): Arb<T>
not sure what the name should bemitch
09/15/2021, 12:16 AMfun <T> gen(fn: suspend GenBuilderSyntax.(RandomSource) -> T): Gen<T>
or in a different package
package io.kotest.property.arbitrary.builders
fun <T> arb(fn: suspend GenBuilderSyntax.(RandomSource) -> T): Arb<T>
I just realized we can also support Exhaustive<T>.bind()
if you’re cool with it.sam
09/15/2021, 12:17 AMmitch
09/15/2021, 12:17 AMsam
09/15/2021, 12:18 AMsam
09/15/2021, 12:18 AMmitch
09/15/2021, 12:18 AMsam
09/15/2021, 12:19 AMmitch
09/15/2021, 12:19 AMsam
09/15/2021, 12:19 AMsam
09/15/2021, 12:19 AMsam
09/15/2021, 12:19 AMmitch
09/15/2021, 12:19 AM.computation
packagesam
09/15/2021, 12:20 AMmitch
09/15/2021, 12:20 AMsam
09/15/2021, 12:20 AMsam
09/15/2021, 12:20 AMmitch
09/15/2021, 12:21 AMsam
09/15/2021, 12:22 AMmitch
09/15/2021, 12:23 AMArb.bind {
val one = arbOne.bind()
val two = arbTwo(one).bind()
Foo(one, two)
}
or
bind {
val one = arbOne.bind()
val two = arbTwo(one).bind()
Foo(one, two)
}
I personally like the lattermitch
09/15/2021, 12:23 AMarbitrary {
val one = arbOne.bind()
val two = arbTwo(one).bind()
Foo(one, two)
}
sam
09/15/2021, 12:27 AMeither {
val a = myeither.either()
val b = myeither2.either()
}
mitch
09/15/2021, 12:31 AMarrow.core.computations.either
and arrow.core.computations.option
either {
val a = myeither.bind()
val b = myeither2.bind()
b
}
the nomenclature is also the same, .bind()
sam
09/15/2021, 12:31 AMmitch
09/15/2021, 12:33 AMval flowValue: Flow<X> = flow {
...
}
val eitherValue: Either<L, R> = either {
...
}
val sequenceValue: Sequence<A> = sequence {
...
}
sam
09/15/2021, 12:34 AMsam
09/15/2021, 12:34 AMsam
09/15/2021, 12:34 AMsam
09/15/2021, 12:34 AMsam
09/15/2021, 12:34 AMmitch
09/15/2021, 12:35 AMmitch
09/15/2021, 12:37 AMsequence
is suspend, generateSequence
is non-suspend,
• arbitrary
is non-suspend, generateArbitrary
is suspend
we’ve flipped the definition in stdlib. does that matter?sam
09/15/2021, 12:38 AMsam
09/15/2021, 12:39 AMsam
09/15/2021, 12:39 AMmitch
09/15/2021, 12:40 AMmitch
09/15/2021, 12:41 AMsam
09/15/2021, 12:42 AMsam
09/15/2021, 12:42 AMarbitrary { delay(100) }
sam
09/15/2021, 12:42 AMmitch
09/15/2021, 12:46 AMarbitrary { delay(100) }
currently arbitrary isn’t inlinesam
09/15/2021, 12:46 AMsam
09/15/2021, 12:46 AMsam
09/15/2021, 12:46 AMsam
09/15/2021, 12:47 AMmitch
09/15/2021, 12:49 AMsam
09/15/2021, 12:49 AMsam
09/15/2021, 12:49 AMmitch
09/15/2021, 12:50 AMsam
09/15/2021, 12:50 AMsam
09/15/2021, 12:50 AMsam
09/15/2021, 12:50 AMmitch
09/15/2021, 12:50 AMsam
09/15/2021, 12:52 AMmitch
09/15/2021, 12:53 AMmitch
09/17/2021, 8:59 PMgenerateSequence
isn’t suspendmitch
09/17/2021, 8:59 PMsam
09/17/2021, 9:00 PMsam
09/17/2021, 9:00 PMmitch
09/17/2021, 9:02 PMmitch
09/17/2021, 9:02 PMsam
09/17/2021, 9:03 PMmitch
09/17/2021, 9:48 PMcoXYZ
, i don't like it but it's an idea, 🤔 another idea that i got is suspendArbitrary
mitch
09/17/2021, 9:49 PMmitch
09/17/2021, 10:13 PMmitch
09/17/2021, 10:13 PMmitch
09/17/2021, 11:49 PM