diff --git a/arrow-libs/core/arrow-atomic/build.gradle.kts b/arrow-libs/core/arrow-atomic/build.gradle.kts index a38d7f61e23..fcb518fac59 100644 --- a/arrow-libs/core/arrow-atomic/build.gradle.kts +++ b/arrow-libs/core/arrow-atomic/build.gradle.kts @@ -53,5 +53,22 @@ kotlin { implementation(libs.kotlin.stdlibJS) } } + + if (!enableCompatibilityMetadataVariant) { + commonTest { + dependencies { + implementation(projects.arrowFxCoroutines) + implementation(libs.kotest.frameworkApi) + implementation(libs.kotest.assertionsCore) + implementation(libs.kotest.property) + } + } + jvmTest { + dependencies { + runtimeOnly(libs.kotest.frameworkEngine) + runtimeOnly(libs.kotest.runnerJUnit5) + } + } + } } } 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 dece0ef79fd..00000000000 --- a/arrow-libs/core/arrow-continuations/build.gradle.kts +++ /dev/null @@ -1,55 +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(projects.arrowCore) - implementation(libs.kotest.frameworkEngine) - implementation(libs.kotest.assertionsCore) - implementation(libs.kotest.property) - } - } - 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 c6a4dab39d7..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` 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 234953e85a9..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` 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 128a4f351e5..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/SuspendingComputationTest.kt +++ /dev/null @@ -1,221 +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 io.kotest.assertions.fail -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.arbitrary.string -import io.kotest.property.checkAll -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 : StringSpec({ - - "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 12314a24a27..00000000000 --- a/arrow-libs/core/arrow-continuations/src/commonTest/kotlin/generic/TestSuite.kt +++ /dev/null @@ -1,24 +0,0 @@ -package generic - -import arrow.continuations.Reset -import arrow.continuations.generic.RestrictedScope -import arrow.core.Either -import arrow.core.Either.Left -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe - -class SingleShotContTestSuite : StringSpec({ - "yield a list (also verifies stacksafety)" { - Reset.restricted { - 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" { - Reset.restricted> { - val no: Int = shift { Left("No thank you") } - throw IllegalStateException("This should not be executed") - } shouldBe Left("No thank you") - } -}) 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 aab29577711..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` 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 46bf67112e5..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` 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 839dc4043ba..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` also don't catch [ControlThrowable]. - */ -@Deprecated(deprecateArrowContinuation) -public actual open class ControlThrowable : Throwable() diff --git a/arrow-libs/core/arrow-core/api/arrow-core.api b/arrow-libs/core/arrow-core/api/arrow-core.api index fbb6dd02f7c..8f0f4850d69 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; @@ -320,108 +288,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 @@ -767,7 +633,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; @@ -1431,591 +1296,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 @@ -2174,7 +1454,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 @@ -2183,24 +1462,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; } @@ -2212,128 +1478,6 @@ public final class arrow/core/UtilsKt { public static final fun mapNullable (Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; } -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 (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;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;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 (Ljava/lang/Object;)Ljava/lang/Object; -} - -public final class arrow/core/computations/ResultEffect$result { - public static final field INSTANCE Larrow/core/computations/ResultEffect$result; - public final fun invoke-IoAF18A (Lkotlin/jvm/functions/Function1;)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/continuations/DefaultRaise : arrow/core/continuations/Raise { public fun ()V public fun bind (Larrow/core/Either;)Ljava/lang/Object; @@ -2649,7 +1793,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/Semigroup;Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public abstract fun empty ()Ljava/lang/Object; public static fun endo ()Larrow/typeclasses/Monoid; @@ -2669,7 +1812,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 synthetic fun either (Larrow/typeclasses/Monoid;Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public final fun either (Larrow/typeclasses/Semigroup;Larrow/typeclasses/Monoid;)Larrow/typeclasses/Monoid; public final fun endo ()Larrow/typeclasses/Monoid; @@ -2700,7 +1842,6 @@ public abstract interface class arrow/typeclasses/Semigroup { public static fun Short ()Larrow/typeclasses/Semigroup; public abstract fun append (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 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; @@ -2721,7 +1862,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/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index 60ae0ca847a..87549a71ae3 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")) @@ -24,7 +24,6 @@ kotlin { sourceSets { commonMain { dependencies { - api(projects.arrowContinuations) api(projects.arrowAtomic) api(projects.arrowAnnotations) api(libs.kotlin.stdlibCommon) @@ -39,9 +38,10 @@ kotlin { implementation(libs.kotest.property) } } - jvmTest { dependencies { + implementation(projects.arrowFxCoroutines) + runtimeOnly(libs.kotest.frameworkEngine) runtimeOnly(libs.kotest.runnerJUnit5) } } 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/Option.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt index 6fe6dbaaf87..6a552bef578 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 @@ -298,49 +298,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) @@ -432,7 +389,7 @@ public sealed class Option { * none().tapNone { println("flower") } // Result: prints "flower" and returns: None * } * ``` - * + * */ public inline fun tapNone(f: () -> Unit): Option = when (this) { @@ -459,7 +416,7 @@ public sealed class Option { * none().tap { println("flower") } // Result: None * } * ``` - * + * */ public inline fun tap(f: (A) -> Unit): Option = when (this) { @@ -732,7 +689,7 @@ public sealed class Option { * none.exists { it > 10 } // Result: false * } * ``` - * + * * * @param predicate the predicate to test */ @@ -757,7 +714,7 @@ public sealed class Option { * none.exists { it > 10 } // Result: null * } * ``` - * + * */ public inline fun findOrNull(predicate: (A) -> Boolean): A? = when (this) { @@ -799,15 +756,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 } } @@ -1010,7 +958,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/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/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 4939b08d7ad..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/either.kt +++ /dev/null @@ -1,111 +0,0 @@ -package arrow.core.computations - -import arrow.continuations.Effect -import arrow.core.Either -import arrow.core.Either.Left -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 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 f2893377b91..00000000000 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/computations/result.kt +++ /dev/null @@ -1,55 +0,0 @@ -package arrow.core.computations - -import arrow.core.Either -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(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.ResultEffect.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 889aae95f06..0490d94fdd6 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 @@ -89,15 +88,6 @@ public interface Monoid : Semigroup { override fun append(a: Endo, b: Endo): Endo = Endo(a.f.compose(b.f)) } - @JvmStatic - @JvmName("constant") - public fun const(MA: Monoid): Monoid> = - object : Monoid> { - override fun empty(): Const = Const(MA.empty()) - override fun append(a: Const, b: Const): Const = - a.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 dbaa26d1c72..fd28e4ee3d3 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 @@ -70,11 +69,6 @@ public fun interface Semigroup { public fun endo(): Semigroup> = Semigroup { f, g -> Endo(f.f.compose(g.f)) } - @JvmStatic - @JvmName("constant") - public fun const(SA: Semigroup): Semigroup> = - Semigroup { a, b -> a.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/EitherTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherTest.kt index ee40790501b..b2f083b6b1d 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 @@ -30,22 +30,6 @@ class EitherTest : StringSpec({ 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/EitherZipTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EitherZipTest.kt index 7a0d7244a80..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 @@ -29,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() } } @@ -57,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() } } @@ -88,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>>() @@ -100,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/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 c77faef7345..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/EvalTest.kt +++ /dev/null @@ -1,134 +0,0 @@ -package arrow.core - -import arrow.core.test.stackSafeIteration -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe - -internal data class SideEffect(var counter: Int = 0) { - fun increment() { - counter++ - } -} - -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) - } - } -} - -class EvalTest : StringSpec({ - - "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 - } - -}) 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 063c666abb1..8b87abc8abe 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 @@ -170,34 +170,6 @@ class IterableTest : StringSpec({ } } - "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/MapKTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/MapKTest.kt index ab3b0e06b79..8d176b8895e 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 @@ -187,34 +187,6 @@ class MapKTest : StringSpec({ } } - "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/NonEmptyListTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonEmptyListTest.kt index bf582259ff7..7469f44da12 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 @@ -161,26 +161,6 @@ class NonEmptyListTest : StringSpec({ } } - "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/OptionTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/OptionTest.kt index 60a7e320bab..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 @@ -1,6 +1,5 @@ package arrow.core -import arrow.core.continuations.ensureNotNull import arrow.core.continuations.option import arrow.core.test.laws.MonoidLaws import arrow.core.test.option @@ -23,22 +22,6 @@ class OptionTest : StringSpec({ 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() - }*/ ) "ensure null in option computation" { 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 8d0244b8b18..f473287a449 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.typeclasses.Monoid import arrow.core.test.laws.MonoidLaws import arrow.core.test.option import arrow.core.test.sequence import arrow.core.test.testLaws +import arrow.typeclasses.Monoid import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.sequences.shouldBeEmpty import io.kotest.property.Arb @@ -155,34 +155,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/computations/NullableTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/NullableTest.kt deleted file mode 100644 index d47281f9c0f..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/NullableTest.kt +++ /dev/null @@ -1,97 +0,0 @@ -package arrow.core.computations - -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 NullableTest : StringSpec({ - "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 e74ff849cd8..00000000000 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/computations/ResultTest.kt +++ /dev/null @@ -1,223 +0,0 @@ -package arrow.core.computations - -import arrow.core.Eval -import arrow.core.Tuple10 -import arrow.core.composeErrors -import arrow.core.computations.ResultEffect.result -import arrow.core.flatMap -import arrow.core.handleErrorWith -import arrow.core.redeemWith -import arrow.core.test.result -import arrow.core.test.suspend -import arrow.core.test.throwable -import arrow.core.zip -import io.kotest.assertions.fail -import io.kotest.core.spec.style.StringSpec -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 : StringSpec({ - "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/test/Generators.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/test/Generators.kt index d176e45fa33..c424bd291cc 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/test/Generators.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/test/Generators.kt @@ -2,7 +2,6 @@ package arrow.core.test import arrow.core.Either import arrow.core.Endo -import arrow.core.Eval import arrow.core.Ior import arrow.core.NonEmptyList import arrow.core.Option @@ -70,9 +69,6 @@ fun Arb.Companion.unit(): Arb = fun Arb.Companion.ior(arbA: Arb, arbB: Arb): Arb> = arbA.alignWith(arbB) { it } -fun Arb.eval(): Arb> = - map { Eval.now(it) } - private fun Arb.alignWith(arbB: Arb, transform: (Ior) -> R): Arb = Arb.bind(this, arbB) { a, b -> transform(Ior.Both(a, b)) } 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/DeadlockTest.kt b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/DeadlockTest.kt index 9750daf6bb4..47450994cd8 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 @@ -50,18 +50,4 @@ class DeadlockTest : StringSpec({ } } - "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 a0c5c659be9..0935aa5540b 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 @@ -13,11 +13,6 @@ class EitherJvmTest : StringSpec({ Arb.suspendFunThatThrowsFatalThrowable(), Arb.any() ) { f: suspend () -> Either, returnObject: Any -> - - val comparator: Comparator = - Comparator.comparingInt(Person::age) - .thenComparing(Person::name) - shouldThrow { Either.resolve( f = { f() }, 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 cf466decb01..00000000000 --- a/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/EvalJvmTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -package arrow.core - -import io.kotest.assertions.fail -import io.kotest.core.spec.style.StringSpec -import io.kotest.property.Arb -import io.kotest.property.Sample -import io.kotest.property.arbitrary.arbitrary -import io.kotest.property.arbitrary.choice -import io.kotest.property.checkAll - -class EvalJvmTest : StringSpec({ - "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/java/arrow/typeclasses/MonoidUsageTest.java b/arrow-libs/core/arrow-core/src/jvmTest/java/arrow/typeclasses/MonoidUsageTest.java index 41821542af6..a0e98b53aae 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 @@ -24,7 +24,5 @@ public void testUsage() { Monoid> map = Monoid.map(Semigroup.Integer()); Monoid> option = Monoid.option(Semigroup.Integer()); 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 3485ee812ec..3138ef231de 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 @@ -22,7 +22,6 @@ public void testUsage() { Semigroup> option = Semigroup.option(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-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-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()) -} 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-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/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 20281fe4a0e..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.ResultEffect.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/api/arrow-fx-coroutines.api b/arrow-libs/fx/arrow-fx-coroutines/api/arrow-fx-coroutines.api index 07ebb70cceb..23bc767feb4 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 @@ -409,21 +409,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; @@ -433,10 +433,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/fx/arrow-fx-coroutines/build.gradle.kts b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts index 3ce6a7f2844..6da957283cd 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 = @@ -31,6 +31,7 @@ kotlin { if (!enableCompatibilityMetadataVariant) { commonTest { dependencies { + implementation(projects.arrowCore) implementation(libs.kotest.frameworkEngine) implementation(libs.kotest.assertionsCore) implementation(libs.kotest.property) 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 246d38a2f44..a0b4a4e26f5 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-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ScheduleTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ScheduleTest.kt index b121fa3d4aa..f5c1f355496 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ScheduleTest.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ScheduleTest.kt @@ -1,7 +1,6 @@ package arrow.fx.coroutines import arrow.core.Either -import arrow.core.Eval import io.kotest.assertions.fail import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should @@ -32,14 +31,14 @@ class ScheduleTest : StringSpec({ "Schedule.identity()" { val dec = Schedule.identity().calculateSchedule1(1) - val expected = Schedule.Decision(true, 0.0, Unit, Eval.now(1)) + val expected = Schedule.Decision(true, 0.0, Unit, { 1 }) dec eqv expected } "Schedule.unfold()" { val dec = Schedule.unfold(0) { it + 1 }.calculateSchedule1(0) - val expected = Schedule.Decision(true, 0.0, 1, Eval.now(1)) + val expected = Schedule.Decision(true, 0.0, 1, { 1 }) dec eqv expected } @@ -70,7 +69,7 @@ class ScheduleTest : StringSpec({ res.dropLast(1).map { it.delayInNanos.nanoseconds } shouldBe res.dropLast(1).map { 0.nanoseconds } res.dropLast(1).map { it.cont } shouldBe res.dropLast(1).map { true } - res.last() eqv Schedule.Decision(false, 0.0, n + 1, Eval.now(n + 1)) + res.last() eqv Schedule.Decision(false, 0.0, n + 1, { n + 1 }) } "Schedule.once() repeats 1 additional time" { @@ -190,7 +189,7 @@ class ScheduleTest : StringSpec({ "repeat" { val stop = RuntimeException("WOOO") - val dec = Schedule.Decision(true, 10.0, 0, Eval.now("state")) + val dec = Schedule.Decision(true, 10.0, 0, { "state" }) val n = 100 val schedule = Schedule({ 0 }) { _: Unit, _ -> dec } @@ -209,7 +208,7 @@ class ScheduleTest : StringSpec({ "repeatAsFlow" { val stop = RuntimeException("WOOO") - val dec = Schedule.Decision(true, 10.0, 0, Eval.now("state")) + val dec = Schedule.Decision(true, 10.0, 0, { "state" }) val n = 100 val schedule = Schedule({ 0 }) { _: Unit, _ -> dec } @@ -352,8 +351,8 @@ private infix fun Schedule.Decision.eqv(other: Schedule.Decision withContext(_single) { threadName() shouldStartWith "single" - + val (s1, s2, s3, s4, s5, s6) = parZip( _mapCtx, threadName, threadName, threadName, threadName, threadName, threadName ) { a, b, c, d, e, f -> Tuple6(a, b, c, d, e, f) } - + s1 shouldStartWith mapCtxName s2 shouldStartWith mapCtxName s3 shouldStartWith mapCtxName 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 b5eb62b0f6d..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 @@ -23,13 +23,13 @@ class ParMap7JvmTest : StringSpec({ parallelCtx(7, mapCtxName) { _single, _mapCtx -> withContext(_single) { threadName() shouldStartWith "single" - + val (s1, s2, s3, s4, s5, s6, s7) = parZip( _mapCtx, threadName, threadName, threadName, threadName, threadName, threadName, threadName ) { a, b, c, d, e, f, g -> Tuple7(a, b, c, d, e, f, g) } - + s1 shouldStartWith mapCtxName s2 shouldStartWith mapCtxName s3 shouldStartWith mapCtxName 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 0259914e322..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 @@ -23,13 +23,13 @@ class ParMap8JvmTest : StringSpec({ parallelCtx(7, mapCtxName) { _single, _mapCtx -> withContext(_single) { threadName() shouldStartWith "single" - + 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 -> Tuple8(a, b, c, d, e, f, g, h) } - + s1 shouldStartWith mapCtxName s2 shouldStartWith mapCtxName s3 shouldStartWith mapCtxName diff --git a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts index ccec09d7679..c367ea639a2 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/fx/arrow-fx-stm/src/commonTest/kotlin/arrow/fx/stm/STMTest.kt b/arrow-libs/fx/arrow-fx-stm/src/commonTest/kotlin/arrow/fx/stm/STMTest.kt index 540772bb7ea..ad3dc1b103f 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/commonTest/kotlin/arrow/fx/stm/STMTest.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/commonTest/kotlin/arrow/fx/stm/STMTest.kt @@ -267,5 +267,5 @@ class STMTest : StringSpec({ // the above only finishes if the consumer reads at least 100 values, this here is just to make sure there are no leftovers atomically { tq.flush() } shouldBe emptyList() } - } -) + +}) diff --git a/arrow-libs/optics/arrow-optics/api/arrow-optics.api b/arrow-libs/optics/arrow-optics/api/arrow-optics.api index 785225f47fa..796525e2c59 100644 --- a/arrow-libs/optics/arrow-optics/api/arrow-optics.api +++ b/arrow-libs/optics/arrow-optics/api/arrow-optics.api @@ -23,7 +23,6 @@ public final class arrow/optics/Every { public static final fun sequence ()Larrow/optics/PTraversal; public static final fun string ()Larrow/optics/PTraversal; public static final fun triple ()Larrow/optics/PTraversal; - public static final fun tuple10 ()Larrow/optics/PTraversal; public static final fun tuple4 ()Larrow/optics/PTraversal; public static final fun tuple5 ()Larrow/optics/PTraversal; public static final fun tuple6 ()Larrow/optics/PTraversal; @@ -300,7 +299,6 @@ public abstract interface class arrow/optics/PTraversal { 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; @@ -314,7 +312,6 @@ public abstract interface class arrow/optics/PTraversal { public abstract fun size (Ljava/lang/Object;)I 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; @@ -342,7 +339,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; @@ -353,7 +349,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; diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index 168b0342d2c..6b62b5800ac 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")) @@ -39,6 +37,7 @@ kotlin { 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/commonMain/kotlin/arrow/optics/Every.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Every.kt index d8d368a6e36..9fb1faabffb 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 @@ -42,7 +41,10 @@ public object Every { source.map(map) override fun foldMap(M: Monoid, source: Either, map: (focus: R) -> A): A = - source.foldMap(M, map) + when (source) { + is Either.Left -> M.empty() + is Either.Right -> map(source.value) + } } @JvmStatic @@ -318,42 +320,4 @@ public object Every { } } - /** - * [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> = - object : Traversal, 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/Traversal.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Traversal.kt index 5060254b364..5d06c9c42a4 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 @@ -588,31 +587,6 @@ public interface PTraversal { 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/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 2acec09fa9c..305ecd5b84f 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 @@ -5,7 +5,6 @@ import arrow.optics.test.option import arrow.optics.test.laws.TraversalLaws import arrow.optics.test.laws.testLaws import arrow.optics.test.nonEmptyList -import arrow.optics.test.sequence import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.char @@ -40,7 +39,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/FilterIndexInstanceTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/instances/FilterIndexInstanceTest.kt index 0fa58d2ed94..01366a14f0d 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 @@ -4,7 +4,6 @@ import arrow.optics.test.functionAToB import arrow.optics.test.laws.TraversalLaws import arrow.optics.test.laws.testLaws import arrow.optics.test.nonEmptyList -import arrow.optics.test.sequence import arrow.optics.typeclasses.FilterIndex import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb @@ -30,7 +29,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() } 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 6c139de4b8d..9aabe3d874d 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 @@ -30,7 +30,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/std/TupleTest.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/std/TupleTest.kt index 8df130ff3bd..4759fe80246 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 @@ -6,6 +6,12 @@ import arrow.optics.test.functionAToB import arrow.optics.test.laws.LensLaws import arrow.optics.test.laws.TraversalLaws import arrow.optics.test.laws.testLaws +import arrow.optics.test.tuple4 +import arrow.optics.test.tuple5 +import arrow.optics.test.tuple6 +import arrow.optics.test.tuple7 +import arrow.optics.test.tuple8 +import arrow.optics.test.tuple9 import io.kotest.core.spec.style.StringSpec import io.kotest.property.Arb import io.kotest.property.arbitrary.boolean @@ -86,4 +92,91 @@ class TupleTest : StringSpec({ ) ) + testLaws( + "Traversal tuple4 - ", + TraversalLaws.laws( + traversal = Traversal.tuple4(), + aGen = Arb.tuple4(Arb.boolean(), Arb.boolean(), Arb.boolean(), Arb.boolean()), + bGen = Arb.boolean(), + funcGen = Arb.functionAToB(Arb.boolean()), + ) + ) + + testLaws( + "Traversal tuple5 - ", + TraversalLaws.laws( + traversal = Traversal.tuple5(), + aGen = Arb.tuple5(Arb.boolean(), Arb.boolean(), Arb.boolean(), Arb.boolean(), Arb.boolean()), + bGen = Arb.boolean(), + funcGen = Arb.functionAToB(Arb.boolean()), + ) + ) + + testLaws( + "Traversal tuple6 - ", + TraversalLaws.laws( + traversal = Traversal.tuple6(), + aGen = Arb.tuple6(Arb.boolean(), Arb.boolean(), Arb.boolean(), Arb.boolean(), Arb.boolean(), Arb.boolean()), + bGen = Arb.boolean(), + funcGen = Arb.functionAToB(Arb.boolean()), + ) + ) + + testLaws( + "Traversal tuple7 - ", + TraversalLaws.laws( + traversal = Traversal.tuple7(), + aGen = Arb.tuple7( + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean() + ), + bGen = Arb.boolean(), + funcGen = Arb.functionAToB(Arb.boolean()), + ) + ) + + testLaws( + "Traversal tuple8 - ", + TraversalLaws.laws( + traversal = Traversal.tuple8(), + aGen = Arb.tuple8( + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean(), + Arb.boolean() + ), + bGen = Arb.boolean(), + funcGen = Arb.functionAToB(Arb.boolean()), + ) + ) + + testLaws( + "Traversal tuple9 - ", + TraversalLaws.laws( + traversal = Traversal.tuple9(), + aGen = Arb.tuple9( + 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.int()), + ) + ) + }) diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/test/Generators.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/test/Generators.kt index bb0674539a2..1f66bd4a5cb 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/test/Generators.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/test/Generators.kt @@ -3,6 +3,12 @@ package arrow.optics.test import arrow.core.Either import arrow.core.NonEmptyList import arrow.core.Option +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.toOption import io.kotest.property.Arb import io.kotest.property.arbitrary.bind @@ -28,3 +34,66 @@ fun Arb.Companion.either(arbE: Arb, arbA: Arb): Arb> { val arbRight = arbA.map { Either.Right(it) } return Arb.choice(arbLeft, arbRight) } + +fun Arb.Companion.tuple4( + arbA: Arb, + arbB: Arb, + arbC: Arb, + arbD: Arb +): Arb> = + Arb.bind(arbA, arbB, arbC, arbD, ::Tuple4) + +fun Arb.Companion.tuple5( + arbA: Arb, + arbB: Arb, + arbC: Arb, + arbD: Arb, + arbE: Arb +): Arb> = + Arb.bind(arbA, arbB, arbC, arbD, arbE, ::Tuple5) + +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) + +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) + +fun Arb.Companion.tuple8( + arbA: Arb, + arbB: Arb, + arbC: Arb, + arbD: Arb, + arbE: Arb, + arbF: Arb, + arbG: Arb, + arbH: Arb +): Arb> = + Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, arbG, arbH, ::Tuple8) + +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(arbA, arbB, arbC, arbD, arbE, arbF, arbG, arbH, arbI, ::Tuple9) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 19d8125c22a..6ea793880ce 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" } diff --git a/settings.gradle.kts b/settings.gradle.kts index e263f36ed8d..a143d74025f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -38,9 +38,6 @@ val enableCompatibilityMetadataVariant = providers.gradleProperty("kotlin.mpp.enableCompatibilityMetadataVariant") .forUseAtConfigurationTime().orNull?.toBoolean() == true -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")