From ee22816e7275f90c200c75878ed454f4738f6504 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Tue, 2 Aug 2022 17:14:28 +0200 Subject: [PATCH 01/13] Remove Tuple10 to Tuple22, Const, and Eval --- .../src/commonMain/kotlin/arrow/core/Const.kt | 176 ------ .../src/commonMain/kotlin/arrow/core/Eval.kt | 566 ------------------ .../commonMain/kotlin/arrow/core/Tuple10.kt | 57 -- .../commonMain/kotlin/arrow/core/TupleN.kt | 283 +-------- .../kotlin/examples/example-eval-01.kt | 21 - .../kotlin/examples/example-eval-02.kt | 9 - .../kotlin/examples/example-eval-03.kt | 9 - .../kotlin/examples/example-eval-04.kt | 9 - 8 files changed, 2 insertions(+), 1128 deletions(-) delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Const.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Eval.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Tuple10.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-01.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-02.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-03.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-04.kt diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Const.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Const.kt deleted file mode 100644 index 4d09516f9b5..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Const.kt +++ /dev/null @@ -1,176 +0,0 @@ -package arrow.core - -import arrow.typeclasses.Semigroup - -public data class Const(private val value: A) { - - @Suppress("UNCHECKED_CAST") - public fun retag(): Const = - this as Const - - public companion object {} - - public fun value(): A = - value - - public fun map(f: (T) -> U): Const = - retag() - - public inline fun zip( - SG: Semigroup, - b: Const, - map: (T, B) -> C - ): Const = - retag().combine(SG, b.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - map: (T, B, C) -> D - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - map: (T, B, C, D) -> E - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - e: Const, - map: (T, B, C, D, E) -> F - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - .combine(SG, e.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - e: Const, - f: Const, - map: (A, B, C, D, E, F) -> G - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - .combine(SG, e.retag()) - .combine(SG, f.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - e: Const, - f: Const, - g: Const, - map: (A, B, C, D, E, F, G) -> H - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - .combine(SG, e.retag()) - .combine(SG, f.retag()) - .combine(SG, g.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - e: Const, - f: Const, - g: Const, - h: Const, - map: (A, B, C, D, E, F, G, H) -> I - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - .combine(SG, e.retag()) - .combine(SG, f.retag()) - .combine(SG, g.retag()) - .combine(SG, h.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - e: Const, - f: Const, - g: Const, - h: Const, - i: Const, - map: (A, B, C, D, E, F, G, H, I) -> J - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - .combine(SG, e.retag()) - .combine(SG, f.retag()) - .combine(SG, g.retag()) - .combine(SG, h.retag()) - .combine(SG, i.retag()) - - public inline fun zip( - SG: Semigroup, - b: Const, - c: Const, - d: Const, - e: Const, - f: Const, - g: Const, - h: Const, - i: Const, - j: Const, - map: (A, B, C, D, E, F, G, H, I, J) -> K - ): Const = - retag() - .combine(SG, b.retag()) - .combine(SG, c.retag()) - .combine(SG, d.retag()) - .combine(SG, e.retag()) - .combine(SG, f.retag()) - .combine(SG, g.retag()) - .combine(SG, h.retag()) - .combine(SG, i.retag()) - .combine(SG, j.retag()) - - override fun toString(): String = - "$Const($value)" -} - -public fun Const.combine(SG: Semigroup, that: Const): Const = - Const(SG.run { this@combine.value().combine(that.value()) }) - -public inline fun A.const(): Const = - Const(this) - -public fun Const.contramap(f: (U) -> T): Const = - retag() - -public operator fun , T> Const.compareTo(other: Const): Int = - value().compareTo(other.value()) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Eval.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Eval.kt deleted file mode 100644 index d3c73905223..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Eval.kt +++ /dev/null @@ -1,566 +0,0 @@ -package arrow.core - -import arrow.typeclasses.Monoid -import kotlin.js.JsName -import kotlin.jvm.JvmStatic - -/** - * Eval is a monad which controls evaluation of a value or a computation that produces a value. - * - * Three basic evaluation strategies: - * - * - Now: evaluated immediately - * - Later: evaluated once when value is needed - * - Always: evaluated every time value is needed - * - * The Later and Always are both lazy strategies while Now is eager. - * Later and Always are distinguished from each other only by - * memoization: once evaluated Later will save the value to be returned - * immediately if it is needed again. Always will run its computation - * every time. - * - * methods, which use an internal trampoline to avoid stack overflows. - * Computation done within .map and .flatMap is always done lazily, - * even when applied to a Now instance. - * - * It is not generally good style to pattern-match on Eval instances. - * Rather, use .map and .flatMap to chain computation, and use .value - * to get the result when needed. It is also not good style to create - * Eval instances whose computation involves calling .value on another - * Eval instance -- this can defeat the trampolining and lead to stack - * overflows. - * - * Example of stack safety: - * - * ```kotlin - * import arrow.core.Eval - * - * //sampleStart - * fun even(n: Int): Eval = - * Eval.always { n == 0 }.flatMap { - * if(it == true) Eval.now(true) - * else odd(n - 1) - * } - * - * fun odd(n: Int): Eval = - * Eval.always { n == 0 }.flatMap { - * if(it == true) Eval.now(false) - * else even(n - 1) - * } - * - * // if not wrapped in eval this type of computation would blow the stack and result in a StackOverflowError - * fun main() { - * println(odd(100000).value()) - * } - * //sampleEnd - * ``` - * - * - */ -public sealed class Eval { - - public companion object { - - /** - * Creates an Eval instance from an already constructed value but still defers evaluation when chaining expressions with `map` and `flatMap` - * - * @param a is an already computed value of type [A] - * - * ```kotlin - * import arrow.core.* - * - * fun main() { - * //sampleStart - * val eager = Eval.now(1).map { it + 1 } - * println(eager.value()) - * //sampleEnd - * } - * ``` - * - * - * It will return 2. - */ - @JvmStatic - public fun now(a: A): Eval = - Now(a) - - /** - * Creates an Eval instance from a function deferring it's evaluation until `.value()` is invoked memoizing the computed value. - * - * @param f is a function or computation that will be called only once when `.value()` is invoked for the first time. - * - * ```kotlin - * import arrow.core.* - * - * fun main() { - * //sampleStart - * val lazyEvaled = Eval.later { "expensive computation" } - * println(lazyEvaled.value()) - * //sampleEnd - * } - * ``` - * - * - * "expensive computation" is only computed once since the results are memoized and multiple calls to `value()` will just return the cached value. - */ - @JvmStatic - public inline fun later(crossinline f: () -> A): Later = - Later { f() } - - /** - * Creates an Eval instance from a function deferring it's evaluation until `.value()` is invoked recomputing each time `.value()` is invoked. - * - * @param f is a function or computation that will be called every time `.value()` is invoked. - * - * ```kotlin - * import arrow.core.* - * - * fun main() { - * //sampleStart - * val alwaysEvaled = Eval.always { "expensive computation" } - * println(alwaysEvaled.value()) - * //sampleEnd - * } - * ``` - * - * - * "expensive computation" is computed every time `value()` is invoked. - */ - @JvmStatic - public inline fun always(crossinline f: () -> A): Always = - Always { f() } - - @JvmStatic - public inline fun defer(crossinline f: () -> Eval): Eval = - Defer { f() } - - @JvmStatic - public fun raise(t: Throwable): Eval = - defer { throw t } - - /** - * Collapse the call stack for eager evaluations. - */ - private tailrec fun collapse(fa: Eval): Eval = - when (fa) { - is Defer -> collapse(fa.thunk()) - is FlatMap -> - object : FlatMap() { - override fun start(): Eval = fa.start() - override fun run(s: S): Eval = collapse1(fa.run(s)) - } - else -> fa - } - - // Enforce tailrec call to collapse inside compute loop - private fun collapse1(fa: Eval): Eval = collapse(fa) - - @Suppress("UNCHECKED_CAST") - private fun evaluate(e: Eval): A = run { - var curr: Eval = e - val fs: MutableList<(Any?) -> Eval> = mutableListOf() - - fun addToMemo(m: Memoize): (Any?) -> Eval = { - m.result = Some(it) - now(it) - } - - loop@ while (true) { - when (curr) { - is FlatMap -> { - val currComp = curr as FlatMap - currComp.start().let { cc -> - when (cc) { - is FlatMap -> { - curr = cc.start() - fs.add(0, currComp::run) - fs.add(0, cc::run) - } - is Memoize -> { - cc.result.fold( - { - curr = cc.eval - fs.add(0, currComp::run) - fs.add(0, addToMemo(cc as Memoize)) - }, - { - curr = Now(it) - fs.add(0, currComp::run) - } - ) - } - else -> { - curr = currComp.run(cc.value()) - } - } - } - } - is Memoize -> { - val currComp = curr as Memoize - val eval = currComp.eval - currComp.result.fold( - { - curr = eval - fs.add(0, addToMemo(currComp)) - }, - { - if (fs.isNotEmpty()) { - curr = fs[0](it) - fs.removeAt(0) - } - } - ) - } - else -> - if (fs.isNotEmpty()) { - curr = fs[0](curr.value()) - fs.removeAt(0) - } else { - break@loop - } - } - } - - return curr.value() as A - } - } - - public abstract fun value(): A - - public abstract fun memoize(): Eval - - public inline fun map(crossinline f: (A) -> B): Eval = - flatMap { a -> Now(f(a)) } - - @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE", "UNCHECKED_CAST") - public fun flatMap(f: (A) -> Eval): Eval = - when (this) { - is FlatMap -> object : FlatMap() { - override fun start(): Eval = (this@Eval).start() - - // @IgnoreJRERequirement - override fun run(s: S): Eval = - object : FlatMap() { - override fun start(): Eval = (this@Eval).run(s) as Eval - override fun run(s1: S1): Eval = f(s1 as A) - } - } - is Defer -> object : FlatMap() { - override fun start(): Eval = this@Eval.thunk() as Eval - override fun run(s: S): Eval = f(s as A) - } - else -> object : FlatMap() { - override fun start(): Eval = this@Eval as Eval - override fun run(s: S): Eval = f(s as A) - } - } - - public inline fun coflatMap(crossinline f: (Eval) -> B): Eval = - Later { f(this) } - - /** - * Construct an eager Eval instance. In some sense it is equivalent to using a val. - * - * This type should be used when an A value is already in hand, or when the computation to produce an A value is - * pure and very fast. - */ - public data class Now(@JsName("_value") val value: A) : Eval() { - override fun value(): A = value - override fun memoize(): Eval = this - - override fun toString(): String = - "Eval.Now($value)" - - public companion object { - @PublishedApi - internal val unit: Eval = Now(Unit) - } - } - - /** - * Construct a lazy Eval instance. - * - * This type should be used for most "lazy" values. In some sense it is equivalent to using a lazy val. - * - * When caching is not required or desired (e.g. if the value produced may be large) prefer Always. When there - * is no computation necessary, prefer Now. - * - * Once Later has been evaluated, the closure (and any values captured by the closure) will not be retained, and - * will be available for garbage collection. - */ - public data class Later(private val f: () -> A) : Eval() { - @JsName("_name") - val value: A by lazy(f) - - override fun value(): A = value - override fun memoize(): Eval = this - - override fun toString(): String = - "Eval.Later(f)" - } - - /** - * Construct a lazy Eval instance. - * - * This type can be used for "lazy" values. In some sense it is equivalent to using a Function0 value. - * - * This type will evaluate the computation every time the value is required. It should be avoided except when - * laziness is required and caching must be avoided. Generally, prefer Later. - */ - public data class Always(private val f: () -> A) : Eval() { - override fun value(): A = f() - override fun memoize(): Eval = Later(f) - - override fun toString(): String = - "Eval.Always(f)" - } - - /** - * Defer is a type of Eval that is used to defer computations which produce Eval. - * - * Users should not instantiate Defer instances themselves. Instead, they will be automatically created when needed. - */ - public data class Defer(val thunk: () -> Eval) : Eval() { - override fun memoize(): Eval = Memoize(this) - override fun value(): A = collapse(this).value() - - override fun toString(): String = - "Eval.Defer(thunk)" - } - - /** - * FlatMap is a type of Eval that is used to chain computations involving .map and .flatMap. Along with - * Eval#flatMap. It implements the trampoline that guarantees stack-safety. - * - * Users should not instantiate FlatMap instances themselves. Instead, they will be automatically created when - * needed. - * - * Unlike a traditional trampoline, the internal workings of the trampoline are not exposed. This allows a slightly - * more efficient implementation of the .value method. - */ - public abstract class FlatMap : Eval() { - public abstract fun start(): Eval - public abstract fun run(s: S): Eval - override fun memoize(): Eval = Memoize(this) - override fun value(): A = evaluate(this) - - override fun toString(): String = - "Eval.FlatMap(..)" - } - - /** - * Memoize is a type of Eval that is used to memoize an eval value. Unlike Later, Memoize exposes its cache, - * allowing Eval's internal trampoline to compute it when needed. - * - * Users should not instantiate Memoize instances themselves. Instead, they will be automatically created when - * needed. - */ - internal data class Memoize(val eval: Eval) : Eval() { - var result: Option = None - override fun memoize() = this - override fun value(): A = result.getOrElse { - evaluate(eval).also { result = Some(it) } - } - - override fun toString(): String = - "Eval.Memoize($eval)" - } - - override fun toString(): String = - "Eval(...)" -} - -public fun Iterator.iterateRight(lb: Eval, f: (A, Eval) -> Eval): Eval { - fun loop(): Eval = - Eval.defer { if (this.hasNext()) f(this.next(), loop()) else lb } - return loop() -} - -public fun Eval.zip(b: Eval, map: (A, B) -> Z): Eval = - flatMap { a: A -> b.map { bb: B -> map(a, bb) } } - -public fun Eval.zip(b: Eval): Eval> = - flatMap { a: A -> b.map { bb: B -> Pair(a, bb) } } - -public fun Eval.zip( - b: Eval, - c: Eval, - map: (A, B, C) -> D -): Eval = - zip( - b, - c, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit - ) { aa, bb, cc, _, _, _, _, _, _, _ -> map(aa, bb, cc) } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - map: (A, B, C, D) -> E -): Eval = - zip( - b, - c, - d, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit, - Eval.Now.unit - ) { aa, bb, cc, dd, _, _, _, _, _, _ -> map(aa, bb, cc, dd) } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - e: Eval, - map: (A, B, C, D, E) -> F -): Eval = - zip(b, c, d, e, Eval.Now.unit, Eval.Now.unit, Eval.Now.unit, Eval.Now.unit, Eval.Now.unit) { aa, bb, cc, dd, ee, _, _, _, _, _ -> - map( - aa, - bb, - cc, - dd, - ee - ) - } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - e: Eval, - f: Eval, - map: (A, B, C, D, E, F) -> G -): Eval = - zip(b, c, d, e, f, Eval.Now.unit, Eval.Now.unit, Eval.Now.unit, Eval.Now.unit) { aa, bb, cc, dd, ee, ff, _, _, _, _ -> - map( - aa, - bb, - cc, - dd, - ee, - ff - ) - } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - e: Eval, - f: Eval, - g: Eval, - map: (A, B, C, D, E, F, G) -> H -): Eval = - zip(b, c, d, e, f, g, Eval.Now.unit, Eval.Now.unit, Eval.Now.unit) { aa, bb, cc, dd, ee, ff, gg, _, _, _ -> - map( - aa, - bb, - cc, - dd, - ee, - ff, - gg - ) - } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - e: Eval, - f: Eval, - g: Eval, - h: Eval, - map: (A, B, C, D, E, F, G, H) -> I -): Eval = - zip(b, c, d, e, f, g, h, Eval.Now.unit, Eval.Now.unit) { aa, bb, cc, dd, ee, ff, gg, hh, _, _ -> - map( - aa, - bb, - cc, - dd, - ee, - ff, - gg, - hh - ) - } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - e: Eval, - f: Eval, - g: Eval, - h: Eval, - i: Eval, - map: (A, B, C, D, E, F, G, H, I) -> J -): Eval = - zip(b, c, d, e, f, g, h, i, Eval.Now.unit) { aa, bb, cc, dd, ee, ff, gg, hh, ii, _ -> - map( - aa, - bb, - cc, - dd, - ee, - ff, - gg, - hh, - ii - ) - } - -public fun Eval.zip( - b: Eval, - c: Eval, - d: Eval, - e: Eval, - f: Eval, - g: Eval, - h: Eval, - i: Eval, - j: Eval, - map: (A, B, C, D, E, F, G, H, I, J) -> K -): Eval = - flatMap { aa -> - b.flatMap { bb -> - c.flatMap { cc -> - d.flatMap { dd -> - e.flatMap { ee -> - f.flatMap { ff -> - g.flatMap { gg -> - h.flatMap { hh -> - i.flatMap { ii -> - j.map { jj -> - map(aa, bb, cc, dd, ee, ff, gg, hh, ii, jj) - } - } - } - } - } - } - } - } - } - } - -public fun Eval.replicate(n: Int): Eval> = - if (n <= 0) Eval.now(emptyList()) - else this.zip(replicate(n - 1)) { a: A, xs: List -> listOf(a) + xs } - -public fun Eval.replicate(n: Int, MA: Monoid): Eval = MA.run { - if (n <= 0) Eval.now(MA.empty()) - else this@replicate.zip(replicate(n - 1, MA)) { a: A, xs: A -> MA.run { a + xs } } -} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Tuple10.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Tuple10.kt deleted file mode 100644 index 5c81d2ab261..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Tuple10.kt +++ /dev/null @@ -1,57 +0,0 @@ -@file:JvmMultifileClass -@file:JvmName("TupleNKt") - -package arrow.core - -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName - -public data class Tuple10( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J -) { - - override fun toString(): String = - "($first, $second, $third, $fourth, $fifth, $sixth, $seventh, $eighth, $ninth, $tenth)" - - public companion object -} - -public operator fun , B : Comparable, C : Comparable, D : Comparable, E : Comparable, F : Comparable, G : Comparable, H : Comparable, I : Comparable, J : Comparable> -Tuple10.compareTo(other: Tuple10): Int { - val first = first.compareTo(other.first) - return if (first == 0) { - val second = second.compareTo(other.second) - if (second == 0) { - val third = third.compareTo(other.third) - if (third == 0) { - val fourth = fourth.compareTo(other.fourth) - if (fourth == 0) { - val fifth = fifth.compareTo(other.fifth) - if (fifth == 0) { - val sixth = sixth.compareTo(other.sixth) - if (sixth == 0) { - val seventh = seventh.compareTo(other.seventh) - if (seventh == 0) { - val eighth = eighth.compareTo(other.eighth) - if (eighth == 0) { - val ninth = ninth.compareTo(other.ninth) - if (ninth == 0) tenth.compareTo(other.tenth) - else ninth - } else eighth - } else seventh - } else sixth - } else fifth - } else fourth - } else third - } else second - } else first -} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/TupleN.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/TupleN.kt index a75f0c357af..1fbff275366 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/TupleN.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/TupleN.kt @@ -6,274 +6,6 @@ package arrow.core import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName -public data class Tuple11( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, -) { - public companion object -} - -public data class Tuple12( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L -) { - public companion object -} - -public data class Tuple13( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M -) { - - public companion object -} - -public data class Tuple14( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N -) { - - public companion object -} - -public data class Tuple15( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O -) { - - public companion object -} - -public data class Tuple16( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P -) { - - public companion object -} - -public data class Tuple17( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P, - val seventeenth: Q -) { - - public companion object -} - -public data class Tuple18( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P, - val seventeenth: Q, - val eighteenth: R -) { - - public companion object -} - -public data class Tuple19( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P, - val seventeenth: Q, - val eighteenth: R, - val nineteenth: S -) { - - public companion object -} - -public data class Tuple20( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P, - val seventeenth: Q, - val eighteenth: R, - val nineteenth: S, - val twentieth: T -) { - - public companion object -} - -public data class Tuple21( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P, - val seventeenth: Q, - val eighteenth: R, - val nineteenth: S, - val twentieth: T, - val twentyFirst: U -) { - public companion object -} - -public data class Tuple22( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J, - val eleventh: K, - val twelfth: L, - val thirteenth: M, - val fourteenth: N, - val fifteenth: O, - val sixteenth: P, - val seventeenth: Q, - val eighteenth: R, - val nineteenth: S, - val twentieth: T, - val twentyFirst: U, - val twentySecond: V -) { - public companion object -} - -private const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1 - public operator fun Pair.plus(c: C): Triple = Triple(this.first, this.second, c) public operator fun Triple.plus(d: D): Tuple4 = Tuple4(this.first, this.second, this.third, d) public operator fun Tuple4.plus(e: E): Tuple5 = Tuple5(this.first, this.second, this.third, this.fourth, e) @@ -281,19 +13,8 @@ public operator fun Tuple5.plus(f: F): Tuple6< public operator fun Tuple6.plus(g: G): Tuple7 = Tuple7(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, g) public operator fun Tuple7.plus(h: H): Tuple8 = Tuple8(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, h) public operator fun Tuple8.plus(i: I): Tuple9 = Tuple9(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, i) -public operator fun Tuple9.plus(j: J): Tuple10 = Tuple10(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, j) -public operator fun Tuple10.plus(k: K): Tuple11 = Tuple11(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, k) -public operator fun Tuple11.plus(l: L): Tuple12 = Tuple12(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, l) -public operator fun Tuple12.plus(m: M): Tuple13 = Tuple13(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, m) -public operator fun Tuple13.plus(n: N): Tuple14 = Tuple14(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, n) -public operator fun Tuple14.plus(o: O): Tuple15 = Tuple15(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, o) -public operator fun Tuple15.plus(p: P): Tuple16 = Tuple16(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, p) -public operator fun Tuple16.plus(q: Q): Tuple17 = Tuple17(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, this.sixteenth, q) -public operator fun Tuple17.plus(r: R): Tuple18 = Tuple18(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, this.sixteenth, this.seventeenth, r) -public operator fun Tuple18.plus(s: S): Tuple19 = Tuple19(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, this.sixteenth, this.seventeenth, this.eighteenth, s) -public operator fun Tuple19.plus(t: T): Tuple20 = Tuple20(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, this.sixteenth, this.seventeenth, this.eighteenth, this.nineteenth, t) -public operator fun Tuple20.plus(u: U): Tuple21 = Tuple21(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, this.sixteenth, this.seventeenth, this.eighteenth, this.nineteenth, this.twentieth, u) -public operator fun Tuple21.plus(v: V): Tuple22 = Tuple22(this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth, this.tenth, this.eleventh, this.twelfth, this.thirteenth, this.fourteenth, this.fifteenth, this.sixteenth, this.seventeenth, this.eighteenth, this.nineteenth, this.twentieth, this.twentyFirst, v) + +private const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1 internal fun mapCapacity(expectedSize: Int): Int = when { diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-01.kt deleted file mode 100644 index a66dcc08cd2..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-01.kt +++ /dev/null @@ -1,21 +0,0 @@ -// This file was automatically generated from Eval.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleEval01 - -import arrow.core.Eval - -fun even(n: Int): Eval = - Eval.always { n == 0 }.flatMap { - if(it == true) Eval.now(true) - else odd(n - 1) - } - -fun odd(n: Int): Eval = - Eval.always { n == 0 }.flatMap { - if(it == true) Eval.now(false) - else even(n - 1) - } - -// if not wrapped in eval this type of computation would blow the stack and result in a StackOverflowError -fun main() { - println(odd(100000).value()) -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-02.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-02.kt deleted file mode 100644 index 0923e57eb8d..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-02.kt +++ /dev/null @@ -1,9 +0,0 @@ -// This file was automatically generated from Eval.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleEval02 - -import arrow.core.* - -fun main() { - val eager = Eval.now(1).map { it + 1 } - println(eager.value()) -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-03.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-03.kt deleted file mode 100644 index 7fd34596244..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-03.kt +++ /dev/null @@ -1,9 +0,0 @@ -// This file was automatically generated from Eval.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleEval03 - -import arrow.core.* - -fun main() { - val lazyEvaled = Eval.later { "expensive computation" } - println(lazyEvaled.value()) -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-04.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-04.kt deleted file mode 100644 index 4b38eb8331a..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eval-04.kt +++ /dev/null @@ -1,9 +0,0 @@ -// This file was automatically generated from Eval.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleEval04 - -import arrow.core.* - -fun main() { - val alwaysEvaled = Eval.always { "expensive computation" } - println(alwaysEvaled.value()) -} From 62044120c483b01304819900a5e4cd8b4f1e8ece Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 12:31:07 +0200 Subject: [PATCH 02/13] Remove computation blocks and test modules --- .../api/arrow-continuations.api | 52 ---- .../core/arrow-continuations/build.gradle.kts | 52 ---- .../arrow-continuations/gradle.properties | 4 - .../kotlin/arrow/continuations/Effect.kt | 27 -- .../kotlin/arrow/continuations/Reset.kt | 42 --- .../arrow/continuations/generic/AtomicRef.kt | 57 ---- .../continuations/generic/ControlThrowable.kt | 13 - .../continuations/generic/DelimContScope.kt | 133 --------- .../continuations/generic/DelimitedCont.kt | 34 --- .../generic/MultiShotDelimCont.kt | 140 --------- .../continuations/generic/ShortCircuit.kt | 4 - .../generic/SuspendingComputation.kt | 97 ------ .../arrow/continuations/generic/Token.kt | 7 - .../src/commonTest/kotlin/generic/Maybe.kt | 15 - .../commonTest/kotlin/generic/MaybeEffect.kt | 11 - .../generic/SuspendingComputationTest.kt | 220 -------------- .../commonTest/kotlin/generic/TestSuite.kt | 100 ------- .../arrow/continuations/generic/AtomicRef.kt | 31 -- .../continuations/generic/ControlThrowable.kt | 10 - .../arrow/continuations/generic/AtomicRef.kt | 8 - .../continuations/generic/ControlThrowable.kt | 13 - .../arrow.continuations/generic/AtomicRef.kt | 30 -- .../generic/ControlThrowable.kt | 10 - .../core/arrow-core-retrofit/build.gradle.kts | 1 - .../arrow-core-test/api/arrow-core-test.api | 158 ---------- .../core/arrow-core-test/build.gradle.kts | 37 --- .../core/arrow-core-test/gradle.properties | 3 - .../core/arrow-core-test/knit.properties | 5 - .../kotlin/arrow/core/test/Platform.kt | 14 - .../kotlin/arrow/core/test/UnitSpec.kt | 277 ------------------ .../arrow/core/test/concurrency/SideEffect.kt | 12 - .../arrow/core/test/generators/Generators.kt | 276 ----------------- .../arrow/core/test/generators/utils.kt | 33 --- .../kotlin/arrow/core/test/laws/FxLaws.kt | 186 ------------ .../kotlin/arrow/core/test/laws/Law.kt | 12 - .../kotlin/arrow/core/test/laws/MonoidLaws.kt | 45 --- .../arrow/core/test/laws/SemigroupLaws.kt | 21 -- .../arrow/core/test/laws/SemiringLaws.kt | 157 ---------- .../kotlin/arrow.core/test/Platform-js.kt | 10 - .../kotlin/arrow/core/test/Platform-jvm.kt | 10 - .../core/test/generators/GeneratorsJvm.kt | 15 - .../kotlin/arrow/core/test/Platform-native.kt | 10 - arrow-libs/core/arrow-core/build.gradle.kts | 15 +- .../commonMain/kotlin/arrow/core/Option.kt | 9 - .../kotlin/arrow/core/computations/either.kt | 118 -------- .../kotlin/arrow/core/computations/eval.kt | 27 -- .../arrow/core/computations/nullable.kt | 95 ------ .../kotlin/arrow/core/computations/option.kt | 93 ------ .../kotlin/arrow/core/computations/result.kt | 60 ---- .../kotlin/arrow/typeclasses/Monoid.kt | 9 - .../kotlin/arrow/typeclasses/Semigroup.kt | 9 - .../commonTest/kotlin/arrow/core/EvalTest.kt | 140 --------- .../kotlin/arrow/core/SequenceKTest.kt | 4 +- .../kotlin/arrow/core/ValidatedTest.kt | 6 +- .../arrow/core/computations/NullableTest.kt | 99 ------- .../arrow/core/computations/ResultTest.kt | 224 -------------- .../arrow/core/continuations/NullableSpec.kt | 122 -------- .../arrow/core/continuations/OptionSpec.kt | 50 ---- .../src/jsMain/kotlin/arrow/core/NonFatal.kt | 3 +- .../src/jvmMain/kotlin/arrow/core/NonFatal.kt | 3 +- .../jvmTest/java/arrow/core/EvalJvmTest.kt | 68 ----- .../jvmTest/java/arrow/core/EvalUsage.java | 12 - .../example-either-computations-01.kt | 16 - .../example-either-computations-02.kt | 17 -- .../example-nullable-computations-01.kt | 16 - .../example-nullable-computations-02.kt | 17 -- .../example-option-computations-01.kt | 16 - .../example-option-computations-02.kt | 17 -- .../example-result-computations-01.kt | 23 -- .../nativeMain/kotlin/arrow/core/NonFatal.kt | 3 +- .../api/arrow-fx-coroutines-test.api | 60 ---- .../arrow-fx-coroutines-test/build.gradle.kts | 41 --- .../gradle.properties | 2 - .../arrow-fx-coroutines-test/knit.properties | 5 - .../kotlin/arrow/fx/coroutines/ArrowFxSpec.kt | 15 - .../kotlin/arrow/fx/coroutines/predef-test.kt | 264 ----------------- .../kotlin/examples/example-predef-test-01.kt | 11 - .../arrow/fx/coroutines/predef-test-jvm.kt | 24 -- .../kotlin/arrow/fx/coroutines/PredefTest.kt | 52 ---- .../fx/arrow-fx-coroutines/build.gradle.kts | 2 +- .../arrow/fx/coroutines/ParTraverseEither.kt | 6 +- .../kotlin/arrow/fx/coroutines/Schedule.kt | 59 ++-- arrow-libs/fx/arrow-fx-stm/build.gradle.kts | 2 +- .../optics/plugin/internals/processor.kt | 2 +- .../arrow-optics-reflect/build.gradle.kts | 5 +- .../api/arrow-optics-test.api | 69 ----- .../optics/arrow-optics-test/build.gradle.kts | 38 --- .../arrow-optics-test/gradle.properties | 3 - .../optics/arrow-optics-test/knit.properties | 5 - .../kotlin/arrow/optics/test/laws/IsoLaws.kt | 61 ---- .../kotlin/arrow/optics/test/laws/LensLaws.kt | 95 ------ .../arrow/optics/test/laws/OptionalLaws.kt | 128 -------- .../arrow/optics/test/laws/PrismLaws.kt | 63 ---- .../arrow/optics/test/laws/SetterLaws.kt | 53 ---- .../arrow/optics/test/laws/TraversalLaws.kt | 58 ---- .../optics/arrow-optics/build.gradle.kts | 5 +- .../commonMain/kotlin/arrow/optics/Every.kt | 39 --- .../commonMain/kotlin/arrow/optics/Fold.kt | 8 - .../kotlin/arrow/optics/Traversal.kt | 26 -- build.gradle.kts | 13 +- gradle/libs.versions.toml | 4 + settings.gradle.kts | 16 - 102 files changed, 68 insertions(+), 4849 deletions(-) delete mode 100644 arrow-libs/core/arrow-continuations/api/arrow-continuations.api delete mode 100644 arrow-libs/core/arrow-continuations/build.gradle.kts delete mode 100644 arrow-libs/core/arrow-continuations/gradle.properties delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Effect.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Reset.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/AtomicRef.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ControlThrowable.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimContScope.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimitedCont.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/MultiShotDelimCont.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ShortCircuit.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/SuspendingComputation.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/Token.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/Maybe.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/MaybeEffect.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/SuspendingComputationTest.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/TestSuite.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/AtomicRef.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/ControlThrowable.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/AtomicRef.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/ControlThrowable.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/AtomicRef.kt delete mode 100644 arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/ControlThrowable.kt delete mode 100644 arrow-libs/core/arrow-core-test/api/arrow-core-test.api delete mode 100644 arrow-libs/core/arrow-core-test/build.gradle.kts delete mode 100644 arrow-libs/core/arrow-core-test/gradle.properties delete mode 100644 arrow-libs/core/arrow-core-test/knit.properties delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt delete mode 100644 arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/either.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/eval.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/nullable.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/option.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/result.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EvalTest.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/NullableTest.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/ResultTest.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/NullableSpec.kt delete mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/OptionSpec.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalJvmTest.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalUsage.java delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-01.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-02.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-01.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-02.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-01.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-02.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-result-computations-01.kt delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/api/arrow-fx-coroutines-test.api delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/build.gradle.kts delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/gradle.properties delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/knit.properties delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/src/commonTest/kotlin/examples/example-predef-test-01.kt delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt delete mode 100644 arrow-libs/fx/arrow-fx-coroutines-test/src/jvmTest/kotlin/arrow/fx/coroutines/PredefTest.kt delete mode 100644 arrow-libs/optics/arrow-optics-test/api/arrow-optics-test.api delete mode 100644 arrow-libs/optics/arrow-optics-test/build.gradle.kts delete mode 100644 arrow-libs/optics/arrow-optics-test/gradle.properties delete mode 100644 arrow-libs/optics/arrow-optics-test/knit.properties delete mode 100644 arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt delete mode 100644 arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt delete mode 100644 arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt delete mode 100644 arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt delete mode 100644 arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt delete mode 100644 arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt diff --git a/arrow-libs/core/arrow-continuations/api/arrow-continuations.api b/arrow-libs/core/arrow-continuations/api/arrow-continuations.api deleted file mode 100644 index 5e268c691e4..00000000000 --- a/arrow-libs/core/arrow-continuations/api/arrow-continuations.api +++ /dev/null @@ -1,52 +0,0 @@ -public abstract interface class arrow/continuations/Effect { - public static final field Companion Larrow/continuations/Effect$Companion; - public abstract fun control ()Larrow/continuations/generic/DelimitedScope; -} - -public final class arrow/continuations/Effect$Companion { - public final fun restricted (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; - public final fun suspended (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/continuations/Reset { - public static final field INSTANCE Larrow/continuations/Reset; - public final fun restricted (Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; - public final fun suspended (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/continuations/generic/AtomicRefKt { - public static final fun getAndUpdate (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun loop (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)Ljava/lang/Void; - public static final fun update (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)V - public static final fun updateAndGet (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; -} - -public class arrow/continuations/generic/ControlThrowable : java/lang/Throwable { - public fun ()V - public fun fillInStackTrace ()Ljava/lang/Throwable; -} - -public abstract interface class arrow/continuations/generic/DelimitedContinuation { - public abstract fun invoke (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/continuations/generic/DelimitedScope { - public abstract fun shift (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/continuations/generic/RestrictedScope : arrow/continuations/generic/DelimitedScope { - public abstract fun shift (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun shift (Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/continuations/generic/RestrictedScope$DefaultImpls { - public static fun shift (Larrow/continuations/generic/RestrictedScope;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/continuations/generic/ShortCircuit : arrow/continuations/generic/ControlThrowable { - public final fun getRaiseValue ()Ljava/lang/Object; -} - -public abstract interface class arrow/continuations/generic/SuspendedScope : arrow/continuations/generic/DelimitedScope { -} - diff --git a/arrow-libs/core/arrow-continuations/build.gradle.kts b/arrow-libs/core/arrow-continuations/build.gradle.kts deleted file mode 100644 index 550219e33d4..00000000000 --- a/arrow-libs/core/arrow-continuations/build.gradle.kts +++ /dev/null @@ -1,52 +0,0 @@ -plugins { - id(libs.plugins.kotlin.multiplatform.get().pluginId) - alias(libs.plugins.arrowGradleConfig.kotlin) - alias(libs.plugins.arrowGradleConfig.publish) -} - -apply(from = property("TEST_COVERAGE")) -apply(from = property("ANIMALSNIFFER_MPP")) -apply(plugin = "io.kotest.multiplatform") - -val enableCompatibilityMetadataVariant = - providers.gradleProperty("kotlin.mpp.enableCompatibilityMetadataVariant") - .forUseAtConfigurationTime().orNull?.toBoolean() == true - - -if (enableCompatibilityMetadataVariant) { - tasks.withType().configureEach { - exclude("**/*") - } -} - -kotlin { - sourceSets { - commonMain { - dependencies { - implementation(libs.kotlin.stdlibCommon) - } - } - if(!enableCompatibilityMetadataVariant) { - commonTest { - dependencies { - implementation(project(":arrow-core-test")) - } - } - jvmTest { - dependencies { - runtimeOnly(libs.kotest.runnerJUnit5) - } - } - } - jvmMain { - dependencies { - implementation(libs.kotlin.stdlibJDK8) - } - } - jsMain { - dependencies { - implementation(libs.kotlin.stdlibJS) - } - } - } -} diff --git a/arrow-libs/core/arrow-continuations/gradle.properties b/arrow-libs/core/arrow-continuations/gradle.properties deleted file mode 100644 index b657b4ed748..00000000000 --- a/arrow-libs/core/arrow-continuations/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Maven publishing configuration -pom.name=Arrow Continuations -# Build configuration -kapt.incremental.apt=false diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Effect.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Effect.kt deleted file mode 100644 index 798141bbe30..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Effect.kt +++ /dev/null @@ -1,27 +0,0 @@ -package arrow.continuations - -import arrow.continuations.generic.DelimitedScope -import arrow.continuations.generic.deprecateArrowContinuation - -@Deprecated(deprecateArrowContinuation) -public fun interface Effect { - public fun control(): DelimitedScope - - public companion object { - @Deprecated("$deprecateArrowContinuation Here one can use effect { } directly") - public suspend inline fun , F, A> suspended( - crossinline eff: (DelimitedScope) -> Eff, - crossinline just: (A) -> F, - crossinline f: suspend Eff.() -> A, - ): F = - Reset.suspended { just(f(eff(this))) } - - @Deprecated("$deprecateArrowContinuation Here one can use eagerEffect { } directly") - public inline fun , F, A> restricted( - crossinline eff: (DelimitedScope) -> Eff, - crossinline just: (A) -> F, - crossinline f: suspend Eff.() -> A, - ): F = - Reset.restricted { just(f(eff(this))) } - } -} diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Reset.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Reset.kt deleted file mode 100644 index cd620c38fa7..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/Reset.kt +++ /dev/null @@ -1,42 +0,0 @@ -package arrow.continuations - -import arrow.continuations.generic.ShortCircuit -import arrow.continuations.generic.ControlThrowable -import arrow.continuations.generic.DelimContScope -import arrow.continuations.generic.RestrictedScope -import arrow.continuations.generic.SuspendMonadContinuation -import arrow.continuations.generic.SuspendedScope -import arrow.continuations.generic.deprecateArrowContinuation -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn - -@PublishedApi -@Deprecated(deprecateArrowContinuation) -internal object Reset { - /** - * Allows for building suspending single-shot computation blocks. - * For short-circuiting, or shifting, a [ShortCircuit] [ControlThrowable] is used. - * This ensures that any concurrent nested scopes are correctly closed. - * - * The usage of `try { ... } catch(e: Throwable) { ... }` will catch the [ShortCircuit] error, - * and will lead to recover of short-circuiting. - * You should always prefer to catch the most specific exception class, or - * use `Either.catch`, `Validated.catch` etc or `e.nonFatalOrThrow()` - * to ensure you're not catching `ShortCircuit`. - */ - @Deprecated(deprecateArrowContinuation) - public suspend fun suspended(block: suspend SuspendedScope.() -> A): A = - suspendCoroutineUninterceptedOrReturn { cont -> - SuspendMonadContinuation(cont, block) - .startCoroutineUninterceptedOrReturn() - } - - /** - * Allows for building eager single-shot computation blocks. - * For short-circuiting, or shifting, `@RestrictSuspension` state machine is used. - * This doesn't allow nesting of computation blocks, or foreign suspension. - */ - @Deprecated(deprecateArrowContinuation) - // TODO This should be @RestrictSuspension but that breaks because a superclass is not considered to be correct scope - fun restricted(block: suspend RestrictedScope.() -> A): A = - DelimContScope(block).invoke() -} diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/AtomicRef.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/AtomicRef.kt deleted file mode 100644 index 8b4c0433661..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/AtomicRef.kt +++ /dev/null @@ -1,57 +0,0 @@ -package arrow.continuations.generic - -@Deprecated("$deprecateArrowContinuation The AtomicRef APIs have been moved to arrow.core.generic", ReplaceWith("AtomicRef", "arrow.core.generic.AtomicRef")) -public expect class AtomicRef(initialValue: V) { - public fun get(): V - public fun set(value: V) - public fun getAndSet(value: V): V - - /** - * Compare current value with expected and set to new if they're the same. Note, 'compare' is checking - * the actual object id, not 'equals'. - */ - public fun compareAndSet(expected: V, new: V): Boolean -} - -/** - * Infinite loop that reads this atomic variable and performs the specified [action] on its value. - */ -@Deprecated("$deprecateArrowContinuation The AtomicRef APIs have been moved to arrow.core.generic", ReplaceWith("loop(action)", "arrow.core.generic.loop")) -public inline fun AtomicRef.loop(action: (V) -> Unit): Nothing { - while (true) { - action(get()) - } -} - -@Deprecated("$deprecateArrowContinuation The AtomicRef APIs have been moved to arrow.core.generic", ReplaceWith("update(function)", "arrow.core.generic.update")) -public inline fun AtomicRef.update(function: (V) -> V) { - while (true) { - val cur = get() - val upd = function(cur) - if (compareAndSet(cur, upd)) return - } -} - -/** - * Updates variable atomically using the specified [function] of its value and returns its old value. - */ -@Deprecated("$deprecateArrowContinuation The AtomicRef APIs have been moved to arrow.core.generic", ReplaceWith("getAndUpdate(function)", "arrow.core.generic.getAndUpdate")) -public inline fun AtomicRef.getAndUpdate(function: (V) -> V): V { - while (true) { - val cur = get() - val upd = function(cur) - if (compareAndSet(cur, upd)) return cur - } -} - -/** - * Updates variable atomically using the specified [function] of its value and returns its new value. - */ -@Deprecated("$deprecateArrowContinuation The AtomicRef APIs have been moved to arrow.core.generic", ReplaceWith("updateAndGet", "arrow.core.generic.updateAndGet")) -public inline fun AtomicRef.updateAndGet(function: (V) -> V): V { - while (true) { - val cur = get() - val upd = function(cur) - if (compareAndSet(cur, upd)) return upd - } -} diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ControlThrowable.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ControlThrowable.kt deleted file mode 100644 index 4ddbfe07b65..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ControlThrowable.kt +++ /dev/null @@ -1,13 +0,0 @@ -package arrow.continuations.generic - -/** - * A [Throwable] class intended for control flow. - * Instance of [ControlThrowable] should **not** be caught, - * and `arrow.core.NonFatal` does not catch this [Throwable]. - * Thus by extension `Either.catch` and `Validated.catch` also don't catch [ControlThrowable]. - */ -@Deprecated(deprecateArrowContinuation) -public expect open class ControlThrowable() : Throwable - -internal const val deprecateArrowContinuation: String = - "arrow.continuation is being discontinued and will be removed in the next version in favor of the Effect/ EagerEffect Runtime. If you depend on low-level APIs as in arrow.continuation, feel free to write us in the Kotlin Slack channel for guidance." diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimContScope.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimContScope.kt deleted file mode 100644 index 4ce2b6bea2a..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimContScope.kt +++ /dev/null @@ -1,133 +0,0 @@ -package arrow.continuations.generic - -import kotlin.coroutines.Continuation -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn -import kotlin.coroutines.resume - -/** - * Implements delimited continuations with with no multi shot support (apart from shiftCPS which trivially supports it). - * - * For a version that simulates multishot (albeit with drawbacks) see [MultiShotDelimContScope]. - * For a version that allows nesting [reset] and calling parent scopes inside inner scopes see [NestedDelimContScope]. - * - * The basic concept here is appending callbacks and polling for a result. - * Every shift is evaluated until it either finishes (short-circuit) or suspends (called continuation). When it suspends its - * continuation is appended to a list waiting to be invoked with the final result of the block. - * When running a function we jump back and forth between the main function and every function inside shift via their continuations. - */ -internal open class DelimContScope(private val f: suspend RestrictedScope.() -> R) : RestrictedScope { - - /** - * Variable used for polling the result after suspension happened. - */ - private var resultVar: Any? = EMPTY_VALUE - - /** - * Variable for the next shift block to (partially) run, if it is empty that usually means we are done. - */ - private var nextShift: (suspend () -> R)? = null - - /** - * "Callbacks"/partially evaluated shift blocks which now wait for the final result - */ - // TODO This can be append only, but needs fast reversed access - private val shiftFnContinuations = mutableListOf>() - - /** - * Small wrapper that handles invoking the correct continuations and appending continuations from shift blocks - */ - public data class SingleShotCont( - private val continuation: Continuation, - private val shiftFnContinuations: MutableList> - ) : DelimitedContinuation { - public override suspend fun invoke(a: A): R = suspendCoroutineUninterceptedOrReturn { resumeShift -> - shiftFnContinuations.add(resumeShift) - continuation.resume(a) - COROUTINE_SUSPENDED - } - } - - /** - * Wrapper that handles invoking manually cps transformed continuations - */ - public data class CPSCont( - private val runFunc: suspend DelimitedScope.(A) -> R - ) : DelimitedContinuation { - public override suspend fun invoke(a: A): R = DelimContScope { runFunc(a) }.invoke() - } - - /** - * Captures the continuation and set [f] with the continuation to be executed next by the runloop. - */ - public override suspend fun shift(f: suspend RestrictedScope.(DelimitedContinuation) -> R): A = - suspendCoroutineUninterceptedOrReturn { continueMain -> - val delCont = SingleShotCont(continueMain, shiftFnContinuations) - require(nextShift == null) - nextShift = suspend { this.f(delCont) } - COROUTINE_SUSPENDED - } - - /** - * Same as [shift] except we never resume execution because we only continue in [c]. - */ - public suspend fun shiftCPS(f: suspend (DelimitedContinuation) -> R, c: suspend DelimitedScope.(A) -> B): Nothing = - suspendCoroutineUninterceptedOrReturn { - require(nextShift == null) - nextShift = suspend { f(CPSCont(c)) } - COROUTINE_SUSPENDED - } - - /** - * Unsafe if [f] calls [shift] on this scope! Use [NestedDelimContScope] instead if this is a problem. - */ - fun reset(f: suspend DelimitedScope.() -> A): A = - DelimContScope(f).invoke() - - @Suppress("UNCHECKED_CAST") - fun invoke(): R { - f.startCoroutineUninterceptedOrReturn( - this, - Continuation(EmptyCoroutineContext) { result -> - resultVar = result.getOrThrow() - } - ).let { - if (it == COROUTINE_SUSPENDED) { - // we have a call to shift so we must start execution the blocks there - while (true) { - if (resultVar === EMPTY_VALUE) { - val nextShiftFn = requireNotNull(nextShift) { "No further work to do but also no result!" } - nextShift = null - nextShiftFn.startCoroutineUninterceptedOrReturn( - Continuation(EmptyCoroutineContext) { result -> - resultVar = result.getOrThrow() - } - ).let { nextRes -> - // If we suspended here we can just continue to loop because we should now have a new function to run - // If we did not suspend we short-circuited and are thus done with looping - if (nextRes != COROUTINE_SUSPENDED) resultVar = nextRes as R - } - // Break out of the infinite loop if we have a result - } else return@let - } - } - // we can return directly if we never suspended/called shift - else return@invoke it as R - } - require(resultVar !== EMPTY_VALUE) - // We need to finish the partially evaluated shift blocks by passing them our result. - // This will update the result via the continuations that now finish up - for (c in shiftFnContinuations.asReversed()) c.resume(resultVar as R) - // Return the final result - return resultVar as R - } -} - -@Suppress("ClassName") -internal object EMPTY_VALUE { - @Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE") - public inline fun unbox(value: Any?): T = - if (value === this) null as T else value as T -} diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimitedCont.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimitedCont.kt deleted file mode 100644 index a84f969fcd9..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/DelimitedCont.kt +++ /dev/null @@ -1,34 +0,0 @@ -package arrow.continuations.generic - -/** - * Base interface for a continuation - */ -@Deprecated(deprecateArrowContinuation) -public interface DelimitedContinuation { - public suspend operator fun invoke(a: A): R -} - -/** - * Base interface for our scope. - */ -@Deprecated(deprecateArrowContinuation) -public interface DelimitedScope { - - /** - * Exit the [DelimitedScope] with [R] - */ - public suspend fun shift(r: R): A -} - -@Deprecated(deprecateArrowContinuation) -public interface RestrictedScope : DelimitedScope { - /** - * Capture the continuation and pass it to [f]. - */ - public suspend fun shift(f: suspend RestrictedScope.(DelimitedContinuation) -> R): A - - public override suspend fun shift(r: R): A = shift { r } -} - -@Deprecated(deprecateArrowContinuation) -public interface SuspendedScope : DelimitedScope diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/MultiShotDelimCont.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/MultiShotDelimCont.kt deleted file mode 100644 index 32a8824b8f8..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/MultiShotDelimCont.kt +++ /dev/null @@ -1,140 +0,0 @@ -package arrow.continuations.generic - -import kotlin.coroutines.Continuation -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine - -/** - * (Simulated) Multishot capable delimited control scope - * - * This has several drawbacks: - * - f will rerun completely on multishot and only the results of [shift] are cached so any sideeffects outside of - * [shift] will rerun! - * - This accumulates all results of [shift] (every argument passed when invoking the continuation) so on long running computations - * this may keep quite a bit of memory - * - If the pure part before a multishot is expensive the multishot itself will have to rerun that, which makes it somewhat slow - * - This is terribly hard to implement properly with nested scopes (which this one does not support) - * - * As per usual understanding of [DelimContScope] is required as I will only be commenting differences for now. - */ -internal open class MultiShotDelimContScope(val f: suspend RestrictedScope.() -> R) : RestrictedScope { - - // TODO Since runs blocking these don't need to be atomic - private val resultVar = AtomicRef(null) - private val nextShift = AtomicRef<(suspend RestrictedScope.() -> R)?>(null) - - // TODO This can be append only and needs fast reversed access - private val shiftFnContinuations = mutableListOf>() - - /** - * Keep the arguments passed to [DelimitedContinuation.invoke] to be able to replay the scope if necessary - */ - // TODO This can be append only and needs fast random access and slicing - internal open val stack = mutableListOf() - - /** - * Our continuation now includes the function [f] to rerun on multishot, the current live (single-shot) continuation, - * the current stack and the offset from that stack when this is created which is used to know when to resume normal - * execution again on a replay. - */ - public class MultiShotCont( - liveContinuation: Continuation, - private val f: suspend RestrictedScope.() -> R, - private val stack: MutableList, - private val shiftFnContinuations: MutableList> - ) : DelimitedContinuation { - // To make sure the continuation is only invoked once we put it in a nullable atomic and only access it through getAndSet - private val liveContinuation = AtomicRef?>(liveContinuation) - private val stackOffset = stack.size - - public override suspend fun invoke(a: A): R = - when (val cont = liveContinuation.getAndSet(null)) { - // On multishot we replay with a prefilled stack from start to the point at which this object was created - // (when the shift block this runs in was first called) - null -> PrefilledDelimContScope((stack.subList(0, stackOffset).toList() + a).toMutableList(), f).invoke() - // on the first pass we operate like a normal delimited scope but we also save the argument to the stack before resuming - else -> suspendCoroutine { resumeShift -> - shiftFnContinuations.add(resumeShift) - stack.add(a) - cont.resume(a) - } - } - } - - public data class CPSCont( - private val runFunc: suspend DelimitedScope.(A) -> R - ) : DelimitedContinuation { - public override suspend fun invoke(a: A): R = DelimContScope { runFunc(a) }.invoke() - } - - public override suspend fun shift(func: suspend RestrictedScope.(DelimitedContinuation) -> R): A = - suspendCoroutineUninterceptedOrReturn { continueMain -> - val c = MultiShotCont(continueMain, f, stack, shiftFnContinuations) - val s: suspend RestrictedScope.() -> R = { this.func(c) } - require(nextShift.compareAndSet(null, s)) - COROUTINE_SUSPENDED - } - - public suspend fun shiftCPS(func: suspend DelimitedScope.(DelimitedContinuation) -> R, c: suspend DelimitedScope.(A) -> B): Nothing = - suspendCoroutine { - val s: suspend DelimitedScope.() -> R = { func(CPSCont(c)) } - require(nextShift.compareAndSet(null, s)) - } - - // This assumes RestrictSuspension or at least assumes the user to never reference the parent scope in f. - public suspend fun reset(f: suspend DelimitedScope.() -> A): A = - MultiShotDelimContScope(f).invoke() - - fun invoke(): R { - f.startCoroutineUninterceptedOrReturn( - this, - Continuation(EmptyCoroutineContext) { result -> - resultVar.set(result.getOrThrow()) - } - ).let { - if (it == COROUTINE_SUSPENDED) { - resultVar.loop { mRes -> - if (mRes == null) { - val nextShiftFn = nextShift.getAndSet(null) - ?: throw IllegalStateException("No further work to do but also no result!") - nextShiftFn.startCoroutineUninterceptedOrReturn( - this, - Continuation(EmptyCoroutineContext) { result -> - resultVar.set(result.getOrThrow()) - } - ).let { - if (it != COROUTINE_SUSPENDED) resultVar.set(it as R) - } - } else return@let - } - } else return@invoke it as R - } - require(resultVar.get() != null) - for (c in shiftFnContinuations.asReversed()) c.resume(resultVar.get()!!) - return resultVar.get()!! - } - - public companion object { - internal fun reset(f: suspend RestrictedScope.() -> R): R = MultiShotDelimContScope(f).invoke() - } -} - -private class PrefilledDelimContScope( - override val stack: MutableList, - f: suspend RestrictedScope.() -> R -) : MultiShotDelimContScope(f) { - var depth = 0 - - // Here we first check if we still have values in our local stack and if so we use those first - // if not we delegate to the normal delimited control implementation - public override suspend fun shift(func: suspend RestrictedScope.(DelimitedContinuation) -> R): A = - if (stack.size > depth) stack[depth++] as A - else { - @Suppress("ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL") - super.shift(func).also { depth++ } - } -} diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ShortCircuit.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ShortCircuit.kt deleted file mode 100644 index 66b2c445979..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/ShortCircuit.kt +++ /dev/null @@ -1,4 +0,0 @@ -package arrow.continuations.generic - -@Deprecated(deprecateArrowContinuation) -public class ShortCircuit internal constructor(internal val token: Token, public val raiseValue: Any?) : ControlThrowable() diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/SuspendingComputation.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/SuspendingComputation.kt deleted file mode 100644 index 88e8b5c13c5..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/SuspendingComputation.kt +++ /dev/null @@ -1,97 +0,0 @@ -package arrow.continuations.generic - -import kotlin.coroutines.Continuation -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn -import kotlin.coroutines.resumeWithException - -internal const val UNDECIDED = 0 -internal const val SUSPENDED = 1 - -@Suppress("UNCHECKED_CAST") -internal open class SuspendMonadContinuation( - private val parent: Continuation, - val f: suspend SuspendedScope.() -> R -) : Continuation, SuspendedScope { - - /** - * State is either - * 0 - UNDECIDED - * 1 - SUSPENDED - * Any? (3) `resumeWith` always stores it upon UNDECIDED, and `getResult` can atomically get it. - */ - private val _decision = AtomicRef(UNDECIDED) - private val token: Token = Token() - - override val context: CoroutineContext = parent.context - - override fun resumeWith(result: Result) { - _decision.loop { decision -> - when (decision) { - UNDECIDED -> { - val r: R? = result.fold({ it }) { EMPTY_VALUE.unbox(it.shiftedOrNull()) } - when { - r == null -> { - parent.resumeWithException(result.exceptionOrNull()!!) - return - } - _decision.compareAndSet(UNDECIDED, r) -> { - return - } - else -> Unit // loop again - } - } - else -> { // If not `UNDECIDED` then we need to pass result to `parent` - val res: Result = result.fold( - { Result.success(it) }, - { t -> - val x = t.shiftedOrNull() - if (x === EMPTY_VALUE) Result.failure(t) - else Result.success(EMPTY_VALUE.unbox(x)) - } - ) - parent.resumeWith(res) - return - } - } - } - } - - @PublishedApi // return the result - internal fun getResult(): Any? = - _decision.loop { decision -> - when (decision) { - UNDECIDED -> if (this._decision.compareAndSet(UNDECIDED, SUSPENDED)) return COROUTINE_SUSPENDED - else -> return decision - } - } - - // If ShortCircuit causes CancellationException, we also want to shift back to R - private tailrec fun Throwable.shortCircuitCause(): ShortCircuit? = - when (val cause = this.cause) { - null -> null - is ShortCircuit -> cause - else -> cause.shortCircuitCause() - } - - private fun Throwable.shiftedOrNull(): Any? { - val shortCircuit = if (this is ShortCircuit) this else shortCircuitCause() - return if (shortCircuit != null && shortCircuit.token === token) shortCircuit.raiseValue as R - else EMPTY_VALUE - } - - public override suspend fun shift(r: R): A = - throw ShortCircuit(token, r) - - fun startCoroutineUninterceptedOrReturn(): Any? = - try { - f.startCoroutineUninterceptedOrReturn(this, this)?.let { - if (it == COROUTINE_SUSPENDED) getResult() - else it - } - } catch (e: Throwable) { - val x = e.shiftedOrNull() - if (x === EMPTY_VALUE) throw e else x - } -} diff --git a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/Token.kt b/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/Token.kt deleted file mode 100644 index 511f90b1fef..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonMain/kotlin/arrow/continuations/generic/Token.kt +++ /dev/null @@ -1,7 +0,0 @@ -package arrow.continuations.generic - -/** Represents a unique identifier using object equality. */ -@Deprecated(deprecateArrowContinuation) -internal class Token { - override fun toString(): String = "Token(${hashCode().toString(16)})" -} diff --git a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/Maybe.kt b/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/Maybe.kt deleted file mode 100644 index fa0b12cbede..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/Maybe.kt +++ /dev/null @@ -1,15 +0,0 @@ -package generic - -import arrow.continuations.Reset - -sealed class Maybe -data class Just(val a: A) : Maybe() -object None : Maybe() - -object maybeEff { // if you change the name to maybe it breaks the tests in 1.4.10 - inline fun restricted(crossinline c: suspend MaybeEffect<*>.() -> A): Maybe = - Reset.restricted { Just(c(MaybeEffect { this })) } - - suspend inline operator fun invoke(crossinline c: suspend MaybeEffect<*>.() -> A): Maybe = - Reset.suspended { Just(c(MaybeEffect { this })) } -} diff --git a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/MaybeEffect.kt b/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/MaybeEffect.kt deleted file mode 100644 index c082f7f5bff..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/MaybeEffect.kt +++ /dev/null @@ -1,11 +0,0 @@ -package generic - -import arrow.continuations.Effect - -fun interface MaybeEffect : Effect> { - suspend fun Maybe.bind(): B = - when (this) { - is Just -> a - is None -> control().shift(None) - } -} diff --git a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/SuspendingComputationTest.kt b/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/SuspendingComputationTest.kt deleted file mode 100644 index 2a3d9e50f65..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/SuspendingComputationTest.kt +++ /dev/null @@ -1,220 +0,0 @@ -package arrow.continuations - -import arrow.core.Either -import arrow.core.computations.either -import arrow.core.Either.Right -import arrow.core.Either.Left -import arrow.core.Eval -import arrow.core.computations.ensureNotNull -import arrow.core.computations.eval -import arrow.core.left -import arrow.core.right -import arrow.core.test.UnitSpec -import io.kotest.assertions.fail -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.orNull -import io.kotest.property.arbitrary.string -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll -import kotlinx.coroutines.suspendCancellableCoroutine -import kotlin.coroutines.Continuation -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.intercepted -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn -import kotlin.coroutines.startCoroutine - -class SuspendingComputationTest : UnitSpec({ - - "immediate values" { - either { - Right(1).bind() - } shouldBe Right(1) - } - - "suspended value" { - either { - Right(1).suspend().bind() - } shouldBe Right(1) - } - - "immediate short-circuit" { - either { - Left("hello").bind() - } shouldBe Left("hello") - } - - "suspended short-circuit" { - either { - Left("hello").suspend().bind() - } shouldBe Left("hello") - } - - "Rethrows immediate exceptions" { - val e = RuntimeException("test") - Either.catch { - either { - Right(1).bind() - Right(1).suspend().bind() - throw e - } - } shouldBe Left(e) - } - - "Rethrows suspended exceptions" { - val e = RuntimeException("test") - Either.catch { - either { - Right(1).bind() - Right(1).suspend().bind() - e.suspend() - } - } shouldBe Either.Left(e) - } - - "Can short-circuit immediately from nested blocks" { - either { - val x = eval { - Left("test").bind() - 5L - } - - println(x) - 1 - } shouldBe Left("test") - } - - "Can short-circuit suspended from nested blocks" { - either { - val x = eval { - Left("test").suspend().bind() - 5L - } - - println(x) - 1 - } shouldBe Left("test") - } - - "Can short-circuit immediately after suspending from nested blocks" { - either { - val x = eval { - Eval.Now(1L).suspend().bind() - Left("test").suspend().bind() - 5L - } - - println(x) - 1 - } shouldBe Left("test") - } - - "Can short-circuit suspended after suspending from nested blocks" { - either { - val x = eval { - Eval.Now(1L).suspend().bind() - Left("test").suspend().bind() - 5L - } - - println(x) - 1 - } shouldBe Left("test") - } - - "ensure null in either computation" { - checkAll(Arb.boolean(), Arb.int(), Arb.string()) { predicate, rValue, lValue -> - either { - ensure(predicate) { lValue } - rValue - } shouldBe if (predicate) rValue.right() else lValue.left() - } - } - - "ensureNotNull in either computation" { - fun square(i: Int): Int = i * i - - checkAll(Arb.int().orNull(), Arb.string()) { i: Int?, lValue: String -> - val res = either { - val ii = i - ensureNotNull(ii) { lValue } - square(ii) // Smart-cast by contract - } - val expected = i?.let(::square)?.right() ?: lValue.left() - res shouldBe expected - } - } - - "Short-circuiting cancels KotlinX Coroutines" { - val scope = CoroutineScope(Dispatchers.Default) - val latch = CompletableDeferred() - val cancelled = CompletableDeferred() - - either { - val deferreds: List> = listOf( - scope.async { - completeOnCancellation(latch, cancelled) - 1 - }, - scope.async { - latch.await() - Left("hello").bind() - } - ) - - deferreds.awaitAll().sum() - } shouldBe Left("hello") - - cancelled.await() - } - - "Computation blocks run on parent context" { - val parentCtx = currentContext() - either { - currentContext() shouldBe parentCtx - } - } -}) - -suspend fun currentContext(): CoroutineContext = - kotlin.coroutines.coroutineContext - -suspend fun completeOnCancellation(latch: CompletableDeferred, cancelled: CompletableDeferred): Unit = - suspendCancellableCoroutine { cont -> - cont.invokeOnCancellation { - if (!cancelled.complete(Unit)) fail("cancelled latch was completed twice") - else Unit - } - - if (!latch.complete(Unit)) fail("latch was completed twice") - else Unit - } - -internal suspend fun Throwable.suspend(): Nothing = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { throw this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } - -internal suspend fun A.suspend(): A = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } diff --git a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/TestSuite.kt b/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/TestSuite.kt deleted file mode 100644 index ecfdec48bdc..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/TestSuite.kt +++ /dev/null @@ -1,100 +0,0 @@ -package generic - -import arrow.continuations.Reset -import arrow.continuations.generic.RestrictedScope -import arrow.core.Either -import arrow.core.Either.Left -import arrow.core.test.UnitSpec -import io.kotest.matchers.shouldBe - -abstract class ContTestSuite : UnitSpec() { - abstract suspend fun runScope(func: (suspend RestrictedScope.() -> A)): A - - abstract fun capabilities(): Set - - init { - "yield a list (also verifies stacksafety)" { - runScope> { - suspend fun RestrictedScope>.yield(a: A): Unit = shift { k -> listOf(a) + k(Unit) } - for (i in 0..10_000) yield(i) - emptyList() - } shouldBe (0..10_000).toList() - } - "short circuit" { - runScope> { - val no: Int = shift { Left("No thank you") } - throw IllegalStateException("This should not be executed") - } shouldBe Left("No thank you") - } - - // some examples from http://homes.sice.indiana.edu/ccshan/recur/recur.pdf - if (capabilities().contains(ScopeCapabilities.MultiShot)) { - "multshot nondet" { - runScope>> { - val i: Int = shift { k -> k(10) + k(20) } - val j: Int = shift { k -> k(15) + k(25) } - listOf(i to j) - } shouldBe listOf(10 to 15, 10 to 25, 20 to 15, 20 to 25) - } - "multishot more than twice" { - runScope>> { - val i: Int = shift { k -> k(10) + k(20) } - val j: Int = shift { k -> k(15) + k(25) } - val k: Int = shift { k -> k(17) + k(27) } - listOf(Triple(i, j, k)) - } shouldBe listOf(10, 20).flatMap { i -> listOf(15, 25).flatMap { j -> listOf(17, 27).map { k -> Triple(i, j, k) } } } - } - "multishot more than twice and with more multishot invocations" { - runScope>> { - val i: Int = shift { k -> k(10) + k(20) + k(30) + k(40) + k(50) } - val j: Int = shift { k -> k(15) + k(25) + k(35) + k(45) + k(55) } - val k: Int = shift { k -> k(17) + k(27) + k(37) + k(47) + k(57) } - listOf(Triple(i, j, k)) - } shouldBe - listOf(10, 20, 30, 40, 50) - .flatMap { i -> - listOf(15, 25, 35, 45, 55) - .flatMap { j -> - listOf(17, 27, 37, 47, 57) - .map { k -> Triple(i, j, k) } - } - } - } - "multishot is stacksafe regardless of stack size" { - runScope { - // bring 10k elements on the stack - var sum = 0 - for (i0 in 1..10_000) sum += shift { it(i0) } - - // run the continuation from here 10k times and sum the results - // This is about as bad as a scenario as it gets :) - val j: Int = shift { - var sum2 = 0 - for (i0 in 1..10_000) sum2 += it(i0) - sum2 - } - - sum + j - } - } - } - } -} - -sealed class ScopeCapabilities { - object MultiShot : ScopeCapabilities() -} - -class SingleShotContTestSuite : ContTestSuite() { - override suspend fun runScope(func: (suspend RestrictedScope.() -> A)): A = - Reset.restricted { func(this) } - - override fun capabilities(): Set = emptySet() -} - -// class MultiShotContTestSuite : ContTestSuite() { -// override suspend fun runScope(func: (suspend RestrictedScope.() -> A)): A = -// MultiShotDelimContScope.reset { func(this) } -// -// override fun capabilities(): Set = setOf(ScopeCapabilities.MultiShot) -// } diff --git a/arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/AtomicRef.kt b/arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/AtomicRef.kt deleted file mode 100644 index 9b845acb0a9..00000000000 --- a/arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/AtomicRef.kt +++ /dev/null @@ -1,31 +0,0 @@ -package arrow.continuations.generic - -@Deprecated(deprecateArrowContinuation) -public actual class AtomicRef actual constructor(initialValue: V) { - private var internalValue: V = initialValue - - /** - * Compare current value with expected and set to new if they're the same. Note, 'compare' is checking - * the actual object id, not 'equals'. - */ - public actual fun compareAndSet(expected: V, new: V): Boolean { - return if (expected === internalValue) { - internalValue = new - true - } else { - false - } - } - - public actual fun getAndSet(value: V): V { - val oldValue = internalValue - internalValue = value - return oldValue - } - - public actual fun get(): V = internalValue - - public actual fun set(value: V) { - internalValue = value - } -} diff --git a/arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/ControlThrowable.kt b/arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/ControlThrowable.kt deleted file mode 100644 index 83e3ef54c08..00000000000 --- a/arrow-libs/core/arrow-continuations/src/jsMain/kotlin/arrow/continuations/generic/ControlThrowable.kt +++ /dev/null @@ -1,10 +0,0 @@ -package arrow.continuations.generic - -/** - * A [Throwable] class intended for control flow. - * Instance of [ControlThrowable.kt] should **not** be caught, - * and `arrow.core.NonFatal` does not catch this [Throwable]. - * Thus by extension `Either.catch` and `Validated.catch` also don't catch [ControlThrowable.kt]. - */ -@Deprecated(deprecateArrowContinuation) -public actual open class ControlThrowable : Throwable() diff --git a/arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/AtomicRef.kt b/arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/AtomicRef.kt deleted file mode 100644 index 2a6268230d7..00000000000 --- a/arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/AtomicRef.kt +++ /dev/null @@ -1,8 +0,0 @@ -@file:JvmName("AtomicReferenceActual") - -package arrow.continuations.generic - -import java.util.concurrent.atomic.AtomicReference - -@Deprecated(deprecateArrowContinuation) -public actual typealias AtomicRef = AtomicReference diff --git a/arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/ControlThrowable.kt b/arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/ControlThrowable.kt deleted file mode 100644 index 5b773b30a7d..00000000000 --- a/arrow-libs/core/arrow-continuations/src/jvmMain/kotlin/arrow/continuations/generic/ControlThrowable.kt +++ /dev/null @@ -1,13 +0,0 @@ - -package arrow.continuations.generic - -/** - * A [Throwable] class intended for control flow. - * Instance of [ControlThrowable.kt] should **not** be caught, - * and `arrow.core.NonFatal` does not catch this [Throwable]. - * Thus by extension `Either.catch` and `Validated.catch` also don't catch [ControlThrowable.kt]. - */ -@Deprecated(deprecateArrowContinuation) -public actual open class ControlThrowable : Throwable() { - override fun fillInStackTrace(): Throwable = this -} diff --git a/arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/AtomicRef.kt b/arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/AtomicRef.kt deleted file mode 100644 index 36d201b6cbc..00000000000 --- a/arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/AtomicRef.kt +++ /dev/null @@ -1,30 +0,0 @@ -package arrow.continuations.generic - -import kotlin.native.concurrent.AtomicReference -import kotlin.native.concurrent.freeze -import kotlin.native.concurrent.isFrozen - -@Deprecated(deprecateArrowContinuation) -public actual class AtomicRef actual constructor(initialValue: V) { - private val atom = AtomicReference(initialValue.freeze()) - public actual fun get(): V = atom.value - - public actual fun set(value: V) { - atom.value = value.freeze() - } - - public actual fun getAndSet(value: V): V { - if (atom.isFrozen) value.freeze() - while (true) { - val cur = atom.value - if (cur === value) return cur - if (atom.compareAndSwap(cur, value) === cur) return cur - } - } - - /** - * Compare current value with expected and set to new if they're the same. Note, 'compare' is checking - * the actual object id, not 'equals'. - */ - public actual fun compareAndSet(expected: V, new: V): Boolean = atom.compareAndSet(expected, new.freeze()) -} diff --git a/arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/ControlThrowable.kt b/arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/ControlThrowable.kt deleted file mode 100644 index dedc2b8463c..00000000000 --- a/arrow-libs/core/arrow-continuations/src/nativeMain/kotlin/arrow.continuations/generic/ControlThrowable.kt +++ /dev/null @@ -1,10 +0,0 @@ -package arrow.continuations.generic - -/** - * A [Throwable] class intended for control flow. - * Instance of [ControlThrowable] should **not** be caught, - * and `arrow.core.NonFatal` does not catch this [Throwable]. - * Thus by extension `Either.catch` and `Validated.catch` also don't catch [ControlThrowable]. - */ -@Deprecated(deprecateArrowContinuation) -public actual open class ControlThrowable : Throwable() diff --git a/arrow-libs/core/arrow-core-retrofit/build.gradle.kts b/arrow-libs/core/arrow-core-retrofit/build.gradle.kts index 46ba73e1399..feeba04f015 100644 --- a/arrow-libs/core/arrow-core-retrofit/build.gradle.kts +++ b/arrow-libs/core/arrow-core-retrofit/build.gradle.kts @@ -26,7 +26,6 @@ dependencies { if (!enableCompatibilityMetadataVariant) { testCompileOnly(libs.kotlin.reflect) testRuntimeOnly(libs.kotest.runnerJUnit5) - testImplementation(project(":arrow-core-test")) testImplementation(libs.squareup.okhttpMockWebServer) testImplementation(libs.squareup.retrofitConverterGson) testImplementation(libs.squareup.retrofitConverterMoshi) diff --git a/arrow-libs/core/arrow-core-test/api/arrow-core-test.api b/arrow-libs/core/arrow-core-test/api/arrow-core-test.api deleted file mode 100644 index 1d009c7d92f..00000000000 --- a/arrow-libs/core/arrow-core-test/api/arrow-core-test.api +++ /dev/null @@ -1,158 +0,0 @@ -public final class arrow/core/test/PlatformKt { - public static final fun stackSafeIteration ()I -} - -public final class arrow/core/test/Platform_jvmKt { - public static final fun isJs ()Z - public static final fun isJvm ()Z - public static final fun isNative ()Z -} - -public abstract class arrow/core/test/UnitSpec : io/kotest/core/spec/style/StringSpec { - public fun ()V - public fun (IILkotlin/jvm/functions/Function1;)V - public synthetic fun (IILkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Lkotlin/jvm/functions/Function1;)V - public final synthetic fun array (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function12;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function11;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function10;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function9;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function8;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function7;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function6;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function5;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function4;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun checkAll (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun forFew (ILkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getIterations ()I - public final fun getMaxDepth ()I - public final fun list (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Gen;Lkotlin/ranges/IntRange;)Lio/kotest/property/Arb; - public static synthetic fun list$default (Larrow/core/test/UnitSpec;Lio/kotest/property/Arb$Companion;Lio/kotest/property/Gen;Lkotlin/ranges/IntRange;ILjava/lang/Object;)Lio/kotest/property/Arb; - public final fun map (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;II)Lio/kotest/property/Arb; - public static synthetic fun map$default (Larrow/core/test/UnitSpec;Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;IIILjava/lang/Object;)Lio/kotest/property/Arb; - public final fun nonEmptyList (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;I)Lio/kotest/property/Arb; - public static synthetic fun nonEmptyList$default (Larrow/core/test/UnitSpec;Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;IILjava/lang/Object;)Lio/kotest/property/Arb; - public final fun sequence (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lkotlin/ranges/IntRange;)Lio/kotest/property/Arb; - public static synthetic fun sequence$default (Larrow/core/test/UnitSpec;Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lkotlin/ranges/IntRange;ILjava/lang/Object;)Lio/kotest/property/Arb; - public final fun testLaws (Ljava/lang/String;[Ljava/util/List;)V - public final fun testLaws ([Ljava/util/List;)V -} - -public final class arrow/core/test/concurrency/SideEffect { - public fun ()V - public fun (I)V - public synthetic fun (IILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()I - public final fun copy (I)Larrow/core/test/concurrency/SideEffect; - public static synthetic fun copy$default (Larrow/core/test/concurrency/SideEffect;IILjava/lang/Object;)Larrow/core/test/concurrency/SideEffect; - public fun equals (Ljava/lang/Object;)Z - public final fun getCounter ()I - public fun hashCode ()I - public final fun increment ()V - public final fun setCounter (I)V - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/test/concurrency/SideEffectKt { - public static final field deprecateArrowTestModules Ljava/lang/String; -} - -public final class arrow/core/test/generators/GeneratorsJvmKt { - public static final fun fatalThrowable (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun suspendFunThatThrowsFatalThrowable (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; -} - -public final class arrow/core/test/generators/GeneratorsKt { - public static final fun any (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun arbConst (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun byteSmall (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun doubleSmall (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun either (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun endo (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun eval (Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun floatSmall (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun functionAAToA (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun functionABToB (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun functionAToB (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun functionBAToB (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun functionToA (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun intPredicate (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun intSmall (Lio/kotest/property/Arb$Companion;I)Lio/kotest/property/Arb; - public static synthetic fun intSmall$default (Lio/kotest/property/Arb$Companion;IILjava/lang/Object;)Lio/kotest/property/Arb; - public static final fun ior (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun longSmall (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun nonZeroInt (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun option (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun or (Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun result (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun shortSmall (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun suspendFunThatReturnsAnyLeft (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun suspendFunThatReturnsAnyRight (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun suspendFunThatReturnsEitherAnyOrAnyOrThrows (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun suspendFunThatThrows (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun throwable (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun tuple10 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun tuple4 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun tuple5 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun tuple6 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun tuple7 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun tuple8 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun tuple9 (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun unit (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun validated (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; -} - -public final class arrow/core/test/generators/UtilsKt { - public static final fun suspend (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun suspend (Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/test/laws/FxLaws { - public static final field INSTANCE Larrow/core/test/laws/FxLaws; - public final fun eager (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Ljava/util/List; - public final fun suspended (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;)Ljava/util/List; -} - -public final class arrow/core/test/laws/Law { - public fun (Ljava/lang/String;Lkotlin/jvm/functions/Function2;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2 ()Lkotlin/jvm/functions/Function2; - public final fun copy (Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Larrow/core/test/laws/Law; - public static synthetic fun copy$default (Larrow/core/test/laws/Law;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Larrow/core/test/laws/Law; - public fun equals (Ljava/lang/Object;)Z - public final fun getName ()Ljava/lang/String; - public final fun getTest ()Lkotlin/jvm/functions/Function2; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/test/laws/LawKt { - public static final fun equalUnderTheLaw (Ljava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Z - public static synthetic fun equalUnderTheLaw$default (Ljava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Z -} - -public final class arrow/core/test/laws/MonoidLaws { - public static final field INSTANCE Larrow/core/test/laws/MonoidLaws; - public final fun combineAllIsDerived (Larrow/typeclasses/Monoid;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun combineAllOfEmptyIsEmpty (Larrow/typeclasses/Monoid;Lkotlin/jvm/functions/Function2;)V - public final fun laws (Larrow/typeclasses/Monoid;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/core/test/laws/MonoidLaws;Larrow/typeclasses/Monoid;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun monoidLeftIdentity (Larrow/typeclasses/Monoid;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun monoidRightIdentity (Larrow/typeclasses/Monoid;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/test/laws/SemigroupLaws { - public static final field INSTANCE Larrow/core/test/laws/SemigroupLaws; - public final fun laws (Larrow/typeclasses/Semigroup;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/core/test/laws/SemigroupLaws;Larrow/typeclasses/Semigroup;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun semigroupAssociative (Larrow/typeclasses/Semigroup;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/test/laws/SemiringLaws { - public static final field INSTANCE Larrow/core/test/laws/SemiringLaws; - public final fun laws (Larrow/typeclasses/Semiring;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/core/test/laws/SemiringLaws;Larrow/typeclasses/Semiring;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; -} - diff --git a/arrow-libs/core/arrow-core-test/build.gradle.kts b/arrow-libs/core/arrow-core-test/build.gradle.kts deleted file mode 100644 index 4d168762690..00000000000 --- a/arrow-libs/core/arrow-core-test/build.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -plugins { - id(libs.plugins.kotlin.multiplatform.get().pluginId) - alias(libs.plugins.arrowGradleConfig.kotlin) - alias(libs.plugins.arrowGradleConfig.publish) -} - -apply(from = property("ANIMALSNIFFER_MPP")) - -kotlin { - sourceSets { - commonMain { - dependencies { - api(projects.arrowCore) - api(libs.coroutines.core) - api(libs.kotest.assertionsCore) - api(libs.kotest.frameworkEngine) - api(libs.kotest.property) - implementation(libs.kotlin.stdlibCommon) - } - } - jvmMain { - dependencies { - implementation(libs.kotlin.stdlibJDK8) - } - } - jvmTest { - dependencies { - runtimeOnly(libs.kotest.runnerJUnit5) - } - } - jsMain { - dependencies { - implementation(libs.kotlin.stdlibJS) - } - } - } -} diff --git a/arrow-libs/core/arrow-core-test/gradle.properties b/arrow-libs/core/arrow-core-test/gradle.properties deleted file mode 100644 index 4c111c13f4d..00000000000 --- a/arrow-libs/core/arrow-core-test/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Maven publishing configuration -pom.name=Arrow-Core-Test -kapt.incremental.apt=false diff --git a/arrow-libs/core/arrow-core-test/knit.properties b/arrow-libs/core/arrow-core-test/knit.properties deleted file mode 100644 index 4e14d37ba83..00000000000 --- a/arrow-libs/core/arrow-core-test/knit.properties +++ /dev/null @@ -1,5 +0,0 @@ -knit.package=arrow.core.test.examples -knit.dir=src/commonTest/kotlin/examples/ - -test.package=arrow.core.test.examples.test -test.dir=src/commonTest/kotlin/examples/autogenerated/ diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt deleted file mode 100644 index 1818b04830c..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt +++ /dev/null @@ -1,14 +0,0 @@ -package arrow.core.test - -import arrow.core.test.concurrency.deprecateArrowTestModules - -@Deprecated(deprecateArrowTestModules) -public expect fun isJvm(): Boolean -@Deprecated(deprecateArrowTestModules) -public expect fun isJs(): Boolean -@Deprecated(deprecateArrowTestModules) -public expect fun isNative(): Boolean - -@Deprecated(deprecateArrowTestModules) -public fun stackSafeIteration(): Int = - if (isJvm()) 500_000 else 1000 diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt deleted file mode 100644 index bb44b0620dc..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt +++ /dev/null @@ -1,277 +0,0 @@ -package arrow.core.test - -import arrow.core.* -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.core.test.generators.unit -import arrow.core.test.laws.Law -import io.kotest.core.names.TestName -import io.kotest.core.spec.style.StringSpec -import io.kotest.core.spec.style.scopes.StringSpecScope -import io.kotest.core.spec.style.scopes.addTest -import io.kotest.property.Arb -import io.kotest.property.Gen -import io.kotest.property.PropertyContext -import io.kotest.property.arbitrary.bind -import io.kotest.property.arbitrary.filterIsInstance -import io.kotest.property.arbitrary.map -import io.kotest.property.arbitrary.list as KList -import io.kotest.property.arbitrary.map as KMap -import io.kotest.property.checkAll -import kotlin.jvm.JvmOverloads -import kotlin.math.max - -/** - * Base class for unit tests - */ -@Deprecated(deprecateArrowTestModules) -public abstract class UnitSpec( - public val iterations: Int = 250, - public val maxDepth: Int = 15, - spec: UnitSpec.() -> Unit = {} -) : StringSpec() { - - @Deprecated(deprecateArrowTestModules) - public constructor(spec: UnitSpec.() -> Unit) : this(250, 15, spec) - - @Deprecated(deprecateArrowTestModules) - public fun Arb.Companion.list(gen: Gen, range: IntRange = 0..maxDepth): Arb> = - Arb.KList(gen, range) - - @Deprecated(deprecateArrowTestModules) - public fun Arb.Companion.nonEmptyList(arb: Arb, depth: Int = maxDepth): Arb> { - return Arb.list(arb, 1..max(1, depth)) - .map { Option.fromNullable(it.toNonEmptyListOrNull()) } - .filterIsInstance>, Some>>() - .map { it.value } - } - - @Deprecated(deprecateArrowTestModules) - public fun Arb.Companion.sequence(arbA: Arb, range: IntRange = 0..maxDepth): Arb> = - Arb.list(arbA, range).map { it.asSequence() } - - @JvmOverloads - @Deprecated(deprecateArrowTestModules) - public inline fun Arb.Companion.array(gen: Arb, range: IntRange = 0..maxDepth): Arb> = - Arb.list(gen, range).map { it.toTypedArray() } - - @Deprecated(deprecateArrowTestModules) - public fun Arb.Companion.map( - keyArb: Arb, - valueArb: Arb, - minSize: Int = 1, - maxSize: Int = 15 - ): Arb> = - Arb.KMap(keyArb, valueArb, minSize = minSize, maxSize = maxSize) - - init { - spec() - } - - @Deprecated(deprecateArrowTestModules) - public fun testLaws(vararg laws: List): Unit = laws - .flatMap { list: List -> list.asIterable() } - .distinctBy { law: Law -> law.name } - .forEach { law: Law -> - addTest(TestName(null, law.name, false), false, null) { - law.test(StringSpecScope(this.coroutineContext, testCase)) - } - } - - @Deprecated(deprecateArrowTestModules) - public fun testLaws(prefix: String, vararg laws: List): Unit = laws - .flatMap { list: List -> list.asIterable() } - .distinctBy { law: Law -> law.name } - .forEach { law: Law -> - addTest(TestName(prefix, law.name, false), false, null) { - law.test(StringSpecScope(this.coroutineContext, testCase)) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll(property: suspend PropertyContext.() -> Unit): PropertyContext = - checkAll(iterations, Arb.unit()) { property() } - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - genA: Arb, - property: suspend PropertyContext.(A) -> Unit - ): PropertyContext = - checkAll( - iterations, - genA, - property - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - genA: Arb, - genB: Arb, - property: suspend PropertyContext.(A, B) -> Unit - ): PropertyContext = - checkAll( - iterations, - genA, - genB, - property - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - genA: Arb, - genB: Arb, - genC: Arb, - property: suspend PropertyContext.(A, B, C) -> Unit - ): PropertyContext = - checkAll( - iterations, - genA, - genB, - genC, - property - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - genA: Arb, - genB: Arb, - genC: Arb, - genD: Arb, - property: suspend PropertyContext.(A, B, C, D) -> Unit - ): PropertyContext = - checkAll( - iterations, - genA, - genB, - genC, - genD, - property - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - genA: Arb, - genB: Arb, - genC: Arb, - genD: Arb, - genE: Arb, - property: suspend PropertyContext.(A, B, C, D, E) -> Unit - ): PropertyContext = - checkAll( - iterations, - genA, - genB, - genC, - genD, - genE, - property - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - genA: Arb, - genB: Arb, - genC: Arb, - genD: Arb, - genE: Arb, - genF: Arb, - property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit - ): PropertyContext = - checkAll( - iterations, - genA, - genB, - genC, - genD, - genE, - genF, - property - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - gena: Arb, - genb: Arb, - genc: Arb, - gend: Arb, - gene: Arb, - genf: Arb, - geng: Arb, - fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G) -> Unit - ) { - checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, ::Pair)) { a, b, c, d, e, (f, g) -> - fn(a, b, c, d, e, f, g) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - gena: Arb, - genb: Arb, - genc: Arb, - gend: Arb, - gene: Arb, - genf: Arb, - geng: Arb, - genh: Arb, - fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) -> Unit - ) { - checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, genh, ::Triple)) { a, b, c, d, e, (f, g, h) -> - fn(a, b, c, d, e, f, g, h) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - gena: Arb, - genb: Arb, - genc: Arb, - gend: Arb, - gene: Arb, - genf: Arb, - geng: Arb, - genh: Arb, - geni: Arb, - fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) -> Unit - ) { - checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, genh, geni, ::Tuple4)) { a, b, c, d, e, (f, g, h, i) -> - fn(a, b, c, d, e, f, g, h, i) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun checkAll( - gena: Arb, - genb: Arb, - genc: Arb, - gend: Arb, - gene: Arb, - genf: Arb, - geng: Arb, - genh: Arb, - geni: Arb, - genj: Arb, - fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) -> Unit - ) { - checkAll( - gena, - genb, - genc, - gend, - gene, - Arb.bind(genf, geng, genh, geni, genj, ::Tuple5) - ) { a, b, c, d, e, (f, g, h, i, j) -> - fn(a, b, c, d, e, f, g, h, i, j) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun forFew( - iterations: Int, - property: suspend PropertyContext.(Unit) -> Unit - ): PropertyContext = - checkAll( - iterations, - Arb.unit(), - property - ) -} diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt deleted file mode 100644 index d643af6395e..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt +++ /dev/null @@ -1,12 +0,0 @@ -package arrow.core.test.concurrency - -@Deprecated(deprecateArrowTestModules) -public data class SideEffect(var counter: Int = 0) { - @Deprecated(deprecateArrowTestModules) - public fun increment() { - counter++ - } -} - -public const val deprecateArrowTestModules: String = - "arrow test modules are being deprecated in favour of kotest-arrow-extension libraries" diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt deleted file mode 100644 index 49c19601228..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt +++ /dev/null @@ -1,276 +0,0 @@ -package arrow.core.test.generators - -import arrow.core.Const -import arrow.core.Either -import arrow.core.Endo -import arrow.core.Eval -import arrow.core.Ior -import arrow.core.Option -import arrow.core.Tuple10 -import arrow.core.Tuple4 -import arrow.core.Tuple5 -import arrow.core.Tuple6 -import arrow.core.Tuple7 -import arrow.core.Tuple8 -import arrow.core.Tuple9 -import arrow.core.Validated -import arrow.core.left -import arrow.core.right -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.core.toOption -import io.kotest.property.Arb -import io.kotest.property.arbitrary.bind -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.byte -import io.kotest.property.arbitrary.choice -import io.kotest.property.arbitrary.constant -import io.kotest.property.arbitrary.filter -import io.kotest.property.arbitrary.flatMap -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.long -import io.kotest.property.arbitrary.map -import io.kotest.property.arbitrary.numericDoubles -import io.kotest.property.arbitrary.numericFloats -import io.kotest.property.arbitrary.of -import io.kotest.property.arbitrary.orNull -import io.kotest.property.arbitrary.short -import io.kotest.property.arbitrary.string -import kotlin.Result.Companion.failure -import kotlin.Result.Companion.success -import kotlin.math.abs -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.functionAToB(arb: Arb): Arb<(A) -> B> = - arb.map { b: B -> { _: A -> b } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.functionAAToA(arb: Arb): Arb<(A, A) -> A> = - arb.map { a: A -> { _: A, _: A -> a } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.functionBAToB(arb: Arb): Arb<(B, A) -> B> = - arb.map { b: B -> { _: B, _: A -> b } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.functionABToB(arb: Arb): Arb<(A, B) -> B> = - arb.map { b: B -> { _: A, _: B -> b } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.functionToA(arb: Arb): Arb<() -> A> = - arb.map { a: A -> { a } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.throwable(): Arb = - Arb.of(listOf(RuntimeException(), NoSuchElementException(), IllegalArgumentException())) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.result(arbA: Arb): Arb> = - Arb.choice(arbA.map(::success), throwable().map(::failure)) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.doubleSmall(): Arb = - Arb.numericDoubles(from = 0.0, to = 100.0) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.floatSmall(): Arb = - Arb.numericFloats(from = 0F, to = 100F) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.intSmall(factor: Int = 10000): Arb = - Arb.int((Int.MIN_VALUE / factor)..(Int.MAX_VALUE / factor)) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.byteSmall(): Arb = - Arb.byte(min = (Byte.MIN_VALUE / 10).toByte(), max = (Byte.MAX_VALUE / 10).toByte()) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.shortSmall(): Arb { - val range = (Short.MIN_VALUE / 1000)..(Short.MAX_VALUE / 1000) - return Arb.short().filter { it in range } -} - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.longSmall(): Arb = - Arb.long((Long.MIN_VALUE / 100000L)..(Long.MAX_VALUE / 100000L)) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple4(arbA: Arb, arbB: Arb, arbC: Arb, arbD: Arb): Arb> = - Arb.bind(arbA, arbB, arbC, arbD, ::Tuple4) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple5( - arbA: Arb, - arbB: Arb, - arbC: Arb, - arbD: Arb, - arbE: Arb -): Arb> = - Arb.bind(arbA, arbB, arbC, arbD, arbE, ::Tuple5) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple6( - arbA: Arb, - arbB: Arb, - arbC: Arb, - arbD: Arb, - arbE: Arb, - arbF: Arb -): Arb> = - Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, ::Tuple6) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple7( - arbA: Arb, - arbB: Arb, - arbC: Arb, - arbD: Arb, - arbE: Arb, - arbF: Arb, - arbG: Arb -): Arb> = - Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, arbG, ::Tuple7) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple8( - arbA: Arb, - arbB: Arb, - arbC: Arb, - arbD: Arb, - arbE: Arb, - arbF: Arb, - arbG: Arb, - arbH: Arb -): Arb> = - Arb.bind( - Arb.tuple7(arbA, arbB, arbC, arbD, arbE, arbF, arbG), - arbH - ) { (a, b, c, d, e, f, g), h -> - Tuple8(a, b, c, d, e, f, g, h) - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple9( - arbA: Arb, - arbB: Arb, - arbC: Arb, - arbD: Arb, - arbE: Arb, - arbF: Arb, - arbG: Arb, - arbH: Arb, - arbI: Arb -): Arb> = - Arb.bind( - Arb.tuple8(arbA, arbB, arbC, arbD, arbE, arbF, arbG, arbH), - arbI - ) { (a, b, c, d, e, f, g, h), i -> - Tuple9(a, b, c, d, e, f, g, h, i) - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.tuple10( - arbA: Arb, - arbB: Arb, - arbC: Arb, - arbD: Arb, - arbE: Arb, - arbF: Arb, - arbG: Arb, - arbH: Arb, - arbI: Arb, - arbJ: Arb -): Arb> = - Arb.bind( - Arb.tuple9(arbA, arbB, arbC, arbD, arbE, arbF, arbG, arbH, arbI), - arbJ - ) { (a, b, c, d, e, f, g, h, i), j -> - Tuple10(a, b, c, d, e, f, g, h, i, j) - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.nonZeroInt(): Arb = Arb.int().filter { it != 0 } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.intPredicate(): Arb<(Int) -> Boolean> = - Arb.nonZeroInt().flatMap { num -> - val absNum = abs(num) - Arb.of( - listOf<(Int) -> Boolean>( - { it > num }, - { it <= num }, - { it % absNum == 0 }, - { it % absNum == absNum - 1 } - ) - ) - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.endo(arb: Arb): Arb> = arb.map { a: A -> Endo { a } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.option(arb: Arb): Arb> = - arb.orNull().map { it.toOption() } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.either(arbE: Arb, arbA: Arb): Arb> { - val arbLeft = arbE.map { Either.Left(it) } - val arbRight = arbA.map { Either.Right(it) } - return Arb.choice(arbLeft, arbRight) -} - -@Deprecated(deprecateArrowTestModules) -public fun Arb.or(arbA: Arb): Arb> = Arb.either(this, arbA) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.validated(arbE: Arb, arbA: Arb): Arb> = - Arb.either(arbE, arbA).map { Validated.fromEither(it) } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.unit(): Arb = - Arb.constant(Unit) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.ior(arbA: Arb, arbB: Arb): Arb> = - arbA.alignWith(arbB) { it } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.arbConst(arb: Arb): Arb> = - arb.map { Const(it) } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.eval(): Arb> = - map { Eval.now(it) } - -@Deprecated(deprecateArrowTestModules) -private fun Arb.alignWith(arbB: Arb, transform: (Ior) -> R): Arb = - Arb.bind(this, arbB) { a, b -> transform(Ior.Both(a, b)) } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.suspendFunThatReturnsEitherAnyOrAnyOrThrows(): Arb Either> = - choice( - suspendFunThatReturnsAnyRight(), - suspendFunThatReturnsAnyLeft(), - suspendFunThatThrows() - ) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.suspendFunThatReturnsAnyRight(): Arb Either> = - any().map { suspend { it.right() } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.suspendFunThatReturnsAnyLeft(): Arb Either> = - any().map { suspend { it.left() } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.suspendFunThatThrows(): Arb Either> = - throwable().map { suspend { throw it } } as Arb Either> - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.any(): Arb = - choice( - Arb.string() as Arb, - Arb.int() as Arb, - Arb.long() as Arb, - Arb.boolean() as Arb, - Arb.throwable() as Arb, - Arb.unit() as Arb - ) diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt deleted file mode 100644 index 838fc1004be..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt +++ /dev/null @@ -1,33 +0,0 @@ -package arrow.core.test.generators - -import arrow.core.test.concurrency.deprecateArrowTestModules -import kotlin.coroutines.Continuation -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.intercepted -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn -import kotlin.coroutines.startCoroutine -import kotlinx.coroutines.Dispatchers - -@Deprecated(deprecateArrowTestModules) -public suspend fun Throwable.suspend(): Nothing = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { throw this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } - -@Deprecated(deprecateArrowTestModules) -public suspend fun A.suspend(): A = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt deleted file mode 100644 index 02f311cdee1..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt +++ /dev/null @@ -1,186 +0,0 @@ -package arrow.core.test.laws - -import arrow.continuations.Effect -import arrow.core.Either -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.core.test.generators.throwable -import io.kotest.assertions.fail -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.checkAll -import kotlinx.coroutines.Dispatchers -import kotlin.coroutines.Continuation -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.intercepted -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn -import kotlin.coroutines.startCoroutine - -private typealias EagerFxBlock = (suspend Eff.() -> A) -> F -private typealias SuspendFxBlock = suspend (suspend Eff.() -> A) -> F - -@Deprecated(deprecateArrowTestModules) -public object FxLaws { - - @Deprecated(deprecateArrowTestModules) - public fun , F, A> suspended( - pureArb: Arb, - G: Arb, - eq: (F, F) -> Boolean, - fxSuspend: SuspendFxBlock, - invoke: suspend Eff.(F) -> A - ): List = listOf( - Law("suspended fx can bind immediate values") { suspendedCanBindImmediateValues(G, eq, fxSuspend, invoke) }, - Law("suspended fx can bind suspended values") { suspendedCanBindSuspendedValues(G, eq, fxSuspend, invoke) }, - Law("suspended fx can bind immediate exceptions") { - suspendedCanBindImmediateExceptions( - pureArb, - fxSuspend, - invoke - ) - }, - Law("suspended fx can bind suspended exceptions") { - suspendedCanBindSuspendedExceptions( - pureArb, - fxSuspend, - invoke - ) - } - ) - - @Deprecated(deprecateArrowTestModules) - public fun , F, A> eager( - pureArb: Arb, - G: Arb, - eq: (F, F) -> Boolean, - fxEager: EagerFxBlock, - invoke: suspend Eff.(F) -> A - ): List = listOf( - Law("non-suspended fx can bind immediate values") { nonSuspendedCanBindImmediateValues(G, eq, fxEager, invoke) }, - Law("non-suspended fx can bind immediate exceptions") { - nonSuspendedCanBindImmediateException( - pureArb, - fxEager, - invoke - ) - } - ) - - private suspend fun , F, A> nonSuspendedCanBindImmediateValues( - G: Arb, - eq: (F, F) -> Boolean, - fxBlock: EagerFxBlock, - invoke: suspend Eff.(F) -> A - ) { - checkAll(G) { f: F -> - fxBlock { - val res = invoke(f) - res - }.equalUnderTheLaw(f, eq) - } - } - - private suspend fun , F, A> nonSuspendedCanBindImmediateException( - G: Arb, - fxBlock: EagerFxBlock, - invoke: suspend Eff.(F) -> A - ) { - checkAll(G, Arb.throwable()) { f, exception -> - Either.catch { - fxBlock { - val res = invoke(f) - throw exception - res - } - - fail("It should never reach here. fx should've thrown $exception") - } shouldBe Either.Left(exception) - } - } - - private suspend fun , F, A> suspendedCanBindImmediateValues( - G: Arb, - eq: (F, F) -> Boolean, - fxBlock: SuspendFxBlock, - invoke: suspend Eff.(F) -> A - ) { - checkAll(G) { value -> - fxBlock { - val res = invoke(value) - res - }.equalUnderTheLaw(value, eq) - } - } - - private suspend fun , F, A> suspendedCanBindSuspendedValues( - G: Arb, - eq: (F, F) -> Boolean, - fxBlock: SuspendFxBlock, - invoke: suspend Eff.(F) -> A - ) { - checkAll(10, G) { value -> - fxBlock { - val res = invoke(value.suspend()) - res - }.equalUnderTheLaw(value, eq) - } - } - - private suspend fun , F, A> suspendedCanBindImmediateExceptions( - G: Arb, - fxBlock: SuspendFxBlock, - invoke: suspend Eff.(F) -> A - ) { - checkAll(G, Arb.throwable()) { value, e -> - Either.catch { - fxBlock { - val res = invoke(value) - throw e - res - } - fail("It should never reach here. fx should've thrown $e but found $e") - } shouldBe Either.Left(e) - } - } - - private suspend fun , F, A> suspendedCanBindSuspendedExceptions( - G: Arb, - fxBlock: SuspendFxBlock, - invoke: suspend Eff.(F) -> A - ) { - checkAll(10, G, Arb.throwable()) { value, e -> - Either.catch { - val res = fxBlock { - val res = invoke(value) - e.suspend() - res - } - fail("It should never reach here. fx should've thrown $e but found $res") - } shouldBe Either.Left(e) - } - } -} - -// TODO expose for tests -@Deprecated(deprecateArrowTestModules) -internal suspend fun Throwable.suspend(): Nothing = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { throw this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } - -@Deprecated(deprecateArrowTestModules) -internal suspend fun A.suspend(): A = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt deleted file mode 100644 index ab07d42bd01..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt +++ /dev/null @@ -1,12 +0,0 @@ -package arrow.core.test.laws - -import arrow.core.test.concurrency.deprecateArrowTestModules -import io.kotest.assertions.fail -import io.kotest.core.test.TestContext - -@Deprecated(deprecateArrowTestModules) -public data class Law(val name: String, val test: suspend TestContext.() -> Unit) - -@Deprecated(deprecateArrowTestModules) -public fun A.equalUnderTheLaw(b: A, f: (A, A) -> Boolean = { a, b -> a == b }): Boolean = - if (f(this, b)) true else fail("Found $this but expected: $b") diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt deleted file mode 100644 index 8d8822e2e37..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt +++ /dev/null @@ -1,45 +0,0 @@ -package arrow.core.test.laws - -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.typeclasses.Monoid -import io.kotest.property.Arb -import io.kotest.property.checkAll -import io.kotest.matchers.shouldBe -import io.kotest.property.PropertyContext -import io.kotest.property.arbitrary.list - -@Deprecated(deprecateArrowTestModules) -public object MonoidLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws(M: Monoid, GEN: Arb, eq: (F, F) -> Boolean = { a, b -> a == b }): List = - SemigroupLaws.laws(M, GEN, eq) + - listOf( - Law("Monoid Laws: Left identity") { M.monoidLeftIdentity(GEN, eq) }, - Law("Monoid Laws: Right identity") { M.monoidRightIdentity(GEN, eq) }, - Law("Monoid Laws: combineAll should be derived") { M.combineAllIsDerived(GEN, eq) }, - Law("Monoid Laws: combineAll of empty list is empty") { M.combineAllOfEmptyIsEmpty(eq) } - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun Monoid.monoidLeftIdentity(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN) { a -> - (empty().combine(a)).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Monoid.monoidRightIdentity(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN) { a -> - a.combine(empty()).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Monoid.combineAllIsDerived(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(5, Arb.list(GEN)) { list -> - list.combineAll().equalUnderTheLaw(if (list.isEmpty()) empty() else list.reduce { acc, f -> acc.combine(f) }, eq) - } - - @Deprecated(deprecateArrowTestModules) - public fun Monoid.combineAllOfEmptyIsEmpty(eq: (F, F) -> Boolean): Unit = - emptyList().combineAll().equalUnderTheLaw(empty(), eq) shouldBe true -} diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt deleted file mode 100644 index d031c3f62a3..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt +++ /dev/null @@ -1,21 +0,0 @@ -package arrow.core.test.laws - -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.typeclasses.Semigroup -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.checkAll - -@Deprecated(deprecateArrowTestModules) -public object SemigroupLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws(SG: Semigroup, G: Arb, eq: (F, F) -> Boolean = { a, b -> a == b }): List = - listOf(Law("Semigroup: associativity") { SG.semigroupAssociative(G, eq) }) - - @Deprecated(deprecateArrowTestModules) - public suspend fun Semigroup.semigroupAssociative(G: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(G, G, G) { A, B, C -> - A.combine(B).combine(C).equalUnderTheLaw(A.combine(B.combine(C)), eq) - } -} diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt deleted file mode 100644 index 0f30f49e64b..00000000000 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt +++ /dev/null @@ -1,157 +0,0 @@ -package arrow.core.test.laws - -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.typeclasses.Semiring -import io.kotest.property.Arb -import io.kotest.property.checkAll -import io.kotest.matchers.shouldBe -import io.kotest.property.PropertyContext - -@Deprecated(deprecateArrowTestModules) -public object SemiringLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws(SG: Semiring, GEN: Arb, eq: (F, F) -> Boolean = { a, b -> a == b }): List = - listOf( - Law("Semiring: Additive commutativity") { SG.semiringAdditiveCommutativity(GEN, eq) }, - Law("Semiring: Additive left identity") { SG.semiringAdditiveLeftIdentity(GEN, eq) }, - Law("Semiring: Additive right identity") { SG.semiringAdditiveRightIdentity(GEN, eq) }, - Law("Semiring: Additive associativity") { SG.semiringAdditiveAssociativity(GEN, eq) }, - Law("Semiring: Multiplicative commutativity") { SG.semiringMultiplicativeCommutativity(GEN, eq) }, - Law("Semiring: Multiplicative left identity") { SG.semiringMultiplicativeLeftIdentity(GEN, eq) }, - Law("Semiring: Multiplicative right identity") { SG.semiringMultiplicativeRightIdentity(GEN, eq) }, - Law("Semiring: Multiplicative associativity") { SG.semiringMultiplicativeAssociativity(GEN, eq) }, - Law("Semiring: Right distributivity") { SG.semiringRightDistributivity(GEN, eq) }, - Law("Semiring: Left distributivity") { SG.semiringLeftDistributivity(GEN, eq) }, - Law("Semiring: Multiplicative left absorption") { SG.semiringMultiplicativeLeftAbsorption(GEN, eq) }, - Law("Semiring: Multiplicative right absorption") { SG.semiringMultiplicativeRightAbsorption(GEN, eq) }, - Law("Semiring: times is derived") { SG.timesIsDerived(GEN, eq) }, - Law("Semiring: plus is derived") { SG.plusIsDerived(GEN, eq) }, - Law("Semiring: maybeCombineAddition is derived") { SG.maybeCombineAdditionIsDerived(GEN, eq) }, - Law("Semiring: maybeCombineAddition left null") { SG.maybeCombineAdditionLeftNull(GEN, eq) }, - Law("Semiring: maybeCombineAddition right null") { SG.maybeCombineAdditionRightNull(GEN, eq) }, - Law("Semiring: maybeCombineAddition both null") { SG.maybeCombineAdditionBothNull(eq) }, - Law("Semiring: maybeCombineMultiplicate is derived") { SG.maybeCombineMultiplicateIsDerived(GEN, eq) }, - Law("Semiring: maybeCombineMultiplicate left null") { SG.maybeCombineMultiplicateLeftNull(GEN, eq) }, - Law("Semiring: maybeCombineMultiplicate right null") { SG.maybeCombineMultiplicateRightNull(GEN, eq) }, - Law("Semiring: maybeCombineMultiplicate both null") { SG.maybeCombineMultiplicateBothNull(eq) } - ) - - // a + b = b + a - private suspend fun Semiring.semiringAdditiveCommutativity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN, GEN) { a, b -> - a.combine(b).equalUnderTheLaw(b.combine(a), eq) - } - - // 0 + a = a - private suspend fun Semiring.semiringAdditiveLeftIdentity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN) { A -> - (zero().combine(A)).equalUnderTheLaw(A, eq) - } - - // a + 0 = a - private suspend fun Semiring.semiringAdditiveRightIdentity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN) { A -> - A.combine(zero()).equalUnderTheLaw(A, eq) - } - - // a + (b + c) = (a + b) + c - private suspend fun Semiring.semiringAdditiveAssociativity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN, GEN, GEN) { A, B, C -> - A.combine(B.combine(C)).equalUnderTheLaw((A.combine(B)).combine(C), eq) - } - - // a · b = b · a - private suspend fun Semiring.semiringMultiplicativeCommutativity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN, GEN) { a, b -> - a.combineMultiplicate(b).equalUnderTheLaw(b.combineMultiplicate(a), eq) - } - - // 1 · a = a - private suspend fun Semiring.semiringMultiplicativeLeftIdentity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN) { A -> - (one().combineMultiplicate(A)).equalUnderTheLaw(A, eq) - } - - // a · 1 = a - private suspend fun Semiring.semiringMultiplicativeRightIdentity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN) { A -> - A.combineMultiplicate(one()).equalUnderTheLaw(A, eq) - } - - // a · (b · c) = (a · b) · c - private suspend fun Semiring.semiringMultiplicativeAssociativity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN, GEN, GEN) { A, B, C -> - A.combineMultiplicate(B.combineMultiplicate(C)).equalUnderTheLaw((B.combineMultiplicate(A)).combineMultiplicate(C), eq) - } - - // (a + b) · c = a · c + b · c - private suspend fun Semiring.semiringRightDistributivity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN, GEN, GEN) { A, B, C -> - (A.combine(B)).combineMultiplicate(C).equalUnderTheLaw((A.combineMultiplicate(C)).combine(B.combineMultiplicate(C)), eq) - } - - // a · (b + c) = a · b + a · c - private suspend fun Semiring.semiringLeftDistributivity(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN, GEN, GEN) { A, B, C -> - A.combineMultiplicate(B.combine(C)).equalUnderTheLaw((A.combineMultiplicate(B)).combine(A.combineMultiplicate(C)), eq) - } - - // 0 · a = 0 - private suspend fun Semiring.semiringMultiplicativeLeftAbsorption(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN) { A -> - (zero().combineMultiplicate(A)).equalUnderTheLaw(zero(), eq) - } - - // a · 0 = 0 - private suspend fun Semiring.semiringMultiplicativeRightAbsorption(GEN: Arb, eq: (F, F) -> Boolean) = - checkAll(GEN) { A -> - A.combineMultiplicate(zero()).equalUnderTheLaw(zero(), eq) - } - - private suspend fun Semiring.timesIsDerived(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN, GEN) { A, B -> - A.times(B).equalUnderTheLaw(A.combineMultiplicate(B), eq) - } - - private suspend fun Semiring.plusIsDerived(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN, GEN) { A, B -> - A.plus(B).equalUnderTheLaw(A.combine(B), eq) - } - - private suspend fun Semiring.maybeCombineAdditionIsDerived(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN, GEN) { A, B -> - A.maybeCombineAddition(B).equalUnderTheLaw(A.combine(B), eq) - } - - private suspend fun Semiring.maybeCombineAdditionLeftNull(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN) { A -> - null.maybeCombineAddition(A).equalUnderTheLaw(zero(), eq) - } - - private suspend fun Semiring.maybeCombineAdditionRightNull(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN) { A -> - A.maybeCombineAddition(null).equalUnderTheLaw(A, eq) - } - - private fun Semiring.maybeCombineAdditionBothNull(eq: (F, F) -> Boolean): Unit = - null.maybeCombineAddition(null).equalUnderTheLaw(zero(), eq) shouldBe true - - private suspend fun Semiring.maybeCombineMultiplicateIsDerived(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN, GEN) { A, B -> - A.maybeCombineMultiplicate(B).equalUnderTheLaw(A.combineMultiplicate(B), eq) - } - - private suspend fun Semiring.maybeCombineMultiplicateLeftNull(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN) { A -> - null.maybeCombineMultiplicate(A).equalUnderTheLaw(one(), eq) - } - - private suspend fun Semiring.maybeCombineMultiplicateRightNull(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = - checkAll(GEN) { A -> - A.maybeCombineMultiplicate(null).equalUnderTheLaw(A, eq) - } - - private fun Semiring.maybeCombineMultiplicateBothNull(eq: (F, F) -> Boolean): Unit = - null.maybeCombineMultiplicate(null).equalUnderTheLaw(one(), eq) shouldBe true -} diff --git a/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt b/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt deleted file mode 100644 index 64c647e2734..00000000000 --- a/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt +++ /dev/null @@ -1,10 +0,0 @@ -package arrow.core.test - -import arrow.core.test.concurrency.deprecateArrowTestModules - -@Deprecated(deprecateArrowTestModules) -public actual fun isJvm(): Boolean = false -@Deprecated(deprecateArrowTestModules) -public actual fun isJs(): Boolean = true -@Deprecated(deprecateArrowTestModules) -public actual fun isNative(): Boolean = false diff --git a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt b/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt deleted file mode 100644 index c5c0ba90ee6..00000000000 --- a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt +++ /dev/null @@ -1,10 +0,0 @@ -package arrow.core.test - -import arrow.core.test.concurrency.deprecateArrowTestModules - -@Deprecated(deprecateArrowTestModules) -public actual fun isJvm(): Boolean = true -@Deprecated(deprecateArrowTestModules) -public actual fun isJs(): Boolean = false -@Deprecated(deprecateArrowTestModules) -public actual fun isNative(): Boolean = false diff --git a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt b/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt deleted file mode 100644 index 47242d610c9..00000000000 --- a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt +++ /dev/null @@ -1,15 +0,0 @@ -package arrow.core.test.generators - -import arrow.core.Either -import arrow.core.test.concurrency.deprecateArrowTestModules -import io.kotest.property.Arb -import io.kotest.property.arbitrary.map -import io.kotest.property.arbitrary.of - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.suspendFunThatThrowsFatalThrowable(): Arb Either> = - fatalThrowable().map { suspend { throw it } } as Arb Either> - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.fatalThrowable(): Arb = - Arb.of(listOf(ThreadDeath(), StackOverflowError(), OutOfMemoryError(), InterruptedException())) diff --git a/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt b/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt deleted file mode 100644 index 60e4ea88939..00000000000 --- a/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt +++ /dev/null @@ -1,10 +0,0 @@ -package arrow.core.test - -import arrow.core.test.concurrency.deprecateArrowTestModules - -@Deprecated(deprecateArrowTestModules) -public actual fun isJvm(): Boolean = false -@Deprecated(deprecateArrowTestModules) -public actual fun isJs(): Boolean = false -@Deprecated(deprecateArrowTestModules) -public actual fun isNative(): Boolean = true diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index 5c3541f2696..d5910f0848a 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -24,7 +24,6 @@ kotlin { sourceSets { commonMain { dependencies { - api(projects.arrowContinuations) api(projects.arrowAnnotations) api(libs.kotlin.stdlibCommon) } @@ -32,11 +31,14 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(project(":arrow-core-test")) - implementation(project(":arrow-fx-coroutines")) + implementation(libs.kotest.runnerJUnit5) + implementation(libs.kotest.assertionsCore) + implementation(libs.kotest.property) + implementation(libs.kotest.arrowAssertions) + implementation(libs.kotest.arrowProperty) + implementation(projects.arrowFxCoroutines) } } - jvmTest { dependencies { runtimeOnly(libs.kotest.runnerJUnit5) @@ -62,3 +64,8 @@ kotlin { tasks.named("compileTestKotlinJvm") { kotlinOptions.freeCompilerArgs += "-Xcontext-receivers" } +dependencies { + testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0") + testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0") + testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0") +} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt index 0c86bd2ccbe..978cacd651a 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt @@ -801,15 +801,6 @@ public sealed class Option { is Some -> operation(initial(value), value) } - public inline fun reduceRightEvalOrNull( - initial: (A) -> B, - operation: (A, acc: Eval) -> Eval - ): Eval = - when (this) { - is None -> Eval.now(null) - is Some -> operation(value, Eval.now(initial(value))) - } - public fun replicate(n: Int): Option> = if (n <= 0) Some(emptyList()) else map { a -> List(n) { a } } diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/either.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/either.kt deleted file mode 100644 index ffeaccf5db9..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/either.kt +++ /dev/null @@ -1,118 +0,0 @@ -package arrow.core.computations - -import arrow.continuations.Effect -import arrow.core.Either -import arrow.core.Either.Left -import arrow.core.Validated -import arrow.core.identity -import arrow.core.left -import arrow.core.right -import kotlin.contracts.ExperimentalContracts -import kotlin.contracts.contract -import kotlin.coroutines.RestrictsSuspension - -@Deprecated(deprecateInFavorOfEffectScope, ReplaceWith("EffectScope", "arrow.core.continuations.EffectScope")) -public fun interface EitherEffect : Effect> { - - public suspend fun Either.bind(): B = - when (this) { - is Either.Right -> value - is Left -> control().shift(this@bind) - } - - public suspend fun Validated.bind(): B = - when (this) { - is Validated.Valid -> value - is Validated.Invalid -> control().shift(Left(value)) - } - - public suspend fun Result.bind(transform: (Throwable) -> E): B = - fold(::identity) { throwable -> - control().shift(transform(throwable).left()) - } - - /** - * Ensure check if the [value] is `true`, - * and if it is it allows the `either { }` binding to continue. - * In case it is `false`, then it short-circuits the binding and returns - * the provided value by [orLeft] inside an [Either.Left]. - * - * ```kotlin - * import arrow.core.computations.either - * - * //sampleStart - * suspend fun main() { - * either { - * ensure(true) { "" } - * println("ensure(true) passes") - * ensure(false) { "failed" } - * 1 - * } - * //sampleEnd - * .let(::println) - * } - * // println: "ensure(true) passes" - * // res: Either.Left("failed") - * ``` - * - */ - public suspend fun ensure(value: Boolean, orLeft: () -> E): Unit = - if (value) Unit else orLeft().left().bind() -} - -/** - * Ensures that [value] is not null. - * When the value is not null, then it will be returned as non null and the check value is now smart-checked to non-null. - * Otherwise, if the [value] is null then the [either] binding will short-circuit with [orLeft] inside of [Either.Left]. - * - * ```kotlin - * import arrow.core.computations.either - * import arrow.core.computations.ensureNotNull - * - * //sampleStart - * suspend fun main() { - * either { - * val x: Int? = 1 - * ensureNotNull(x) { "passes" } - * println(x) - * ensureNotNull(null) { "failed" } - * } - * //sampleEnd - * .let(::println) - * } - * // println: "1" - * // res: Either.Left("failed") - * ``` - * - */ -@Deprecated(deprecateInFavorOfEffectScope) -@OptIn(ExperimentalContracts::class) // Contracts not available on open functions, so made it top-level. -public suspend fun EitherEffect.ensureNotNull(value: B?, orLeft: () -> E): B { - contract { - returns() implies (value != null) - } - - return value ?: orLeft().left().bind() -} - -@Deprecated(deprecatedInFavorOfEagerEffectScope, ReplaceWith("EagerEffectScope", "arrow.core.continuations.EagerEffectScope")) -@RestrictsSuspension -public fun interface RestrictedEitherEffect : EitherEffect - -@Deprecated(deprecateInFavorOfEffectOrEagerEffect, ReplaceWith("either", "arrow.core.continuations.either")) -@Suppress("ClassName") -public object either { - @Deprecated(deprecateInFavorOfEagerEffect, ReplaceWith("either.eager(c)", "arrow.core.continuations.either")) - public inline fun eager(crossinline c: suspend RestrictedEitherEffect.() -> A): Either = - Effect.restricted(eff = { RestrictedEitherEffect { it } }, f = c, just = { it.right() }) - - @Deprecated(deprecateInFavorOfEffect, ReplaceWith("either(c)", "arrow.core.continuations.either")) - public suspend inline operator fun invoke(crossinline c: suspend EitherEffect.() -> A): Either = - Effect.suspended(eff = { EitherEffect { it } }, f = c, just = { it.right() }) -} - -internal const val deprecatedInFavorOfEagerEffectScope: String = "Deprecated in favor of Eager Effect DSL: EagerEffectScope" -internal const val deprecateInFavorOfEffectScope: String = "Deprecated in favor of Effect DSL: EffectScope" -internal const val deprecateInFavorOfEffect: String = "Deprecated in favor of the Effect Runtime" -internal const val deprecateInFavorOfEagerEffect: String = "Deprecated in favor of the EagerEffect Runtime" -internal const val deprecateInFavorOfEffectOrEagerEffect: String = "Deprecated in favor of the Effect or EagerEffect Runtime" diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/eval.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/eval.kt deleted file mode 100644 index 20579e4ebf2..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/eval.kt +++ /dev/null @@ -1,27 +0,0 @@ -package arrow.core.computations - -import arrow.continuations.Effect -import arrow.core.Eval -import kotlin.coroutines.RestrictsSuspension - -@Deprecated(deprecateInFavorOfEffectScope, ReplaceWith("EffectScope", "arrow.core.continuations.EffectScope")) -public fun interface EvalEffect : Effect> { - public suspend fun Eval.bind(): B = - value() -} - -@Deprecated(deprecatedInFavorOfEagerEffectScope, ReplaceWith("EagerEffectScope", "arrow.core.continuations.EagerEffectScope")) -@RestrictsSuspension -public fun interface RestrictedEvalEffect : EvalEffect - -@Deprecated(deprecateInFavorOfEffectOrEagerEffect) -@Suppress("ClassName") -public object eval { - @Deprecated(deprecateInFavorOfEagerEffect, ReplaceWith("eagerEffect(func)", "arrow.core.continuations.eagerEffect")) - public inline fun eager(crossinline func: suspend RestrictedEvalEffect.() -> A): Eval = - Effect.restricted(eff = { RestrictedEvalEffect { it } }, f = func, just = Eval.Companion::now) - - @Deprecated(deprecateInFavorOfEffect, ReplaceWith("effect(func)", "arrow.core.continuations.effect")) - public suspend inline operator fun invoke(crossinline func: suspend EvalEffect<*>.() -> A): Eval = - Effect.suspended(eff = { EvalEffect { it } }, f = func, just = Eval.Companion::now) -} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/nullable.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/nullable.kt deleted file mode 100644 index 883da45cf17..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/nullable.kt +++ /dev/null @@ -1,95 +0,0 @@ -package arrow.core.computations - -import arrow.continuations.Effect -import arrow.core.None -import arrow.core.Option -import kotlin.contracts.ExperimentalContracts -import kotlin.contracts.contract -import kotlin.coroutines.RestrictsSuspension - -@Deprecated(deprecateInFavorOfEffectScope) -public fun interface NullableEffect : Effect { - public suspend fun B?.bind(): B = - this ?: control().shift(null) - - public suspend fun Option.bind(): B = - orNull().bind() - - /** - * Ensure check if the [value] is `true`, - * and if it is it allows the `nullable { }` binding to continue. - * In case it is `false`, then it short-circuits the binding and returns `null`. - * - * ```kotlin - * import arrow.core.computations.nullable - * - * //sampleStart - * suspend fun main() { - * nullable { - * ensure(true) - * println("ensure(true) passes") - * ensure(false) - * 1 - * } - * //sampleEnd - * .let(::println) - * } - * // println: "ensure(true) passes" - * // res: null - * ``` - * - */ - public suspend fun ensure(value: Boolean): Unit = - if (value) Unit else control().shift(null) -} - -/** - * Ensures that [value] is not null. - * When the value is not null, then it will be returned as non null and the check value is now smart-checked to non-null. - * Otherwise, if the [value] is null then the [option] binding will short-circuit with [None]. - * - * ```kotlin - * import arrow.core.computations.nullable - * import arrow.core.computations.ensureNotNull - * - * //sampleStart - * suspend fun main() { - * nullable { - * val x: Int? = 1 - * ensureNotNull(x) - * println(x) - * ensureNotNull(null) - * } - * //sampleEnd - * .let(::println) - * } - * // println: "1" - * // res: null - * ``` - * - */ -@Deprecated(deprecateInFavorOfEffectScope, ReplaceWith("ensureNotNull", "arrow.core.continuations.ensureNotNull")) -@OptIn(ExperimentalContracts::class) // Contracts not available on open functions, so made it top-level. -public suspend fun NullableEffect<*>.ensureNotNull(value: B?): B { - contract { - returns() implies (value != null) - } - - return value ?: control().shift(null) -} - -@Deprecated(deprecatedInFavorOfEagerEffectScope) -@RestrictsSuspension -public fun interface RestrictedNullableEffect : NullableEffect - -@Deprecated(deprecateInFavorOfEffectOrEagerEffect, ReplaceWith("nullable", "arrow.core.continuations.nullable")) -@Suppress("ClassName") -public object nullable { - @Deprecated(deprecateInFavorOfEagerEffect, ReplaceWith("nullable.eager(func)", "arrow.core.continuations.nullable")) - public inline fun eager(crossinline func: suspend RestrictedNullableEffect.() -> A?): A? = - Effect.restricted(eff = { RestrictedNullableEffect { it } }, f = func, just = { it }) - - @Deprecated(deprecateInFavorOfEffect, ReplaceWith("nullable(func)", "arrow.core.continuations.nullable")) - public suspend inline operator fun invoke(crossinline func: suspend NullableEffect<*>.() -> A?): A? = - Effect.suspended(eff = { NullableEffect { it } }, f = func, just = { it }) -} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/option.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/option.kt deleted file mode 100644 index 754bf1eb7c5..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/option.kt +++ /dev/null @@ -1,93 +0,0 @@ -package arrow.core.computations - -import arrow.continuations.Effect -import arrow.core.None -import arrow.core.Option -import arrow.core.identity -import kotlin.contracts.ExperimentalContracts -import kotlin.contracts.contract -import kotlin.coroutines.RestrictsSuspension - -@Deprecated(deprecateInFavorOfEffectScope, ReplaceWith("EffectScope", "arrow.core.continuations.EffectScope")) -public fun interface OptionEffect : Effect> { - public suspend fun Option.bind(): B = - fold({ control().shift(None) }, ::identity) - - /** - * Ensure check if the [value] is `true`, - * and if it is it allows the `option { }` binding to continue. - * In case it is `false`, then it short-circuits the binding and returns [None]. - * - * ```kotlin - * import arrow.core.computations.option - * - * //sampleStart - * suspend fun main() { - * option { - * ensure(true) - * println("ensure(true) passes") - * ensure(false) - * 1 - * } - * //sampleEnd - * .let(::println) - * } - * // println: "ensure(true) passes" - * // res: None - * ``` - * - */ - public suspend fun ensure(value: Boolean): Unit = - if (value) Unit else control().shift(None) -} - -/** - * Ensures that [value] is not null. - * When the value is not null, then it will be returned as non null and the check value is now smart-checked to non-null. - * Otherwise, if the [value] is null then the [option] binding will short-circuit with [None]. - * - * ```kotlin - * import arrow.core.computations.option - * import arrow.core.computations.ensureNotNull - * - * //sampleStart - * suspend fun main() { - * option { - * val x: Int? = 1 - * ensureNotNull(x) - * println(x) - * ensureNotNull(null) - * } - * //sampleEnd - * .let(::println) - * } - * // println: "1" - * // res: None - * ``` - * - */ -@Deprecated(deprecateInFavorOfEffectScope) -@OptIn(ExperimentalContracts::class) // Contracts not available on open functions, so made it top-level. -public suspend fun OptionEffect<*>.ensureNotNull(value: B?): B { - contract { - returns() implies (value != null) - } - - return value ?: (this as OptionEffect).control().shift(None) -} - -@Deprecated(deprecatedInFavorOfEagerEffectScope, ReplaceWith("EagerEffectScope", "arrow.core.continuations.EagerEffectScope")) -@RestrictsSuspension -public fun interface RestrictedOptionEffect : OptionEffect - -@Deprecated(deprecateInFavorOfEffectOrEagerEffect, ReplaceWith("option", "arrow.core.continuations.option")) -@Suppress("ClassName") -public object option { - @Deprecated(deprecateInFavorOfEagerEffect, ReplaceWith("option.eager(func)", "arrow.core.continuations.option")) - public inline fun eager(crossinline func: suspend RestrictedOptionEffect.() -> A): Option = - Effect.restricted(eff = { RestrictedOptionEffect { it } }, f = func, just = { Option.fromNullable(it) }) - - @Deprecated(deprecateInFavorOfEffect, ReplaceWith("option(func)", "arrow.core.continuations.option")) - public suspend inline operator fun invoke(crossinline func: suspend OptionEffect<*>.() -> A?): Option = - Effect.suspended(eff = { OptionEffect { it } }, f = func, just = { Option.fromNullable(it) }) -} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/result.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/result.kt deleted file mode 100644 index 68061797952..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/result.kt +++ /dev/null @@ -1,60 +0,0 @@ -package arrow.core.computations - -import arrow.core.Either -import arrow.core.Validated -import arrow.core.identity - -/** - * DSL Receiver Syntax for [result]. - */ -@Deprecated("$deprecatedInFavorOfEagerEffectScope\nThis object introduces dangerous behavior and will be removed in the next version: https://github.com/arrow-kt/arrow/issues/2547") -public object ResultEffect { - - @Deprecated("$deprecatedInFavorOfEagerEffectScope\nThis object introduces dangerous behavior and will be removed in the next version: https://github.com/arrow-kt/arrow/issues/2547") - public fun Result.bind(): A = - getOrThrow() - - @Deprecated("$deprecatedInFavorOfEagerEffectScope\nThis object introduces dangerous behavior and will be removed in the next version: https://github.com/arrow-kt/arrow/issues/2547") - public fun Either.bind(): A = - fold({ throw it }, ::identity) - - @Deprecated("$deprecatedInFavorOfEagerEffectScope\nThis object introduces dangerous behavior and will be removed in the next version: https://github.com/arrow-kt/arrow/issues/2547") - public fun Validated.bind(): A = - fold({ throw it }, ::identity) -} - -@Deprecated(deprecateInFavorOfEffectOrEagerEffect, ReplaceWith("result", "arrow.core.continuations.result")) -@Suppress("ClassName") -public object result { - - /** - * Provides a computation block for [Result] which is build on top of Kotlin's Result Std operations. - * - * ```kotlin - * import arrow.core.* - * import arrow.core.computations.result - * - * fun main() { - * result { // We can safely use assertion based operation inside blocks - * kotlin.require(false) { "Boom" } - * } // Result.Failure(IllegalArgumentException("Boom")) - * - * result { - * Result.failure(RuntimeException("Boom")) - * .recover { 1 } - * .bind() - * } // Result.Success(1) - * - * result { - * val x = Result.success(1).bind() - * val y = Result.success(x + 1).bind() - * x + y - * } // Result.Success(3) - * } - * ``` - * - */ - @Deprecated(deprecateInFavorOfEffect, ReplaceWith("result.eager(block)", "arrow.core.continuations.result")) - public inline operator fun invoke(block: ResultEffect.() -> A): Result = - kotlin.runCatching { block(ResultEffect) } -} diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Monoid.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Monoid.kt index 3de4fd8bcfa..5a75d62c69f 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Monoid.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Monoid.kt @@ -1,6 +1,5 @@ package arrow.typeclasses -import arrow.core.Const import arrow.core.Either import arrow.core.Endo import arrow.core.None @@ -86,14 +85,6 @@ public interface Monoid : Semigroup { override fun Endo.combine(g: Endo): Endo = Endo(f.compose(g.f)) } - @JvmStatic - @JvmName("constant") - public fun const(MA: Monoid): Monoid> = - object : Monoid> { - override fun empty(): Const = Const(MA.empty()) - override fun Const.combine(b: Const): Const = this.combine(MA, b) - } - @JvmStatic public fun map(SG: Semigroup): Monoid> = MapMonoid(SG) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Semigroup.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Semigroup.kt index 2de78ae1f4d..408b6a37655 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Semigroup.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/typeclasses/Semigroup.kt @@ -1,6 +1,5 @@ package arrow.typeclasses -import arrow.core.Const import arrow.core.Either import arrow.core.Endo import arrow.core.Ior @@ -68,14 +67,6 @@ public fun interface Semigroup { override fun Endo.combine(g: Endo): Endo = Endo(f.compose(g.f)) } - @JvmStatic - @JvmName("constant") - public fun const(SA: Semigroup): Semigroup> = - object : Semigroup> { - override fun Const.combine(b: Const): Const = - this.combine(SA, b) - } - @JvmStatic public fun map(SG: Semigroup): Semigroup> = MapSemigroup(SG) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EvalTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EvalTest.kt deleted file mode 100644 index fe4417e3b90..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EvalTest.kt +++ /dev/null @@ -1,140 +0,0 @@ -package arrow.core - -import arrow.core.test.UnitSpec -import arrow.core.test.concurrency.SideEffect -import arrow.core.test.stackSafeIteration -import io.kotest.matchers.shouldBe - -class EvalTest : UnitSpec() { - - init { - - testLaws( - /*FxLaws.suspended, Eval, Int>(Arb.int().map(Eval.Companion::now), Arb.int().map(Eval.Companion::now), Eval::equals, eval::invoke) { - it.bind() - }, - FxLaws.eager, Eval, Int>(Arb.int().map(Eval.Companion::now), Arb.int().map(Eval.Companion::now), Eval::equals, eval::eager) { - it.bind() - }*/ - ) - - "should map wrapped value" { - val sideEffect = SideEffect() - val mapped = Eval.now(0) - .map { sideEffect.increment(); it + 1 } - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 2 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 3 - } - - "later should lazily evaluate values once" { - val sideEffect = SideEffect() - val mapped = Eval.later { sideEffect.increment(); sideEffect.counter } - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - } - - "later should memoize values" { - val sideEffect = SideEffect() - val mapped = Eval.later { sideEffect.increment(); sideEffect.counter }.memoize() - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - } - - "always should lazily evaluate values repeatedly" { - val sideEffect = SideEffect() - val mapped = Eval.always { sideEffect.increment(); sideEffect.counter } - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 2 - sideEffect.counter shouldBe 2 - mapped.value() shouldBe 3 - sideEffect.counter shouldBe 3 - } - - "always should memoize values" { - val sideEffect = SideEffect() - val mapped = Eval.always { sideEffect.increment(); sideEffect.counter }.memoize() - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - } - - "defer should lazily evaluate other Evals" { - val sideEffect = SideEffect() - val mapped = Eval.defer { sideEffect.increment(); Eval.later { sideEffect.increment(); sideEffect.counter } } - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 2 - sideEffect.counter shouldBe 2 - mapped.value() shouldBe 4 - sideEffect.counter shouldBe 4 - mapped.value() shouldBe 6 - sideEffect.counter shouldBe 6 - } - - "defer should memoize Eval#later" { - val sideEffect = SideEffect() - val mapped = Eval.defer { sideEffect.increment(); Eval.later { sideEffect.increment(); sideEffect.counter } }.memoize() - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 2 - sideEffect.counter shouldBe 2 - mapped.value() shouldBe 2 - sideEffect.counter shouldBe 2 - mapped.value() shouldBe 2 - sideEffect.counter shouldBe 2 - } - - "defer should memoize Eval#now" { - val sideEffect = SideEffect() - val mapped = Eval.defer { sideEffect.increment(); Eval.now(sideEffect.counter) }.memoize() - sideEffect.counter shouldBe 0 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - mapped.value() shouldBe 1 - sideEffect.counter shouldBe 1 - } - - "flatMap should complete without blowing up the stack" { - val limit = stackSafeIteration() - val sideEffect = SideEffect() - val flatMapped = Eval.now(0).flatMap(recur(limit, sideEffect)) - sideEffect.counter shouldBe 0 - flatMapped.value() shouldBe -1 - sideEffect.counter shouldBe limit + 1 - } - } - - private fun recur(limit: Int, sideEffect: SideEffect): (Int) -> Eval { - return { num -> - if (num <= limit) { - sideEffect.increment() - Eval.defer { - recur(limit, sideEffect).invoke(num + 1) - } - } else { - Eval.now(-1) - } - } - } -} diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt index 1ad6bffe6f2..9b9056e2a6a 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt @@ -1,10 +1,10 @@ package arrow.core -import arrow.core.test.UnitSpec import arrow.core.test.generators.option import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid import arrow.typeclasses.Semigroup +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.sequences.shouldBeEmpty import io.kotest.property.Arb import io.kotest.property.checkAll @@ -15,7 +15,7 @@ import io.kotest.property.arbitrary.string import kotlin.math.max import kotlin.math.min -class SequenceKTest : UnitSpec() { +class SequenceKTest : StringSpec() { init { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt index 0dca116a255..a4837e38cbb 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt @@ -2,11 +2,10 @@ package arrow.core import arrow.core.Either.Left import arrow.core.Either.Right -import arrow.core.test.UnitSpec import arrow.typeclasses.Monoid import arrow.typeclasses.Semigroup -import arrow.core.test.generators.validated import io.kotest.assertions.fail +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.nulls.shouldBeNull import io.kotest.property.Arb import io.kotest.matchers.shouldBe @@ -14,9 +13,10 @@ import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.long import io.kotest.property.arbitrary.orNull import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.validated @Suppress("RedundantSuspendModifier") -class ValidatedTest : UnitSpec() { +class ValidatedTest : StringSpec() { init { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/NullableTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/NullableTest.kt deleted file mode 100644 index cee22f545ce..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/NullableTest.kt +++ /dev/null @@ -1,99 +0,0 @@ -package arrow.core.computations - -import arrow.core.Some -import arrow.core.test.UnitSpec -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.orNull - -class NullableTest : UnitSpec() { - - init { - "simple case" { - nullable { - "s".length.bind() - } shouldBe 1 - } - "multiple types" { - nullable { - val number = "s".length - val string = number.toString().bind() - string - } shouldBe "1" - } - "binding option in nullable" { - nullable { - val number = Some("s".length) - val string = number.map(Int::toString).bind() - string - } shouldBe "1" - } - "short circuit" { - nullable { - val number: Int = "s".length - (number.takeIf { it > 1 }?.toString()).bind() - throw IllegalStateException("This should not be executed") - } shouldBe null - } - "short circuit option" { - nullable { - val number = Some("s".length) - number.filter { it > 1 }.map(Int::toString).bind() - throw IllegalStateException("This should not be executed") - } shouldBe null - } - "when expression" { - nullable { - val number = "s".length.bind() - val string = when (number) { - 1 -> number.toString() - else -> null - }.bind() - string - } shouldBe "1" - } - "if expression" { - nullable { - val number = "s".length.bind() - val string = if (number == 1) { - number.toString() - } else { - null - }.bind() - string - } shouldBe "1" - } - "if expression short circuit" { - nullable { - val number = "s".length.bind() - val string = if (number != 1) { - number.toString() - } else { - null - }.bind() - string - } shouldBe null - } - "ensure null in nullable computation" { - checkAll(Arb.boolean(), Arb.int()) { predicate, i -> - nullable { - ensure(predicate) - i - } shouldBe if (predicate) i else null - } - } - - "ensureNotNull in nullable computation" { - fun square(i: Int): Int = i * i - checkAll(Arb.int().orNull()) { i: Int? -> - nullable { - val ii = i - ensureNotNull(ii) - square(ii) // Smart-cast by contract - } shouldBe i?.let(::square) - } - } - } -} diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/ResultTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/ResultTest.kt deleted file mode 100644 index 301ffb7a5d9..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/ResultTest.kt +++ /dev/null @@ -1,224 +0,0 @@ -package arrow.core.computations - -import arrow.core.Eval -import arrow.core.Tuple10 -import arrow.core.composeErrors -import arrow.core.flatMap -import arrow.core.handleErrorWith -import arrow.core.redeemWith -import arrow.core.test.UnitSpec -import arrow.core.test.generators.result -import arrow.core.test.generators.suspend -import arrow.core.test.generators.throwable -import arrow.core.zip -import io.kotest.assertions.fail -import io.kotest.matchers.nulls.shouldNotBeNull -import io.kotest.matchers.result.shouldBeFailureOfType -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.map -import io.kotest.property.arbitrary.string -import io.kotest.property.checkAll -import kotlin.Result.Companion.failure -import kotlin.Result.Companion.success -import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll -import kotlinx.coroutines.suspendCancellableCoroutine - -class ResultTest : UnitSpec() { - init { - "flatMap" { - checkAll(Arb.result(Arb.int()), Arb.result(Arb.string())) { ints, strs -> - val res = ints.flatMap { strs } - if (ints.isFailure) res shouldBe ints - else res shouldBe strs - } - } - - "handleErrorWith" { - checkAll(Arb.result(Arb.int()), Arb.result(Arb.string())) { ints, strs -> - val res = ints.handleErrorWith { strs } - if (ints.isFailure) res shouldBe strs - else res shouldBe ints - } - } - - "redeemWith" { - checkAll(Arb.result(Arb.int()), Arb.result(Arb.string()), Arb.result(Arb.string())) { ints, failed, success -> - val res = ints.redeemWith({ failed }, { success }) - if (ints.isFailure) res shouldBe failed - else res shouldBe success - } - } - - "zip" { - checkAll( - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - Arb.result(Arb.int()), - ) { a, b, c, d, e, f, g, h, i, j -> - val res = a.zip(b, c, d, e, f, g, h, i, j, ::Tuple10) - val all = listOf(a, b, c, d, e, f, g, h, i, j) - if (all.all { it.isSuccess }) res shouldBe success( - Tuple10( - a.getOrThrow(), - b.getOrThrow(), - c.getOrThrow(), - d.getOrThrow(), - e.getOrThrow(), - f.getOrThrow(), - g.getOrThrow(), - h.getOrThrow(), - i.getOrThrow(), - j.getOrThrow() - ) - ) else res shouldBe failure( - composeErrors( - a.exceptionOrNull(), - b.exceptionOrNull(), - c.exceptionOrNull(), - d.exceptionOrNull(), - e.exceptionOrNull(), - f.exceptionOrNull(), - g.exceptionOrNull(), - h.exceptionOrNull(), - i.exceptionOrNull(), - j.exceptionOrNull() - ).shouldNotBeNull() - ) - } - } - - "immediate values" { - checkAll(Arb.result(Arb.int())) { res -> - result { - res.bind() - } shouldBe res - } - } - - "suspended value" { - checkAll(Arb.result(Arb.int())) { res -> - result { - res.suspend().bind() - } shouldBe res - } - } - - "Rethrows immediate exceptions" { - checkAll(Arb.throwable(), Arb.int(), Arb.int()) { e, a, b -> - result { - success(a).bind() - success(b).suspend().bind() - throw e - } shouldBe failure(e) - } - } - - "result captures exception" { - checkAll(Arb.throwable(), Arb.int(), Arb.int()) { e, a, b -> - result { - success(a).bind() - success(b).suspend().bind() - e.suspend() - } shouldBe failure(e) - } - } - - "Can short-circuit from nested blocks" { - checkAll(Arb.throwable()) { e -> - result { - val x = eval { - failure(e).suspend().bind() - 5L - } - - x.value() - } shouldBe failure(e) - } - } - - "Can short-circuit suspended from nested blocks" { - checkAll(Arb.throwable().map { failure(it) }) { res -> - result { - val x = eval { - res.suspend().bind() - 5L - } - - x.value() - } shouldBe res - } - } - - "Can short-circuit after bind from nested blocks" { - checkAll(Arb.throwable().map { failure(it) }) { res -> - result { - val x = eval { - Eval.Now(1L).suspend().bind() - res.suspend().bind() - 5L - } - - 1 - } shouldBe res - } - } - - "Short-circuiting cancels KotlinX Coroutines" { - suspend fun completeOnCancellation(latch: CompletableDeferred, cancelled: CompletableDeferred): Unit = - suspendCancellableCoroutine { cont -> - cont.invokeOnCancellation { - if (!cancelled.complete(Unit)) fail("cancelled latch was completed twice") - else Unit - } - - if (!latch.complete(Unit)) fail("latch was completed twice") - else Unit - } - - val scope = CoroutineScope(Dispatchers.Default) - val latch = CompletableDeferred() - val cancelled = CompletableDeferred() - result { - val deferreds: List> = listOf( - scope.async { - completeOnCancellation(latch, cancelled) - success(1).bind() - }, - scope.async { - latch.await() - failure(RuntimeException()).bind() - } - ) - - deferreds.awaitAll().sum() - }.shouldBeFailureOfType() - - cancelled.await() - } - - "Computation blocks run on parent context" { - suspend fun currentContext(): CoroutineContext = - kotlin.coroutines.coroutineContext - - val parentCtx = currentContext() - result { - currentContext() shouldBe parentCtx - } - } - } -} diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/NullableSpec.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/NullableSpec.kt deleted file mode 100644 index d5036e9659b..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/NullableSpec.kt +++ /dev/null @@ -1,122 +0,0 @@ -package arrow.core.continuations - -import arrow.core.Either -import arrow.core.Some -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.orNull -import io.kotest.property.checkAll - -class NullableSpec : StringSpec({ - "ensure null in nullable computation" { - checkAll(Arb.boolean(), Arb.int()) { predicate, i -> - nullable { - ensure(predicate) - i - } shouldBe if (predicate) i else null - } - } - - "ensureNotNull in nullable computation" { - fun square(i: Int): Int = i * i - checkAll(Arb.int().orNull()) { i: Int? -> - nullable { - val ii = i - ensureNotNull(ii) - square(ii) // Smart-cast by contract - } shouldBe i?.let(::square) - } - } - - "short circuit null" { - nullable { - val number: Int = "s".length - (number.takeIf { it > 1 }?.toString()).bind() - throw IllegalStateException("This should not be executed") - } shouldBe null - } - - "ensureNotNull short circuit" { - nullable { - val number: Int = "s".length - val x = ensureNotNull(number.takeIf { it > 1 }) - x - throw IllegalStateException("This should not be executed") - } shouldBe null - } - - "simple case" { - nullable { - "s".length.bind() - } shouldBe 1 - } - - "multiple types" { - nullable { - val number = "s".length - val string = number.toString().bind() - string - } shouldBe "1" - } - - "binding option in nullable" { - nullable { - val number = Some("s".length) - val string = number.map(Int::toString).bind() - string - } shouldBe "1" - } - - "short circuit option" { - nullable { - val number = Some("s".length) - number.filter { it > 1 }.map(Int::toString).bind() - throw IllegalStateException("This should not be executed") - } shouldBe null - } - - "when expression" { - nullable { - val number = "s".length.bind() - val string = when (number) { - 1 -> number.toString() - else -> null - }.bind() - string - } shouldBe "1" - } - - "if expression" { - nullable { - val number = "s".length.bind() - val string = if (number == 1) { - number.toString() - } else { - null - }.bind() - string - } shouldBe "1" - } - - "if expression short circuit" { - nullable { - val number = "s".length.bind() - val string = if (number != 1) { - number.toString() - } else { - null - }.bind() - string - } shouldBe null - } - - "Either can be bind" { - nullable { - val either: Either = Either.Right(4) - either.bind() + 3 - } shouldBe 7 - } -}) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/OptionSpec.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/OptionSpec.kt deleted file mode 100644 index 59d677ac9b7..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/continuations/OptionSpec.kt +++ /dev/null @@ -1,50 +0,0 @@ -package arrow.core.continuations - -import arrow.core.None -import arrow.core.toOption -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.orNull -import io.kotest.property.checkAll - -class OptionSpec : StringSpec({ - "ensureNotNull in option computation" { - fun square(i: Int): Int = i * i - checkAll(Arb.int().orNull()) { i: Int? -> - option { - val ii = i - ensureNotNull(ii) - square(ii) // Smart-cast by contract - } shouldBe i.toOption().map(::square) - } - } - - "short circuit option" { - option { - val number: Int = "s".length - ensureNotNull(number.takeIf { it > 1 }) - throw IllegalStateException("This should not be executed") - } shouldBe None - } - - "ensureNotNull in eager option computation" { - fun square(i: Int): Int = i * i - checkAll(Arb.int().orNull()) { i: Int? -> - option { - val ii = i - ensureNotNull(ii) - square(ii) // Smart-cast by contract - } shouldBe i.toOption().map(::square) - } - } - - "eager short circuit null" { - option.eager { - val number: Int = "s".length - ensureNotNull(number.takeIf { it > 1 }) - throw IllegalStateException("This should not be executed") - } shouldBe None - } -}) diff --git a/arrow-libs/core/arrow-core/src/jsMain/kotlin/arrow/core/NonFatal.kt b/arrow-libs/core/arrow-core/src/jsMain/kotlin/arrow/core/NonFatal.kt index 6f6aead04a3..befa68dc021 100644 --- a/arrow-libs/core/arrow-core/src/jsMain/kotlin/arrow/core/NonFatal.kt +++ b/arrow-libs/core/arrow-core/src/jsMain/kotlin/arrow/core/NonFatal.kt @@ -1,10 +1,9 @@ package arrow.core -import arrow.continuations.generic.ControlThrowable import kotlin.coroutines.cancellation.CancellationException public actual fun NonFatal(t: Throwable): Boolean = when (t) { - is ControlThrowable, is CancellationException -> false + is CancellationException -> false else -> true } diff --git a/arrow-libs/core/arrow-core/src/jvmMain/kotlin/arrow/core/NonFatal.kt b/arrow-libs/core/arrow-core/src/jvmMain/kotlin/arrow/core/NonFatal.kt index 5074cadc9b4..b27c7f3bdcb 100644 --- a/arrow-libs/core/arrow-core/src/jvmMain/kotlin/arrow/core/NonFatal.kt +++ b/arrow-libs/core/arrow-core/src/jvmMain/kotlin/arrow/core/NonFatal.kt @@ -2,11 +2,10 @@ @file:JvmName("NonFatalKt") package arrow.core -import arrow.continuations.generic.ControlThrowable import kotlin.coroutines.cancellation.CancellationException public actual fun NonFatal(t: Throwable): Boolean = when (t) { - is VirtualMachineError, is ThreadDeath, is InterruptedException, is LinkageError, is ControlThrowable, is CancellationException -> false + is VirtualMachineError, is ThreadDeath, is InterruptedException, is LinkageError, is CancellationException -> false else -> true } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalJvmTest.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalJvmTest.kt deleted file mode 100644 index ba1484c4407..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalJvmTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package arrow.core - -import arrow.core.test.UnitSpec -import io.kotest.assertions.fail -import io.kotest.property.Arb -import io.kotest.property.Sample -import io.kotest.property.arbitrary.arbitrary -import io.kotest.property.arbitrary.choice - -class EvalJvmTest : UnitSpec(spec = { - "stack safety stress test" { - checkAll(DeepEval.gen) { d: DeepEval -> - try { - d.eval.value() - } catch (e: StackOverflowError) { - fail("stack overflowed with eval-depth ${DeepEval.maxDepth}") - } - } - } -}) - -private data class DeepEval(val eval: Eval) { - sealed class O { - data class Map(val f: (Int) -> Int) : O() - data class FlatMap(val f: (Int) -> Eval) : O() - class Memoize : O() - class Defer : O() - - companion object { - val gen = Arb.choice( - arbitrary { O.Map { it + 1 } }, - arbitrary { O.FlatMap { Eval.Now(it) } }, - arbitrary { O.Memoize() }, - arbitrary { O.Defer() } - ) - } - } - - companion object { - const val maxDepth = 10000 - - fun build(leaf: () -> Eval, os: List) = run { - tailrec fun step(i: Int, leaf: () -> Eval, cbs: MutableList<(Eval) -> Eval>): Eval = - if (i >= os.size) { - cbs.fold(leaf()) { e, f -> f(e) } - } else { - val o = os[i] - when (o) { - is O.Defer -> Eval.defer { - @Suppress("NON_TAIL_RECURSIVE_CALL") - step(i + 1, leaf, cbs) - } - is O.Memoize -> step(i + 1, leaf, cbs.also { it.add(0) { e: Eval -> e.memoize() } }) - is O.Map -> step(i + 1, leaf, cbs.also { it.add(0) { e: Eval -> e.map(o.f) } }) - is O.FlatMap -> step(i + 1, leaf, cbs.also { it.add(0) { e: Eval -> e.flatMap(o.f) } }) - } - } - - step(0, leaf, mutableListOf()) - } - - val gen = arbitrary { rs -> - val leaf = { Eval.Now(0) } - val eval = build(leaf, O.gen.samples().map(Sample::value).take(maxDepth).toList()) - DeepEval(eval) - } - } -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalUsage.java b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalUsage.java deleted file mode 100644 index 82d2d43f8be..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalUsage.java +++ /dev/null @@ -1,12 +0,0 @@ -package arrow.core; - -public class EvalUsage { - - public void testUsage() { - Eval now = Eval.now(1); - Eval.Later later = Eval.later(() -> 1); - Eval raise = Eval.raise(new RuntimeException()); - Eval.Always always = Eval.always(() -> 1); - Eval.defer(() -> Eval.now(1)); - } -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-01.kt deleted file mode 100644 index e02ffc279db..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-01.kt +++ /dev/null @@ -1,16 +0,0 @@ -// This file was automatically generated from either.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleEitherComputations01 - -import arrow.core.computations.either - -suspend fun main() { - either { - ensure(true) { "" } - println("ensure(true) passes") - ensure(false) { "failed" } - 1 - } - .let(::println) -} -// println: "ensure(true) passes" -// res: Either.Left("failed") diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-02.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-02.kt deleted file mode 100644 index ba2f60c2023..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-computations-02.kt +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated from either.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleEitherComputations02 - -import arrow.core.computations.either -import arrow.core.computations.ensureNotNull - -suspend fun main() { - either { - val x: Int? = 1 - ensureNotNull(x) { "passes" } - println(x) - ensureNotNull(null) { "failed" } - } - .let(::println) -} -// println: "1" -// res: Either.Left("failed") diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-01.kt deleted file mode 100644 index 56bda9ce6f8..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-01.kt +++ /dev/null @@ -1,16 +0,0 @@ -// This file was automatically generated from nullable.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleNullableComputations01 - -import arrow.core.computations.nullable - -suspend fun main() { - nullable { - ensure(true) - println("ensure(true) passes") - ensure(false) - 1 - } - .let(::println) -} -// println: "ensure(true) passes" -// res: null diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-02.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-02.kt deleted file mode 100644 index a14151a5e3f..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nullable-computations-02.kt +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated from nullable.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleNullableComputations02 - -import arrow.core.computations.nullable -import arrow.core.computations.ensureNotNull - -suspend fun main() { - nullable { - val x: Int? = 1 - ensureNotNull(x) - println(x) - ensureNotNull(null) - } - .let(::println) -} -// println: "1" -// res: null diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-01.kt deleted file mode 100644 index bd53693beba..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-01.kt +++ /dev/null @@ -1,16 +0,0 @@ -// This file was automatically generated from option.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleOptionComputations01 - -import arrow.core.computations.option - -suspend fun main() { - option { - ensure(true) - println("ensure(true) passes") - ensure(false) - 1 - } - .let(::println) -} -// println: "ensure(true) passes" -// res: None diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-02.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-02.kt deleted file mode 100644 index cc9f62c7d1b..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-computations-02.kt +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated from option.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleOptionComputations02 - -import arrow.core.computations.option -import arrow.core.computations.ensureNotNull - -suspend fun main() { - option { - val x: Int? = 1 - ensureNotNull(x) - println(x) - ensureNotNull(null) - } - .let(::println) -} -// println: "1" -// res: None diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-result-computations-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-result-computations-01.kt deleted file mode 100644 index 66f22e58f7f..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-result-computations-01.kt +++ /dev/null @@ -1,23 +0,0 @@ -// This file was automatically generated from result.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleResultComputations01 - -import arrow.core.* -import arrow.core.computations.result - -fun main() { - result { // We can safely use assertion based operation inside blocks - kotlin.require(false) { "Boom" } - } // Result.Failure(IllegalArgumentException("Boom")) - - result { - Result.failure(RuntimeException("Boom")) - .recover { 1 } - .bind() - } // Result.Success(1) - - result { - val x = Result.success(1).bind() - val y = Result.success(x + 1).bind() - x + y - } // Result.Success(3) -} diff --git a/arrow-libs/core/arrow-core/src/nativeMain/kotlin/arrow/core/NonFatal.kt b/arrow-libs/core/arrow-core/src/nativeMain/kotlin/arrow/core/NonFatal.kt index 6f6aead04a3..befa68dc021 100644 --- a/arrow-libs/core/arrow-core/src/nativeMain/kotlin/arrow/core/NonFatal.kt +++ b/arrow-libs/core/arrow-core/src/nativeMain/kotlin/arrow/core/NonFatal.kt @@ -1,10 +1,9 @@ package arrow.core -import arrow.continuations.generic.ControlThrowable import kotlin.coroutines.cancellation.CancellationException public actual fun NonFatal(t: Throwable): Boolean = when (t) { - is ControlThrowable, is CancellationException -> false + is CancellationException -> false else -> true } diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/api/arrow-fx-coroutines-test.api b/arrow-libs/fx/arrow-fx-coroutines-test/api/arrow-fx-coroutines-test.api deleted file mode 100644 index 7a122419aa3..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/api/arrow-fx-coroutines-test.api +++ /dev/null @@ -1,60 +0,0 @@ -public abstract class arrow/fx/coroutines/ArrowFxSpec : arrow/core/test/UnitSpec { - public fun ()V - public fun (ILkotlin/jvm/functions/Function1;)V - public synthetic fun (ILkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V -} - -public final class arrow/fx/coroutines/NamedThreadFactory : java/util/concurrent/ThreadFactory { - public fun (Lkotlin/jvm/functions/Function1;)V - public fun newThread (Ljava/lang/Runnable;)Ljava/lang/Thread; -} - -public final class arrow/fx/coroutines/Predef_testKt { - public static final fun assertThrowable (Lkotlin/jvm/functions/Function0;)Ljava/lang/Throwable; - public static final fun awaitExitCase (Lkotlinx/coroutines/CompletableDeferred;Lkotlinx/coroutines/CompletableDeferred;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun awaitExitCase (Lkotlinx/coroutines/channels/Channel;Lkotlinx/coroutines/CompletableDeferred;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun charRange (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun either (Larrow/core/Either;)Lio/kotest/matchers/Matcher; - public static final fun either (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun flow (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun function (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun functionAToB (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun intRange (Lio/kotest/property/Arb$Companion;II)Lio/kotest/property/Arb; - public static synthetic fun intRange$default (Lio/kotest/property/Arb$Companion;IIILjava/lang/Object;)Lio/kotest/property/Arb; - public static final fun leftException (Ljava/lang/Throwable;)Lio/kotest/matchers/Matcher; - public static final fun longRange (Lio/kotest/property/Arb$Companion;JJ)Lio/kotest/property/Arb; - public static synthetic fun longRange$default (Lio/kotest/property/Arb$Companion;JJILjava/lang/Object;)Lio/kotest/property/Arb; - public static final fun nullable (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun rethrow (Larrow/core/Either;)Ljava/lang/Object; - public static final fun shift (Lkotlin/coroutines/CoroutineContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun suspend (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun suspend (Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun suspended (Ljava/lang/Object;)Lkotlin/jvm/functions/Function1; - public static final fun throwable (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun toEither (Ljava/lang/Object;)Larrow/core/Either; - public static final fun unit (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; - public static final fun validated (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; - public static final fun validatedNel (Lio/kotest/property/Arb$Companion;Lio/kotest/property/Arb;Lio/kotest/property/Arb;)Lio/kotest/property/Arb; -} - -public final class arrow/fx/coroutines/Predef_test_jvmKt { - public static final fun getSingle ()Larrow/fx/coroutines/Resource; - public static final fun getSingleThreadName ()Ljava/lang/String; - public static final fun getThreadName ()Lkotlin/jvm/functions/Function1; -} - -public final class arrow/fx/coroutines/SideEffect { - public fun ()V - public fun (I)V - public synthetic fun (IILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()I - public final fun copy (I)Larrow/fx/coroutines/SideEffect; - public static synthetic fun copy$default (Larrow/fx/coroutines/SideEffect;IILjava/lang/Object;)Larrow/fx/coroutines/SideEffect; - public fun equals (Ljava/lang/Object;)Z - public final fun getCounter ()I - public fun hashCode ()I - public final fun increment ()V - public final fun setCounter (I)V - public fun toString ()Ljava/lang/String; -} - diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/build.gradle.kts b/arrow-libs/fx/arrow-fx-coroutines-test/build.gradle.kts deleted file mode 100644 index 18702163321..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/build.gradle.kts +++ /dev/null @@ -1,41 +0,0 @@ -plugins { - id(libs.plugins.kotlin.multiplatform.get().pluginId) - alias(libs.plugins.arrowGradleConfig.kotlin) - alias(libs.plugins.arrowGradleConfig.publish) -} - -apply(from = property("ANIMALSNIFFER_MPP")) - -kotlin { - sourceSets { - sourceSets { - commonMain { - dependencies { - api(projects.arrowCoreTest) - api(projects.arrowFxCoroutines) - api(libs.coroutines.core) - api(libs.kotest.assertionsCore) - api(libs.kotest.frameworkEngine) - api(libs.kotest.property) - implementation(libs.kotlin.stdlibCommon) - } - } - - named("jvmMain") { - dependencies { - implementation(libs.kotlin.stdlibJDK8) - } - } - named("jvmTest") { - dependencies { - runtimeOnly(libs.kotest.runnerJUnit5) - } - } - named("jsMain") { - dependencies { - implementation(libs.kotlin.stdlibJS) - } - } - } - } -} diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/gradle.properties b/arrow-libs/fx/arrow-fx-coroutines-test/gradle.properties deleted file mode 100644 index 5092830b03b..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -# Maven publishing configuration -pom.name=Arrow-Fx-Coroutines-Test diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/knit.properties b/arrow-libs/fx/arrow-fx-coroutines-test/knit.properties deleted file mode 100644 index d54ae8bfbf2..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/knit.properties +++ /dev/null @@ -1,5 +0,0 @@ -knit.package=arrow.fx.coroutines.test.examples -knit.dir=src/commonTest/kotlin/examples/ - -test.package=arrow.fx.coroutines.test.examples.test -test.dir=src/commonTest/kotlin/examples/autogenerated/ diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt deleted file mode 100644 index 9c8f8a888d3..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt +++ /dev/null @@ -1,15 +0,0 @@ -package arrow.fx.coroutines - -import arrow.core.test.UnitSpec -import arrow.core.test.concurrency.deprecateArrowTestModules - -/** Simple overwritten Kotest StringSpec (UnitSpec) to reduce stress on tests. */ -@Deprecated(deprecateArrowTestModules) -public abstract class ArrowFxSpec( - iterations: Int = 250, - spec: ArrowFxSpec.() -> Unit = {} -) : UnitSpec(iterations) { - init { - spec() - } -} diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt deleted file mode 100644 index 3e38d073d2b..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt +++ /dev/null @@ -1,264 +0,0 @@ -package arrow.fx.coroutines - -import arrow.core.Either -import arrow.core.Validated -import arrow.core.ValidatedNel -import arrow.core.identity -import arrow.core.invalid -import arrow.core.invalidNel -import arrow.core.left -import arrow.core.right -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.core.valid -import arrow.core.validNel -import io.kotest.assertions.fail -import io.kotest.matchers.Matcher -import io.kotest.matchers.MatcherResult -import io.kotest.matchers.equalityMatcher -import io.kotest.property.Arb -import io.kotest.property.arbitrary.bind -import io.kotest.property.arbitrary.char -import io.kotest.property.arbitrary.choice -import io.kotest.property.arbitrary.choose -import io.kotest.property.arbitrary.constant -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.list -import io.kotest.property.arbitrary.long -import io.kotest.property.arbitrary.map -import io.kotest.property.arbitrary.string -import kotlin.coroutines.Continuation -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.intercepted -import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn -import kotlin.coroutines.resume -import kotlin.coroutines.startCoroutine -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.awaitCancellation -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.asFlow -import kotlinx.coroutines.flow.buffer -import kotlinx.coroutines.flow.channelFlow -import kotlinx.coroutines.flow.emptyFlow - -@Deprecated(deprecateArrowTestModules) -public data class SideEffect(var counter: Int = 0) { - @Deprecated(deprecateArrowTestModules) - public fun increment() { - counter++ - } -} - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.flow(arbA: Arb): Arb> = - Arb.choose( - 10 to Arb.list(arbA).map { it.asFlow() }, - 10 to Arb.list(arbA).map { channelFlow { it.forEach { send(it) } }.buffer(Channel.RENDEZVOUS) }, - 1 to Arb.constant(emptyFlow()), - ) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.throwable(): Arb = - Arb.string().map(::RuntimeException) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.either(left: Arb, right: Arb): Arb> { - val failure: Arb> = left.map { l -> l.left() } - val success: Arb> = right.map { r -> r.right() } - return Arb.choice(failure, success) -} - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.validated(left: Arb, right: Arb): Arb> { - val failure: Arb> = left.map { l -> l.invalid() } - val success: Arb> = right.map { r -> r.valid() } - return Arb.choice(failure, success) -} - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.validatedNel(left: Arb, right: Arb): Arb> { - val failure: Arb> = left.map { l -> l.invalidNel() } - val success: Arb> = right.map { r -> r.validNel() } - return Arb.choice(failure, success) -} - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.intRange(min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE): Arb = - Arb.bind(Arb.int(min, max), Arb.int(min, max)) { a, b -> - if (a < b) a..b else b..a - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.longRange(min: Long = Long.MIN_VALUE, max: Long = Long.MAX_VALUE): Arb = - Arb.bind(Arb.long(min, max), Arb.long(min, max)) { a, b -> - if (a < b) a..b else b..a - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.charRange(): Arb = - Arb.bind(Arb.char(), Arb.char()) { a, b -> - if (a < b) a..b else b..a - } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.function(arb: Arb): Arb<() -> O> = - arb.map { { it } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.unit(): Arb = - Arb.constant(Unit) - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.functionAToB(arb: Arb): Arb<(A) -> B> = - arb.map { b: B -> { _: A -> b } } - -@Deprecated(deprecateArrowTestModules) -public fun Arb.Companion.nullable(arb: Arb): Arb = - Arb.Companion.choice(arb, arb.map { null }) - -/** Useful for testing success & error scenarios with an `Either` generator **/ -@Deprecated(deprecateArrowTestModules) -public fun Either.rethrow(): A = - fold({ throw it }, ::identity) - -@Deprecated(deprecateArrowTestModules) -public fun Result.toEither(): Either = - fold({ a -> Either.Right(a) }, { e -> Either.Left(e) }) - -@Deprecated(deprecateArrowTestModules) -public suspend fun Throwable.suspend(): Nothing = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { throw this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } - -@Deprecated(deprecateArrowTestModules) -public suspend fun A.suspend(): A = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { this }.startCoroutine( - Continuation(Dispatchers.Default) { - cont.intercepted().resumeWith(it) - } - ) - - COROUTINE_SUSPENDED - } - -@Deprecated(deprecateArrowTestModules) -public fun A.suspended(): suspend () -> A = - suspend { suspend() } - -/** - * Example usage: - * ```kotlin - * import arrow.fx.coroutines.assertThrowable - * - * fun main() { - * val exception = assertThrowable { - * throw IllegalArgumentException("Talk to a duck") - * } - * require("Talk to a duck" == exception.message) - * } - * ``` - * - * @see Assertions.assertThrows - */ -@Deprecated(deprecateArrowTestModules) -public inline fun assertThrowable(executable: () -> A): Throwable { - val a = try { - executable.invoke() - } catch (e: Throwable) { - e - } - - return if (a is Throwable) a else fail("Expected an exception but found: $a") -} - -@Deprecated(deprecateArrowTestModules) -public suspend fun CoroutineContext.shift(): Unit = - suspendCoroutineUninterceptedOrReturn { cont -> - suspend { this }.startCoroutine( - Continuation(this) { - cont.resume(Unit) - } - ) - - COROUTINE_SUSPENDED - } - -@Deprecated(deprecateArrowTestModules) -public fun leftException(e: Throwable): Matcher> = - object : Matcher> { - override fun test(value: Either): MatcherResult = - when (value) { - is Either.Left -> when { - value.value::class != e::class -> MatcherResult( - false, - "Expected exception of type ${e::class} but found ${value.value::class}", - "Should not be exception of type ${e::class}" - ) - value.value.message != e.message -> MatcherResult( - false, - "Expected exception with message ${e.message} but found ${value.value.message}", - "Should not be exception with message ${e.message}" - ) - else -> MatcherResult( - true, - "Expected exception of type ${e::class} and found ${value.value::class}", - "Expected exception of type ${e::class} and found ${value.value::class}" - ) - } - is Either.Right -> MatcherResult( - false, - "Expected Either.Left with exception of type ${e::class} and found Right with ${value.value}", - "Should not be Either.Left with exception" - ) - } - } - -@Deprecated(deprecateArrowTestModules) -public fun either(e: Either): Matcher> = - object : Matcher> { - override fun test(value: Either): MatcherResult = - when (value) { - is Either.Left -> when { - value.value::class != (e.swap().orNull() ?: Int)::class -> MatcherResult( - false, - "Expected $e but found $value", - "Should not be $e" - ) - value.value.message != (e.swap().orNull()?.message ?: -1) -> MatcherResult( - false, - "Expected $e but found $value", - "Should not be $e" - ) - else -> MatcherResult( - true, - "Expected exception of type ${e::class} and found ${value.value::class}", - "Expected exception of type ${e::class} and found ${value.value::class}" - ) - } - is Either.Right -> equalityMatcher(e).test(value) - } - } - -@Deprecated(deprecateArrowTestModules) -public suspend fun awaitExitCase(send: Channel, exit: CompletableDeferred): A = - guaranteeCase({ - send.receive() - awaitCancellation() - }) { ex -> exit.complete(ex) } - -@Deprecated(deprecateArrowTestModules) -public suspend fun awaitExitCase(start: CompletableDeferred, exit: CompletableDeferred): A = - guaranteeCase({ - start.complete(Unit) - awaitCancellation() - }) { ex -> exit.complete(ex) } diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonTest/kotlin/examples/example-predef-test-01.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonTest/kotlin/examples/example-predef-test-01.kt deleted file mode 100644 index 917a69ce42a..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonTest/kotlin/examples/example-predef-test-01.kt +++ /dev/null @@ -1,11 +0,0 @@ -// This file was automatically generated from predef-test.kt by Knit tool. Do not edit. -package arrow.fx.coroutines.test.examples.examplePredefTest01 - -import arrow.fx.coroutines.assertThrowable - -fun main() { - val exception = assertThrowable { - throw IllegalArgumentException("Talk to a duck") - } - require("Talk to a duck" == exception.message) -} diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt deleted file mode 100644 index bb8480abd1c..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt +++ /dev/null @@ -1,24 +0,0 @@ -package arrow.fx.coroutines - -import arrow.core.continuations.AtomicRef -import arrow.core.test.concurrency.deprecateArrowTestModules -import java.util.concurrent.ThreadFactory -import kotlin.coroutines.CoroutineContext - -@Deprecated(deprecateArrowTestModules) -public val singleThreadName: String = "single" - -@Deprecated(deprecateArrowTestModules) -public val single: Resource = Resource.singleThreadContext(singleThreadName) - -@Deprecated(deprecateArrowTestModules) -public val threadName: suspend () -> String = - { Thread.currentThread().name } - -@Deprecated(deprecateArrowTestModules) -public class NamedThreadFactory(private val mkName: (Int) -> String) : ThreadFactory { - private val count = AtomicRef(0) - override fun newThread(r: Runnable): Thread = - Thread(r, mkName(count.get())) - .apply { isDaemon = true } -} diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmTest/kotlin/arrow/fx/coroutines/PredefTest.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmTest/kotlin/arrow/fx/coroutines/PredefTest.kt deleted file mode 100644 index 6ede23a21cc..00000000000 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmTest/kotlin/arrow/fx/coroutines/PredefTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -package arrow.fx.coroutines - -import arrow.core.Either -import io.kotest.matchers.shouldBe -import io.kotest.property.Arb -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.string -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.completeWith -import kotlin.coroutines.Continuation -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED -import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn - -class PredefTest : ArrowFxSpec( - spec = { - - "suspended always suspends" { - checkAll(Arb.int()) { i -> - val promise = CompletableDeferred() - - val x = i.suspended() - .startCoroutineUninterceptedOrReturn( - Continuation(EmptyCoroutineContext) { - promise.completeWith(it) - } - ) - - x shouldBe COROUTINE_SUSPENDED - promise.await() shouldBe i - } - } - - "shift" { - checkAll(Arb.string(), Arb.string()) { a, b -> - val t0 = threadName.invoke() - - Resource.singleThreadContext(a) - .zip(Resource.singleThreadContext(b)) - .use { (ui, io) -> - t0 shouldBe threadName.invoke() - - ui.shift() - threadName.invoke() shouldBe a - - io.shift() - threadName.invoke() shouldBe b - } - } - } - } -) diff --git a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts index 701e2c7d715..392397dd985 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts @@ -30,7 +30,7 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(project(":arrow-fx-coroutines-test")) + // implementation(libs.kotest.arrowFxAssertions) } } jvmTest { diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParTraverseEither.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParTraverseEither.kt index e6ba2bd7be5..5f2e5d4fd46 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParTraverseEither.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParTraverseEither.kt @@ -3,7 +3,7 @@ package arrow.fx.coroutines import arrow.core.Either -import arrow.core.computations.either +import arrow.core.continuations.effect import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -197,8 +197,8 @@ public suspend fun Iterable.parTraverseEither( ctx: CoroutineContext = EmptyCoroutineContext, f: suspend CoroutineScope.(A) -> Either ): Either> = - either { + effect> { coroutineScope { map { async(ctx) { f.invoke(this, it).bind() } }.awaitAll() } - } + }.toEither() diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt index 10d06ef1d28..c01f6514184 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt @@ -1,7 +1,6 @@ package arrow.fx.coroutines import arrow.core.Either -import arrow.core.Eval import arrow.core.identity import arrow.core.left import arrow.core.nonFatalOrThrow @@ -474,12 +473,12 @@ public sealed class Schedule { try { val a = fa.invoke() val step = update(a, state) - if (!step.cont) return Either.Right(step.finish.value()) + if (!step.cont) return Either.Right(step.finish()) else { delay((step.delayInNanos / 1_000_000).toLong()) // Set state before looping again - last = { step.finish.value() } + last = { step.finish() } state = step.state } } catch (e: Throwable) { @@ -503,11 +502,11 @@ public sealed class Schedule { val a = fa.invoke() val step = update(a, state) if (!step.cont) { - emit(Either.Right(step.finish.value())) + emit(Either.Right(step.finish())) loop = false } else { delay((step.delayInNanos / 1_000_000).toLong()) - val output = step.finish.value() + val output = step.finish() // Set state before looping again and emit Output emit(Either.Right(output)) last = { output } @@ -530,7 +529,7 @@ public sealed class Schedule { updated { f -> { a: A, s: State -> val dec = f(a, s) - if (dec.cont) pred(a, dec.finish.value()).let { dec.copy(cont = it) } + if (dec.cont) pred(a, dec.finish()).let { dec.copy(cont = it) } else dec } } @@ -587,7 +586,7 @@ public sealed class Schedule { updated { update -> { a: Input, s: State -> val step = update(a, s) - val d = f(step.finish.value(), step.delayInNanos) + val d = f(step.finish(), step.delayInNanos) step.copy(delayInNanos = d) } } @@ -602,14 +601,14 @@ public sealed class Schedule { override fun logOutput(f: suspend (output: Output) -> Unit): Schedule = updated { update -> { a: Input, s: State -> - update(a, s).also { f(it.finish.value()) } + update(a, s).also { f(it.finish()) } } } override fun foldLazy(initial: suspend () -> C, f: suspend (acc: C, output: Output) -> C): Schedule = ScheduleImpl(suspend { Pair(initialState.invoke(), initial.invoke()) }) { i, s -> val dec = update(i, s.first) - val c = if (dec.cont) f(s.second, dec.finish.value()) else s.second + val c = if (dec.cont) f(s.second, dec.finish()) else s.second dec.bimap({ state -> Pair(state, c) }, { c }) } @@ -618,7 +617,7 @@ public sealed class Schedule { (other as ScheduleImpl).let { other -> ScheduleImpl(suspend { Pair(initialState.invoke(), other.initialState.invoke()) }) { i, s -> val dec1 = update(i, s.first) - val dec2 = other.update(dec1.finish.value(), s.second) + val dec2 = other.update(dec1.finish(), s.second) dec1.combineNanos(dec2, { a, b -> a && b }, { a, b -> a + b }, { _, b -> b }) } } @@ -687,7 +686,7 @@ public sealed class Schedule { val cont: Boolean, val delayInNanos: Double, val state: A, - val finish: Eval + val finish: () -> B ) { @ExperimentalTime @@ -698,7 +697,7 @@ public sealed class Schedule { copy(cont = !cont) public fun bimap(f: (A) -> C, g: (B) -> D): Decision = - Decision(cont, delayInNanos, f(state), finish.map(g)) + Decision(cont, delayInNanos, f(state), { g(finish()) }) public fun mapLeft(f: (A) -> C): Decision = bimap(f, ::identity) @@ -715,7 +714,7 @@ public sealed class Schedule { f(cont, other.cont), g(delayInNanos, other.delayInNanos), Pair(state, other.state), - finish.flatMap { first -> other.finish.map { second -> zip(first, second) } } + { zip(finish(), other.finish()) } ) @ExperimentalTime @@ -728,7 +727,7 @@ public sealed class Schedule { f(cont, other.cont), g(delayInNanos.nanoseconds, other.delayInNanos.nanoseconds).toDouble(NANOSECONDS), Pair(state, other.state), - finish.flatMap { first -> other.finish.map { second -> zip(first, second) } } + { zip(finish(), other.finish()) } ) override fun equals(other: Any?): Boolean = @@ -736,21 +735,21 @@ public sealed class Schedule { else cont == other.cont && state == other.state && delayInNanos == other.delayInNanos && - finish.value() == other.finish.value() + finish() == other.finish() public companion object { - public fun cont(d: Double, a: A, b: Eval): Decision = + public fun cont(d: Double, a: A, b: () -> B): Decision = Decision(true, d, a, b) - public fun done(d: Double, a: A, b: Eval): Decision = + public fun done(d: Double, a: A, b: () -> B): Decision = Decision(false, d, a, b) @ExperimentalTime - public fun cont(d: Duration, a: A, b: Eval): Decision = + public fun cont(d: Duration, a: A, b: () -> B): Decision = cont(d.toDouble(NANOSECONDS), a, b) @ExperimentalTime - public fun done(d: Duration, a: A, b: Eval): Decision = + public fun done(d: Duration, a: A, b: () -> B): Decision = done(d.toDouble(NANOSECONDS), a, b) } } @@ -771,7 +770,7 @@ public sealed class Schedule { */ public fun identity(): Schedule = Schedule({ Unit }) { a, s -> - Decision.cont(0.0, s, Eval.now(a)) + Decision.cont(0.0, s, { a }) } /** @@ -788,7 +787,7 @@ public sealed class Schedule { public fun unfoldLazy(c: suspend () -> A, f: suspend (A) -> A): Schedule = Schedule(c) { _: I, acc -> val a = f(acc) - Decision.cont(0.0, a, Eval.now(a)) + Decision.cont(0.0, a, { a }) } /** @@ -808,8 +807,8 @@ public sealed class Schedule { */ public fun recurs(n: Int): Schedule = Schedule(suspend { 0 }) { _: A, acc -> - if (acc < n) Decision.cont(0.0, acc + 1, Eval.now(acc + 1)) - else Decision.done(0.0, acc, Eval.now(acc)) + if (acc < n) Decision.cont(0.0, acc + 1, { acc + 1 }) + else Decision.done(0.0, acc, { acc }) } /** @@ -825,7 +824,7 @@ public sealed class Schedule { */ public fun never(): Schedule = Schedule(suspend { arrow.fx.coroutines.never() }) { _, _ -> - Decision(false, 0.0, Unit, Eval.later { throw IllegalArgumentException("Impossible") }) + Decision(false, 0.0, Unit, { throw IllegalArgumentException("Impossible") }) } /** @@ -842,7 +841,7 @@ public sealed class Schedule { @JvmName("delayedNanos") public fun delayed(delaySchedule: Schedule): Schedule = (delaySchedule.modifyNanos { a, b -> a + b } as ScheduleImpl) - .reconsider { _, dec -> dec.copy(finish = Eval.now(dec.delayInNanos)) } + .reconsider { _, dec -> dec.copy(finish = { dec.delayInNanos }) } /** * Creates a Schedule that uses another Schedule to generate the delay of this schedule. @@ -856,7 +855,7 @@ public sealed class Schedule { @JvmName("delayedDuration") public fun delayed(delaySchedule: Schedule): Schedule = (delaySchedule.modify { a, b -> a + b } as ScheduleImpl) - .reconsider { _, dec -> dec.copy(finish = Eval.now(dec.delayInNanos.nanoseconds)) } + .reconsider { _, dec -> dec.copy(finish = { dec.delayInNanos.nanoseconds }) } /** * Creates a Schedule which collects all its inputs in a list. @@ -894,7 +893,7 @@ public sealed class Schedule { cont = decision.cont, delayInNanos = decision.delayInNanos, state = decision.state, - finish = Eval.now(decision.delayInNanos) + finish = { decision.delayInNanos } ) } @@ -905,7 +904,7 @@ public sealed class Schedule { cont = decision.cont, delayInNanos = decision.delayInNanos, state = decision.state, - finish = Eval.now(decision.delayInNanos.nanoseconds) + finish = { decision.delayInNanos.nanoseconds } ) } @@ -919,7 +918,7 @@ public sealed class Schedule { cont = decision.cont, delayInNanos = decision.delayInNanos, state = decision.state, - finish = Eval.now(decision.cont) + finish = { decision.cont } ) } @@ -1037,7 +1036,7 @@ public suspend fun Schedule.retryOrElseEither( state = dec.state if (dec.cont) delay((dec.delayInNanos / 1_000_000).toLong()) - else return Either.Left(orElse(e.nonFatalOrThrow(), dec.finish.value())) + else return Either.Left(orElse(e.nonFatalOrThrow(), dec.finish())) } } } diff --git a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts index c720bc248e2..d6af6a73474 100644 --- a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts @@ -30,7 +30,7 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(project(":arrow-fx-coroutines-test")) + // implementation(libs.kotest.arrowFxAssertions) } } jvmTest { diff --git a/arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/internals/processor.kt b/arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/internals/processor.kt index c974b948d91..db356ed9f94 100644 --- a/arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/internals/processor.kt +++ b/arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/internals/processor.kt @@ -51,7 +51,7 @@ internal fun KSClassDeclaration.targetsFromOpticsAnnotation(): List } + ?.flatMap { (it.value as? ArrayList<*>).orEmpty().mapNotNull { it as? KSType } } ?.mapNotNull { when (it.qualifiedString() ) { "arrow.optics.OpticsTarget.ISO" -> OpticsTarget.ISO diff --git a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts index f03e1c83993..17565ac6948 100644 --- a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts @@ -24,7 +24,10 @@ dependencies { implementation(libs.kotlin.stdlibJDK8) if(!enableCompatibilityMetadataVariant) { - testImplementation(project(":arrow-optics-test")) + testImplementation(libs.kotest.runnerJUnit5) + testImplementation(libs.kotest.assertionsCore) + testImplementation(libs.kotest.property) + testImplementation(libs.kotest.arrowOpticsProperty) testImplementation(libs.kotlin.stdlibJDK8) testImplementation(libs.junitJupiterEngine) testImplementation(libs.kotlin.reflect) diff --git a/arrow-libs/optics/arrow-optics-test/api/arrow-optics-test.api b/arrow-libs/optics/arrow-optics-test/api/arrow-optics-test.api deleted file mode 100644 index 94ebd0c7826..00000000000 --- a/arrow-libs/optics/arrow-optics-test/api/arrow-optics-test.api +++ /dev/null @@ -1,69 +0,0 @@ -public final class arrow/optics/test/laws/IsoLaws { - public static final field INSTANCE Larrow/optics/test/laws/IsoLaws; - public final fun composeModify (Larrow/optics/PIso;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun consistentSetModify (Larrow/optics/PIso;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun laws (Larrow/optics/PIso;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/IsoLaws;Larrow/optics/PIso;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun modifyIdentity (Larrow/optics/PIso;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun roundTripOneWay (Larrow/optics/PIso;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun roundTripOtherWay (Larrow/optics/PIso;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/optics/test/laws/LensLaws { - public static final field INSTANCE Larrow/optics/test/laws/LensLaws; - public final fun laws (Larrow/optics/PLens;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public final fun laws (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/LensLaws;Larrow/optics/PLens;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/LensLaws;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun lensComposeModify (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun lensConsistentSetModify (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun lensGetSet (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun lensModifyIdentity (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun lensSetGet (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun lensSetIdempotent (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/optics/test/laws/OptionalLaws { - public static final field INSTANCE Larrow/optics/test/laws/OptionalLaws; - public final fun composeModify (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun consistentSetModify (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getOptionSet (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun laws (Larrow/optics/POptional;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public final fun laws (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/OptionalLaws;Larrow/optics/POptional;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/OptionalLaws;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun modifyIdentity (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun setGetOption (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun setIdempotent (Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/optics/test/laws/PrismLaws { - public static final field INSTANCE Larrow/optics/test/laws/PrismLaws; - public final fun composeModify (Larrow/optics/PPrism;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun consistentSetModify (Larrow/optics/PPrism;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun laws (Larrow/optics/PPrism;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/PrismLaws;Larrow/optics/PPrism;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun modifyIdentity (Larrow/optics/PPrism;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun partialRoundTripOneWay (Larrow/optics/PPrism;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun roundTripOtherWay (Larrow/optics/PPrism;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/optics/test/laws/SetterLaws { - public static final field INSTANCE Larrow/optics/test/laws/SetterLaws; - public final fun composeModify (Larrow/optics/PSetter;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lio/kotest/property/Arb;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun consistentSetModify (Larrow/optics/PSetter;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun laws (Larrow/optics/PSetter;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/SetterLaws;Larrow/optics/PSetter;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun modifyIdentity (Larrow/optics/PSetter;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun setIdempotent (Larrow/optics/PSetter;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/optics/test/laws/TraversalLaws { - public static final field INSTANCE Larrow/optics/test/laws/TraversalLaws; - public final fun composeModify (Larrow/optics/PTraversal;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun laws (Larrow/optics/PTraversal;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;)Ljava/util/List; - public static synthetic fun laws$default (Larrow/optics/test/laws/TraversalLaws;Larrow/optics/PTraversal;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/List; - public final fun modifyIdentity (Larrow/optics/PTraversal;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun setIdempotent (Larrow/optics/PTraversal;Lio/kotest/property/Arb;Lio/kotest/property/Arb;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - diff --git a/arrow-libs/optics/arrow-optics-test/build.gradle.kts b/arrow-libs/optics/arrow-optics-test/build.gradle.kts deleted file mode 100644 index 8075d8f296d..00000000000 --- a/arrow-libs/optics/arrow-optics-test/build.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -plugins { - id(libs.plugins.kotlin.multiplatform.get().pluginId) - alias(libs.plugins.arrowGradleConfig.kotlin) - alias(libs.plugins.arrowGradleConfig.publish) -} - -apply(from = property("ANIMALSNIFFER_MPP")) - -kotlin { - sourceSets { - commonMain { - dependencies { - api(projects.arrowOptics) - api(projects.arrowCoreTest) - api(libs.coroutines.core) - api(libs.kotest.assertionsCore) - api(libs.kotest.frameworkEngine) - api(libs.kotest.property) - implementation(libs.kotlin.stdlibCommon) - } - } - jvmMain { - dependencies { - implementation(libs.kotlin.stdlibJDK8) - } - } - jvmTest { - dependencies { - runtimeOnly(libs.kotest.runnerJUnit5) - } - } - jsMain { - dependencies { - implementation(libs.kotlin.stdlibJS) - } - } - } -} diff --git a/arrow-libs/optics/arrow-optics-test/gradle.properties b/arrow-libs/optics/arrow-optics-test/gradle.properties deleted file mode 100644 index 68b2b448dde..00000000000 --- a/arrow-libs/optics/arrow-optics-test/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Maven publishing configuration -pom.name=Arrow-Optics-Test -kapt.incremental.apt=false diff --git a/arrow-libs/optics/arrow-optics-test/knit.properties b/arrow-libs/optics/arrow-optics-test/knit.properties deleted file mode 100644 index 1609dd116da..00000000000 --- a/arrow-libs/optics/arrow-optics-test/knit.properties +++ /dev/null @@ -1,5 +0,0 @@ -knit.package=arrow.optics.test.examples -knit.dir=src/commonTest/kotlin/examples/ - -test.package=arrow.optics.test.examples.test -test.dir=src/commonTest/kotlin/examples/autogenerated/ diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt deleted file mode 100644 index 148ea91208a..00000000000 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt +++ /dev/null @@ -1,61 +0,0 @@ -package arrow.optics.test.laws - -import arrow.core.compose -import arrow.core.identity -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.optics.Iso -import arrow.core.test.laws.Law -import arrow.core.test.laws.equalUnderTheLaw -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.checkAll - -@Deprecated(deprecateArrowTestModules)public object IsoLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws( - iso: Iso, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eqa: (A, A) -> Boolean = { a, b -> a == b }, - eqb: (B, B) -> Boolean = { a, b -> a == b } - ): List = - listOf( - Law("Iso Law: round trip one way") { iso.roundTripOneWay(aGen, eqa) }, - Law("Iso Law: round trip other way") { iso.roundTripOtherWay(bGen, eqb) }, - Law("Iso Law: modify identity is identity") { iso.modifyIdentity(aGen, eqa) }, - Law("Iso Law: compose modify") { iso.composeModify(aGen, funcGen, eqa) }, - Law("Iso Law: consitent set with modify") { iso.consistentSetModify(aGen, bGen, eqa) } - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun Iso.roundTripOneWay(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen) { a -> - reverseGet(get(a)).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Iso.roundTripOtherWay(bGen: Arb, eq: (B, B) -> Boolean): PropertyContext = - checkAll(100, bGen) { b -> - get(reverseGet(b)).equalUnderTheLaw(b, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Iso.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen) { a -> - modify(a, ::identity).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Iso.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen, funcGen, funcGen) { a, f, g -> - modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Iso.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen, bGen) { a, b -> - set(b).equalUnderTheLaw(modify(a) { b }, eq) - } -} diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt deleted file mode 100644 index a6cd370a787..00000000000 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt +++ /dev/null @@ -1,95 +0,0 @@ -package arrow.optics.test.laws - -import arrow.core.compose -import arrow.core.identity -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.optics.Lens -import arrow.core.test.laws.Law -import arrow.core.test.laws.equalUnderTheLaw -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.arbitrary.constant -import io.kotest.property.checkAll - -@Deprecated(deprecateArrowTestModules) -public object LensLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws( - lensGen: Arb>, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eqa: (A, A) -> Boolean = { a, b -> a == b }, - eqb: (B, B) -> Boolean = { a, b -> a == b } - ): List = - listOf( - Law("Lens law: get set") { lensGetSet(lensGen, aGen, eqa) }, - Law("Lens law: set get") { lensSetGet(lensGen, aGen, bGen, eqb) }, - Law("Lens law: is set idempotent") { lensSetIdempotent(lensGen, aGen, bGen, eqa) }, - Law("Lens law: modify identity") { lensModifyIdentity(lensGen, aGen, eqa) }, - Law("Lens law: compose modify") { lensComposeModify(lensGen, aGen, funcGen, eqa) }, - Law("Lens law: consistent set modify") { lensConsistentSetModify(lensGen, aGen, bGen, eqa) } - ) - - /** - * Warning: Use only when a `Gen.constant()` applies - */ - @Deprecated(deprecateArrowTestModules) - public fun laws( - lens: Lens, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eqa: (A, A) -> Boolean = { a, b -> a == b }, - eqb: (B, B) -> Boolean = { a, b -> a == b } - ): List = laws(Arb.constant(lens), aGen, bGen, funcGen, eqa, eqb) - - @Deprecated(deprecateArrowTestModules) - public suspend fun lensGetSet(lensGen: Arb>, aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, lensGen, aGen) { lens, a -> - lens.run { - set(a, get(a)).equalUnderTheLaw(a, eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun lensSetGet(lensGen: Arb>, aGen: Arb, bGen: Arb, eq: (B, B) -> Boolean): PropertyContext = - checkAll(100, lensGen, aGen, bGen) { lens, a, b -> - lens.run { - get(set(a, b)).equalUnderTheLaw(b, eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun lensSetIdempotent(lensGen: Arb>, aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, lensGen, aGen, bGen) { lens, a, b -> - lens.run { - set(set(a, b), b).equalUnderTheLaw(set(a, b), eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun lensModifyIdentity(lensGen: Arb>, aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, lensGen, aGen) { lens, a -> - lens.run { - modify(a, ::identity).equalUnderTheLaw(a, eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun lensComposeModify(lensGen: Arb>, aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, lensGen, aGen, funcGen, funcGen) { lens, a, f, g -> - lens.run { - modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun lensConsistentSetModify(lensGen: Arb>, aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, lensGen, aGen, bGen) { lens, a, b -> - lens.run { - set(a, b).equalUnderTheLaw(modify(a) { b }, eq) - } - } -} diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt deleted file mode 100644 index f9c455f5716..00000000000 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt +++ /dev/null @@ -1,128 +0,0 @@ -package arrow.optics.test.laws - -import arrow.core.compose -import arrow.core.identity -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.optics.Optional -import arrow.core.test.laws.Law -import arrow.core.test.laws.equalUnderTheLaw -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.arbitrary.constant -import io.kotest.property.checkAll - -@Deprecated(deprecateArrowTestModules) -public object OptionalLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws( - optionalGen: Arb>, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eqa: (A, A) -> Boolean = { a, b -> a == b }, - eqb: (B?, B?) -> Boolean = { a, b -> a == b } - ): List = listOf( - Law("Optional Law: set what you get") { getOptionSet(optionalGen, aGen, eqa) }, - Law("Optional Law: set what you get") { setGetOption(optionalGen, aGen, bGen, eqb) }, - Law("Optional Law: set is idempotent") { setIdempotent(optionalGen, aGen, bGen, eqa) }, - Law("Optional Law: modify identity = identity") { modifyIdentity(optionalGen, aGen, eqa) }, - Law("Optional Law: compose modify") { composeModify(optionalGen, aGen, funcGen, eqa) }, - Law("Optional Law: consistent set with modify") { consistentSetModify(optionalGen, aGen, bGen, eqa) } - ) - - /** - * Warning: Use only when a `Gen.constant()` applies - */ - @Deprecated(deprecateArrowTestModules) - public fun laws( - optional: Optional, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eqa: (A, A) -> Boolean = { a, b -> a == b }, - eqb: (B?, B?) -> Boolean = { a, b -> a == b } - ): List = laws(Arb.constant(optional), aGen, bGen, funcGen, eqa, eqb) - - @Deprecated(deprecateArrowTestModules) - public suspend fun getOptionSet( - optionalGen: Arb>, - aGen: Arb, - eq: (A, A) -> Boolean - ): PropertyContext = - checkAll(100, optionalGen, aGen) { optional, a -> - optional.run { - getOrModify(a).fold(::identity) { set(a, it) } - .equalUnderTheLaw(a, eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun setGetOption( - optionalGen: Arb>, - aGen: Arb, - bGen: Arb, - eq: (B?, B?) -> Boolean - ): PropertyContext = - checkAll(100, optionalGen, aGen, bGen) { optional, a, b -> - optional.run { - getOrNull(set(a, b)) - .equalUnderTheLaw(getOrNull(a)?.let { b }) { a, b -> eq(a, b) } - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun setIdempotent( - optionalGen: Arb>, - aGen: Arb, - bGen: Arb, - eq: (A, A) -> Boolean - ): PropertyContext = - checkAll(100, optionalGen, aGen, bGen) { optional, a, b -> - optional.run { - set(set(a, b), b) - .equalUnderTheLaw(set(a, b), eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun modifyIdentity( - optionalGen: Arb>, - aGen: Arb, - eq: (A, A) -> Boolean - ): PropertyContext = - checkAll(100, optionalGen, aGen) { optional, a -> - optional.run { - modify(a, ::identity) - .equalUnderTheLaw(a, eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun composeModify( - optionalGen: Arb>, - aGen: Arb, - funcGen: Arb<(B) -> B>, - eq: (A, A) -> Boolean - ): PropertyContext = - checkAll(100, optionalGen, aGen, funcGen, funcGen) { optional, a, f, g -> - optional.run { - modify(modify(a, f), g) - .equalUnderTheLaw(modify(a, g compose f), eq) - } - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun consistentSetModify( - optionalGen: Arb>, - aGen: Arb, - bGen: Arb, - eq: (A, A) -> Boolean - ): PropertyContext = - checkAll(100, optionalGen, aGen, bGen) { optional, a, b -> - optional.run { - set(a, b) - .equalUnderTheLaw(modify(a) { b }, eq) - } - } -} diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt deleted file mode 100644 index d814d87b600..00000000000 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt +++ /dev/null @@ -1,63 +0,0 @@ -package arrow.optics.test.laws - -import arrow.core.compose -import arrow.core.identity -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.optics.Prism -import arrow.core.test.laws.Law -import arrow.core.test.laws.equalUnderTheLaw -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.checkAll - -@Deprecated(deprecateArrowTestModules) -public object PrismLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws( - prism: Prism, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eqa: (A, A) -> Boolean = { a, b -> a == b }, - eqb: (B?, B?) -> Boolean = { a, b -> a == b } - ): List = listOf( - Law("Prism law: partial round trip one way") { prism.partialRoundTripOneWay(aGen, eqa) }, - Law("Prism law: round trip other way") { prism.roundTripOtherWay(bGen, eqb) }, - Law("Prism law: modify identity") { prism.modifyIdentity(aGen, eqa) }, - Law("Prism law: compose modify") { prism.composeModify(aGen, funcGen, eqa) }, - Law("Prism law: consistent set modify") { prism.consistentSetModify(aGen, bGen, eqa) } - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun Prism.partialRoundTripOneWay(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen) { a -> - getOrModify(a).fold(::identity, ::reverseGet) - .equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Prism.roundTripOtherWay(bGen: Arb, eq: (B?, B?) -> Boolean): PropertyContext = - checkAll(100, bGen) { b -> - getOrNull(reverseGet(b)) - .equalUnderTheLaw(b, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Prism.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen) { a -> - modify(a, ::identity).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Prism.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen, funcGen, funcGen) { a, f, g -> - modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Prism.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen, bGen) { a, b -> - set(a, b).equalUnderTheLaw(modify(a) { b }, eq) - } -} diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt deleted file mode 100644 index 5cb7bb0edb4..00000000000 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt +++ /dev/null @@ -1,53 +0,0 @@ -package arrow.optics.test.laws - -import arrow.core.compose -import arrow.core.identity -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.optics.Setter -import arrow.core.test.laws.Law -import arrow.core.test.laws.equalUnderTheLaw -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.checkAll - -@Deprecated(deprecateArrowTestModules) -public object SetterLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws( - setter: Setter, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eq: (A, A) -> Boolean = { a, b -> a == b } - ): List = listOf( - Law("Setter law: set is idempotent") { setter.setIdempotent(aGen, bGen, eq) }, - Law("Setter law: modify identity") { setter.modifyIdentity(aGen, eq) }, - Law("Setter law: compose modify") { setter.composeModify(aGen, eq, funcGen) }, - Law("Setter law: consistent set modify") { setter.consistentSetModify(aGen, bGen, eq) } - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun Setter.setIdempotent(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen, bGen) { a, b -> - set(set(a, b), b).equalUnderTheLaw(set(a, b), eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Setter.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen) { a -> - modify(a, ::identity).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Setter.composeModify(aGen: Arb, eq: (A, A) -> Boolean, funcGen: Arb<(B) -> B>): PropertyContext = - checkAll(100, aGen, funcGen, funcGen) { a, f, g -> - modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Setter.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(100, aGen, bGen) { a, b -> - modify(a) { b }.equalUnderTheLaw(set(a, b), eq) - } -} diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt deleted file mode 100644 index bc204f85dc3..00000000000 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt +++ /dev/null @@ -1,58 +0,0 @@ -package arrow.optics.test.laws - -import arrow.core.compose -import arrow.core.identity -import arrow.core.test.concurrency.deprecateArrowTestModules -import arrow.optics.Traversal -import arrow.core.test.laws.Law -import arrow.core.test.laws.equalUnderTheLaw -import io.kotest.property.Arb -import io.kotest.property.PropertyContext -import io.kotest.property.checkAll -import kotlin.math.max - -@Deprecated(deprecateArrowTestModules) -public object TraversalLaws { - - @Deprecated(deprecateArrowTestModules) - public fun laws( - traversal: Traversal, - aGen: Arb, - bGen: Arb, - funcGen: Arb<(B) -> B>, - eq: (A, A) -> Boolean = { a, b -> a == b } - ): List = listOf( - Law("Traversal law: set is idempotent") { traversal.setIdempotent(aGen, bGen, eq) }, - Law("Traversal law: modify identity") { traversal.modifyIdentity(aGen, eq) }, - Law("Traversal law: compose modify") { traversal.composeModify(aGen, funcGen, eq) } - ) - - @Deprecated(deprecateArrowTestModules) - public suspend fun Traversal.setIdempotent(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(max(aGen.minIterations(), bGen.minIterations()), aGen, bGen) { a, b -> - set(set(a, b), b) - .equalUnderTheLaw(set(a, b), eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Traversal.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = - checkAll(aGen.minIterations(), aGen) { a -> - modify(a, ::identity).equalUnderTheLaw(a, eq) - } - - @Deprecated(deprecateArrowTestModules) - public suspend fun Traversal.composeModify( - aGen: Arb, - funcGen: Arb<(B) -> B>, - eq: (A, A) -> Boolean - ): PropertyContext = - checkAll( - max(max(aGen.minIterations(), funcGen.minIterations()), funcGen.minIterations()), - aGen, - funcGen, - funcGen - ) { a, f, g -> - modify(modify(a, f), g) - .equalUnderTheLaw(modify(a, g compose f), eq) - } -} diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 194b92b561a..173d37a8a30 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -31,7 +31,10 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(project(":arrow-optics-test")) + implementation(libs.kotest.runnerJUnit5) + implementation(libs.kotest.assertionsCore) + implementation(libs.kotest.property) + implementation(libs.kotest.arrowOpticsProperty) } } jvmTest { diff --git a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Every.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Every.kt index 33b96bf40e7..475d5c93be5 100644 --- a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Every.kt +++ b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Every.kt @@ -3,7 +3,6 @@ package arrow.optics import arrow.core.Either import arrow.core.NonEmptyList import arrow.core.Option -import arrow.core.Tuple10 import arrow.core.Tuple4 import arrow.core.Tuple5 import arrow.core.Tuple6 @@ -353,44 +352,6 @@ public interface PEvery : PTraversal, Fold, PSette .combine(map(source.ninth)) } } - - /** - * [Traversal] to focus into the first, second, third, fourth, fifth, sixth, seventh, eight, ninth and tenth value of a [arrow.core.Tuple10] - */ - @JvmStatic - public fun tuple10(): Every, A> = - object : Every, A> { - override fun modify( - source: Tuple10, - map: (focus: A) -> A - ): Tuple10 = - Tuple10( - map(source.first), - map(source.second), - map(source.third), - map(source.fourth), - map(source.fifth), - map(source.sixth), - map(source.seventh), - map(source.eighth), - map(source.ninth), - map(source.tenth) - ) - - override fun foldMap(M: Monoid, source: Tuple10, map: (focus: A) -> R): R = - M.run { - map(source.first) - .combine(map(source.second)) - .combine(map(source.third)) - .combine(map(source.fourth)) - .combine(map(source.fifth)) - .combine(map(source.sixth)) - .combine(map(source.seventh)) - .combine(map(source.eighth)) - .combine(map(source.ninth)) - .combine(map(source.tenth)) - } - } } /** diff --git a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Fold.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Fold.kt index 446d625743b..e082ec52329 100644 --- a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Fold.kt +++ b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Fold.kt @@ -3,7 +3,6 @@ package arrow.optics import arrow.core.Either import arrow.core.NonEmptyList import arrow.core.Option -import arrow.core.Tuple10 import arrow.core.Tuple4 import arrow.core.Tuple5 import arrow.core.Tuple6 @@ -318,12 +317,5 @@ public interface Fold { @JvmStatic public fun tuple9(): Fold, A> = Every.tuple9() - - /** - * [Traversal] to focus into the first, second, third, fourth, fifth, sixth, seventh, eight, ninth and tenth value of a [arrow.core.Tuple10] - */ - @JvmStatic - public fun tuple10(): Fold, A> = - Every.tuple10() } } diff --git a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Traversal.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Traversal.kt index 6a76c2542c9..051ea3edb02 100644 --- a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Traversal.kt +++ b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Traversal.kt @@ -3,7 +3,6 @@ package arrow.optics import arrow.core.Either import arrow.core.NonEmptyList import arrow.core.Option -import arrow.core.Tuple10 import arrow.core.Tuple4 import arrow.core.Tuple5 import arrow.core.Tuple6 @@ -427,31 +426,6 @@ public fun interface PTraversal : PSetter { public fun tuple9(): Traversal, A> = pTuple9() - /** - * [PTraversal] to focus into the first, second, third, fourth, fifth, sixth, seventh, eight, ninth and tenth value of a [arrow.core.Tuple10] - */ - @JvmStatic - public fun pTuple10(): PTraversal, Tuple10, A, B> = - PTraversal( - get1 = { it.first }, - get2 = { it.second }, - get3 = { it.third }, - get4 = { it.fourth }, - get5 = { it.fifth }, - get6 = { it.sixth }, - get7 = { it.seventh }, - get8 = { it.eighth }, - get9 = { it.ninth }, - get10 = { it.tenth }, - set = { a, b, c, d, e, f, g, h, i, j, _ -> Tuple10(a, b, c, d, e, f, g, h, i, j) } - ) - - /** - * [Traversal] to focus into the first, second, third, fourth, fifth, sixth, seventh, eight, ninth and tenth value of a [arrow.core.Tuple10] - */ - @JvmStatic - public fun tuple10(): Traversal, A> = - pTuple10() } /** diff --git a/build.gradle.kts b/build.gradle.kts index 2713aa18188..bbe845b393d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,16 +61,7 @@ tasks { dependsOn(generateDoc) } - val undocumentedProjects = if (!enableCompatibilityMetadataVariant) { - listOf( - project(":arrow-core-test"), - project(":arrow-fx-coroutines-test"), - project(":arrow-optics-test"), - project(":arrow-optics-ksp-plugin"), - ) - } else { - listOf(project(":arrow-optics-ksp-plugin")) - } + val undocumentedProjects = listOf(project(":arrow-optics-ksp-plugin")) dokkaGfmMultiModule { removeChildTasks(undocumentedProjects) } dokkaHtmlMultiModule { removeChildTasks(undocumentedProjects) } @@ -79,7 +70,7 @@ tasks { apiValidation { val ignoreApiValidation = if (!enableCompatibilityMetadataVariant) { - listOf("arrow-optics-ksp-plugin", "arrow-optics-test", "arrow-site") + listOf("arrow-optics-ksp-plugin", "arrow-site") } else { listOf("arrow-optics-ksp-plugin") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cbc7e980f93..a5c5e2dddfe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,6 +10,7 @@ jUnitJupiter = "5.8.2" jUnitVintage = "5.8.2" kotest = "5.3.1" kotestGradle = "5.3.1" +kotestArrow = "1.2.5" kotlin = "1.6.21" kotlinBinaryCompatibilityValidator = "0.10.1" kotlinCompileTesting = "1.4.8" @@ -32,6 +33,9 @@ kotest-assertionsCore = { module = "io.kotest:kotest-assertions-core", version.r kotest-frameworkEngine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" } kotest-runnerJUnit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } +kotest-arrowAssertions = { module = "io.kotest.extensions:kotest-assertions-arrow", version.ref = "kotestArrow" } +kotest-arrowProperty = { module = "io.kotest.extensions:kotest-property-arrow", version.ref = "kotestArrow" } +kotest-arrowOpticsProperty = { module = "io.kotest.extensions:kotest-property-arrow-optics", version.ref = "kotestArrow" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" } kotlin-stdlibCommon = { module = "org.jetbrains.kotlin:kotlin-stdlib-common" } kotlin-stdlibJDK8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 3836a82132c..2f7ab7a6438 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,13 +35,6 @@ val enableCompatibilityMetadataVariant = providers.gradleProperty("kotlin.mpp.enableCompatibilityMetadataVariant") .forUseAtConfigurationTime().orNull?.toBoolean() == true -if (!enableCompatibilityMetadataVariant) { - include("arrow-core-test") - project(":arrow-core-test").projectDir = file("arrow-libs/core/arrow-core-test") -} -include("arrow-continuations") -project(":arrow-continuations").projectDir = file("arrow-libs/core/arrow-continuations") - include("arrow-core-retrofit") project(":arrow-core-retrofit").projectDir = file("arrow-libs/core/arrow-core-retrofit") @@ -49,10 +42,6 @@ project(":arrow-core-retrofit").projectDir = file("arrow-libs/core/arrow-core-re include("arrow-fx-coroutines") project(":arrow-fx-coroutines").projectDir = file("arrow-libs/fx/arrow-fx-coroutines") -if (!enableCompatibilityMetadataVariant) { - include("arrow-fx-coroutines-test") - project(":arrow-fx-coroutines-test").projectDir = file("arrow-libs/fx/arrow-fx-coroutines-test") -} include("arrow-fx-stm") project(":arrow-fx-stm").projectDir = file("arrow-libs/fx/arrow-fx-stm") @@ -66,11 +55,6 @@ project(":arrow-optics-reflect").projectDir = file("arrow-libs/optics/arrow-opti include("arrow-optics-ksp-plugin") project(":arrow-optics-ksp-plugin").projectDir = file("arrow-libs/optics/arrow-optics-ksp-plugin") -if (!enableCompatibilityMetadataVariant) { - include("arrow-optics-test") - project(":arrow-optics-test").projectDir = file("arrow-libs/optics/arrow-optics-test") -} - // STACK include("arrow-stack") project(":arrow-stack").projectDir = file("arrow-libs/stack") From f15a57ab635b835b6c9610e74d8d087d3953b950 Mon Sep 17 00:00:00 2001 From: serras Date: Wed, 3 Aug 2022 10:34:28 +0000 Subject: [PATCH 03/13] Update API files --- arrow-libs/core/arrow-core/api/arrow-core.api | 864 ------------------ .../api/arrow-fx-coroutines.api | 18 +- .../optics/arrow-optics/api/arrow-optics.api | 8 - 3 files changed, 9 insertions(+), 881 deletions(-) diff --git a/arrow-libs/core/arrow-core/api/arrow-core.api b/arrow-libs/core/arrow-core/api/arrow-core.api index fc33b4f3d0d..ced4d410266 100644 --- a/arrow-libs/core/arrow-core/api/arrow-core.api +++ b/arrow-libs/core/arrow-core/api/arrow-core.api @@ -31,38 +31,6 @@ public final class arrow/core/Composition { public static final fun compose (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; } -public final class arrow/core/Const { - public static final field Companion Larrow/core/Const$Companion; - public fun (Ljava/lang/Object;)V - public final fun copy (Ljava/lang/Object;)Larrow/core/Const; - public static synthetic fun copy$default (Larrow/core/Const;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Const; - public fun equals (Ljava/lang/Object;)Z - public fun hashCode ()I - public final fun map (Lkotlin/jvm/functions/Function1;)Larrow/core/Const; - public final fun retag ()Larrow/core/Const; - public fun toString ()Ljava/lang/String; - public final fun value ()Ljava/lang/Object; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function10;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function9;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function8;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function7;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function6;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function5;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function4;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Larrow/core/Const;Lkotlin/jvm/functions/Function3;)Larrow/core/Const; - public final fun zip (Larrow/typeclasses/Semigroup;Larrow/core/Const;Lkotlin/jvm/functions/Function2;)Larrow/core/Const; -} - -public final class arrow/core/Const$Companion { -} - -public final class arrow/core/ConstKt { - public static final fun combine (Larrow/core/Const;Larrow/typeclasses/Semigroup;Larrow/core/Const;)Larrow/core/Const; - public static final fun compareTo (Larrow/core/Const;Larrow/core/Const;)I - public static final fun const (Ljava/lang/Object;)Larrow/core/Const; - public static final fun contramap (Larrow/core/Const;Lkotlin/jvm/functions/Function1;)Larrow/core/Const; -} - public final class arrow/core/Currying { public static final fun curried (Lkotlin/jvm/functions/Function10;)Lkotlin/jvm/functions/Function1; public static final fun curried (Lkotlin/jvm/functions/Function11;)Lkotlin/jvm/functions/Function1; @@ -310,108 +278,6 @@ public final class arrow/core/Endo { public final class arrow/core/Endo$Companion { } -public abstract class arrow/core/Eval { - public static final field Companion Larrow/core/Eval$Companion; - public static final fun always (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Always; - public final fun coflatMap (Lkotlin/jvm/functions/Function1;)Larrow/core/Eval; - public static final fun defer (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval; - public final fun flatMap (Lkotlin/jvm/functions/Function1;)Larrow/core/Eval; - public static final fun later (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Later; - public final fun map (Lkotlin/jvm/functions/Function1;)Larrow/core/Eval; - public abstract fun memoize ()Larrow/core/Eval; - public static final fun now (Ljava/lang/Object;)Larrow/core/Eval; - public static final fun raise (Ljava/lang/Throwable;)Larrow/core/Eval; - public fun toString ()Ljava/lang/String; - public abstract fun value ()Ljava/lang/Object; -} - -public final class arrow/core/Eval$Always : arrow/core/Eval { - public fun (Lkotlin/jvm/functions/Function0;)V - public final fun copy (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Always; - public static synthetic fun copy$default (Larrow/core/Eval$Always;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Larrow/core/Eval$Always; - public fun equals (Ljava/lang/Object;)Z - public fun hashCode ()I - public fun memoize ()Larrow/core/Eval; - public fun toString ()Ljava/lang/String; - public fun value ()Ljava/lang/Object; -} - -public final class arrow/core/Eval$Companion { - public final fun always (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Always; - public final fun defer (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval; - public final fun later (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Later; - public final fun now (Ljava/lang/Object;)Larrow/core/Eval; - public final fun raise (Ljava/lang/Throwable;)Larrow/core/Eval; -} - -public final class arrow/core/Eval$Defer : arrow/core/Eval { - public fun (Lkotlin/jvm/functions/Function0;)V - public final fun component1 ()Lkotlin/jvm/functions/Function0; - public final fun copy (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Defer; - public static synthetic fun copy$default (Larrow/core/Eval$Defer;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Larrow/core/Eval$Defer; - public fun equals (Ljava/lang/Object;)Z - public final fun getThunk ()Lkotlin/jvm/functions/Function0; - public fun hashCode ()I - public fun memoize ()Larrow/core/Eval; - public fun toString ()Ljava/lang/String; - public fun value ()Ljava/lang/Object; -} - -public abstract class arrow/core/Eval$FlatMap : arrow/core/Eval { - public fun ()V - public fun memoize ()Larrow/core/Eval; - public abstract fun run (Ljava/lang/Object;)Larrow/core/Eval; - public abstract fun start ()Larrow/core/Eval; - public fun toString ()Ljava/lang/String; - public fun value ()Ljava/lang/Object; -} - -public final class arrow/core/Eval$Later : arrow/core/Eval { - public fun (Lkotlin/jvm/functions/Function0;)V - public final fun copy (Lkotlin/jvm/functions/Function0;)Larrow/core/Eval$Later; - public static synthetic fun copy$default (Larrow/core/Eval$Later;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Larrow/core/Eval$Later; - public fun equals (Ljava/lang/Object;)Z - public final fun getValue ()Ljava/lang/Object; - public fun hashCode ()I - public fun memoize ()Larrow/core/Eval; - public fun toString ()Ljava/lang/String; - public fun value ()Ljava/lang/Object; -} - -public final class arrow/core/Eval$Now : arrow/core/Eval { - public static final field Companion Larrow/core/Eval$Now$Companion; - public fun (Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;)Larrow/core/Eval$Now; - public static synthetic fun copy$default (Larrow/core/Eval$Now;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Eval$Now; - public fun equals (Ljava/lang/Object;)Z - public final fun getValue ()Ljava/lang/Object; - public fun hashCode ()I - public fun memoize ()Larrow/core/Eval; - public fun toString ()Ljava/lang/String; - public fun value ()Ljava/lang/Object; -} - -public final class arrow/core/Eval$Now$Companion { - public final fun getUnit ()Larrow/core/Eval; -} - -public final class arrow/core/EvalKt { - public static final fun iterateRight (Ljava/util/Iterator;Larrow/core/Eval;Lkotlin/jvm/functions/Function2;)Larrow/core/Eval; - public static final fun replicate (Larrow/core/Eval;I)Larrow/core/Eval; - public static final fun replicate (Larrow/core/Eval;ILarrow/typeclasses/Monoid;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function10;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function9;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function8;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function7;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function6;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function5;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function4;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function3;)Larrow/core/Eval; - public static final fun zip (Larrow/core/Eval;Larrow/core/Eval;Lkotlin/jvm/functions/Function2;)Larrow/core/Eval; -} - public abstract class arrow/core/Ior { public static final field Companion Larrow/core/Ior$Companion; public final fun all (Lkotlin/jvm/functions/Function1;)Z @@ -832,7 +698,6 @@ public abstract class arrow/core/Option { public final fun pairLeft (Ljava/lang/Object;)Larrow/core/Option; public final fun pairRight (Ljava/lang/Object;)Larrow/core/Option; public final fun reduceOrNull (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; - public final fun reduceRightEvalOrNull (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Larrow/core/Eval; public final fun replicate (I)Larrow/core/Option; public final fun tap (Lkotlin/jvm/functions/Function1;)Larrow/core/Option; public final fun tapNone (Lkotlin/jvm/functions/Function0;)Larrow/core/Option; @@ -1522,591 +1387,6 @@ public final class arrow/core/StringKt { public static final fun escaped (Ljava/lang/String;)Ljava/lang/String; } -public final class arrow/core/Tuple10 { - public static final field Companion Larrow/core/Tuple10$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple10; - public static synthetic fun copy$default (Larrow/core/Tuple10;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple10; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple10$Companion { -} - -public final class arrow/core/Tuple11 { - public static final field Companion Larrow/core/Tuple11$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple11; - public static synthetic fun copy$default (Larrow/core/Tuple11;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple11; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple11$Companion { -} - -public final class arrow/core/Tuple12 { - public static final field Companion Larrow/core/Tuple12$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple12; - public static synthetic fun copy$default (Larrow/core/Tuple12;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple12; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple12$Companion { -} - -public final class arrow/core/Tuple13 { - public static final field Companion Larrow/core/Tuple13$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple13; - public static synthetic fun copy$default (Larrow/core/Tuple13;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple13; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple13$Companion { -} - -public final class arrow/core/Tuple14 { - public static final field Companion Larrow/core/Tuple14$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple14; - public static synthetic fun copy$default (Larrow/core/Tuple14;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple14; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple14$Companion { -} - -public final class arrow/core/Tuple15 { - public static final field Companion Larrow/core/Tuple15$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple15; - public static synthetic fun copy$default (Larrow/core/Tuple15;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple15; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple15$Companion { -} - -public final class arrow/core/Tuple16 { - public static final field Companion Larrow/core/Tuple16$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple16; - public static synthetic fun copy$default (Larrow/core/Tuple16;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple16; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple16$Companion { -} - -public final class arrow/core/Tuple17 { - public static final field Companion Larrow/core/Tuple17$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component17 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple17; - public static synthetic fun copy$default (Larrow/core/Tuple17;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple17; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventeenth ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple17$Companion { -} - -public final class arrow/core/Tuple18 { - public static final field Companion Larrow/core/Tuple18$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component17 ()Ljava/lang/Object; - public final fun component18 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple18; - public static synthetic fun copy$default (Larrow/core/Tuple18;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple18; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighteenth ()Ljava/lang/Object; - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventeenth ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple18$Companion { -} - -public final class arrow/core/Tuple19 { - public static final field Companion Larrow/core/Tuple19$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component17 ()Ljava/lang/Object; - public final fun component18 ()Ljava/lang/Object; - public final fun component19 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple19; - public static synthetic fun copy$default (Larrow/core/Tuple19;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple19; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighteenth ()Ljava/lang/Object; - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNineteenth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventeenth ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple19$Companion { -} - -public final class arrow/core/Tuple20 { - public static final field Companion Larrow/core/Tuple20$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component17 ()Ljava/lang/Object; - public final fun component18 ()Ljava/lang/Object; - public final fun component19 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component20 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple20; - public static synthetic fun copy$default (Larrow/core/Tuple20;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple20; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighteenth ()Ljava/lang/Object; - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNineteenth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventeenth ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public final fun getTwentieth ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple20$Companion { -} - -public final class arrow/core/Tuple21 { - public static final field Companion Larrow/core/Tuple21$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component17 ()Ljava/lang/Object; - public final fun component18 ()Ljava/lang/Object; - public final fun component19 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component20 ()Ljava/lang/Object; - public final fun component21 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple21; - public static synthetic fun copy$default (Larrow/core/Tuple21;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple21; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighteenth ()Ljava/lang/Object; - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNineteenth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventeenth ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public final fun getTwentieth ()Ljava/lang/Object; - public final fun getTwentyFirst ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple21$Companion { -} - -public final class arrow/core/Tuple22 { - public static final field Companion Larrow/core/Tuple22$Companion; - public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - public final fun component1 ()Ljava/lang/Object; - public final fun component10 ()Ljava/lang/Object; - public final fun component11 ()Ljava/lang/Object; - public final fun component12 ()Ljava/lang/Object; - public final fun component13 ()Ljava/lang/Object; - public final fun component14 ()Ljava/lang/Object; - public final fun component15 ()Ljava/lang/Object; - public final fun component16 ()Ljava/lang/Object; - public final fun component17 ()Ljava/lang/Object; - public final fun component18 ()Ljava/lang/Object; - public final fun component19 ()Ljava/lang/Object; - public final fun component2 ()Ljava/lang/Object; - public final fun component20 ()Ljava/lang/Object; - public final fun component21 ()Ljava/lang/Object; - public final fun component22 ()Ljava/lang/Object; - public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Ljava/lang/Object; - public final fun component5 ()Ljava/lang/Object; - public final fun component6 ()Ljava/lang/Object; - public final fun component7 ()Ljava/lang/Object; - public final fun component8 ()Ljava/lang/Object; - public final fun component9 ()Ljava/lang/Object; - public final fun copy (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Larrow/core/Tuple22; - public static synthetic fun copy$default (Larrow/core/Tuple22;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Larrow/core/Tuple22; - public fun equals (Ljava/lang/Object;)Z - public final fun getEighteenth ()Ljava/lang/Object; - public final fun getEighth ()Ljava/lang/Object; - public final fun getEleventh ()Ljava/lang/Object; - public final fun getFifteenth ()Ljava/lang/Object; - public final fun getFifth ()Ljava/lang/Object; - public final fun getFirst ()Ljava/lang/Object; - public final fun getFourteenth ()Ljava/lang/Object; - public final fun getFourth ()Ljava/lang/Object; - public final fun getNineteenth ()Ljava/lang/Object; - public final fun getNinth ()Ljava/lang/Object; - public final fun getSecond ()Ljava/lang/Object; - public final fun getSeventeenth ()Ljava/lang/Object; - public final fun getSeventh ()Ljava/lang/Object; - public final fun getSixteenth ()Ljava/lang/Object; - public final fun getSixth ()Ljava/lang/Object; - public final fun getTenth ()Ljava/lang/Object; - public final fun getThird ()Ljava/lang/Object; - public final fun getThirteenth ()Ljava/lang/Object; - public final fun getTwelfth ()Ljava/lang/Object; - public final fun getTwentieth ()Ljava/lang/Object; - public final fun getTwentyFirst ()Ljava/lang/Object; - public final fun getTwentySecond ()Ljava/lang/Object; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class arrow/core/Tuple22$Companion { -} - public final class arrow/core/Tuple4 { public static final field Companion Larrow/core/Tuple4$Companion; public fun (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V @@ -2265,7 +1545,6 @@ public final class arrow/core/Tuple9$Companion { public final class arrow/core/TupleNKt { public static final fun combine (Lkotlin/Pair;Larrow/typeclasses/Semigroup;Larrow/typeclasses/Semigroup;Lkotlin/Pair;)Lkotlin/Pair; - public static final fun compareTo (Larrow/core/Tuple10;Larrow/core/Tuple10;)I public static final fun compareTo (Larrow/core/Tuple4;Larrow/core/Tuple4;)I public static final fun compareTo (Larrow/core/Tuple5;Larrow/core/Tuple5;)I public static final fun compareTo (Larrow/core/Tuple6;Larrow/core/Tuple6;)I @@ -2274,24 +1553,11 @@ public final class arrow/core/TupleNKt { public static final fun compareTo (Larrow/core/Tuple9;Larrow/core/Tuple9;)I public static final fun compareTo (Lkotlin/Pair;Lkotlin/Pair;)I public static final fun compareTo (Lkotlin/Triple;Lkotlin/Triple;)I - public static final fun plus (Larrow/core/Tuple10;Ljava/lang/Object;)Larrow/core/Tuple11; - public static final fun plus (Larrow/core/Tuple11;Ljava/lang/Object;)Larrow/core/Tuple12; - public static final fun plus (Larrow/core/Tuple12;Ljava/lang/Object;)Larrow/core/Tuple13; - public static final fun plus (Larrow/core/Tuple13;Ljava/lang/Object;)Larrow/core/Tuple14; - public static final fun plus (Larrow/core/Tuple14;Ljava/lang/Object;)Larrow/core/Tuple15; - public static final fun plus (Larrow/core/Tuple15;Ljava/lang/Object;)Larrow/core/Tuple16; - public static final fun plus (Larrow/core/Tuple16;Ljava/lang/Object;)Larrow/core/Tuple17; - public static final fun plus (Larrow/core/Tuple17;Ljava/lang/Object;)Larrow/core/Tuple18; - public static final fun plus (Larrow/core/Tuple18;Ljava/lang/Object;)Larrow/core/Tuple19; - public static final fun plus (Larrow/core/Tuple19;Ljava/lang/Object;)Larrow/core/Tuple20; - public static final fun plus (Larrow/core/Tuple20;Ljava/lang/Object;)Larrow/core/Tuple21; - public static final fun plus (Larrow/core/Tuple21;Ljava/lang/Object;)Larrow/core/Tuple22; public static final fun plus (Larrow/core/Tuple4;Ljava/lang/Object;)Larrow/core/Tuple5; public static final fun plus (Larrow/core/Tuple5;Ljava/lang/Object;)Larrow/core/Tuple6; public static final fun plus (Larrow/core/Tuple6;Ljava/lang/Object;)Larrow/core/Tuple7; public static final fun plus (Larrow/core/Tuple7;Ljava/lang/Object;)Larrow/core/Tuple8; public static final fun plus (Larrow/core/Tuple8;Ljava/lang/Object;)Larrow/core/Tuple9; - public static final fun plus (Larrow/core/Tuple9;Ljava/lang/Object;)Larrow/core/Tuple10; public static final fun plus (Lkotlin/Pair;Ljava/lang/Object;)Lkotlin/Triple; public static final fun plus (Lkotlin/Triple;Ljava/lang/Object;)Larrow/core/Tuple4; } @@ -2451,132 +1717,6 @@ public final class arrow/core/ValidatedKt { public static final fun zip (Larrow/core/Validated;Larrow/typeclasses/Semigroup;Larrow/core/Validated;Lkotlin/jvm/functions/Function2;)Larrow/core/Validated; } -public abstract interface class arrow/core/computations/EitherEffect : arrow/continuations/Effect { - public abstract fun bind (Larrow/core/Either;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun bind (Larrow/core/Validated;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun bind (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun ensure (ZLkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/EitherEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/EitherEffect;Larrow/core/Either;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun bind (Larrow/core/computations/EitherEffect;Larrow/core/Validated;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun bind (Larrow/core/computations/EitherEffect;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun ensure (Larrow/core/computations/EitherEffect;ZLkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/EitherKt { - public static final fun ensureNotNull (Larrow/core/computations/EitherEffect;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/EvalEffect : arrow/continuations/Effect { - public abstract fun bind (Larrow/core/Eval;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/EvalEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/EvalEffect;Larrow/core/Eval;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/NullableEffect : arrow/continuations/Effect { - public abstract fun bind (Larrow/core/Option;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun bind (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun ensure (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/NullableEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/NullableEffect;Larrow/core/Option;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun bind (Larrow/core/computations/NullableEffect;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun ensure (Larrow/core/computations/NullableEffect;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/NullableKt { - public static final fun ensureNotNull (Larrow/core/computations/NullableEffect;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/OptionEffect : arrow/continuations/Effect { - public abstract fun bind (Larrow/core/Option;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun ensure (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/OptionEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/OptionEffect;Larrow/core/Option;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun ensure (Larrow/core/computations/OptionEffect;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/OptionKt { - public static final fun ensureNotNull (Larrow/core/computations/OptionEffect;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/RestrictedEitherEffect : arrow/core/computations/EitherEffect { -} - -public final class arrow/core/computations/RestrictedEitherEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/RestrictedEitherEffect;Larrow/core/Either;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun bind (Larrow/core/computations/RestrictedEitherEffect;Larrow/core/Validated;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun bind (Larrow/core/computations/RestrictedEitherEffect;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun ensure (Larrow/core/computations/RestrictedEitherEffect;ZLkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/RestrictedEvalEffect : arrow/core/computations/EvalEffect { -} - -public final class arrow/core/computations/RestrictedEvalEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/RestrictedEvalEffect;Larrow/core/Eval;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/RestrictedNullableEffect : arrow/core/computations/NullableEffect { -} - -public final class arrow/core/computations/RestrictedNullableEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/RestrictedNullableEffect;Larrow/core/Option;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun bind (Larrow/core/computations/RestrictedNullableEffect;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun ensure (Larrow/core/computations/RestrictedNullableEffect;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public abstract interface class arrow/core/computations/RestrictedOptionEffect : arrow/core/computations/OptionEffect { -} - -public final class arrow/core/computations/RestrictedOptionEffect$DefaultImpls { - public static fun bind (Larrow/core/computations/RestrictedOptionEffect;Larrow/core/Option;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun ensure (Larrow/core/computations/RestrictedOptionEffect;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/ResultEffect { - public static final field INSTANCE Larrow/core/computations/ResultEffect; - public final fun bind (Larrow/core/Either;)Ljava/lang/Object; - public final fun bind (Larrow/core/Validated;)Ljava/lang/Object; - public final fun bind (Ljava/lang/Object;)Ljava/lang/Object; -} - -public final class arrow/core/computations/either { - public static final field INSTANCE Larrow/core/computations/either; - public final fun eager (Lkotlin/jvm/functions/Function2;)Larrow/core/Either; - public final fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/eval { - public static final field INSTANCE Larrow/core/computations/eval; - public final fun eager (Lkotlin/jvm/functions/Function2;)Larrow/core/Eval; - public final fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/nullable { - public static final field INSTANCE Larrow/core/computations/nullable; - public final fun eager (Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; - public final fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/option { - public static final field INSTANCE Larrow/core/computations/option; - public final fun eager (Lkotlin/jvm/functions/Function2;)Larrow/core/Option; - public final fun invoke (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class arrow/core/computations/result { - public static final field INSTANCE Larrow/core/computations/result; - public final fun invoke-IoAF18A (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; -} - public final class arrow/core/continuations/AtomicRefKt { public static final fun getAndUpdate (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun loop (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)Ljava/lang/Void; @@ -3047,7 +2187,6 @@ public abstract interface class arrow/typeclasses/Monoid : arrow/typeclasses/Sem public static fun Short ()Larrow/typeclasses/Monoid; public abstract fun combineAll (Ljava/util/Collection;)Ljava/lang/Object; public abstract fun combineAll (Ljava/util/List;)Ljava/lang/Object; - public static fun constant (Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public static fun either (Larrow/typeclasses/Monoid;Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public abstract fun empty ()Ljava/lang/Object; public static fun endo ()Larrow/typeclasses/Monoid; @@ -3068,7 +2207,6 @@ public final class arrow/typeclasses/Monoid$Companion { public final fun Integer ()Larrow/typeclasses/Monoid; public final fun Long ()Larrow/typeclasses/Monoid; public final fun Short ()Larrow/typeclasses/Monoid; - public final fun constant (Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public final fun either (Larrow/typeclasses/Monoid;Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public final fun endo ()Larrow/typeclasses/Monoid; public final fun list ()Larrow/typeclasses/Monoid; @@ -3097,7 +2235,6 @@ public abstract interface class arrow/typeclasses/Semigroup { public static fun Long ()Larrow/typeclasses/Semigroup; public static fun Short ()Larrow/typeclasses/Semigroup; public abstract fun combine (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun constant (Larrow/typeclasses/Semigroup;)Larrow/typeclasses/Semigroup; public static fun either (Larrow/typeclasses/Semigroup;Larrow/typeclasses/Semigroup;)Larrow/typeclasses/Semigroup; public static fun endo ()Larrow/typeclasses/Semigroup; public static fun ior (Larrow/typeclasses/Semigroup;Larrow/typeclasses/Semigroup;)Larrow/typeclasses/Semigroup; @@ -3119,7 +2256,6 @@ public final class arrow/typeclasses/Semigroup$Companion { public final fun Integer ()Larrow/typeclasses/Semigroup; public final fun Long ()Larrow/typeclasses/Semigroup; public final fun Short ()Larrow/typeclasses/Semigroup; - public final fun constant (Larrow/typeclasses/Semigroup;)Larrow/typeclasses/Semigroup; public final fun either (Larrow/typeclasses/Semigroup;Larrow/typeclasses/Semigroup;)Larrow/typeclasses/Semigroup; public final fun endo ()Larrow/typeclasses/Semigroup; public final fun ior (Larrow/typeclasses/Semigroup;Larrow/typeclasses/Semigroup;)Larrow/typeclasses/Semigroup; diff --git a/arrow-libs/fx/arrow-fx-coroutines/api/arrow-fx-coroutines.api b/arrow-libs/fx/arrow-fx-coroutines/api/arrow-fx-coroutines.api index 9400aa58ce8..28c832b5dc6 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/api/arrow-fx-coroutines.api +++ b/arrow-libs/fx/arrow-fx-coroutines/api/arrow-fx-coroutines.api @@ -458,21 +458,21 @@ public final class arrow/fx/coroutines/Schedule$Companion { public final class arrow/fx/coroutines/Schedule$Decision { public static final field Companion Larrow/fx/coroutines/Schedule$Decision$Companion; - public fun (ZDLjava/lang/Object;Larrow/core/Eval;)V + public fun (ZDLjava/lang/Object;Lkotlin/jvm/functions/Function0;)V public final fun bimap (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Larrow/fx/coroutines/Schedule$Decision; public final fun combine (Larrow/fx/coroutines/Schedule$Decision;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Larrow/fx/coroutines/Schedule$Decision; public final fun combineNanos (Larrow/fx/coroutines/Schedule$Decision;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)Larrow/fx/coroutines/Schedule$Decision; public final fun component1 ()Z public final fun component2 ()D public final fun component3 ()Ljava/lang/Object; - public final fun component4 ()Larrow/core/Eval; - public final fun copy (ZDLjava/lang/Object;Larrow/core/Eval;)Larrow/fx/coroutines/Schedule$Decision; - public static synthetic fun copy$default (Larrow/fx/coroutines/Schedule$Decision;ZDLjava/lang/Object;Larrow/core/Eval;ILjava/lang/Object;)Larrow/fx/coroutines/Schedule$Decision; + public final fun component4 ()Lkotlin/jvm/functions/Function0; + public final fun copy (ZDLjava/lang/Object;Lkotlin/jvm/functions/Function0;)Larrow/fx/coroutines/Schedule$Decision; + public static synthetic fun copy$default (Larrow/fx/coroutines/Schedule$Decision;ZDLjava/lang/Object;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Larrow/fx/coroutines/Schedule$Decision; public fun equals (Ljava/lang/Object;)Z public final fun getCont ()Z public final fun getDelayInNanos ()D public final fun getDuration-UwyO8pc ()J - public final fun getFinish ()Larrow/core/Eval; + public final fun getFinish ()Lkotlin/jvm/functions/Function0; public final fun getState ()Ljava/lang/Object; public fun hashCode ()I public final fun map (Lkotlin/jvm/functions/Function1;)Larrow/fx/coroutines/Schedule$Decision; @@ -482,10 +482,10 @@ public final class arrow/fx/coroutines/Schedule$Decision { } public final class arrow/fx/coroutines/Schedule$Decision$Companion { - public final fun cont (DLjava/lang/Object;Larrow/core/Eval;)Larrow/fx/coroutines/Schedule$Decision; - public final fun cont-KLykuaI (JLjava/lang/Object;Larrow/core/Eval;)Larrow/fx/coroutines/Schedule$Decision; - public final fun done (DLjava/lang/Object;Larrow/core/Eval;)Larrow/fx/coroutines/Schedule$Decision; - public final fun done-KLykuaI (JLjava/lang/Object;Larrow/core/Eval;)Larrow/fx/coroutines/Schedule$Decision; + public final fun cont (DLjava/lang/Object;Lkotlin/jvm/functions/Function0;)Larrow/fx/coroutines/Schedule$Decision; + public final fun cont-KLykuaI (JLjava/lang/Object;Lkotlin/jvm/functions/Function0;)Larrow/fx/coroutines/Schedule$Decision; + public final fun done (DLjava/lang/Object;Lkotlin/jvm/functions/Function0;)Larrow/fx/coroutines/Schedule$Decision; + public final fun done-KLykuaI (JLjava/lang/Object;Lkotlin/jvm/functions/Function0;)Larrow/fx/coroutines/Schedule$Decision; } public final class arrow/fx/coroutines/ScheduleKt { diff --git a/arrow-libs/optics/arrow-optics/api/arrow-optics.api b/arrow-libs/optics/arrow-optics/api/arrow-optics.api index d8ef229e8fe..d6888217a76 100644 --- a/arrow-libs/optics/arrow-optics/api/arrow-optics.api +++ b/arrow-libs/optics/arrow-optics/api/arrow-optics.api @@ -28,7 +28,6 @@ public abstract interface class arrow/optics/Fold { public abstract fun size (Ljava/lang/Object;)I public static fun string ()Larrow/optics/Fold; public static fun triple ()Larrow/optics/Fold; - public static fun tuple10 ()Larrow/optics/Fold; public static fun tuple4 ()Larrow/optics/Fold; public static fun tuple5 ()Larrow/optics/Fold; public static fun tuple6 ()Larrow/optics/Fold; @@ -51,7 +50,6 @@ public final class arrow/optics/Fold$Companion { public final fun sequence ()Larrow/optics/Fold; public final fun string ()Larrow/optics/Fold; public final fun triple ()Larrow/optics/Fold; - public final fun tuple10 ()Larrow/optics/Fold; public final fun tuple4 ()Larrow/optics/Fold; public final fun tuple5 ()Larrow/optics/Fold; public final fun tuple6 ()Larrow/optics/Fold; @@ -166,7 +164,6 @@ public abstract interface class arrow/optics/PEvery : arrow/optics/Fold, arrow/o public static fun sequence ()Larrow/optics/PEvery; public static fun string ()Larrow/optics/PEvery; public static fun triple ()Larrow/optics/PEvery; - public static fun tuple10 ()Larrow/optics/PEvery; public static fun tuple4 ()Larrow/optics/PEvery; public static fun tuple5 ()Larrow/optics/PEvery; public static fun tuple6 ()Larrow/optics/PEvery; @@ -186,7 +183,6 @@ public final class arrow/optics/PEvery$Companion { public final fun sequence ()Larrow/optics/PEvery; public final fun string ()Larrow/optics/PEvery; public final fun triple ()Larrow/optics/PEvery; - public final fun tuple10 ()Larrow/optics/PEvery; public final fun tuple4 ()Larrow/optics/PEvery; public final fun tuple5 ()Larrow/optics/PEvery; public final fun tuple6 ()Larrow/optics/PEvery; @@ -702,7 +698,6 @@ public abstract interface class arrow/optics/PTraversal : arrow/optics/PSetter { public static fun option ()Larrow/optics/PTraversal; public static fun pPair ()Larrow/optics/PTraversal; public static fun pTriple ()Larrow/optics/PTraversal; - public static fun pTuple10 ()Larrow/optics/PTraversal; public static fun pTuple4 ()Larrow/optics/PTraversal; public static fun pTuple5 ()Larrow/optics/PTraversal; public static fun pTuple6 ()Larrow/optics/PTraversal; @@ -714,7 +709,6 @@ public abstract interface class arrow/optics/PTraversal : arrow/optics/PSetter { public static fun sequence ()Larrow/optics/PTraversal; public static fun string ()Larrow/optics/PTraversal; public static fun triple ()Larrow/optics/PTraversal; - public static fun tuple10 ()Larrow/optics/PTraversal; public static fun tuple4 ()Larrow/optics/PTraversal; public static fun tuple5 ()Larrow/optics/PTraversal; public static fun tuple6 ()Larrow/optics/PTraversal; @@ -742,7 +736,6 @@ public final class arrow/optics/PTraversal$Companion { public final fun option ()Larrow/optics/PTraversal; public final fun pPair ()Larrow/optics/PTraversal; public final fun pTriple ()Larrow/optics/PTraversal; - public final fun pTuple10 ()Larrow/optics/PTraversal; public final fun pTuple4 ()Larrow/optics/PTraversal; public final fun pTuple5 ()Larrow/optics/PTraversal; public final fun pTuple6 ()Larrow/optics/PTraversal; @@ -753,7 +746,6 @@ public final class arrow/optics/PTraversal$Companion { public final fun sequence ()Larrow/optics/PTraversal; public final fun string ()Larrow/optics/PTraversal; public final fun triple ()Larrow/optics/PTraversal; - public final fun tuple10 ()Larrow/optics/PTraversal; public final fun tuple4 ()Larrow/optics/PTraversal; public final fun tuple5 ()Larrow/optics/PTraversal; public final fun tuple6 ()Larrow/optics/PTraversal; From f1b84b178bdd4b1c3a82309816c240ddf66977bc Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 14:59:30 +0200 Subject: [PATCH 04/13] Fix tests for arrow-core and arrow-core-retrofit --- .../core/arrow-core-retrofit/build.gradle.kts | 3 + .../either/ArrowEitherCallAdapterTest.kt | 4 +- .../either/ArrowResponseEAdapterTest.kt | 4 +- arrow-libs/core/arrow-core/build.gradle.kts | 9 ++- .../commonMain/kotlin/arrow/core/Option.kt | 53 ++--------------- .../kotlin/arrow/core/AndThenTests.kt | 10 ++-- .../kotlin/arrow/core/BooleanTest.kt | 7 ++- .../arrow/core/CollectionsSyntaxTests.kt | 4 +- .../kotlin/arrow/core/ComparisonKtTest.kt | 4 +- .../kotlin/arrow/core/EitherTest.kt | 32 ++-------- .../commonTest/kotlin/arrow/core/EndoTest.kt | 9 +-- .../kotlin/arrow/core/FunctionSyntaxTest.kt | 4 +- .../commonTest/kotlin/arrow/core/IorTest.kt | 9 +-- .../kotlin/arrow/core/IterableTest.kt | 46 +++------------ .../commonTest/kotlin/arrow/core/ListKTest.kt | 7 ++- .../commonTest/kotlin/arrow/core/MapKTest.kt | 44 +++----------- .../kotlin/arrow/core/MemoizationTest.kt | 4 +- .../kotlin/arrow/core/NonEmptyListTest.kt | 29 ++------- .../kotlin/arrow/core/NonFatalTest.kt | 4 +- .../kotlin/arrow/core/NullableTest.kt | 6 +- .../kotlin/arrow/core/OptionTest.kt | 59 +++---------------- .../kotlin/arrow/core/SequenceKTest.kt | 34 ++--------- .../kotlin/arrow/core/ValidatedTest.kt | 1 + .../core/extensions/NumberInstancesTest.kt | 10 ++-- .../kotlin/arrow/core/generators.kt | 54 +++++++++++++++++ .../jvmTest/java/arrow/core/DeadlockTest.kt | 18 +----- .../jvmTest/java/arrow/core/EitherJvmTest.kt | 7 +-- .../java/arrow/core/NonFatalJvmTest.kt | 4 +- .../jvmTest/java/arrow/core/generatorsJvm.kt | 12 ++++ .../arrow/typeclasses/MonoidUsageTest.java | 2 - .../arrow/typeclasses/SemigroupUsageTest.java | 1 - .../kotlin/examples/example-option-17.kt | 15 ++--- .../kotlin/examples/example-option-18.kt | 14 +---- .../kotlin/examples/example-option-19.kt | 10 +++- .../kotlin/examples/example-option-20.kt | 10 +++- .../kotlin/examples/example-option-21.kt | 11 ---- .../kotlin/examples/example-option-22.kt | 14 ----- .../kotlin/examples/example-option-23.kt | 3 - .../arrow-optics-reflect/build.gradle.kts | 2 +- .../optics/arrow-optics/build.gradle.kts | 2 +- gradle.properties | 1 + 41 files changed, 196 insertions(+), 380 deletions(-) create mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt create mode 100644 arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/generatorsJvm.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-22.kt delete mode 100644 arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-23.kt diff --git a/arrow-libs/core/arrow-core-retrofit/build.gradle.kts b/arrow-libs/core/arrow-core-retrofit/build.gradle.kts index feeba04f015..dfefc820546 100644 --- a/arrow-libs/core/arrow-core-retrofit/build.gradle.kts +++ b/arrow-libs/core/arrow-core-retrofit/build.gradle.kts @@ -26,6 +26,9 @@ dependencies { if (!enableCompatibilityMetadataVariant) { testCompileOnly(libs.kotlin.reflect) testRuntimeOnly(libs.kotest.runnerJUnit5) + testImplementation(libs.kotest.frameworkEngine) + testImplementation(libs.kotest.assertionsCore) + testImplementation(projects.arrowCore) testImplementation(libs.squareup.okhttpMockWebServer) testImplementation(libs.squareup.retrofitConverterGson) testImplementation(libs.squareup.retrofitConverterMoshi) diff --git a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt index 61342550cf9..27cbc0dcb2f 100644 --- a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt +++ b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt @@ -2,10 +2,10 @@ package arrow.retrofit.adapter.either import arrow.core.left import arrow.core.right -import arrow.core.test.UnitSpec import arrow.retrofit.adapter.mock.ErrorMock import arrow.retrofit.adapter.mock.ResponseMock import arrow.retrofit.adapter.retrofit.SuspendApiTestClient +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer @@ -13,7 +13,7 @@ import okhttp3.mockwebserver.SocketPolicy import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory -class ArrowEitherCallAdapterTest : UnitSpec() { +class ArrowEitherCallAdapterTest : StringSpec() { private lateinit var server: MockWebServer private lateinit var service: SuspendApiTestClient diff --git a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt index da0cbb273a4..cffed728692 100644 --- a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt +++ b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt @@ -2,10 +2,10 @@ package arrow.retrofit.adapter.either import arrow.core.left import arrow.core.right -import arrow.core.test.UnitSpec import arrow.retrofit.adapter.mock.ErrorMock import arrow.retrofit.adapter.mock.ResponseMock import arrow.retrofit.adapter.retrofit.SuspendApiTestClient +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer @@ -13,7 +13,7 @@ import okhttp3.mockwebserver.SocketPolicy import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory -class ArrowResponseEAdapterTest : UnitSpec() { +class ArrowResponseEAdapterTest : StringSpec() { private lateinit var server: MockWebServer private lateinit var service: SuspendApiTestClient diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index d5910f0848a..143a8d0a8fb 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -31,16 +31,21 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(libs.kotest.runnerJUnit5) + implementation(libs.kotest.frameworkEngine) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) implementation(libs.kotest.arrowAssertions) implementation(libs.kotest.arrowProperty) - implementation(projects.arrowFxCoroutines) } } jvmTest { dependencies { + implementation(libs.kotest.frameworkEngine) + implementation(libs.kotest.assertionsCore) + implementation(libs.kotest.property) + implementation(libs.kotest.arrowAssertions) + implementation(libs.kotest.arrowProperty) + implementation(projects.arrowFxCoroutines) runtimeOnly(libs.kotest.runnerJUnit5) } } diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt index 978cacd651a..efd2608b40f 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt @@ -300,49 +300,6 @@ import kotlin.jvm.JvmStatic * ``` * * - * ### Computing over dependent values ignoring absence - * - * ```kotlin - * import arrow.core.computations.option - * import arrow.core.Some - * import arrow.core.Option - * - * suspend fun value(): Option = - * //sampleStart - * option { - * val a = Some(1).bind() - * val b = Some(1 + a).bind() - * val c = Some(1 + b).bind() - * a + b + c - * } - * //sampleEnd - * suspend fun main() { - * println(value()) - * } - * ``` - * - * - * ```kotlin - * import arrow.core.computations.option - * import arrow.core.Some - * import arrow.core.none - * import arrow.core.Option - * - * suspend fun value(): Option = - * //sampleStart - * option { - * val x = none().bind() - * val y = Some(1 + x).bind() - * val z = Some(1 + y).bind() - * x + y + z - * } - * //sampleEnd - * suspend fun main() { - * println(value()) - * } - * ``` - * - * * ## Credits * * Contents partially adapted from [Scala Exercises Option Tutorial](https://www.scala-exercises.org/std_lib/options) @@ -434,7 +391,7 @@ public sealed class Option { * none().tapNone { println("flower") } // Result: prints "flower" and returns: None * } * ``` - * + * */ public inline fun tapNone(f: () -> Unit): Option = when (this) { @@ -461,7 +418,7 @@ public sealed class Option { * none().tap { println("flower") } // Result: None * } * ``` - * + * */ public inline fun tap(f: (A) -> Unit): Option = when (this) { @@ -734,7 +691,7 @@ public sealed class Option { * none.exists { it > 10 } // Result: false * } * ``` - * + * * * @param predicate the predicate to test */ @@ -759,7 +716,7 @@ public sealed class Option { * none.exists { it > 10 } // Result: null * } * ``` - * + * */ public inline fun findOrNull(predicate: (A) -> Boolean): A? = when (this) { @@ -1066,7 +1023,7 @@ public inline fun Option.unzip(f: (C) -> Pair): Pair + * */ public fun Option.widen(): Option = this diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/AndThenTests.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/AndThenTests.kt index 4bdff64a870..518c8d687b4 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/AndThenTests.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/AndThenTests.kt @@ -1,15 +1,15 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.functionAToB -import arrow.core.test.stackSafeIteration +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.matchers.shouldBe import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.list +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.checkAll -class AndThenTests : UnitSpec(spec = { - val count = stackSafeIteration() +class AndThenTests : StringSpec({ + val count = 1000 "AndThen0 - compose a chain of functions with andThen should be same with AndThen" { checkAll(Arb.int(), Arb.list(Arb.functionAToB(Arb.int()))) { i, fs -> diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/BooleanTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/BooleanTest.kt index 3d7a5eb6996..1ed8305b1a1 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/BooleanTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/BooleanTest.kt @@ -1,12 +1,13 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.laws.testLaws -class BooleanTest : UnitSpec() { +class BooleanTest : StringSpec() { init { testLaws( MonoidLaws.laws(Monoid.boolean(), Arb.boolean()) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/CollectionsSyntaxTests.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/CollectionsSyntaxTests.kt index d55d788fb19..4ea910a241b 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/CollectionsSyntaxTests.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/CollectionsSyntaxTests.kt @@ -16,10 +16,10 @@ package arrow.core -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe -class CollectionsSyntaxTests : UnitSpec() { +class CollectionsSyntaxTests : StringSpec() { init { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ComparisonKtTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ComparisonKtTest.kt index 1be3c7e8c42..86a9879b86c 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ComparisonKtTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ComparisonKtTest.kt @@ -1,7 +1,7 @@ package arrow.core -import arrow.core.test.UnitSpec import io.kotest.assertions.assertSoftly +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.checkAll import io.kotest.matchers.shouldBe @@ -28,7 +28,7 @@ data class Person(val age: Int, val name: String) : Comparable { fun Arb.Companion.person(): Arb = Arb.bind(Arb.int(), Arb.string(), ::Person) -class ComparisonKtTest : UnitSpec({ +class ComparisonKtTest : StringSpec({ "Arberic - sort2" { checkAll(Arb.person(), Arb.person()) { a, b -> val (first, second) = sort(a, b) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherTest.kt index 3e5212c7e58..f43287c6358 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherTest.kt @@ -2,17 +2,9 @@ package arrow.core import arrow.core.Either.Left import arrow.core.Either.Right -import arrow.core.test.UnitSpec -import arrow.core.test.generators.any -import arrow.core.test.generators.either -import arrow.core.test.generators.intSmall -import arrow.core.test.generators.suspendFunThatReturnsAnyLeft -import arrow.core.test.generators.suspendFunThatReturnsAnyRight -import arrow.core.test.generators.suspendFunThatReturnsEitherAnyOrAnyOrThrows -import arrow.core.test.generators.suspendFunThatThrows -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid import io.kotest.assertions.throwables.shouldThrow +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean @@ -20,30 +12,18 @@ import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.long import io.kotest.property.arbitrary.string import io.kotest.property.arbitrary.nonPositiveInt +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class EitherTest : UnitSpec() { +class EitherTest : StringSpec() { private val ARB = Arb.either(Arb.string(), Arb.int()) init { testLaws( MonoidLaws.laws(Monoid.either(Monoid.string(), Monoid.int()), ARB), - /*FxLaws.suspended, Either, Int>( - Arb.int().map(::Right), - ARB.map { it }, - Either::equals, - either::invoke - ) { - it.bind() - }, - FxLaws.eager, Either, Int>( - Arb.int().map(::Right), - ARB.map { it }, - Either::equals, - either::eager - ) { - it.bind() - }*/ ) "isLeft should return true if Left and false if Right" { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EndoTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EndoTest.kt index ad1bc172d2e..b953e77f594 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EndoTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EndoTest.kt @@ -1,13 +1,14 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.endo -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.int +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.core.endo +import io.kotest.property.arrow.laws.testLaws -class EndoTest : UnitSpec() { +class EndoTest : StringSpec() { init { testLaws( MonoidLaws.laws(Monoid.endo(), Arb.endo(Arb.int())) { a, b -> diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/FunctionSyntaxTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/FunctionSyntaxTest.kt index a8275ba6939..a828091e2f4 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/FunctionSyntaxTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/FunctionSyntaxTest.kt @@ -1,9 +1,9 @@ package arrow.core -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe -class FunctionSyntaxTest : UnitSpec() { +class FunctionSyntaxTest : StringSpec() { val f = { prefix: String, numericPostfix: Int, values: List -> values.map { "$prefix$it$numericPostfix" } diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IorTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IorTest.kt index 4b83bc15750..a9d3b4f65cb 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IorTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IorTest.kt @@ -1,9 +1,7 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.ior -import arrow.core.test.laws.SemigroupLaws import arrow.typeclasses.Semigroup +import io.kotest.core.spec.style.StringSpec import io.kotest.data.forAll import io.kotest.data.row import io.kotest.property.Arb @@ -12,8 +10,11 @@ import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.long import io.kotest.property.arbitrary.orNull import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.SemigroupLaws +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class IorTest : UnitSpec() { +class IorTest : StringSpec() { init { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt index 3be29c3c0bf..81fd2860cf1 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt @@ -1,25 +1,21 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.either -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.option import arrow.typeclasses.Semigroup -import io.kotest.matchers.collections.shouldBeEmpty +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.collections.shouldContainExactly import io.kotest.matchers.nulls.shouldBeNull import io.kotest.matchers.nulls.shouldNotBeNull -import io.kotest.matchers.should import io.kotest.property.Arb import io.kotest.matchers.shouldBe -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.orNull -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.option +import io.kotest.property.checkAll import kotlin.math.max import kotlin.math.min -class IterableTest : UnitSpec() { +class IterableTest : StringSpec() { init { "traverse Either stack-safe" { // also verifies result order and execution order (l to r) @@ -355,34 +351,6 @@ class IterableTest : UnitSpec() { } } - "zip10" { - checkAll( - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()), - Arb.list(Arb.int()) - ) { a, b, c, d, e, f, g, h, i, j -> - val result = a.zip(b, c, d, e, f, g, h, i, j, ::Tuple10) - val expected = a.zip(b, ::Pair) - .zip(c) { (a, b), c -> Triple(a, b, c) } - .zip(d) { (a, b, c), d -> Tuple4(a, b, c, d) } - .zip(e) { (a, b, c, d), e -> Tuple5(a, b, c, d, e) } - .zip(f) { (a, b, c, d, e), f -> Tuple6(a, b, c, d, e, f) } - .zip(g) { (a, b, c, d, e, f), g -> Tuple7(a, b, c, d, e, f, g) } - .zip(h) { (a, b, c, d, e, f, g), h -> Tuple8(a, b, c, d, e, f, g, h) } - .zip(i) { (a, b, c, d, e, f, g, h), i -> Tuple9(a, b, c, d, e, f, g, h, i) } - .zip(j) { (a, b, c, d, e, f, g, h, i), j -> Tuple10(a, b, c, d, e, f, g, h, i, j) } - - result shouldBe expected - } - } - "can align lists with different lengths" { checkAll(Arb.list(Arb.boolean()), Arb.list(Arb.boolean())) { a, b -> a.align(b).size shouldBe max(a.size, b.size) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ListKTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ListKTest.kt index 784df77e0a9..57f27186653 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ListKTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ListKTest.kt @@ -1,15 +1,16 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.list +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.laws.testLaws import io.kotest.property.checkAll -class ListKTest : UnitSpec() { +class ListKTest : StringSpec() { init { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MapKTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MapKTest.kt index 478062cae4b..d37cdd00a7e 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MapKTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MapKTest.kt @@ -1,19 +1,17 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.intSmall -import arrow.core.test.generators.longSmall -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid import arrow.typeclasses.Semigroup +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.matchers.shouldBe -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.long -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.core.nonEmptyList +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class MapKTest : UnitSpec() { +class MapKTest : StringSpec() { init { testLaws( @@ -271,34 +269,6 @@ class MapKTest : UnitSpec() { } } - "zip10" { - checkAll( - Arb.map(Arb.intSmall(), Arb.intSmall()), - Arb.map(Arb.intSmall(), Arb.intSmall()) - ) { a, b -> - val result = a.zip(b, b, b, b, b, b, b, b, b) { _, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj -> - Tuple10( - aa, - bb, - cc, - dd, - ee, - ff, - gg, - hh, - ii, - jj - ) - } - - val expected = a.filter { (k, _) -> b.containsKey(k) } - .map { (k, v) -> Pair(k, Tuple10(v, b[k]!!, b[k]!!, b[k]!!, b[k]!!, b[k]!!, b[k]!!, b[k]!!, b[k]!!, b[k]!!)) } - .toMap() - - result shouldBe expected - } - } - "flatMap" { checkAll( Arb.map(Arb.string(), Arb.intSmall()), diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MemoizationTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MemoizationTest.kt index 21e6fb90bc2..0e27a37af6c 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MemoizationTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MemoizationTest.kt @@ -1,13 +1,13 @@ package arrow.core -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.property.checkAll import io.kotest.matchers.shouldBe import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlin.random.Random -class MemoizationTest : UnitSpec({ +class MemoizationTest : StringSpec({ "Memoize races" { checkAll { fun sum(): Int = diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonEmptyListTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonEmptyListTest.kt index 1d748c1b93c..1ad902de008 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonEmptyListTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonEmptyListTest.kt @@ -1,16 +1,19 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.laws.SemigroupLaws import arrow.typeclasses.Semigroup +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.matchers.shouldBe import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int +import io.kotest.property.arrow.core.SemigroupLaws +import io.kotest.property.arrow.core.nonEmptyList +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll import kotlin.math.max import kotlin.math.min -class NonEmptyListTest : UnitSpec() { +class NonEmptyListTest : StringSpec() { init { testLaws(SemigroupLaws.laws(Semigroup.nonEmptyList(), Arb.nonEmptyList(Arb.int()))) @@ -248,26 +251,6 @@ class NonEmptyListTest : UnitSpec() { } } - "zip10" { - checkAll( - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()), - Arb.nonEmptyList(Arb.int()) - ) { a, b, c, d, e, f, g, h, i, j -> - val result = a.zip(b, c, d, e, f, g, h, i, j, ::Tuple10) - val expected = a.all.zip(b.all, c.all, d.all, e.all, f.all, g.all, h.all, i.all, j.all, ::Tuple10) - .toNonEmptyListOrNull() - result shouldBe expected - } - } - "max element" { checkAll( Arb.nonEmptyList(Arb.int()) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonFatalTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonFatalTest.kt index 6c13f9767c1..13adf164834 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonFatalTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonFatalTest.kt @@ -1,9 +1,9 @@ package arrow.core -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe -class NonFatalTest : UnitSpec() { +class NonFatalTest : StringSpec() { init { val nonFatals: List = listOf( diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NullableTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NullableTest.kt index bb96ce77d02..4cf87298976 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NullableTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NullableTest.kt @@ -2,16 +2,16 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.intSmall +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.nulls.shouldBeNull import io.kotest.property.Arb import io.kotest.matchers.shouldBe import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.orNull import io.kotest.property.arbitrary.string +import io.kotest.property.checkAll -class NullableTest : UnitSpec(spec = { +class NullableTest : StringSpec({ "map1 short circuits if any arg is null" { Nullable.zip(null) { Unit }.shouldBeNull() } diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt index d01efef505f..87da9f84cc6 100755 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt @@ -1,20 +1,19 @@ package arrow.core -import arrow.core.continuations.ensureNotNull -import arrow.core.continuations.option -import arrow.core.test.UnitSpec -import arrow.core.test.generators.option -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.property.Arb -import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.long import io.kotest.property.arbitrary.orNull +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.core.option +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class OptionTest : UnitSpec() { +class OptionTest : StringSpec() { val some: Option = Some("kotlin") val none: Option = None @@ -22,53 +21,9 @@ class OptionTest : UnitSpec() { init { testLaws( - MonoidLaws.laws(Monoid.option(Monoid.int()), Arb.option(Arb.int())), - /*FxLaws.suspended, Option, String>( - Arb.string().map(Option.Companion::invoke), - Arb.option(Arb.string()), - Option::equals, - option::invoke - ) { - it.bind() - }, - FxLaws.eager, Option, String>( - Arb.string().map(Option.Companion::invoke), - Arb.option(Arb.string()), - Option::equals, - option::eager - ) { - it.bind() - }*/ + MonoidLaws.laws(Monoid.option(Monoid.int()), Arb.option(Arb.int())) ) - "ensure null in option computation" { - checkAll(Arb.boolean(), Arb.int()) { predicate, i -> - option { - ensure(predicate) - i - } shouldBe if (predicate) Some(i) else None - } - } - - "ensureNotNull in option computation" { - fun square(i: Int): Int = i * i - checkAll(Arb.int().orNull()) { i: Int? -> - option { - val ii = i - ensureNotNull(ii) - square(ii) // Smart-cast by contract - } shouldBe i.toOption().map(::square) - } - } - - "short circuit null" { - option { - val number: Int = "s".length - ensureNotNull(number.takeIf { it > 1 }) - throw IllegalStateException("This should not be executed") - } shouldBe None - } - "tap applies effects returning the original value" { checkAll(Arb.option(Arb.long())) { option -> var effect = 0 diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt index 9b9056e2a6a..19cff0a70af 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt @@ -1,7 +1,5 @@ package arrow.core -import arrow.core.test.generators.option -import arrow.core.test.laws.MonoidLaws import arrow.typeclasses.Monoid import arrow.typeclasses.Semigroup import io.kotest.core.spec.style.StringSpec @@ -10,8 +8,12 @@ import io.kotest.property.Arb import io.kotest.property.checkAll import io.kotest.matchers.shouldBe import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.positiveInt import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.option +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.laws.testLaws import kotlin.math.max import kotlin.math.min @@ -207,34 +209,6 @@ class SequenceKTest : StringSpec() { } } - "zip10" { - checkAll( - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()), - Arb.sequence(Arb.int()) - ) { a, b, c, d, e, f, g, h, i, j -> - val result = a.zip(b, c, d, e, f, g, h, i, j, ::Tuple10) - val expected = a.zip(b, ::Pair) - .zip(c) { (a, b), c -> Triple(a, b, c) } - .zip(d) { (a, b, c), d -> Tuple4(a, b, c, d) } - .zip(e) { (a, b, c, d), e -> Tuple5(a, b, c, d, e) } - .zip(f) { (a, b, c, d, e), f -> Tuple6(a, b, c, d, e, f) } - .zip(g) { (a, b, c, d, e, f), g -> Tuple7(a, b, c, d, e, f, g) } - .zip(h) { (a, b, c, d, e, f, g), h -> Tuple8(a, b, c, d, e, f, g, h) } - .zip(i) { (a, b, c, d, e, f, g, h), i -> Tuple9(a, b, c, d, e, f, g, h, i) } - .zip(j) { (a, b, c, d, e, f, g, h, i), j -> Tuple10(a, b, c, d, e, f, g, h, i, j) } - - result.toList() shouldBe expected.toList() - } - } - "can align sequences - 1" { checkAll(Arb.sequence(Arb.int()), Arb.sequence(Arb.string())) { a, b -> a.align(b).toList().size shouldBe max(a.toList().size, b.toList().size) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt index a4837e38cbb..1a2aecaea3e 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/ValidatedTest.kt @@ -14,6 +14,7 @@ import io.kotest.property.arbitrary.long import io.kotest.property.arbitrary.orNull import io.kotest.property.arbitrary.string import io.kotest.property.arrow.core.validated +import io.kotest.property.checkAll @Suppress("RedundantSuspendModifier") class ValidatedTest : StringSpec() { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/extensions/NumberInstancesTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/extensions/NumberInstancesTest.kt index 15288634365..a5aba1ee200 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/extensions/NumberInstancesTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/extensions/NumberInstancesTest.kt @@ -1,18 +1,20 @@ package arrow.core.extensions -import arrow.core.test.UnitSpec -import arrow.core.test.laws.MonoidLaws -import arrow.core.test.laws.SemiringLaws import arrow.typeclasses.Monoid import arrow.typeclasses.Semiring +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.byte import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.long import io.kotest.property.arbitrary.short +import io.kotest.property.arrow.core.MonoidLaws +import io.kotest.property.arrow.core.SemiringLaws +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class NumberInstancesTest : UnitSpec() { +class NumberInstancesTest : StringSpec() { fun testAllLaws( SG: Semiring, diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt new file mode 100644 index 00000000000..638f3f5e575 --- /dev/null +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt @@ -0,0 +1,54 @@ +package arrow.core + +import io.kotest.property.Arb +import io.kotest.property.arbitrary.* + +public fun Arb.Companion.intSmall(factor: Int = 10000): Arb = + Arb.int((Int.MIN_VALUE / factor)..(Int.MAX_VALUE / factor)) + +public fun Arb.Companion.longSmall(): Arb = + Arb.long((Long.MIN_VALUE / 100000L)..(Long.MAX_VALUE / 100000L)) + +public fun Arb.Companion.throwable(): Arb = + Arb.of(listOf(RuntimeException(), NoSuchElementException(), IllegalArgumentException())) + +public fun Arb.Companion.sequence(inner: Arb): Arb> = + Arb.list(inner).map { it.asSequence() } + +public inline fun Arb.Companion.array(inner: Arb, range: IntRange): Arb> = + Arb.list(inner, range).map { it.toTypedArray() } + +public fun Arb.Companion.ior(arbA: Arb, arbB: Arb): Arb> = + arbA.alignWith(arbB) { it } + +private fun Arb.alignWith(arbB: Arb, transform: (Ior) -> R): Arb = + Arb.bind(this, arbB) { a, b -> transform(Ior.Both(a, b)) } + +public fun Arb.Companion.suspendFunThatReturnsEitherAnyOrAnyOrThrows(): Arb Either> = + choice( + suspendFunThatReturnsAnyRight(), + suspendFunThatReturnsAnyLeft(), + suspendFunThatThrows() + ) + +public fun Arb.Companion.suspendFunThatReturnsAnyRight(): Arb Either> = + any().map { suspend { it.right() } } + +public fun Arb.Companion.suspendFunThatReturnsAnyLeft(): Arb Either> = + any().map { suspend { it.left() } } + +public fun Arb.Companion.suspendFunThatThrows(): Arb Either> = + throwable().map { suspend { throw it } } as Arb Either> + +public fun Arb.Companion.unit(): Arb = + Arb.constant(Unit) + +public fun Arb.Companion.any(): Arb = + choice( + Arb.string() as Arb, + Arb.int() as Arb, + Arb.long() as Arb, + Arb.boolean() as Arb, + Arb.throwable() as Arb, + Arb.unit() as Arb + ) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/DeadlockTest.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/DeadlockTest.kt index b55d4d20084..62c4c5105b7 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/DeadlockTest.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/DeadlockTest.kt @@ -1,12 +1,12 @@ package arrow.core -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -class DeadlockTest : UnitSpec() { +class DeadlockTest : StringSpec() { init { @@ -65,19 +65,5 @@ class DeadlockTest : UnitSpec() { }.joinAll() } } - - "classloader should not deadlock Eval initialization" { - runBlocking { - (0..10).map { i -> - GlobalScope.launch { - if (i % 2 == 0) { - Eval.Now(Unit) - } else { - Eval.Later { null } - } - } - }.joinAll() - } - } } } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EitherJvmTest.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EitherJvmTest.kt index 37b8cde6e65..b415a3597c6 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EitherJvmTest.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EitherJvmTest.kt @@ -1,12 +1,11 @@ package arrow.core -import arrow.core.test.UnitSpec -import arrow.core.test.generators.any -import arrow.core.test.generators.suspendFunThatThrowsFatalThrowable +import io.kotest.core.spec.style.StringSpec import io.kotest.assertions.throwables.shouldThrow import io.kotest.property.Arb +import io.kotest.property.checkAll -class EitherJvmTest : UnitSpec({ +class EitherJvmTest : StringSpec({ "resolve should throw a Throwable when a fatal Throwable is thrown" { checkAll( Arb.suspendFunThatThrowsFatalThrowable(), diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/NonFatalJvmTest.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/NonFatalJvmTest.kt index b4845783e8d..2df2fdc013f 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/NonFatalJvmTest.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/NonFatalJvmTest.kt @@ -1,10 +1,10 @@ package arrow.core -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.assertions.throwables.shouldThrowAny import io.kotest.matchers.shouldBe -class NonFatalJvmTest : UnitSpec({ +class NonFatalJvmTest : StringSpec({ val fatals: List = listOf( InterruptedException(), diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/generatorsJvm.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/generatorsJvm.kt new file mode 100644 index 00000000000..0bc9e9c5511 --- /dev/null +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/generatorsJvm.kt @@ -0,0 +1,12 @@ +package arrow.core + +import arrow.core.Either +import io.kotest.property.Arb +import io.kotest.property.arbitrary.map +import io.kotest.property.arbitrary.of + +public fun Arb.Companion.suspendFunThatThrowsFatalThrowable(): Arb Either> = + fatalThrowable().map { suspend { throw it } } as Arb Either> + +public fun Arb.Companion.fatalThrowable(): Arb = + Arb.of(listOf(ThreadDeath(), StackOverflowError(), OutOfMemoryError(), InterruptedException())) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/MonoidUsageTest.java b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/MonoidUsageTest.java index 13bdafaea2c..352f2dd10c2 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/MonoidUsageTest.java +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/MonoidUsageTest.java @@ -27,7 +27,5 @@ public void testUsage() { Monoid> option = Monoid.option(Semigroup.Integer()); Monoid> validated = Monoid.validated(Semigroup.Integer(), Monoid.Boolean()); Monoid> pair = Monoid.pair(Monoid.Boolean(), Monoid.Integer()); - - Monoid.constant(Monoid.Integer()); } } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/SemigroupUsageTest.java b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/SemigroupUsageTest.java index 57d4320f09c..cc76035146b 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/SemigroupUsageTest.java +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/SemigroupUsageTest.java @@ -23,7 +23,6 @@ public void testUsage() { Semigroup> validated = Semigroup.validated(Semigroup.Boolean(), Semigroup.Integer()); Semigroup> nonEmptyList = Semigroup.nonEmptyList(); Semigroup> pair = Semigroup.pair(Semigroup.Boolean(), Semigroup.Integer()); - Semigroup> constant = Semigroup.constant(Semigroup.Integer()); Semigroup aByte = Semigroup.Byte(); Semigroup aShort = Semigroup.Short(); } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-17.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-17.kt index 4fc22facd84..24a65d7ac6f 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-17.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-17.kt @@ -1,17 +1,10 @@ // This file was automatically generated from Option.kt by Knit tool. Do not edit. package arrow.core.examples.exampleOption17 -import arrow.core.computations.option import arrow.core.Some -import arrow.core.Option +import arrow.core.none -suspend fun value(): Option = - option { - val a = Some(1).bind() - val b = Some(1 + a).bind() - val c = Some(1 + b).bind() - a + b + c -} -suspend fun main() { - println(value()) +fun main() { + Some(12).tapNone { println("flower") } // Result: Some(12) + none().tapNone { println("flower") } // Result: prints "flower" and returns: None } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-18.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-18.kt index e47211b5ef6..d03af3c4b3a 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-18.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-18.kt @@ -1,18 +1,10 @@ // This file was automatically generated from Option.kt by Knit tool. Do not edit. package arrow.core.examples.exampleOption18 -import arrow.core.computations.option import arrow.core.Some import arrow.core.none -import arrow.core.Option -suspend fun value(): Option = - option { - val x = none().bind() - val y = Some(1 + x).bind() - val z = Some(1 + y).bind() - x + y + z - } -suspend fun main() { - println(value()) +fun main() { + Some(12).tap { println("flower") } // Result: prints "flower" and returns: Some(12) + none().tap { println("flower") } // Result: None } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-19.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-19.kt index 364813486b9..de3db082548 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-19.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-19.kt @@ -2,9 +2,13 @@ package arrow.core.examples.exampleOption19 import arrow.core.Some -import arrow.core.none +import arrow.core.None +import arrow.core.Option fun main() { - Some(12).tapNone { println("flower") } // Result: Some(12) - none().tapNone { println("flower") } // Result: prints "flower" and returns: None + Some(12).exists { it > 10 } // Result: true + Some(7).exists { it > 10 } // Result: false + + val none: Option = None + none.exists { it > 10 } // Result: false } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-20.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-20.kt index 2e5652f4aac..8c562e7f4a5 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-20.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-20.kt @@ -2,9 +2,13 @@ package arrow.core.examples.exampleOption20 import arrow.core.Some -import arrow.core.none +import arrow.core.None +import arrow.core.Option fun main() { - Some(12).tap { println("flower") } // Result: prints "flower" and returns: Some(12) - none().tap { println("flower") } // Result: None + Some(12).exists { it > 10 } // Result: 12 + Some(7).exists { it > 10 } // Result: null + + val none: Option = None + none.exists { it > 10 } // Result: null } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-21.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-21.kt index 07a9d4ec693..6b92d2b9051 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-21.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-21.kt @@ -1,14 +1,3 @@ // This file was automatically generated from Option.kt by Knit tool. Do not edit. package arrow.core.examples.exampleOption21 -import arrow.core.Some -import arrow.core.None -import arrow.core.Option - -fun main() { - Some(12).exists { it > 10 } // Result: true - Some(7).exists { it > 10 } // Result: false - - val none: Option = None - none.exists { it > 10 } // Result: false -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-22.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-22.kt deleted file mode 100644 index 9263fd76499..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-22.kt +++ /dev/null @@ -1,14 +0,0 @@ -// This file was automatically generated from Option.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleOption22 - -import arrow.core.Some -import arrow.core.None -import arrow.core.Option - -fun main() { - Some(12).exists { it > 10 } // Result: 12 - Some(7).exists { it > 10 } // Result: null - - val none: Option = None - none.exists { it > 10 } // Result: null -} diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-23.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-23.kt deleted file mode 100644 index dfcf262a5ae..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-23.kt +++ /dev/null @@ -1,3 +0,0 @@ -// This file was automatically generated from Option.kt by Knit tool. Do not edit. -package arrow.core.examples.exampleOption23 - diff --git a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts index 17565ac6948..a46d1e585a1 100644 --- a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(libs.kotlin.stdlibJDK8) if(!enableCompatibilityMetadataVariant) { - testImplementation(libs.kotest.runnerJUnit5) + testImplementation(libs.kotest.frameworkEngine) testImplementation(libs.kotest.assertionsCore) testImplementation(libs.kotest.property) testImplementation(libs.kotest.arrowOpticsProperty) diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 173d37a8a30..6759cc32e75 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -31,7 +31,7 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(libs.kotest.runnerJUnit5) + implementation(libs.kotest.frameworkEngine) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) implementation(libs.kotest.arrowOpticsProperty) diff --git a/gradle.properties b/gradle.properties index 015b803c986..4f07dc0321f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,6 +31,7 @@ kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.enableCompatibilityMetadataVariant=false # https://youtrack.jetbrains.com/issue/KT-45545#focus=Comments-27-4773544.0-0 kapt.use.worker.api=false +kotest.proptest.default.iteration.count=10 COMMON_SETUP=../gradle/setup.gradle ROOT_PROJECT=../gradle/main.gradle From 7aed62b5c1776572c3b25aece0ce3edfcdf2ff90 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 15:10:06 +0200 Subject: [PATCH 05/13] Fix test for arrow-optics-reflect --- arrow-libs/optics/arrow-optics-reflect/build.gradle.kts | 1 + .../src/test/kotlin/arrow/optics/ReflectionTest.kt | 6 ++++-- arrow-libs/optics/arrow-optics/build.gradle.kts | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts index a46d1e585a1..3fc7fa922aa 100644 --- a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts @@ -27,6 +27,7 @@ dependencies { testImplementation(libs.kotest.frameworkEngine) testImplementation(libs.kotest.assertionsCore) testImplementation(libs.kotest.property) + testImplementation(libs.kotest.arrowProperty) testImplementation(libs.kotest.arrowOpticsProperty) testImplementation(libs.kotlin.stdlibJDK8) testImplementation(libs.junitJupiterEngine) diff --git a/arrow-libs/optics/arrow-optics-reflect/src/test/kotlin/arrow/optics/ReflectionTest.kt b/arrow-libs/optics/arrow-optics-reflect/src/test/kotlin/arrow/optics/ReflectionTest.kt index b4c32470df9..1531da8b6bc 100644 --- a/arrow-libs/optics/arrow-optics-reflect/src/test/kotlin/arrow/optics/ReflectionTest.kt +++ b/arrow-libs/optics/arrow-optics-reflect/src/test/kotlin/arrow/optics/ReflectionTest.kt @@ -1,10 +1,12 @@ package arrow.optics -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.string +import io.kotest.property.checkAll data class Person(val name: String, val friends: List) @@ -12,7 +14,7 @@ sealed interface Cutlery object Fork: Cutlery object Spoon: Cutlery -object ReflectionTest: UnitSpec() { +object ReflectionTest: StringSpec() { init { "optional for function" { checkAll(Arb.list(Arb.int())) { ints -> diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 6759cc32e75..8aa150d0b8d 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -34,6 +34,7 @@ kotlin { implementation(libs.kotest.frameworkEngine) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) + implementation(libs.kotest.arrowProperty) implementation(libs.kotest.arrowOpticsProperty) } } From d6ce9c10ebfe16af4958a31703df6d5d9af81fed Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 15:31:50 +0200 Subject: [PATCH 06/13] Work on the optics tests --- .../src/commonTest/kotlin/arrow/optics/EveryTest.kt | 6 ++++-- .../src/commonTest/kotlin/arrow/optics/FoldTest.kt | 6 ++++-- .../src/commonTest/kotlin/arrow/optics/GetterTest.kt | 7 ++++--- .../src/commonTest/kotlin/arrow/optics/IsoTest.kt | 7 +++++-- .../commonTest/kotlin/arrow/optics/OptionalGetterTest.kt | 5 +++-- .../src/commonTest/kotlin/arrow/optics/OptionalTest.kt | 6 ++++-- .../src/commonTest/kotlin/arrow/optics/PrismTest.kt | 6 ++++-- .../src/commonTest/kotlin/arrow/optics/SetterTest.kt | 6 ++++-- .../src/commonTest/kotlin/arrow/optics/TraversalTest.kt | 5 +++-- .../kotlin/arrow/optics/instances/AtInstanceTest.kt | 5 +++-- .../kotlin/arrow/optics/instances/ConsInstanceTest.kt | 5 +++-- .../kotlin/arrow/optics/instances/EitherInstanceTest.kt | 5 +++-- .../arrow/optics/instances/FilterIndexInstanceTest.kt | 5 +++-- .../kotlin/arrow/optics/instances/IndexInstanceTest.kt | 5 +++-- .../kotlin/arrow/optics/instances/SnocInstanceTest.kt | 3 ++- 15 files changed, 52 insertions(+), 30 deletions(-) diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/EveryTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/EveryTest.kt index f21eba73a75..a28831f29fa 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/EveryTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/EveryTest.kt @@ -1,13 +1,15 @@ package arrow.optics -import arrow.core.test.UnitSpec import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.orNull +import io.kotest.property.checkAll -class EveryTest : UnitSpec() { +class EveryTest : StringSpec() { init { with(Every.list()) { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/FoldTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/FoldTest.kt index f7ccc662213..3b019a6d166 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/FoldTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/FoldTest.kt @@ -1,14 +1,16 @@ package arrow.optics -import arrow.core.test.UnitSpec import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.orNull +import io.kotest.property.checkAll -class FoldTest : UnitSpec() { +class FoldTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/GetterTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/GetterTest.kt index 98cc17e6a49..3f332662c99 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/GetterTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/GetterTest.kt @@ -2,15 +2,16 @@ package arrow.optics import arrow.core.Either.Left import arrow.core.Either.Right -import arrow.core.test.UnitSpec import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb -import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string import io.kotest.property.arbitrary.boolean +import io.kotest.property.arbitrary.int +import io.kotest.property.checkAll -class GetterTest : UnitSpec() { +class GetterTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt index 6c290dbc442..781a2221af4 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt @@ -1,7 +1,6 @@ package arrow.optics import arrow.core.Either -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.optics.test.laws.IsoLaws import arrow.optics.test.laws.LensLaws @@ -10,13 +9,17 @@ import arrow.optics.test.laws.PrismLaws import arrow.optics.test.laws.SetterLaws import arrow.optics.test.laws.TraversalLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class IsoTest : UnitSpec() { + +class IsoTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt index 6a3fc8ef29b..9e540c74289 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt @@ -1,12 +1,13 @@ package arrow.optics -import arrow.core.test.UnitSpec +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int +import io.kotest.property.checkAll -class OptionalGetterTest : UnitSpec() { +class OptionalGetterTest : StringSpec() { init { "get should return value if predicate is true and null if otherwise" { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt index 34d486a0bdb..f452c14b8c5 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt @@ -4,11 +4,11 @@ import arrow.core.Either.Left import arrow.core.Either.Right import arrow.core.getOrElse import arrow.core.identity -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.core.toOption import arrow.optics.test.laws.OptionalLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe import io.kotest.property.Arb @@ -17,8 +17,10 @@ import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.orNull import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class OptionalTest : UnitSpec() { +class OptionalTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt index 8d0f60cba95..9d6c4621f7c 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt @@ -1,6 +1,5 @@ package arrow.optics -import arrow.core.test.UnitSpec import arrow.core.test.generators.either import arrow.core.test.generators.functionAToB import arrow.optics.test.laws.OptionalLaws @@ -8,14 +7,17 @@ import arrow.optics.test.laws.PrismLaws import arrow.optics.test.laws.SetterLaws import arrow.optics.test.laws.TraversalLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class PrismTest : UnitSpec() { +class PrismTest : StringSpec() { init { testLaws( diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt index 3fc27061c0d..2b447eabab6 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt @@ -3,15 +3,17 @@ package arrow.optics import arrow.core.getOrElse import arrow.core.left import arrow.core.right -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.optics.test.laws.SetterLaws import io.kotest.matchers.shouldBe import io.kotest.property.Arb +import io.kotest.core.spec.style.StringSpec import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.checkAll -class SetterTest : UnitSpec() { +class SetterTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt index d93b5e0eb44..68ce34b0953 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt @@ -1,16 +1,17 @@ package arrow.optics -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.core.test.generators.option import arrow.optics.test.laws.SetterLaws import arrow.optics.test.laws.TraversalLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws -class TraversalTest : UnitSpec() { +class TraversalTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt index 4230efe99b3..2f3152d552d 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt @@ -1,18 +1,19 @@ package arrow.optics.instances -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.core.test.generators.option import arrow.optics.test.laws.LensLaws import arrow.optics.typeclasses.At +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.set import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws -class AtInstanceTest : UnitSpec() { +class AtInstanceTest : StringSpec() { init { testLaws( "At map - ", diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt index 43313bfb6df..01c36f04565 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt @@ -1,17 +1,18 @@ package arrow.optics.instances -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.optics.test.laws.PrismLaws import arrow.optics.typeclasses.Cons +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws -class ConsInstanceTest : UnitSpec() { +class ConsInstanceTest : StringSpec() { init { testLaws( "Const list - ", diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt index d7e14e43d58..449a61c063f 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt @@ -1,15 +1,16 @@ package arrow.optics.instances -import arrow.core.test.UnitSpec import arrow.core.test.generators.either import arrow.core.test.generators.functionAToB import arrow.optics.Traversal import arrow.optics.test.laws.TraversalLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws -class EitherInstanceTest : UnitSpec() { +class EitherInstanceTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt index b04c279fa54..b303a1bbfc1 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt @@ -1,16 +1,17 @@ package arrow.optics.instances -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.core.test.generators.intSmall import arrow.optics.test.laws.TraversalLaws import arrow.optics.typeclasses.FilterIndex +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws -class FilterIndexInstanceTest : UnitSpec() { +class FilterIndexInstanceTest : StringSpec() { init { testLaws( diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt index 34598a122d2..fcc1f75145e 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt @@ -1,16 +1,17 @@ package arrow.optics.instances -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.optics.test.laws.OptionalLaws import arrow.optics.typeclasses.Index +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws -class IndexInstanceTest : UnitSpec() { +class IndexInstanceTest : StringSpec() { init { testLaws( diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt index 1bdc9fd020b..9443a4d98cc 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt @@ -1,14 +1,15 @@ package arrow.optics.instances -import arrow.core.test.UnitSpec import arrow.core.test.generators.functionAToB import arrow.optics.test.laws.PrismLaws import arrow.optics.typeclasses.Snoc +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws class SnocInstanceTest : UnitSpec() { init { From 06201c517733361e3e3505185eba406c1385746f Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 16:01:15 +0200 Subject: [PATCH 07/13] Remove thing added by IntelliJ --- arrow-libs/core/arrow-core/build.gradle.kts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index 143a8d0a8fb..356c28f5c40 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -69,8 +69,3 @@ kotlin { tasks.named("compileTestKotlinJvm") { kotlinOptions.freeCompilerArgs += "-Xcontext-receivers" } -dependencies { - testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0") - testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0") - testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0") -} From 5778c5ce1a90c7a3d37048365731a3d94399e36b Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 16:31:23 +0200 Subject: [PATCH 08/13] Move kotest to plugins block in Gradle --- arrow-libs/core/arrow-core/build.gradle.kts | 7 +------ arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts | 2 +- arrow-libs/fx/arrow-fx-stm/build.gradle.kts | 2 +- arrow-libs/optics/arrow-optics/build.gradle.kts | 4 +--- gradle/libs.versions.toml | 4 ++-- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index 356c28f5c40..5713919f5cd 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -4,9 +4,9 @@ plugins { id(libs.plugins.kotlin.multiplatform.get().pluginId) alias(libs.plugins.arrowGradleConfig.kotlin) alias(libs.plugins.arrowGradleConfig.publish) + alias(libs.plugins.kotest.multiplatform) } -apply(plugin = "io.kotest.multiplatform") apply(from = property("TEST_COVERAGE")) apply(from = property("ANIMALSNIFFER_MPP")) @@ -40,11 +40,6 @@ kotlin { } jvmTest { dependencies { - implementation(libs.kotest.frameworkEngine) - implementation(libs.kotest.assertionsCore) - implementation(libs.kotest.property) - implementation(libs.kotest.arrowAssertions) - implementation(libs.kotest.arrowProperty) implementation(projects.arrowFxCoroutines) runtimeOnly(libs.kotest.runnerJUnit5) } diff --git a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts index 392397dd985..6d38d63fc62 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts @@ -2,9 +2,9 @@ plugins { id(libs.plugins.kotlin.multiplatform.get().pluginId) alias(libs.plugins.arrowGradleConfig.kotlin) alias(libs.plugins.arrowGradleConfig.publish) + // alias(libs.plugins.kotest.multiplatform) } -apply(plugin = "io.kotest.multiplatform") apply(from = property("TEST_COVERAGE")) val enableCompatibilityMetadataVariant = diff --git a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts index d6af6a73474..c7990307720 100644 --- a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts @@ -2,9 +2,9 @@ plugins { id(libs.plugins.kotlin.multiplatform.get().pluginId) alias(libs.plugins.arrowGradleConfig.kotlin) alias(libs.plugins.arrowGradleConfig.publish) + // alias(libs.plugins.kotest.multiplatform) } -apply(plugin = "io.kotest.multiplatform") apply(from = property("TEST_COVERAGE")) apply(from = property("ANIMALSNIFFER_MPP")) diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 8aa150d0b8d..74116e23b10 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -2,11 +2,9 @@ plugins { id(libs.plugins.kotlin.multiplatform.get().pluginId) alias(libs.plugins.arrowGradleConfig.kotlin) alias(libs.plugins.arrowGradleConfig.publish) -// alias(libs.plugins.ksp) + alias(libs.plugins.kotest.multiplatform) } -apply(plugin = "io.kotest.multiplatform") - apply(from = property("TEST_COVERAGE")) apply(from = property("ANIMALSNIFFER_MPP")) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a5c5e2dddfe..66d46d8e60d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,8 +8,8 @@ dokka = "1.6.21" jUnit = "4.13.2" jUnitJupiter = "5.8.2" jUnitVintage = "5.8.2" -kotest = "5.3.1" -kotestGradle = "5.3.1" +kotest = "5.4.1" +kotestGradle = "5.4.1" kotestArrow = "1.2.5" kotlin = "1.6.21" kotlinBinaryCompatibilityValidator = "0.10.1" From 6114a72344285a142bf2846a22dbe65dde8575a3 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 19:24:38 +0200 Subject: [PATCH 09/13] Fix optics tests --- arrow-libs/core/arrow-core/build.gradle.kts | 11 ++++-- .../optics/arrow-optics/build.gradle.kts | 15 +++++-- .../commonTest/kotlin/arrow/optics/IsoTest.kt | 9 +---- .../kotlin/arrow/optics/LensTest.kt | 13 +++---- .../kotlin/arrow/optics/OptionalGetterTest.kt | 1 + .../kotlin/arrow/optics/OptionalTest.kt | 12 ++---- .../kotlin/arrow/optics/PrismTest.kt | 12 +++--- .../kotlin/arrow/optics/SetterTest.kt | 4 +- .../kotlin/arrow/optics/TraversalTest.kt | 15 ++++--- .../arrow/optics/instances/AtInstanceTest.kt | 6 +-- .../optics/instances/ConsInstanceTest.kt | 4 +- .../optics/instances/EitherInstanceTest.kt | 6 +-- .../instances/FilterIndexInstanceTest.kt | 14 +++---- .../optics/instances/IndexInstanceTest.kt | 12 +++--- .../optics/instances/SnocInstanceTest.kt | 11 ++---- .../kotlin/arrow/optics/std/EitherTest.kt | 13 ++++--- .../kotlin/arrow/optics/std/ListTest.kt | 19 +++++---- .../kotlin/arrow/optics/std/MapTest.kt | 10 +++-- .../arrow/optics/std/NonEmptyListTest.kt | 10 +++-- .../kotlin/arrow/optics/std/OptionTest.kt | 15 +++---- .../kotlin/arrow/optics/std/StringTest.kt | 7 ++-- .../kotlin/arrow/optics/std/TupleTest.kt | 39 +++---------------- .../kotlin/arrow/optics/std/ValidatedTest.kt | 13 ++++--- gradle/libs.versions.toml | 1 + 24 files changed, 127 insertions(+), 145 deletions(-) diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index 5713919f5cd..90d79d26f8c 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -31,16 +31,21 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(libs.kotest.frameworkEngine) + implementation(libs.kotest.frameworkApi) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) - implementation(libs.kotest.arrowAssertions) - implementation(libs.kotest.arrowProperty) + implementation("io.kotest.extensions:kotest-assertions-arrow:1.2.5") { + exclude(group = "io.arrow-kt", module = "arrow-core") + } + implementation("io.kotest.extensions:kotest-property-arrow:1.2.5") { + exclude(group = "io.arrow-kt", module = "arrow-core") + } } } jvmTest { dependencies { implementation(projects.arrowFxCoroutines) + runtimeOnly(libs.kotest.frameworkEngine) runtimeOnly(libs.kotest.runnerJUnit5) } } diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 74116e23b10..7319f1ec4ac 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -29,16 +29,25 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - implementation(libs.kotest.frameworkEngine) + implementation(libs.kotest.frameworkApi) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) - implementation(libs.kotest.arrowProperty) - implementation(libs.kotest.arrowOpticsProperty) + implementation("io.kotest.extensions:kotest-assertions-arrow:1.2.5") { + exclude(group = "io.arrow-kt", module = "arrow-core") + } + implementation("io.kotest.extensions:kotest-property-arrow:1.2.5") { + exclude(group = "io.arrow-kt", module = "arrow-core") + } + implementation("io.kotest.extensions:kotest-property-arrow-optics:1.2.5") { + exclude(group = "io.arrow-kt", module = "arrow-core") + exclude(group = "io.arrow-kt", module = "arrow-optics") + } } } jvmTest { dependencies { implementation(libs.kotlin.stdlibJDK8) + implementation(libs.kotest.frameworkEngine) implementation(libs.junitJupiterEngine) implementation(libs.kotlin.reflect) } diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt index 781a2221af4..3cfbba42812 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/IsoTest.kt @@ -1,13 +1,6 @@ package arrow.optics import arrow.core.Either -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.IsoLaws -import arrow.optics.test.laws.LensLaws -import arrow.optics.test.laws.OptionalLaws -import arrow.optics.test.laws.PrismLaws -import arrow.optics.test.laws.SetterLaws -import arrow.optics.test.laws.TraversalLaws import arrow.typeclasses.Monoid import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe @@ -15,7 +8,9 @@ import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.* import io.kotest.property.checkAll diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/LensTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/LensTest.kt index 749b89663ac..f40ebc71408 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/LensTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/LensTest.kt @@ -2,20 +2,19 @@ package arrow.optics import arrow.core.Either.Left import arrow.core.Either.Right -import arrow.core.test.UnitSpec -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.LensLaws -import arrow.optics.test.laws.OptionalLaws -import arrow.optics.test.laws.SetterLaws -import arrow.optics.test.laws.TraversalLaws import arrow.typeclasses.Monoid +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.* +import io.kotest.property.checkAll -class LensTest : UnitSpec() { +class LensTest : StringSpec() { init { testLaws( diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt index 9e540c74289..5d7897ca7bc 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalGetterTest.kt @@ -5,6 +5,7 @@ import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.list import io.kotest.property.checkAll class OptionalGetterTest : StringSpec() { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt index f452c14b8c5..6c5d513c2f2 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/OptionalTest.kt @@ -4,20 +4,16 @@ import arrow.core.Either.Left import arrow.core.Either.Right import arrow.core.getOrElse import arrow.core.identity -import arrow.core.test.generators.functionAToB import arrow.core.toOption -import arrow.optics.test.laws.OptionalLaws import arrow.typeclasses.Monoid import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe import io.kotest.property.Arb -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.orNull -import io.kotest.property.arbitrary.pair -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.OptionalLaws import io.kotest.property.checkAll class OptionalTest : StringSpec() { @@ -165,7 +161,7 @@ class OptionalTest : StringSpec() { } "Set a value over a non empty list target then the first item of the result should be the value" { - checkAll(Arb.list(Arb.int(), 1..maxDepth), Arb.int()) { list, value -> + checkAll(Arb.list(Arb.int(), 1..1000), Arb.int()) { list, value -> Optional.listHead().set(list, value)[0] shouldBe value } } diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt index 9d6c4621f7c..cb1e7469112 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/PrismTest.kt @@ -1,11 +1,5 @@ package arrow.optics -import arrow.core.test.generators.either -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.OptionalLaws -import arrow.optics.test.laws.PrismLaws -import arrow.optics.test.laws.SetterLaws -import arrow.optics.test.laws.TraversalLaws import arrow.typeclasses.Monoid import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe @@ -14,7 +8,13 @@ import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.OptionalLaws +import io.kotest.property.arrow.optics.PrismLaws +import io.kotest.property.arrow.optics.SetterLaws +import io.kotest.property.arrow.optics.TraversalLaws import io.kotest.property.checkAll class PrismTest : StringSpec() { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt index 2b447eabab6..32bc0e66fcd 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/SetterTest.kt @@ -3,14 +3,14 @@ package arrow.optics import arrow.core.getOrElse import arrow.core.left import arrow.core.right -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.SetterLaws import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.core.spec.style.StringSpec import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.SetterLaws import io.kotest.property.checkAll class SetterTest : StringSpec() { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt index 68ce34b0953..f28511fed69 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/TraversalTest.kt @@ -1,15 +1,14 @@ package arrow.optics -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.option -import arrow.optics.test.laws.SetterLaws -import arrow.optics.test.laws.TraversalLaws import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb -import io.kotest.property.arbitrary.char -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.nonEmptyList +import io.kotest.property.arrow.core.option import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.SetterLaws +import io.kotest.property.arrow.optics.TraversalLaws class TraversalTest : StringSpec() { @@ -46,7 +45,7 @@ class TraversalTest : StringSpec() { "Traversal sequence - ", TraversalLaws.laws( traversal = Traversal.sequence(), - aGen = Arb.sequence(Arb.string()), + aGen = Arb.list(Arb.string()).map { it.asSequence() }, bGen = Arb.string(), funcGen = Arb.functionAToB(Arb.string()), eq = { a, b -> a.toList() == b.toList() } diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt index 2f3152d552d..b2ac617db86 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/AtInstanceTest.kt @@ -1,8 +1,5 @@ package arrow.optics.instances -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.option -import arrow.optics.test.laws.LensLaws import arrow.optics.typeclasses.At import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb @@ -11,7 +8,10 @@ import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.set import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.option import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.LensLaws class AtInstanceTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt index 01c36f04565..0ef9e71e183 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/ConsInstanceTest.kt @@ -1,7 +1,5 @@ package arrow.optics.instances -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.PrismLaws import arrow.optics.typeclasses.Cons import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb @@ -10,7 +8,9 @@ import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.PrismLaws class ConsInstanceTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt index 449a61c063f..889664b38c9 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/EitherInstanceTest.kt @@ -1,14 +1,14 @@ package arrow.optics.instances -import arrow.core.test.generators.either -import arrow.core.test.generators.functionAToB import arrow.optics.Traversal -import arrow.optics.test.laws.TraversalLaws import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.TraversalLaws class EitherInstanceTest : StringSpec() { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt index b303a1bbfc1..6bdac93e4d9 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt @@ -1,15 +1,13 @@ package arrow.optics.instances -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.intSmall -import arrow.optics.test.laws.TraversalLaws import arrow.optics.typeclasses.FilterIndex import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb -import io.kotest.property.arbitrary.char -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.nonEmptyList import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.TraversalLaws class FilterIndexInstanceTest : StringSpec() { @@ -28,7 +26,7 @@ class FilterIndexInstanceTest : StringSpec() { "FilterIndex sequence - ", TraversalLaws.laws( traversal = FilterIndex.sequence().filter { true }, - aGen = Arb.sequence(Arb.string()), + aGen = Arb.list(Arb.string()).map { it.asSequence() }, bGen = Arb.string(), funcGen = Arb.functionAToB(Arb.string()), ) { a, b -> a.toList() == b.toList() } @@ -48,7 +46,7 @@ class FilterIndexInstanceTest : StringSpec() { "FilterIndex map - ", TraversalLaws.laws( traversal = FilterIndex.map().filter { true }, - aGen = Arb.map(Arb.char(), Arb.intSmall()), + aGen = Arb.map(Arb.char(), Arb.int()), bGen = Arb.int(), funcGen = Arb.functionAToB(Arb.int()), ) diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt index fcc1f75145e..a1869c48c24 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/IndexInstanceTest.kt @@ -1,15 +1,13 @@ package arrow.optics.instances -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.OptionalLaws import arrow.optics.typeclasses.Index import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb -import io.kotest.property.arbitrary.char -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.map -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.nonEmptyList import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.OptionalLaws class IndexInstanceTest : StringSpec() { @@ -28,7 +26,7 @@ class IndexInstanceTest : StringSpec() { "Index sequence - ", OptionalLaws.laws( optionalGen = Arb.int().map { Index.sequence().index(it) }, - aGen = Arb.sequence(Arb.string()), + aGen = Arb.list(Arb.string()).map { it.asSequence() }, bGen = Arb.string(), funcGen = Arb.functionAToB(Arb.string()), eqa = { a, b -> a.toList() == b.toList() } diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt index 9443a4d98cc..16b7a705ab4 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/SnocInstanceTest.kt @@ -1,17 +1,14 @@ package arrow.optics.instances -import arrow.core.test.generators.functionAToB -import arrow.optics.test.laws.PrismLaws import arrow.optics.typeclasses.Snoc import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb -import io.kotest.property.arbitrary.char -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.pair -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* +import io.kotest.property.arrow.core.functionAToB import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.PrismLaws -class SnocInstanceTest : UnitSpec() { +class SnocInstanceTest : StringSpec() { init { testLaws( "Snoc list - ", diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/EitherTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/EitherTest.kt index e434dd4f2f9..807c326d9dd 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/EitherTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/EitherTest.kt @@ -1,16 +1,17 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.either -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.validated import arrow.optics.Iso -import arrow.optics.test.laws.IsoLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.validated +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.IsoLaws -class EitherTest : UnitSpec() { +class EitherTest : StringSpec() { init { testLaws( diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ListTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ListTest.kt index e5e3ff35748..e93a2f3af28 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ListTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ListTest.kt @@ -1,18 +1,21 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.option import arrow.optics.Iso import arrow.optics.Optional -import arrow.optics.test.laws.IsoLaws -import arrow.optics.test.laws.OptionalLaws -import arrow.optics.test.laws.SetterLaws -import arrow.optics.test.laws.TraversalLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.list +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.nonEmptyList +import io.kotest.property.arrow.core.option +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.IsoLaws +import io.kotest.property.arrow.optics.OptionalLaws +import io.kotest.property.arrow.optics.SetterLaws +import io.kotest.property.arrow.optics.TraversalLaws -class ListTest : UnitSpec() { +class ListTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/MapTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/MapTest.kt index 3f3c373a089..12ec00cf057 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/MapTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/MapTest.kt @@ -1,15 +1,17 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.functionAToB import arrow.optics.Iso -import arrow.optics.test.laws.IsoLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.constant +import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.set import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.IsoLaws -class MapTest : UnitSpec() { +class MapTest : StringSpec() { init { testLaws( diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/NonEmptyListTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/NonEmptyListTest.kt index bce1ae4ef1a..e7b277a7dcd 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/NonEmptyListTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/NonEmptyListTest.kt @@ -1,14 +1,16 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.functionAToB import arrow.optics.Lens -import arrow.optics.test.laws.LensLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.nonEmptyList +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.LensLaws -class NonEmptyListTest : UnitSpec() { +class NonEmptyListTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/OptionTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/OptionTest.kt index 218843b27ac..279d008f6a5 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/OptionTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/OptionTest.kt @@ -1,19 +1,20 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.either -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.option import arrow.optics.Iso import arrow.optics.Prism -import arrow.optics.test.laws.IsoLaws -import arrow.optics.test.laws.PrismLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.constant import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.orNull +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.option +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.IsoLaws +import io.kotest.property.arrow.optics.PrismLaws -class OptionTest : UnitSpec() { +class OptionTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/StringTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/StringTest.kt index 2bbc8658213..3460c394b0e 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/StringTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/StringTest.kt @@ -1,15 +1,16 @@ package arrow.optics.std -import arrow.core.test.UnitSpec import arrow.optics.Iso -import arrow.optics.test.laws.IsoLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char import io.kotest.property.arbitrary.list import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.IsoLaws -class StringTest : UnitSpec() { +class StringTest : StringSpec() { init { diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/TupleTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/TupleTest.kt index 935401542b9..723e604bbe0 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/TupleTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/TupleTest.kt @@ -1,26 +1,20 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.tuple10 -import arrow.core.test.generators.tuple4 -import arrow.core.test.generators.tuple5 -import arrow.core.test.generators.tuple6 -import arrow.core.test.generators.tuple7 -import arrow.core.test.generators.tuple8 -import arrow.core.test.generators.tuple9 import arrow.optics.Lens import arrow.optics.Traversal -import arrow.optics.test.laws.LensLaws -import arrow.optics.test.laws.TraversalLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.pair import io.kotest.property.arbitrary.string import io.kotest.property.arbitrary.triple +import io.kotest.property.arrow.core.* +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.LensLaws +import io.kotest.property.arrow.optics.TraversalLaws -class TupleTest : UnitSpec() { +class TupleTest : StringSpec() { init { @@ -180,26 +174,5 @@ class TupleTest : UnitSpec() { funcGen = Arb.functionAToB(Arb.int()), ) ) - - testLaws( - "Traversal tuple10 - ", - TraversalLaws.laws( - traversal = Traversal.tuple10(), - aGen = Arb.tuple10( - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean(), - Arb.boolean() - ), - bGen = Arb.boolean(), - funcGen = Arb.functionAToB(Arb.boolean()), - ) - ) } } diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ValidatedTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ValidatedTest.kt index fe5b0d1d89f..19e063db316 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ValidatedTest.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/ValidatedTest.kt @@ -1,16 +1,17 @@ package arrow.optics.std -import arrow.core.test.UnitSpec -import arrow.core.test.generators.either -import arrow.core.test.generators.functionAToB -import arrow.core.test.generators.validated import arrow.optics.Iso -import arrow.optics.test.laws.IsoLaws +import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.arrow.core.either +import io.kotest.property.arrow.core.functionAToB +import io.kotest.property.arrow.core.validated +import io.kotest.property.arrow.laws.testLaws +import io.kotest.property.arrow.optics.IsoLaws -class ValidatedTest : UnitSpec() { +class ValidatedTest : StringSpec() { init { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 66d46d8e60d..985076289c2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,6 +30,7 @@ jUnitVintageEngine = { module = "org.junit.vintage:junit-vintage-engine", versio junitJupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jUnitJupiter" } junitJupiterEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "jUnitJupiter" } kotest-assertionsCore = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } +kotest-frameworkApi = { module = "io.kotest:kotest-framework-api", version.ref = "kotest" } kotest-frameworkEngine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" } kotest-runnerJUnit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } From 82e36cb1a2bd08e7f58fa9626ced1a3f2a0de4aa Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Wed, 3 Aug 2022 19:33:02 +0200 Subject: [PATCH 10/13] Do not use hardcoded version for kotest-arrow libs --- arrow-libs/core/arrow-core/build.gradle.kts | 4 ++-- arrow-libs/optics/arrow-optics/build.gradle.kts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index 90d79d26f8c..6a117e58f71 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -34,10 +34,10 @@ kotlin { implementation(libs.kotest.frameworkApi) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) - implementation("io.kotest.extensions:kotest-assertions-arrow:1.2.5") { + implementation(libs.kotest.arrowAssertions.get().toString()) { exclude(group = "io.arrow-kt", module = "arrow-core") } - implementation("io.kotest.extensions:kotest-property-arrow:1.2.5") { + implementation(libs.kotest.arrowProperty.get().toString()) { exclude(group = "io.arrow-kt", module = "arrow-core") } } diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 7319f1ec4ac..a4aa7dbb0b2 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -32,13 +32,13 @@ kotlin { implementation(libs.kotest.frameworkApi) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) - implementation("io.kotest.extensions:kotest-assertions-arrow:1.2.5") { + implementation(libs.kotest.arrowAssertions.get().toString()) { exclude(group = "io.arrow-kt", module = "arrow-core") } - implementation("io.kotest.extensions:kotest-property-arrow:1.2.5") { + implementation(libs.kotest.arrowProperty.get().toString()) { exclude(group = "io.arrow-kt", module = "arrow-core") } - implementation("io.kotest.extensions:kotest-property-arrow-optics:1.2.5") { + implementation(libs.kotest.arrowOpticsProperty.get().toString()) { exclude(group = "io.arrow-kt", module = "arrow-core") exclude(group = "io.arrow-kt", module = "arrow-optics") } From cc1733bb78f8a125ae4287dbe8ebe43efb35f467 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Mon, 5 Dec 2022 15:38:57 +0100 Subject: [PATCH 11/13] Add a few more tests --- arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts | 10 +++++++++- .../kotlin/arrow/fx/coroutines/AtomicTest.kt | 5 +++-- .../kotlin/arrow/fx/coroutines/BracketCaseTest.kt | 5 +++-- .../kotlin/arrow/fx/coroutines/CircuitBreakerTest.kt | 6 +++--- .../kotlin/arrow/fx/coroutines/parMapN/ParMap2Test.kt | 6 +++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts index 6d38d63fc62..1a1fa71f13d 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts @@ -30,7 +30,15 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { - // implementation(libs.kotest.arrowFxAssertions) + implementation(libs.kotest.frameworkApi) + implementation(libs.kotest.assertionsCore) + implementation(libs.kotest.property) + implementation(libs.kotest.arrowAssertions.get().toString()) { + exclude(group = "io.arrow-kt", module = "arrow-core") + } + implementation(libs.kotest.arrowProperty.get().toString()) { + exclude(group = "io.arrow-kt", module = "arrow-core") + } } } jvmTest { diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/AtomicTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/AtomicTest.kt index 19c36f48dd1..74ca01f9037 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/AtomicTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/AtomicTest.kt @@ -1,14 +1,15 @@ package arrow.fx.coroutines +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.property.Arb import io.kotest.property.arbitrary.int +import io.kotest.property.checkAll import kotlin.coroutines.Continuation import kotlin.coroutines.EmptyCoroutineContext import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn -class AtomicTest : ArrowFxSpec( - spec = { +class AtomicTest : StringSpec({ "set get - successful" { checkAll(Arb.int(), Arb.int()) { x, y -> diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/BracketCaseTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/BracketCaseTest.kt index 169069090ea..f5fe81a24ed 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/BracketCaseTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/BracketCaseTest.kt @@ -1,19 +1,20 @@ package arrow.fx.coroutines import arrow.core.Either +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeInstanceOf import io.kotest.property.Arb import io.kotest.property.arbitrary.int +import io.kotest.property.checkAll import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.async import kotlinx.coroutines.channels.Channel import kotlin.time.ExperimentalTime @ExperimentalTime -class BracketCaseTest : ArrowFxSpec( - spec = { +class BracketCaseTest : StringSpec({ "Immediate acquire bracketCase finishes successfully" { checkAll(Arb.int(), Arb.int()) { a, b -> var once = true diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CircuitBreakerTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CircuitBreakerTest.kt index 265b318e453..7437621061d 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CircuitBreakerTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CircuitBreakerTest.kt @@ -1,10 +1,11 @@ package arrow.fx.coroutines +import io.kotest.core.spec.style.StringSpec import arrow.core.Either -import arrow.core.test.stackSafeIteration import io.kotest.assertions.fail import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.shouldBe +import io.kotest.property.checkAll import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -16,8 +17,7 @@ import kotlin.time.DurationUnit.NANOSECONDS import kotlin.time.ExperimentalTime @ExperimentalTime -class CircuitBreakerTest : ArrowFxSpec( - spec = { +class CircuitBreakerTest : StringSpec({ val dummy = RuntimeException("dummy") val maxFailures = 5 val exponentialBackoffFactor = 2.0 diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap2Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap2Test.kt index 9f8ef59c261..8c6613e8170 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap2Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap2Test.kt @@ -1,7 +1,6 @@ package arrow.fx.coroutines.parMapN import arrow.core.Either -import arrow.fx.coroutines.ArrowFxSpec import arrow.fx.coroutines.Atomic import arrow.fx.coroutines.ExitCase import arrow.fx.coroutines.awaitExitCase @@ -10,6 +9,7 @@ import arrow.fx.coroutines.leftException import arrow.fx.coroutines.never import arrow.fx.coroutines.parZip import arrow.fx.coroutines.throwable +import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeTypeOf @@ -17,6 +17,7 @@ import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean import io.kotest.property.arbitrary.int import io.kotest.property.arbitrary.string +import io.kotest.property.checkAll import kotlin.time.ExperimentalTime import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CompletableDeferred @@ -26,8 +27,7 @@ import kotlinx.coroutines.awaitCancellation import kotlinx.coroutines.channels.Channel @OptIn(ExperimentalTime::class) -class ParMap2Test : ArrowFxSpec( - spec = { +class ParMap2Test : StringSpec({ "parMapN 2 runs in parallel" { checkAll(Arb.int(), Arb.int()) { a, b -> From abd2467201171eff214a5146ab1a01422b014dc7 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Thu, 29 Dec 2022 15:36:51 +0100 Subject: [PATCH 12/13] Minimize changes w.r.t. arrow-2 --- .../kotlin/arrow/core/OptionTest.kt | 2 +- .../kotlin/arrow/core/generators.kt | 54 ------------------- .../java/arrow/core/test/JvmGenerators.kt | 4 +- .../fx/coroutines/parMapN/ParMap4Test.kt | 7 ++- .../fx/coroutines/parMapN/ParMap5Test.kt | 13 ++++- .../fx/coroutines/parMapN/ParMap6Test.kt | 6 ++- .../fx/coroutines/parMapN/ParMap7Test.kt | 6 ++- .../fx/coroutines/parMapN/ParMap8Test.kt | 6 ++- .../arrow/fx/coroutines/ParMap4JvmTest.kt | 3 +- .../arrow/fx/coroutines/ParMap5JvmTest.kt | 3 +- .../arrow/fx/coroutines/ParMap6JvmTest.kt | 21 ++++---- .../arrow/fx/coroutines/ParMap7JvmTest.kt | 21 ++++---- .../arrow/fx/coroutines/ParMap8JvmTest.kt | 23 ++++---- .../arrow/fx/coroutines/ResourceTestJvm.kt | 2 +- .../arrow-optics-reflect/build.gradle.kts | 8 +-- 15 files changed, 78 insertions(+), 101 deletions(-) delete mode 100644 arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt index b16b17611de..94e3b61a068 100755 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt @@ -21,7 +21,7 @@ class OptionTest : StringSpec({ val none: Option = None testLaws( - MonoidLaws.laws(Monoid.option(Monoid.int()), Arb.option(Arb.int())) + MonoidLaws.laws(Monoid.option(Monoid.int()), Arb.option(Arb.int())), ) "ensure null in option computation" { diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt deleted file mode 100644 index 638f3f5e575..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/generators.kt +++ /dev/null @@ -1,54 +0,0 @@ -package arrow.core - -import io.kotest.property.Arb -import io.kotest.property.arbitrary.* - -public fun Arb.Companion.intSmall(factor: Int = 10000): Arb = - Arb.int((Int.MIN_VALUE / factor)..(Int.MAX_VALUE / factor)) - -public fun Arb.Companion.longSmall(): Arb = - Arb.long((Long.MIN_VALUE / 100000L)..(Long.MAX_VALUE / 100000L)) - -public fun Arb.Companion.throwable(): Arb = - Arb.of(listOf(RuntimeException(), NoSuchElementException(), IllegalArgumentException())) - -public fun Arb.Companion.sequence(inner: Arb): Arb> = - Arb.list(inner).map { it.asSequence() } - -public inline fun Arb.Companion.array(inner: Arb, range: IntRange): Arb> = - Arb.list(inner, range).map { it.toTypedArray() } - -public fun Arb.Companion.ior(arbA: Arb, arbB: Arb): Arb> = - arbA.alignWith(arbB) { it } - -private fun Arb.alignWith(arbB: Arb, transform: (Ior) -> R): Arb = - Arb.bind(this, arbB) { a, b -> transform(Ior.Both(a, b)) } - -public fun Arb.Companion.suspendFunThatReturnsEitherAnyOrAnyOrThrows(): Arb Either> = - choice( - suspendFunThatReturnsAnyRight(), - suspendFunThatReturnsAnyLeft(), - suspendFunThatThrows() - ) - -public fun Arb.Companion.suspendFunThatReturnsAnyRight(): Arb Either> = - any().map { suspend { it.right() } } - -public fun Arb.Companion.suspendFunThatReturnsAnyLeft(): Arb Either> = - any().map { suspend { it.left() } } - -public fun Arb.Companion.suspendFunThatThrows(): Arb Either> = - throwable().map { suspend { throw it } } as Arb Either> - -public fun Arb.Companion.unit(): Arb = - Arb.constant(Unit) - -public fun Arb.Companion.any(): Arb = - choice( - Arb.string() as Arb, - Arb.int() as Arb, - Arb.long() as Arb, - Arb.boolean() as Arb, - Arb.throwable() as Arb, - Arb.unit() as Arb - ) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/test/JvmGenerators.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/test/JvmGenerators.kt index 670df8afb29..461949d6815 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/test/JvmGenerators.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/test/JvmGenerators.kt @@ -5,8 +5,8 @@ import io.kotest.property.Arb import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.of -fun Arb.Companion.suspendFunThatThrowsFatalThrowable(): Arb Either> = +public fun Arb.Companion.suspendFunThatThrowsFatalThrowable(): Arb Either> = fatalThrowable().map { suspend { throw it } } as Arb Either> -fun Arb.Companion.fatalThrowable(): Arb = +public fun Arb.Companion.fatalThrowable(): Arb = Arb.of(listOf(ThreadDeath(), StackOverflowError(), OutOfMemoryError(), InterruptedException())) diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap4Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap4Test.kt index c6d85d2516a..8554783df95 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap4Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap4Test.kt @@ -3,6 +3,7 @@ package arrow.fx.coroutines.parMapN import arrow.atomic.Atomic import arrow.atomic.update import arrow.core.Either +import arrow.core.Tuple4 import arrow.fx.coroutines.ExitCase import arrow.fx.coroutines.awaitExitCase import arrow.fx.coroutines.leftException @@ -50,7 +51,9 @@ class ParMap4Test : StringSpec({ r.value = "$d" modifyGate1.complete(Unit) } - ) { _a, _b, _c, _d -> } + ) { _a, _b, _c, _d -> + Tuple4(_a, _b, _c, _d) + } r.value shouldBe "$d$c$b$a" } @@ -68,7 +71,7 @@ class ParMap4Test : StringSpec({ val loserC: suspend CoroutineScope.() -> Int = { awaitExitCase(s, pc) } val loserD: suspend CoroutineScope.() -> Int = { awaitExitCase(s, pd) } - val f = async { parZip(loserA, loserB, loserC, loserD) { _a, _b, _c, _d -> } } + val f = async { parZip(loserA, loserB, loserC, loserD) { _a, _b, _c, _d -> Tuple4(_a, _b, _c, _d) } } repeat(4) { s.send(Unit) } // Suspend until all racers started f.cancel() diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap5Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap5Test.kt index 29eef64413c..09fbdc6bef8 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap5Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap5Test.kt @@ -3,6 +3,7 @@ package arrow.fx.coroutines.parMapN import arrow.atomic.Atomic import arrow.atomic.update import arrow.core.Either +import arrow.core.Tuple5 import arrow.fx.coroutines.ExitCase import arrow.fx.coroutines.awaitExitCase import arrow.fx.coroutines.leftException @@ -56,7 +57,9 @@ class ParMap5Test : StringSpec({ r.value = "$e" modifyGate1.complete(Unit) } - ) { _a, _b, _c, _d, _e -> } + ) { _a, _b, _c, _d, _e -> + Tuple5(_a, _b, _c, _d, _e) + } r.value shouldBe "$e$d$c$b$a" } @@ -78,7 +81,13 @@ class ParMap5Test : StringSpec({ val f = async { parZip(loserA, loserB, loserC, loserD, loserE) { _a, _b, _c, _d, _e -> - + Tuple5( + _a, + _b, + _c, + _d, + _e + ) } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap6Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap6Test.kt index 0ef60cdc45c..0a3e4305214 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap6Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap6Test.kt @@ -3,6 +3,7 @@ package arrow.fx.coroutines.parMapN import arrow.atomic.Atomic import arrow.atomic.update import arrow.core.Either +import arrow.core.Tuple6 import arrow.fx.coroutines.ExitCase import arrow.fx.coroutines.awaitExitCase import arrow.fx.coroutines.leftException @@ -62,7 +63,9 @@ class ParMap6Test : StringSpec({ r.value = "$f" modifyGate1.complete(Unit) } - ) { _a, _b, _c, _d, _e, _f -> } + ) { _a, _b, _c, _d, _e, _f -> + Tuple6(_a, _b, _c, _d, _e, _f) + } r.value shouldBe "$f$e$d$c$b$a" } @@ -86,6 +89,7 @@ class ParMap6Test : StringSpec({ val fork = async { parZip(loserA, loserB, loserC, loserD, loserE, loserF) { _a, _b, _c, _d, _e, _f -> + Tuple6(_a, _b, _c, _d, _e, _f) } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap7Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap7Test.kt index 087b03e151a..83c211da923 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap7Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap7Test.kt @@ -3,6 +3,7 @@ package arrow.fx.coroutines.parMapN import arrow.atomic.Atomic import arrow.atomic.update import arrow.core.Either +import arrow.core.Tuple7 import arrow.fx.coroutines.ExitCase import arrow.fx.coroutines.awaitExitCase import arrow.fx.coroutines.leftException @@ -68,7 +69,9 @@ class ParMap7Test : StringSpec({ r.value = "$g" modifyGate1.complete(Unit) } - ) { _a, _b, _c, _d, _e, _f, _g -> } + ) { _a, _b, _c, _d, _e, _f, _g -> + Tuple7(_a, _b, _c, _d, _e, _f, _g) + } r.value shouldBe "$g$f$e$d$c$b$a" } @@ -94,6 +97,7 @@ class ParMap7Test : StringSpec({ val fork = async { parZip(loserA, loserB, loserC, loserD, loserE, loserF, loserG) { a, b, c, d, e, f, g -> + Tuple7(a, b, c, d, e, f, g) } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap8Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap8Test.kt index 393921beba0..759e4a1c403 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap8Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/parMapN/ParMap8Test.kt @@ -3,6 +3,7 @@ package arrow.fx.coroutines.parMapN import arrow.atomic.Atomic import arrow.atomic.update import arrow.core.Either +import arrow.core.Tuple8 import arrow.fx.coroutines.ExitCase import arrow.fx.coroutines.awaitExitCase import arrow.fx.coroutines.leftException @@ -74,7 +75,9 @@ class ParMap8Test : StringSpec({ r.value = "$h" modifyGate1.complete(Unit) } - ) { _a, _b, _c, _d, _e, _f, _g, _h -> } + ) { _a, _b, _c, _d, _e, _f, _g, _h -> + Tuple8(_a, _b, _c, _d, _e, _f, _g, _h) + } r.value shouldBe "$h$g$f$e$d$c$b$a" } @@ -102,6 +105,7 @@ class ParMap8Test : StringSpec({ val fork = async { parZip(loserA, loserB, loserC, loserD, loserE, loserF, loserG, loserH) { a, b, c, d, e, f, g, h -> + Tuple8(a, b, c, d, e, f, g, h) } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap4JvmTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap4JvmTest.kt index 2842870f5c4..f2f367160cc 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap4JvmTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap4JvmTest.kt @@ -1,6 +1,7 @@ package arrow.fx.coroutines import arrow.core.Either +import arrow.core.Tuple4 import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should @@ -26,7 +27,7 @@ class ParMap4JvmTest : StringSpec({ { Thread.currentThread().name }, { Thread.currentThread().name }, { Thread.currentThread().name } - ) { a, b, c, d -> listOf(a, b, c, d) } + ) { a, b, c, d -> Tuple4(a, b, c, d) } s1 shouldStartWith mapCtxName s2 shouldStartWith mapCtxName diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap5JvmTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap5JvmTest.kt index 5c62f44dd10..dba92b9cb33 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap5JvmTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap5JvmTest.kt @@ -1,6 +1,7 @@ package arrow.fx.coroutines import arrow.core.Either +import arrow.core.Tuple5 import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should @@ -26,7 +27,7 @@ class ParMap5JvmTest : StringSpec({ val (s1, s2, s3, s4, s5) = parZip( _mapCtx, threadName, threadName, threadName, threadName, threadName - ) { a, b, c, d, e -> listOf(a, b, c, d, e) } + ) { a, b, c, d, e -> Tuple5(a, b, c, d, e) } s1 shouldStartWith mapCtxName s2 shouldStartWith mapCtxName diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap6JvmTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap6JvmTest.kt index ca9ebcb1b0e..86f419735f5 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap6JvmTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap6JvmTest.kt @@ -1,6 +1,7 @@ package arrow.fx.coroutines import arrow.core.Either +import arrow.core.Tuple6 import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should @@ -22,19 +23,19 @@ class ParMap6JvmTest : StringSpec({ parallelCtx(6, mapCtxName) { _single, _mapCtx -> withContext(_single) { threadName() shouldStartWith "single" - - val result = parZip( + + val (s1, s2, s3, s4, s5, s6) = parZip( _mapCtx, threadName, threadName, threadName, threadName, threadName, threadName ) { a, b, c, d, e, f -> - listOf(a, b, c, d, e, f) + Tuple6(a, b, c, d, e, f) } - - result[0] shouldStartWith mapCtxName - result[1] shouldStartWith mapCtxName - result[2] shouldStartWith mapCtxName - result[3] shouldStartWith mapCtxName - result[4] shouldStartWith mapCtxName - result[5] shouldStartWith mapCtxName + + s1 shouldStartWith mapCtxName + s2 shouldStartWith mapCtxName + s3 shouldStartWith mapCtxName + s4 shouldStartWith mapCtxName + s5 shouldStartWith mapCtxName + s6 shouldStartWith mapCtxName threadName() shouldStartWith "single" } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap7JvmTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap7JvmTest.kt index 93bfe6bf23a..428deb6ea9e 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap7JvmTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap7JvmTest.kt @@ -1,6 +1,7 @@ package arrow.fx.coroutines import arrow.core.Either +import arrow.core.Tuple7 import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should @@ -22,20 +23,20 @@ class ParMap7JvmTest : StringSpec({ parallelCtx(7, mapCtxName) { _single, _mapCtx -> withContext(_single) { threadName() shouldStartWith "single" - - val result = parZip( + + val (s1, s2, s3, s4, s5, s6, s7) = parZip( _mapCtx, threadName, threadName, threadName, threadName, threadName, threadName, threadName ) { a, b, c, d, e, f, g -> - listOf(a, b, c, d, e, f, g) + Tuple7(a, b, c, d, e, f, g) } - result[0] shouldStartWith mapCtxName - result[1] shouldStartWith mapCtxName - result[2] shouldStartWith mapCtxName - result[3] shouldStartWith mapCtxName - result[4] shouldStartWith mapCtxName - result[5] shouldStartWith mapCtxName - result[6] shouldStartWith mapCtxName + s1 shouldStartWith mapCtxName + s2 shouldStartWith mapCtxName + s3 shouldStartWith mapCtxName + s4 shouldStartWith mapCtxName + s5 shouldStartWith mapCtxName + s6 shouldStartWith mapCtxName + s7 shouldStartWith mapCtxName threadName() shouldStartWith "single" } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap8JvmTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap8JvmTest.kt index 32608794bfa..69eadc83e11 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap8JvmTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ParMap8JvmTest.kt @@ -1,6 +1,7 @@ package arrow.fx.coroutines import arrow.core.Either +import arrow.core.Tuple8 import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should @@ -22,21 +23,21 @@ class ParMap8JvmTest : StringSpec({ parallelCtx(7, mapCtxName) { _single, _mapCtx -> withContext(_single) { threadName() shouldStartWith "single" - - val result = parZip( + + val (s1, s2, s3, s4, s5, s6, s7, s8) = parZip( _mapCtx, threadName, threadName, threadName, threadName, threadName, threadName, threadName, threadName ) { a, b, c, d, e, f, g, h -> - listOf(a, b, c, d, e, f, g, h) + Tuple8(a, b, c, d, e, f, g, h) } - result[0] shouldStartWith mapCtxName - result[1] shouldStartWith mapCtxName - result[2] shouldStartWith mapCtxName - result[3] shouldStartWith mapCtxName - result[4] shouldStartWith mapCtxName - result[5] shouldStartWith mapCtxName - result[6] shouldStartWith mapCtxName - result[7] shouldStartWith mapCtxName + s1 shouldStartWith mapCtxName + s2 shouldStartWith mapCtxName + s3 shouldStartWith mapCtxName + s4 shouldStartWith mapCtxName + s5 shouldStartWith mapCtxName + s6 shouldStartWith mapCtxName + s7 shouldStartWith mapCtxName + s8 shouldStartWith mapCtxName threadName() shouldStartWith "single" } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ResourceTestJvm.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ResourceTestJvm.kt index efa50bccbfa..4fa664d4ea5 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ResourceTestJvm.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/ResourceTestJvm.kt @@ -3,11 +3,11 @@ package arrow.fx.coroutines import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe -import io.kotest.property.checkAll import java.util.concurrent.atomic.AtomicBoolean import java.lang.AutoCloseable import java.io.Closeable import io.kotest.property.Arb +import io.kotest.property.checkAll class ResourceTestJvm : StringSpec({ diff --git a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts index ea2ed7d5c60..2410a349744 100644 --- a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts @@ -24,11 +24,13 @@ dependencies { implementation(libs.kotlin.stdlibJDK8) if(!enableCompatibilityMetadataVariant) { - testImplementation(libs.kotest.frameworkEngine) - testImplementation(libs.kotest.assertionsCore) - testImplementation(libs.kotest.property) testImplementation(libs.kotlin.stdlibJDK8) testImplementation(libs.junitJupiterEngine) testImplementation(libs.kotlin.reflect) + + testImplementation(libs.kotest.frameworkEngine) + testImplementation(libs.kotest.assertionsCore) + testImplementation(libs.kotest.property) + testRuntimeOnly(libs.kotest.runnerJUnit5) } } From 88e664e1ef1115ba94dbc07958214e3c67d6daf0 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Sun, 8 Jan 2023 13:33:55 +0100 Subject: [PATCH 13/13] Apply suggestions --- .../kotlin/arrow/core/EitherZipTest.kt | 46 +++++-------------- gradle.properties | 1 - 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherZipTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherZipTest.kt index f91f3c365aa..8d2b7d31d40 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherZipTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherZipTest.kt @@ -18,25 +18,6 @@ import io.kotest.property.arbitrary.short import io.kotest.property.arbitrary.string import io.kotest.property.checkAll -data class Tuple10( - val first: A, - val second: B, - val third: C, - val fourth: D, - val fifth: E, - val sixth: F, - val seventh: G, - val eighth: H, - val ninth: I, - val tenth: J -) { - - override fun toString(): String = - "($first, $second, $third, $fourth, $fifth, $sixth, $seventh, $eighth, $ninth, $tenth)" - - companion object -} - class EitherZipTest : StringSpec({ "zip results in all Right transformed, or all Left combined according to combine" { checkAll( @@ -48,17 +29,16 @@ class EitherZipTest : StringSpec({ Arb.either(Arb.string(), Arb.double()), Arb.either(Arb.string(), Arb.char()), Arb.either(Arb.string(), Arb.string()), - Arb.either(Arb.string(), Arb.boolean()), Arb.either(Arb.string(), Arb.boolean()) - ) { a, b, c, d, e, f, g, h, i, j -> - val res = a.zip({ e1, e2 -> "$e1$e2" }, b, c, d, e, f, g, h, i, j, ::Tuple10) - val all = listOf(a, b, c, d, e, f, g, h, i, j) + ) { a, b, c, d, e, f, g, h, i -> + val res = a.zip({ e1, e2 -> "$e1$e2" }, b, c, d, e, f, g, h, i, ::Tuple9) + val all = listOf(a, b, c, d, e, f, g, h, i) val expected = if (all.any { it.isLeft() }) { all.filterIsInstance>().fold("") { acc, t -> "$acc${t.value}" }.left() } else { all.filterIsInstance>().map { it.value }.let { - Tuple10(it[0], it[1], it[2], it[3], it[4], it[5], it[6], it[7], it[8], it[9]).right() + Tuple9(it[0], it[1], it[2], it[3], it[4], it[5], it[6], it[7], it[8]).right() } } @@ -76,17 +56,16 @@ class EitherZipTest : StringSpec({ Arb.either(Arb.string(), Arb.double()), Arb.either(Arb.string(), Arb.char()), Arb.either(Arb.string(), Arb.string()), - Arb.either(Arb.string(), Arb.boolean()), Arb.either(Arb.string(), Arb.boolean()) - ) { a, b, c, d, e, f, g, h, i, j -> - val res = a.zip(b, c, d, e, f, g, h, i, j, ::Tuple10) - val all = listOf(a, b, c, d, e, f, g, h, i, j) + ) { a, b, c, d, e, f, g, h, i -> + val res = a.zip(b, c, d, e, f, g, h, i, ::Tuple9) + val all = listOf(a, b, c, d, e, f, g, h, i) val expected = if (all.any { it.isLeft() }) { all.filterIsInstance>().map { it.value }.toNonEmptyListOrNull()!!.left() } else { all.filterIsInstance>().map { it.value }.let { - Tuple10(it[0], it[1], it[2], it[3], it[4], it[5], it[6], it[7], it[8], it[9]).right() + Tuple9(it[0], it[1], it[2], it[3], it[4], it[5], it[6], it[7], it[8]).right() } } @@ -107,11 +86,10 @@ class EitherZipTest : StringSpec({ Arb.either(Arb.nonEmptyList(Arb.string()), Arb.double()), Arb.either(Arb.nonEmptyList(Arb.string()), Arb.char()), Arb.either(Arb.nonEmptyList(Arb.string()), Arb.string()), - Arb.either(Arb.nonEmptyList(Arb.string()), Arb.boolean()), Arb.either(Arb.nonEmptyList(Arb.string()), Arb.boolean()) - ) { a, b, c, d, e, f, g, h, i, j -> - val res = a.zip(b, c, d, e, f, g, h, i, j, ::Tuple10) - val all = listOf(a, b, c, d, e, f, g, h, i, j) + ) { a, b, c, d, e, f, g, h, i -> + val res = a.zip(b, c, d, e, f, g, h, i, ::Tuple9) + val all = listOf(a, b, c, d, e, f, g, h, i) val expected = if (all.any { it.isLeft() }) { all.filterIsInstance>>() @@ -119,7 +97,7 @@ class EitherZipTest : StringSpec({ .toNonEmptyListOrNull()!!.left() } else { all.filterIsInstance>().map { it.value }.let { - Tuple10(it[0], it[1], it[2], it[3], it[4], it[5], it[6], it[7], it[8], it[9]).right() + Tuple9(it[0], it[1], it[2], it[3], it[4], it[5], it[6], it[7], it[8]).right() } } diff --git a/gradle.properties b/gradle.properties index 9ad56e602fd..34dd2421a6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,7 +29,6 @@ kotlin.native.ignoreDisabledTargets=true kotlin.mpp.enableCompatibilityMetadataVariant=false # https://youtrack.jetbrains.com/issue/KT-45545#focus=Comments-27-4773544.0-0 kapt.use.worker.api=false -kotest.proptest.default.iteration.count=10 COMMON_SETUP=../gradle/setup.gradle ROOT_PROJECT=../gradle/main.gradle