diff --git a/arrow-libs/core/arrow-atomic/build.gradle.kts b/arrow-libs/core/arrow-atomic/build.gradle.kts index f9e32f25a5d..70f921b0a88 100644 --- a/arrow-libs/core/arrow-atomic/build.gradle.kts +++ b/arrow-libs/core/arrow-atomic/build.gradle.kts @@ -47,11 +47,9 @@ kotlin { } tasks.withType().configureEach { - kotlinOptions { - freeCompilerArgs = freeCompilerArgs + "-Xexpect-actual-classes" - } + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/core/arrow-core-retrofit/build.gradle.kts b/arrow-libs/core/arrow-core-retrofit/build.gradle.kts index 82f1ef25e9e..8a1af47a255 100644 --- a/arrow-libs/core/arrow-core-retrofit/build.gradle.kts +++ b/arrow-libs/core/arrow-core-retrofit/build.gradle.kts @@ -43,6 +43,6 @@ tasks.jar { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/core/arrow-core-retrofit/src/main/kotlin/arrow/retrofit/adapter/either/EitherCallAdapterFactory.kt b/arrow-libs/core/arrow-core-retrofit/src/main/kotlin/arrow/retrofit/adapter/either/EitherCallAdapterFactory.kt index e6e7a910e13..b277e0ee2ad 100644 --- a/arrow-libs/core/arrow-core-retrofit/src/main/kotlin/arrow/retrofit/adapter/either/EitherCallAdapterFactory.kt +++ b/arrow-libs/core/arrow-core-retrofit/src/main/kotlin/arrow/retrofit/adapter/either/EitherCallAdapterFactory.kt @@ -110,7 +110,7 @@ public class EitherCallAdapterFactory : CallAdapter.Factory() { } } - private inline fun extractErrorAndReturnType(wrapperType: Type, returnType: ParameterizedType): Pair { + private fun extractErrorAndReturnType(wrapperType: Type, returnType: ParameterizedType): Pair { if (wrapperType !is ParameterizedType) { val name = parseTypeName(returnType) throw IllegalArgumentException( diff --git a/arrow-libs/core/arrow-core-serialization/build.gradle.kts b/arrow-libs/core/arrow-core-serialization/build.gradle.kts index 53ff992767d..6ba4450f34f 100644 --- a/arrow-libs/core/arrow-core-serialization/build.gradle.kts +++ b/arrow-libs/core/arrow-core-serialization/build.gradle.kts @@ -41,6 +41,6 @@ kotlin { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/core/arrow-core/api/arrow-core.api b/arrow-libs/core/arrow-core/api/arrow-core.api index c536327fe75..9f112df7e83 100644 --- a/arrow-libs/core/arrow-core/api/arrow-core.api +++ b/arrow-libs/core/arrow-core/api/arrow-core.api @@ -1011,7 +1011,7 @@ public final class arrow/core/raise/RaiseKt { public static final fun get (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun get (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun getOrElse (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun getOrElse (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun getOrElse (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun getOrNull (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun getOrNull (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun ior (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Larrow/core/Ior; diff --git a/arrow-libs/core/arrow-core/build.gradle.kts b/arrow-libs/core/arrow-core/build.gradle.kts index afcf7ecbe22..5cba44a0899 100644 --- a/arrow-libs/core/arrow-core/build.gradle.kts +++ b/arrow-libs/core/arrow-core/build.gradle.kts @@ -57,10 +57,14 @@ kotlin { } // enables context receivers for Jvm Tests +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" +} + tasks.named("compileTestKotlinJvm") { kotlinOptions.freeCompilerArgs += "-Xcontext-receivers" } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt index 85590c561d7..305de144f9d 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt @@ -1332,6 +1332,7 @@ public inline infix fun Either.getOrElse(default: (A) -> B): B { * * */ +@Suppress("NOTHING_TO_INLINE") public inline fun Either.merge(): A = fold(::identity, ::identity) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonEmptyList.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonEmptyList.kt index e1f8c963795..5eb622b7bac 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonEmptyList.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonEmptyList.kt @@ -179,7 +179,7 @@ public value class NonEmptyList @PublishedApi internal constructor( else -> head } - @Suppress("OVERRIDE_BY_INLINE") + @Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") public override inline fun distinct(): NonEmptyList = NonEmptyList(all.distinct()) @@ -340,6 +340,7 @@ public fun nonEmptyListOf(head: A, vararg t: A): NonEmptyList = NonEmptyList(listOf(head) + t) @JvmName("nel") +@Suppress("NOTHING_TO_INLINE") public inline fun A.nel(): NonEmptyList = NonEmptyList(listOf(this)) @@ -355,9 +356,11 @@ public inline fun > NonEmptyList.minBy(selector: (A) -> public inline fun > NonEmptyList.maxBy(selector: (A) -> B): A = maxByOrNull(selector)!! +@Suppress("NOTHING_TO_INLINE") public inline fun > NonEmptyList.min(): T = minOrNull()!! +@Suppress("NOTHING_TO_INLINE") public inline fun > NonEmptyList.max(): T = maxOrNull()!! diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonFatal.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonFatal.kt index 05493d03e06..7740e42794f 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonFatal.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/NonFatal.kt @@ -24,7 +24,7 @@ import kotlin.coroutines.cancellation.CancellationException * else -> "Hello" * } * - * fun main(args: Array) { + * fun main() { * val nonFatal: Either = * //sampleStart * try { diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Sequence.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Sequence.kt index e0ba84b2a10..16d501363ae 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Sequence.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Sequence.kt @@ -8,7 +8,6 @@ package arrow.core import arrow.core.Either.Left import arrow.core.Either.Right import arrow.core.raise.RaiseAccumulate -import arrow.core.raise.either import arrow.core.raise.fold import kotlin.experimental.ExperimentalTypeInference @@ -574,7 +573,7 @@ public fun Sequence.salign( * @return a tuple containing Sequence with [Either.Left] and another Sequence with its [Either.Right] values. */ public fun Sequence>.separateEither(): Pair, List> = - fold(listOf() to listOf()) { (lefts, rights), either -> + fold(listOf() to listOf()) { (lefts, rights), either -> when (either) { is Left -> lefts + either.value to rights is Right -> lefts to rights + either.value @@ -637,7 +636,7 @@ public fun Sequence.mapOrAccumulate( * import arrow.core.leftIor * import arrow.core.unalign * - * fun main(args: Array) { + * fun main() { * //sampleStart * val result = sequenceOf(("A" to 1).bothIor(), ("B" to 2).bothIor(), "C".leftIor()).unalign() * //sampleEnd @@ -662,7 +661,7 @@ public fun Sequence>.unalign(): Pair, Sequence> * import arrow.core.leftIor * import arrow.core.unalign * - * fun main(args: Array) { + * fun main() { * //sampleStart * val result = sequenceOf(1, 2, 3).unalign { it.leftIor() } * //sampleEnd @@ -680,7 +679,7 @@ public fun Sequence.unalign(fa: (C) -> Ior): Pair * ```kotlin * import arrow.core.unweave * - * fun main(args: Array) { + * fun main() { * //sampleStart * val result = sequenceOf(1,2,3).unweave { i -> sequenceOf("$i, ${i + 1}") } * //sampleEnd @@ -700,7 +699,7 @@ public fun Sequence.unweave(ffa: (A) -> Sequence): Sequence = * ```kotlin * import arrow.core.unzip * - * fun main(args: Array) { + * fun main() { * //sampleStart * val result = sequenceOf("A" to 1, "B" to 2).unzip() * //sampleEnd @@ -720,7 +719,7 @@ public fun Sequence>.unzip(): Pair, Sequence> = * ```kotlin * import arrow.core.unzip * - * fun main(args: Array) { + * fun main() { * //sampleStart * val result = * sequenceOf("A:1", "B:2", "C:3").unzip { e -> @@ -743,7 +742,7 @@ public fun Sequence.unzip(fc: (C) -> Pair): Pair, * ```kotlin * import arrow.core.widen * - * fun main(args: Array) { + * fun main() { * val original: Sequence = sequenceOf("Hello World") * val result: Sequence = original.widen() * } diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/map.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/map.kt index d4ed66d3b32..4c2bb6977d3 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/map.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/map.kt @@ -35,7 +35,7 @@ public fun Map.zip(other: Map): Map> = * * fun test() { * mapOf(1 to "A", 2 to "B").zip(mapOf(1 to "1", 2 to "2", 3 to "3")) { - * key, a, b -> "$a ~ $b" + * _, a, b -> "$a ~ $b" * } shouldBe mapOf(1 to "A ~ 1", 2 to "B ~ 2") * } * ``` diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/nonFatalOrThrow.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/nonFatalOrThrow.kt index 5a3c58883a5..12efe514998 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/nonFatalOrThrow.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/nonFatalOrThrow.kt @@ -17,7 +17,7 @@ package arrow.core * else -> "Hello" * } * - * fun main(args: Array) { + * fun main() { * val nonFatal: Either = * //sampleStart * try { diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/predef.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/predef.kt index c7171e1793e..e426016dffc 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/predef.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/predef.kt @@ -1,5 +1,6 @@ package arrow.core +@Suppress("NOTHING_TO_INLINE") public inline fun identity(a: A): A = a /** @@ -14,6 +15,7 @@ internal object EmptyValue { inline fun unbox(value: Any?): A = if (value === this) null as A else value as A + @Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE") public inline fun combine(first: Any?, second: T, combine: (T, T) -> T): T = if (first === EmptyValue) second else combine(first as T, second) } diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Effect.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Effect.kt index 761822b6196..232f8318627 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Effect.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Effect.kt @@ -289,8 +289,8 @@ import kotlin.jvm.JvmName * ```kotlin * val default5: Effect = * foreign - * .catch { ex: RuntimeException -> -1 } - * .catch { ex: java.sql.SQLException -> -2 } + * .catch { _: RuntimeException -> -1 } + * .catch { _: java.sql.SQLException -> -2 } * ``` * * Finally, since `catch` also supports `suspend` we can safely call other `suspend` code and throw `Throwable` into the `suspend` system. @@ -456,7 +456,7 @@ import kotlin.jvm.JvmName * effect { * bracketCase( * acquire = { File("build.gradle.kts").bufferedReader() }, - * use = { reader: BufferedReader -> raise(error) }, + * use = { _: BufferedReader -> raise(error) }, * release = { reader, exitCase -> * reader.close() * exit.complete(exitCase) @@ -664,11 +664,13 @@ import kotlin.jvm.JvmName */ public typealias Effect = suspend Raise.() -> A +@Suppress("NOTHING_TO_INLINE") public inline fun effect(@BuilderInference noinline block: suspend Raise.() -> A): Effect = block /** The same behavior and API as [Effect] except without requiring _suspend_. */ public typealias EagerEffect = Raise.() -> A +@Suppress("NOTHING_TO_INLINE") public inline fun eagerEffect(@BuilderInference noinline block: Raise.() -> A): EagerEffect = block public suspend fun Effect.merge(): A = merge { invoke() } diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/ErrorHandlers.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/ErrorHandlers.kt index dbca820ca22..fa49119e799 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/ErrorHandlers.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/ErrorHandlers.kt @@ -23,9 +23,9 @@ import kotlin.jvm.JvmName * * val error = effect { raise(Error) } // Raise(error) * - * val a = error.recover { error -> User } // Success(User) - * val b = error.recover { error -> raise("other-failure") } // Raise(other-failure) - * val c = error.recover { error -> throw RuntimeException("BOOM") } // Exception(BOOM) + * val a = error.recover { _ -> User } // Success(User) + * val b = error.recover { _ -> raise("other-failure") } // Raise(other-failure) + * val c = error.recover { _ -> throw RuntimeException("BOOM") } // Exception(BOOM) * ``` * */ @@ -93,7 +93,7 @@ public fun Effect.catch(): Effect> = catch({ Result.success(invoke()) }, Result.Companion::failure) } -public suspend inline infix fun Effect.getOrElse(recover: suspend (error: Error) -> A): A = +public suspend inline infix fun Effect.getOrElse(recover: (error: Error) -> A): A = recover({ invoke() }) { recover(it) } /** @@ -110,9 +110,9 @@ public suspend inline infix fun Effect.getOrElse(recover: s * * val error = effect { raise(Error) } // Raise(error) * - * val a = error.mapError { error -> "some-failure" } // Raise(some-failure) + * val a = error.mapError { _ -> "some-failure" } // Raise(some-failure) * val b = error.mapError(Any::toString) // Raise(Error) - * val c = error.mapError { error -> throw RuntimeException("BOOM") } // Exception(BOOM) + * val c = error.mapError { _ -> throw RuntimeException("BOOM") } // Exception(BOOM) * ``` * */ @@ -147,7 +147,7 @@ public inline infix fun EagerEffect.getOrElse(recover: (err * * val error = eagerEffect { raise(Error) } // Raise(error) * - * val a = error.mapError { error -> "some-failure" } // Raise(some-failure) + * val a = error.mapError { _ -> "some-failure" } // Raise(some-failure) * val b = error.mapError(Any::toString) // Raise(Error) * ``` * diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt index 0bbd1a4b586..3f3617f65ef 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/Raise.kt @@ -264,7 +264,7 @@ public interface Raise { * * either { * val x = one.bind() - * val y = recover({ left.bind() }) { failure : String -> 1 } + * val y = recover({ left.bind() }) { _ : String -> 1 } * x + y * } shouldBe Either.Right(2) * } @@ -325,7 +325,7 @@ public interface Raise { * recover({ raise("failed") }) { str -> str.length } shouldBe 6 * * either { - * recover({ raise("failed") }) { str -> raise(-1) } + * recover({ raise("failed") }) { _ -> raise(-1) } * } shouldBe Either.Left(-1) * } * ``` @@ -421,7 +421,7 @@ public inline fun recover( * --> * ```kotlin * fun test() { - * catch({ throw RuntimeException("BOOM") }) { t -> + * catch({ throw RuntimeException("BOOM") }) { _ -> * "fallback" * } shouldBe "fallback" * @@ -460,7 +460,7 @@ public inline fun catch(block: () -> A, catch: (throwable: Throwable) -> A): * --> * ```kotlin * fun test() { - * catch({ throw RuntimeException("BOOM") }) { t -> + * catch({ throw RuntimeException("BOOM") }) { _ -> * "fallback" * } shouldBe "fallback" * diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-01.kt index b6d7af378af..eb4cc8e5176 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-01.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-01.kt @@ -9,6 +9,6 @@ object Error val error = effect { raise(Error) } // Raise(error) -val a = error.recover { error -> User } // Success(User) -val b = error.recover { error -> raise("other-failure") } // Raise(other-failure) -val c = error.recover { error -> throw RuntimeException("BOOM") } // Exception(BOOM) +val a = error.recover { _ -> User } // Success(User) +val b = error.recover { _ -> raise("other-failure") } // Raise(other-failure) +val c = error.recover { _ -> throw RuntimeException("BOOM") } // Exception(BOOM) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-04.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-04.kt index 97ddc6117d2..72f5b3736e5 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-04.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-04.kt @@ -9,6 +9,6 @@ object Error val error = effect { raise(Error) } // Raise(error) -val a = error.mapError { error -> "some-failure" } // Raise(some-failure) +val a = error.mapError { _ -> "some-failure" } // Raise(some-failure) val b = error.mapError(Any::toString) // Raise(Error) -val c = error.mapError { error -> throw RuntimeException("BOOM") } // Exception(BOOM) +val c = error.mapError { _ -> throw RuntimeException("BOOM") } // Exception(BOOM) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-05.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-05.kt index d1fab1d6d94..73fd1a576cf 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-05.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-05.kt @@ -9,5 +9,5 @@ object Error val error = eagerEffect { raise(Error) } // Raise(error) -val a = error.mapError { error -> "some-failure" } // Raise(some-failure) +val a = error.mapError { _ -> "some-failure" } // Raise(some-failure) val b = error.mapError(Any::toString) // Raise(Error) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-02.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-02.kt index c7c4ffdd2e6..c61c582f042 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-02.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-02.kt @@ -6,6 +6,6 @@ import io.kotest.matchers.shouldBe fun test() { mapOf(1 to "A", 2 to "B").zip(mapOf(1 to "1", 2 to "2", 3 to "3")) { - key, a, b -> "$a ~ $b" + _, a, b -> "$a ~ $b" } shouldBe mapOf(1 to "A ~ 1", 2 to "B ~ 2") } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatal-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatal-01.kt index 32ebd78ac2e..df6f9a58f15 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatal-01.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatal-01.kt @@ -11,7 +11,7 @@ fun unsafeFunction(i: Int): String = else -> "Hello" } -fun main(args: Array) { +fun main() { val nonFatal: Either = //sampleStart try { diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatalorthrow-01.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatalorthrow-01.kt index 07bf2372556..56a31b281c2 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatalorthrow-01.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonfatalorthrow-01.kt @@ -11,7 +11,7 @@ fun unsafeFunction(i: Int): String = else -> "Hello" } -fun main(args: Array) { +fun main() { val nonFatal: Either = //sampleStart try { diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-04.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-04.kt index 6fa5fe86c21..fe60fd2b1ce 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-04.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-04.kt @@ -43,8 +43,8 @@ val default4: Effect = val default5: Effect = foreign - .catch { ex: RuntimeException -> -1 } - .catch { ex: java.sql.SQLException -> -2 } + .catch { _: RuntimeException -> -1 } + .catch { _: java.sql.SQLException -> -2 } suspend fun java.sql.SQLException.isForeignKeyViolation(): Boolean = true diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-08.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-08.kt index 7f52b2e77e1..73b82b9361f 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-08.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-08.kt @@ -18,7 +18,7 @@ suspend fun main() { effect { bracketCase( acquire = { File("build.gradle.kts").bufferedReader() }, - use = { reader: BufferedReader -> raise(error) }, + use = { _: BufferedReader -> raise(error) }, release = { reader, exitCase -> reader.close() exit.complete(exitCase) diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-05.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-05.kt index 83d6ebd0359..6449d5b0c86 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-05.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-05.kt @@ -13,7 +13,7 @@ fun test() { either { val x = one.bind() - val y = recover({ left.bind() }) { failure : String -> 1 } + val y = recover({ left.bind() }) { _ : String -> 1 } x + y } shouldBe Either.Right(2) } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-06.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-06.kt index 73ef8a21ede..da5185f1b0e 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-06.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-06.kt @@ -10,6 +10,6 @@ fun test() { recover({ raise("failed") }) { str -> str.length } shouldBe 6 either { - recover({ raise("failed") }) { str -> raise(-1) } + recover({ raise("failed") }) { _ -> raise(-1) } } shouldBe Either.Left(-1) } diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-09.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-09.kt index cbf67703845..3e678e2fb3b 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-09.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-09.kt @@ -7,7 +7,7 @@ import arrow.core.raise.catch import io.kotest.matchers.shouldBe fun test() { - catch({ throw RuntimeException("BOOM") }) { t -> + catch({ throw RuntimeException("BOOM") }) { _ -> "fallback" } shouldBe "fallback" diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-10.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-10.kt index 94834cbbb6d..923e84e7c2b 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-10.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-10.kt @@ -7,7 +7,7 @@ import arrow.core.raise.catch import io.kotest.matchers.shouldBe fun test() { - catch({ throw RuntimeException("BOOM") }) { t -> + catch({ throw RuntimeException("BOOM") }) { _ -> "fallback" } shouldBe "fallback" diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-11.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-11.kt index 913edd869ce..c8a06580d4b 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-11.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-11.kt @@ -5,7 +5,7 @@ import arrow.core.bothIor import arrow.core.leftIor import arrow.core.unalign -fun main(args: Array) { +fun main() { //sampleStart val result = sequenceOf(("A" to 1).bothIor(), ("B" to 2).bothIor(), "C".leftIor()).unalign() //sampleEnd diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-12.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-12.kt index c78a9a358d3..768b3e87ec1 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-12.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-12.kt @@ -4,7 +4,7 @@ package arrow.core.examples.exampleSequence12 import arrow.core.leftIor import arrow.core.unalign -fun main(args: Array) { +fun main() { //sampleStart val result = sequenceOf(1, 2, 3).unalign { it.leftIor() } //sampleEnd diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-13.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-13.kt index 2fe0df59e49..45cc0c7710b 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-13.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-13.kt @@ -3,7 +3,7 @@ package arrow.core.examples.exampleSequence13 import arrow.core.unweave -fun main(args: Array) { +fun main() { //sampleStart val result = sequenceOf(1,2,3).unweave { i -> sequenceOf("$i, ${i + 1}") } //sampleEnd diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-14.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-14.kt index a2a90952121..835b67cdb14 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-14.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-14.kt @@ -3,7 +3,7 @@ package arrow.core.examples.exampleSequence14 import arrow.core.unzip -fun main(args: Array) { +fun main() { //sampleStart val result = sequenceOf("A" to 1, "B" to 2).unzip() //sampleEnd diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-15.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-15.kt index b0b55bba261..e45890c3984 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-15.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-15.kt @@ -3,7 +3,7 @@ package arrow.core.examples.exampleSequence15 import arrow.core.unzip -fun main(args: Array) { +fun main() { //sampleStart val result = sequenceOf("A:1", "B:2", "C:3").unzip { e -> diff --git a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-16.kt b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-16.kt index f85ad833147..8eed0fd16b7 100644 --- a/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-16.kt +++ b/arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-16.kt @@ -3,7 +3,7 @@ package arrow.core.examples.exampleSequence16 import arrow.core.widen -fun main(args: Array) { +fun main() { val original: Sequence = sequenceOf("Hello World") val result: Sequence = original.widen() } diff --git a/arrow-libs/core/arrow-functions/build.gradle.kts b/arrow-libs/core/arrow-functions/build.gradle.kts index 3a20ee1e556..748b9680ca8 100644 --- a/arrow-libs/core/arrow-functions/build.gradle.kts +++ b/arrow-libs/core/arrow-functions/build.gradle.kts @@ -46,6 +46,6 @@ kotlin { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/core/arrow-functions/src/commonTest/kotlin/arrow/core/MemoizationTest.kt b/arrow-libs/core/arrow-functions/src/commonTest/kotlin/arrow/core/MemoizationTest.kt index 2c99471e987..ffbd512fc05 100644 --- a/arrow-libs/core/arrow-functions/src/commonTest/kotlin/arrow/core/MemoizationTest.kt +++ b/arrow-libs/core/arrow-functions/src/commonTest/kotlin/arrow/core/MemoizationTest.kt @@ -1,3 +1,5 @@ +@file:Suppress("UNUSED_PARAMETER") + package arrow.core import io.kotest.property.checkAll diff --git a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts index dd17fa7f888..884445b8ca9 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts @@ -47,6 +47,6 @@ kotlin { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Bracket.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Bracket.kt index 3ad336a3b8a..983dc48e558 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Bracket.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Bracket.kt @@ -31,6 +31,7 @@ public sealed class ExitCase { * @see guarantee for registering a handler that is guaranteed to always run. * @see guaranteeCase for registering a handler that executes for any [ExitCase]. */ +@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") public suspend inline fun onCancel( fa: suspend () -> A, crossinline onCancel: suspend () -> Unit @@ -54,6 +55,7 @@ public suspend inline fun onCancel( * @param finalizer handler to run after [fa]. * @see guaranteeCase for registering a handler that tracks the [ExitCase] of [fa]. */ +@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") public suspend inline fun guarantee( fa: suspend () -> A, crossinline finalizer: suspend () -> Unit @@ -83,6 +85,7 @@ public suspend inline fun guarantee( * @param finalizer handler to run after [fa]. * @see guarantee for registering a handler that ignores the [ExitCase] of [fa]. */ +@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") public suspend inline fun guaranteeCase( fa: suspend () -> A, crossinline finalizer: suspend (ExitCase) -> Unit @@ -115,10 +118,10 @@ public suspend inline fun guaranteeCase( * ```kotlin * import arrow.fx.coroutines.* * - * class File(url: String) { + * class File(val url: String) { * fun open(): File = this * fun close(): Unit {} - * override fun toString(): String = "This file contains some interesting content!" + * override fun toString(): String = "This file contains some interesting content from $url!" * } * * suspend fun openFile(uri: String): File = File(uri).open() @@ -138,6 +141,7 @@ public suspend inline fun guaranteeCase( * ``` * */ +@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") public suspend inline fun bracket( crossinline acquire: suspend () -> A, use: suspend (A) -> B, @@ -191,13 +195,13 @@ public suspend inline fun bracket( * ```kotlin * import arrow.fx.coroutines.* * - * class File(url: String) { + * class File(val url: String) { * fun open(): File = this * fun close(): Unit {} * } * * suspend fun File.content(): String = - * "This file contains some interesting content!" + * "This file contains some interesting content from $url!" * suspend fun openFile(uri: String): File = File(uri).open() * suspend fun closeFile(file: File): Unit = file.close() * @@ -221,6 +225,7 @@ public suspend inline fun bracket( * ``` * */ +@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") public suspend inline fun bracketCase( crossinline acquire: suspend () -> A, use: suspend (A) -> B, diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZip.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZip.kt index aef614128b9..46a86a257bc 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZip.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZip.kt @@ -1,3 +1,5 @@ +@file:Suppress("UNCHECKED_CAST") + package arrow.fx.coroutines import kotlinx.coroutines.CoroutineScope diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZipOrAccumulate.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZipOrAccumulate.kt index 08e17606308..3a7ea2104b7 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZipOrAccumulate.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/ParZipOrAccumulate.kt @@ -14,44 +14,44 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, - crossinline f: suspend CoroutineScope.(A, B) -> C + crossinline transform: suspend CoroutineScope.(A, B) -> C ): C = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, - crossinline f: suspend CoroutineScope.(A, B) -> C + crossinline transform: suspend CoroutineScope.(A, B) -> C ): C = parZip( context, { either { fa(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fb(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b -> - Either.zipOrAccumulate(a, b) { aa, bb -> f(aa, bb) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b) { aa, bb -> transform(aa, bb) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, - crossinline f: suspend CoroutineScope.(A, B) -> C + crossinline transform: suspend CoroutineScope.(A, B) -> C ): C = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, - crossinline f: suspend CoroutineScope.(A, B) -> C + crossinline transform: suspend CoroutineScope.(A, B) -> C ): C = parZip( context, { either { fa(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fb(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b -> - Either.zipOrAccumulate(a, b) { aa, bb -> f(aa, bb) }.bind() + Either.zipOrAccumulate(a, b) { aa, bb -> transform(aa, bb) }.bind() } //endregion @@ -61,9 +61,9 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, - crossinline f: suspend CoroutineScope.(A, B, C) -> D + crossinline transform: suspend CoroutineScope.(A, B, C) -> D ): D = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -71,7 +71,7 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, - crossinline f: suspend CoroutineScope.(A, B, C) -> D + crossinline transform: suspend CoroutineScope.(A, B, C) -> D ): D = parZip( context, @@ -79,23 +79,23 @@ public suspend inline fun Raise.parZipOrAccumulate( { either { fb(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fc(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c -> - Either.zipOrAccumulate(a, b, c) { aa, bb, cc -> f(aa, bb, cc) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c) { aa, bb, cc -> transform(aa, bb, cc) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, - crossinline f: suspend CoroutineScope.(A, B, C) -> D + crossinline transform: suspend CoroutineScope.(A, B, C) -> D ): D = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate.() -> A, crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, - crossinline f: suspend CoroutineScope.(A, B, C) -> D + crossinline transform: suspend CoroutineScope.(A, B, C) -> D ): D = parZip( context, @@ -103,7 +103,7 @@ public suspend inline fun Raise>.parZipOrAccumul { either { fb(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fc(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c -> - Either.zipOrAccumulate(a, b, c) { aa, bb, cc -> f(aa, bb, cc) }.bind() + Either.zipOrAccumulate(a, b, c) { aa, bb, cc -> transform(aa, bb, cc) }.bind() } //endregion @@ -114,9 +114,9 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, - crossinline f: suspend CoroutineScope.(A, B, C, D) -> F + crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F ): F = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -125,7 +125,7 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, - crossinline f: suspend CoroutineScope.(A, B, C, D) -> F + crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F ): F = parZip( context, @@ -134,7 +134,7 @@ public suspend inline fun Raise.parZipOrAccumulate( { either { fc(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fd(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d -> - Either.zipOrAccumulate(a, b, c, d) { aa, bb, cc, dd -> f(aa, bb, cc, dd) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c, d) { aa, bb, cc, dd -> transform(aa, bb, cc, dd) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( @@ -142,9 +142,9 @@ public suspend inline fun Raise>.parZipOrAccu crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, - crossinline f: suspend CoroutineScope.(A, B, C, D) -> F + crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F ): F = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, @@ -152,7 +152,7 @@ public suspend inline fun Raise>.parZipOrAccu crossinline fb: suspend ScopedRaiseAccumulate.() -> B, crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, - crossinline f: suspend CoroutineScope.(A, B, C, D) -> F + crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F ): F = parZip( context, @@ -161,7 +161,7 @@ public suspend inline fun Raise>.parZipOrAccu { either { fc(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fd(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d -> - Either.zipOrAccumulate(a, b, c, d) { aa, bb, cc, dd -> f(aa, bb, cc, dd) }.bind() + Either.zipOrAccumulate(a, b, c, d) { aa, bb, cc, dd -> transform(aa, bb, cc, dd) }.bind() } //endregion @@ -173,9 +173,9 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, - crossinline f: suspend CoroutineScope.(A, B, C, D, F) -> G + crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G ): G = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -185,7 +185,7 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, - crossinline f: suspend CoroutineScope.(A, B, C, D, F) -> G + crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G ): G = parZip( context, @@ -195,7 +195,7 @@ public suspend inline fun Raise.parZipOrAccumulate( { either { fd(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { ff(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f -> - Either.zipOrAccumulate(a, b, c, d, f) { aa, bb, cc, dd, ff -> f(aa, bb, cc, dd, ff) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c, d, f) { aa, bb, cc, dd, ff -> transform(aa, bb, cc, dd, ff) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( @@ -204,9 +204,9 @@ public suspend inline fun Raise>.parZipOrA crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, - crossinline f: suspend CoroutineScope.(A, B, C, D, F) -> G + crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G ): G = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, @@ -215,7 +215,7 @@ public suspend inline fun Raise>.parZipOrA crossinline fc: suspend ScopedRaiseAccumulate.() -> C, crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, - crossinline f: suspend CoroutineScope.(A, B, C, D, F) -> G + crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G ): G = parZip( context, @@ -225,7 +225,7 @@ public suspend inline fun Raise>.parZipOrA { either { fd(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { ff(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f -> - Either.zipOrAccumulate(a, b, c, d, f) { aa, bb, cc, dd, ff -> f(aa, bb, cc, dd, ff) }.bind() + Either.zipOrAccumulate(a, b, c, d, f) { aa, bb, cc, dd, ff -> transform(aa, bb, cc, dd, ff) }.bind() } //endregion @@ -238,9 +238,9 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G) -> H + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H ): H = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -251,7 +251,7 @@ public suspend inline fun Raise.parZipOrAccumulate( crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G) -> H + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H ): H = parZip( context, @@ -262,7 +262,7 @@ public suspend inline fun Raise.parZipOrAccumulate( { either { ff(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fg(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f, g -> - Either.zipOrAccumulate(a, b, c, d, f, g) { aa, bb, cc, dd, ff, gg -> f(aa, bb, cc, dd, ff, gg) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c, d, f, g) { aa, bb, cc, dd, ff, gg -> transform(aa, bb, cc, dd, ff, gg) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( @@ -272,9 +272,9 @@ public suspend inline fun Raise>.parZip crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G) -> H + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H ): H = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, @@ -284,7 +284,7 @@ public suspend inline fun Raise>.parZip crossinline fd: suspend ScopedRaiseAccumulate.() -> D, crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G) -> H + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H ): H = parZip( context, @@ -295,7 +295,7 @@ public suspend inline fun Raise>.parZip { either { ff(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fg(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f, g -> - Either.zipOrAccumulate(a, b, c, d, f, g) { aa, bb, cc, dd, ff, gg -> f(aa, bb, cc, dd, ff, gg) }.bind() + Either.zipOrAccumulate(a, b, c, d, f, g) { aa, bb, cc, dd, ff, gg -> transform(aa, bb, cc, dd, ff, gg) }.bind() } //endregion @@ -309,9 +309,9 @@ public suspend inline fun Raise.parZipOrAccumulat crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I ): I = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, fh, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, fh, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -323,7 +323,7 @@ public suspend inline fun Raise.parZipOrAccumulat crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I ): I = parZip( context, @@ -335,7 +335,7 @@ public suspend inline fun Raise.parZipOrAccumulat { either { fg(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fh(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f, g, h -> - Either.zipOrAccumulate(a, b, c, d, f, g, h) { aa, bb, cc, dd, ff, gg, hh -> f(aa, bb, cc, dd, ff, gg, hh) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c, d, f, g, h) { aa, bb, cc, dd, ff, gg, hh -> transform(aa, bb, cc, dd, ff, gg, hh) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( @@ -346,9 +346,9 @@ public suspend inline fun Raise>.par crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I ): I = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, fh, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, fh, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, @@ -359,7 +359,7 @@ public suspend inline fun Raise>.par crossinline ff: suspend ScopedRaiseAccumulate.() -> F, crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I ): I = parZip( context, @@ -371,7 +371,7 @@ public suspend inline fun Raise>.par { either { fg(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fh(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f, g, h -> - Either.zipOrAccumulate(a, b, c, d, f, g, h) { aa, bb, cc, dd, ff, gg, hh -> f(aa, bb, cc, dd, ff, gg, hh) }.bind() + Either.zipOrAccumulate(a, b, c, d, f, g, h) { aa, bb, cc, dd, ff, gg, hh -> transform(aa, bb, cc, dd, ff, gg, hh) }.bind() } //endregion @@ -386,9 +386,9 @@ public suspend inline fun Raise.parZipOrAccumu crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J ): J = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, fh, fi, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, fh, fi, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -401,7 +401,7 @@ public suspend inline fun Raise.parZipOrAccumu crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J ): J = parZip( context, @@ -414,7 +414,7 @@ public suspend inline fun Raise.parZipOrAccumu { either { fh(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fi(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f, g, h, i -> - Either.zipOrAccumulate(a, b, c, d, f, g, h, i) { aa, bb, cc, dd, ff, gg, hh, ii -> f(aa, bb, cc, dd, ff, gg, hh, ii) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c, d, f, g, h, i) { aa, bb, cc, dd, ff, gg, hh, ii -> transform(aa, bb, cc, dd, ff, gg, hh, ii) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( @@ -426,9 +426,9 @@ public suspend inline fun Raise>. crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J ): J = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, fh, fi, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, fh, fi, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, @@ -440,7 +440,7 @@ public suspend inline fun Raise>. crossinline fg: suspend ScopedRaiseAccumulate.() -> G, crossinline fh: suspend ScopedRaiseAccumulate.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J ): J = parZip( context, @@ -453,7 +453,7 @@ public suspend inline fun Raise>. { either { fh(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fi(ScopedRaiseAccumulate(this, this@parZip)) } }, ) { a, b, c, d, f, g, h, i -> - Either.zipOrAccumulate(a, b, c, d, f, g, h, i) { aa, bb, cc, dd, ff, gg, hh, ii -> f(aa, bb, cc, dd, ff, gg, hh, ii) }.bind() + Either.zipOrAccumulate(a, b, c, d, f, g, h, i) { aa, bb, cc, dd, ff, gg, hh, ii -> transform(aa, bb, cc, dd, ff, gg, hh, ii) }.bind() } //endregion @@ -469,9 +469,9 @@ public suspend inline fun Raise.parZipOrAcc crossinline fh: suspend ScopedRaiseAccumulate.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, crossinline fj: suspend ScopedRaiseAccumulate.() -> J, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K ): K = - parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, fh, fi, fj, f) + parZipOrAccumulate(EmptyCoroutineContext, combine, fa, fb, fc, fd, ff, fg, fh, fi, fj, transform) public suspend inline fun Raise.parZipOrAccumulate( context: CoroutineContext, @@ -485,7 +485,7 @@ public suspend inline fun Raise.parZipOrAcc crossinline fh: suspend ScopedRaiseAccumulate.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, crossinline fj: suspend ScopedRaiseAccumulate.() -> J, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K ): K = parZip( context, @@ -499,7 +499,7 @@ public suspend inline fun Raise.parZipOrAcc { either { fi(ScopedRaiseAccumulate(this, this@parZip)) } }, { either { fj(ScopedRaiseAccumulate(this, this@parZip)) } } ) { a, b, c, d, f, g, h, i, j -> - Either.zipOrAccumulate(a, b, c, d, f, g, h, i, j) { aa, bb, cc, dd, ff, gg, hh, ii, jj -> f(aa, bb, cc, dd, ff, gg, hh, ii, jj) }.getOrElse { raise(it.reduce(combine)) } + Either.zipOrAccumulate(a, b, c, d, f, g, h, i, j) { aa, bb, cc, dd, ff, gg, hh, ii, jj -> transform(aa, bb, cc, dd, ff, gg, hh, ii, jj) }.getOrElse { raise(it.reduce(combine)) } } public suspend inline fun Raise>.parZipOrAccumulate( @@ -512,9 +512,9 @@ public suspend inline fun Raise.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, crossinline fj: suspend ScopedRaiseAccumulate.() -> J, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K ): K = - parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, fh, fi, fj, f) + parZipOrAccumulate(EmptyCoroutineContext, fa, fb, fc, fd, ff, fg, fh, fi, fj, transform) public suspend inline fun Raise>.parZipOrAccumulate( context: CoroutineContext, @@ -527,7 +527,7 @@ public suspend inline fun Raise.() -> H, crossinline fi: suspend ScopedRaiseAccumulate.() -> I, crossinline fj: suspend ScopedRaiseAccumulate.() -> J, - crossinline f: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K + crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K ): K = parZip( context, @@ -541,6 +541,6 @@ public suspend inline fun Raise - Either.zipOrAccumulate(a, b, c, d, f, g, h, i, j) { aa, bb, cc, dd, ff, gg, hh, ii, jj -> f(aa, bb, cc, dd, ff, gg, hh, ii, jj) }.bind() + Either.zipOrAccumulate(a, b, c, d, f, g, h, i, j) { aa, bb, cc, dd, ff, gg, hh, ii, jj -> transform(aa, bb, cc, dd, ff, gg, hh, ii, jj) }.bind() } //endregion diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CyclicBarrierSpec.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CyclicBarrierSpec.kt index 42202887750..64cbc6769b1 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CyclicBarrierSpec.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/CyclicBarrierSpec.kt @@ -140,7 +140,7 @@ class CyclicBarrierSpec { val jobs = (0 until n - 1).map { i -> launch(start = CoroutineStart.UNDISPATCHED) { - guaranteeCase(barrier::await, exits[i]::complete) + guaranteeCase({ barrier.await() }, exits[i]::complete) } } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt index 887dc41a809..b36b6e8bf3e 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExecutorCoroutineDispatcher +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.newFixedThreadPoolContext import kotlinx.coroutines.newSingleThreadContext @@ -151,7 +152,7 @@ public fun autoCloseable( * ``` * */ -@OptIn(DelicateCoroutinesApi::class) +@OptIn(DelicateCoroutinesApi::class, ExperimentalCoroutinesApi::class) @ResourceDSL public suspend fun ResourceScope.singleThreadContext(name: String): ExecutorCoroutineDispatcher = closeable { newSingleThreadContext(name) } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-01.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-01.kt index ecec44ced00..5ccc4eeb503 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-01.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-01.kt @@ -3,10 +3,10 @@ package arrow.fx.coroutines.examples.exampleBracket01 import arrow.fx.coroutines.* -class File(url: String) { +class File(val url: String) { fun open(): File = this fun close(): Unit {} - override fun toString(): String = "This file contains some interesting content!" + override fun toString(): String = "This file contains some interesting content from $url!" } suspend fun openFile(uri: String): File = File(uri).open() diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-02.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-02.kt index dfa4131c13e..d16d7ca953d 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-02.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-bracket-02.kt @@ -3,13 +3,13 @@ package arrow.fx.coroutines.examples.exampleBracket02 import arrow.fx.coroutines.* -class File(url: String) { +class File(val url: String) { fun open(): File = this fun close(): Unit {} } suspend fun File.content(): String = - "This file contains some interesting content!" + "This file contains some interesting content from $url!" suspend fun openFile(uri: String): File = File(uri).open() suspend fun closeFile(file: File): Unit = file.close() diff --git a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts index 22f7eff35a7..a44b7d98dbf 100644 --- a/arrow-libs/fx/arrow-fx-stm/build.gradle.kts +++ b/arrow-libs/fx/arrow-fx-stm/build.gradle.kts @@ -1,5 +1,8 @@ @file:Suppress("DSL_SCOPE_VIOLATION") +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + + plugins { id(libs.plugins.kotlin.multiplatform.get().pluginId) alias(libs.plugins.arrowGradleConfig.kotlin) @@ -45,6 +48,10 @@ kotlin { } } -tasks.withType { +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" +} + +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/STM.kt b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/STM.kt index 895be245622..95a93ae33c2 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/STM.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/STM.kt @@ -250,7 +250,7 @@ public interface STM { * suspend fun main() { * //sampleStart * val result = atomically { - * catch({ throw Throwable() }) { e -> "caught" } + * catch({ throw Throwable() }) { _ -> "caught" } * } * //sampleEnd * println("Result $result") @@ -1202,6 +1202,7 @@ public interface STM { * tarr.transform { it + 1 } * } * //sampleEnd + * println("Result $result") * } * ``` * @@ -1538,6 +1539,7 @@ public interface STM { * * Equal to [suspend] just with an [STM] receiver. */ +@Suppress("NOTHING_TO_INLINE") public inline fun stm(noinline f: STM.() -> A): STM.() -> A = f /** diff --git a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TArray.kt b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TArray.kt index 0aa446ecd67..5cb8024f3bc 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TArray.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TArray.kt @@ -86,6 +86,7 @@ public fun STM.newTArray(xs: Iterable): TArray = * tarr.transform { it + 1 } * } * //sampleEnd + * println("Result $result") * } * ``` * diff --git a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TVar.kt b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TVar.kt index f1ced7f5779..195c6b9f99e 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TVar.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/TVar.kt @@ -166,6 +166,7 @@ public class TVar internal constructor(a: A) { * Internal unsafe (non-suspend) version of read. Used by various other internals and [unsafeRead] to * read the current value respecting its state. */ + @Suppress("UNCHECKED_CAST") internal fun readI(): A { while (true) { ref.value.let { a -> diff --git a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Hamt.kt b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Hamt.kt index 7ee918fdc38..d045ed617f3 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Hamt.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Hamt.kt @@ -1,3 +1,5 @@ +@file:Suppress("UNCHECKED_CAST") + package arrow.fx.stm.internal import arrow.fx.stm.TVar @@ -22,7 +24,7 @@ public inline fun STM.lookupHamtWithHash(hmt: Hamt, hash: Int, test: (A) val branches = hamt.branches.read() when (val branch = branches[branchInd]) { null -> return null - is Branch.Leaf -> return@lookupHamtWithHash (branch.value as Array).find(test) + is Branch.Leaf -> return (branch.value as Array).find(test) is Branch.Branches -> { depth = depth.nextDepth() hamt = branch.sub diff --git a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Impl.kt b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Impl.kt index dce1120b864..211d58b8041 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Impl.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/commonMain/kotlin/arrow/fx/stm/internal/Impl.kt @@ -1,3 +1,5 @@ +@file:Suppress("UNCHECKED_CAST") + package arrow.fx.stm.internal import arrow.atomic.Atomic @@ -11,17 +13,17 @@ import kotlin.coroutines.Continuation * A STMFrame keeps the reads and writes performed by a transaction. * It may have a parent which is only used for read lookups. */ -internal class STMFrame(val parent: STMFrame? = null) : STM { +internal class STMFrame(private val parent: STMFrame? = null) : STM { class Entry(var initialVal: Any?, var newVal: Any?) { - object NO_CHANGE - object NOT_PRESENT + object NoChange + object NotPresent fun isWrite(): Boolean = - newVal !== NO_CHANGE + newVal !== NoChange - fun update(v: Any?): Unit { - newVal = if (initialVal === v) NO_CHANGE else v + fun update(v: Any?) { + newVal = if (initialVal === v) NoChange else v } fun getValue(): Any? = if (isWrite()) newVal else initialVal @@ -32,8 +34,8 @@ internal class STMFrame(val parent: STMFrame? = null) : STM { /** * Helper to search the entire hierarchy for stored previous reads */ - private fun readVar(v: TVar): Any? = - accessMap[v]?.getValue() ?: parent?.readVar(v) ?: Entry.NOT_PRESENT + private fun readVar(v: TVar): Any = + accessMap[v]?.getValue() ?: parent?.readVar(v) ?: Entry.NotPresent override fun retry(): Nothing = throw RetryException @@ -57,18 +59,18 @@ internal class STMFrame(val parent: STMFrame? = null) : STM { // If we are already invalid here there is no point in continuing. if (frame.validate()) { this@STMFrame.merge(frame) - return@runLocal res as A + return res } } catch (ignored: RetryException) { if (frame.validate()) { this@STMFrame.mergeReads(frame) - return@runLocal onRetry() + return onRetry() } } catch (e: Throwable) { // An invalid frame retries even if it throws, so our sub-frame also needs to handle this correctly if (frame.validate()) { this@STMFrame.mergeReads(frame) - return@runLocal onError(e) + return onError(e) } } } @@ -79,7 +81,7 @@ internal class STMFrame(val parent: STMFrame? = null) : STM { */ override fun TVar.read(): A = when (val r = readVar(this as TVar)) { - Entry.NOT_PRESENT -> readI().also { accessMap[this] = Entry(it, Entry.NO_CHANGE) } + Entry.NotPresent -> readI().also { accessMap[this] = Entry(it, Entry.NoChange) } else -> r as A } @@ -140,11 +142,11 @@ internal class STMFrame(val parent: STMFrame? = null) : STM { return true } - private fun mergeReads(other: STMFrame): Unit { + private fun mergeReads(other: STMFrame) { accessMap.putAll(other.accessMap.filter { (_, e) -> e.isWrite().not() }) } - private fun merge(other: STMFrame): Unit { + private fun merge(other: STMFrame) { accessMap.putAll(other.accessMap) } } @@ -184,12 +186,12 @@ internal class STMTransaction(val f: STM.() -> A) { try { val res = frame.f() - if (frame.validateAndCommit()) return@commit res + if (frame.validateAndCommit()) return res } catch (ignored: RetryException) { if (frame.accessMap.isEmpty()) throw BlockedIndefinitely() val registered = mutableListOf>() - suspendCancellableCoroutine susp@{ k -> + suspendCancellableCoroutine susp@{ k -> cont.value = k frame.accessMap diff --git a/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-06.kt b/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-06.kt index 8c59628188e..fdd248d9144 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-06.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-06.kt @@ -6,7 +6,7 @@ import arrow.fx.stm.atomically suspend fun main() { //sampleStart val result = atomically { - catch({ throw Throwable() }) { e -> "caught" } + catch({ throw Throwable() }) { _ -> "caught" } } //sampleEnd println("Result $result") diff --git a/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-41.kt b/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-41.kt index 1f2ef07826f..6402fe8de66 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-41.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-41.kt @@ -11,4 +11,5 @@ suspend fun main() { tarr.transform { it + 1 } } //sampleEnd + println("Result $result") } diff --git a/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-04.kt b/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-04.kt index 5af06152e32..6e2bb9b5e56 100644 --- a/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-04.kt +++ b/arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-04.kt @@ -11,4 +11,5 @@ suspend fun main() { tarr.transform { it + 1 } } //sampleEnd + println("Result $result") } diff --git a/arrow-libs/optics/arrow-optics-ksp-plugin/build.gradle.kts b/arrow-libs/optics/arrow-optics-ksp-plugin/build.gradle.kts index cff4ecbb9e3..fc49da7d902 100644 --- a/arrow-libs/optics/arrow-optics-ksp-plugin/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics-ksp-plugin/build.gradle.kts @@ -44,7 +44,7 @@ dependencies { testRuntimeOnly(projects.arrowOptics) } -tasks.withType { +tasks.withType().configureEach { maxParallelForks = 1 useJUnitPlatform() } diff --git a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts index 202c9d680e7..34c9a211738 100644 --- a/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics-reflect/build.gradle.kts @@ -36,6 +36,6 @@ tasks.jar { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/optics/arrow-optics/build.gradle.kts b/arrow-libs/optics/arrow-optics/build.gradle.kts index e7a2843075a..04f76a9e3e5 100644 --- a/arrow-libs/optics/arrow-optics/build.gradle.kts +++ b/arrow-libs/optics/arrow-optics/build.gradle.kts @@ -61,6 +61,6 @@ kotlin { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Optional.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Optional.kt index 2557601ed5c..068f82cd1e2 100644 --- a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Optional.kt +++ b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/Optional.kt @@ -38,10 +38,10 @@ public fun Optional(getOption: (source: S) -> Option, set: (source: S, * } * } * - * fun main(args: Array) { + * fun main() { * val original = User("arrow-user", None) * val set = User.email.set(original, "arRoW-UsEr@arrow-Kt.IO") - * val modified = User.email.modify(set, String::toLowerCase) + * val modified = User.email.modify(set, String::lowercase) * println("original: $original, set: $set, modified: $modified") * } * ``` 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 56a97dd0d4a..dd37b22dd59 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 @@ -195,11 +195,11 @@ public interface PTraversal { set: (B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = - combine(f(get1(s)), f(get2(s))) + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = + combine(map(get1(source)), map(get2(source))) - override fun modify(s: S, transform: (focus: A) -> B): T = - set(transform(get1(s)), transform(get2(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), source) } public operator fun invoke( @@ -209,11 +209,11 @@ public interface PTraversal { set: (B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = - combine(combine(f(get1(s)), f(get2(s))), f(get3(s))) + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = + combine(combine(map(get1(source)), map(get2(source))), map(get3(source))) - override fun modify(s: S, f: (focus: A) -> B): T = - set(f(get1(s)), f(get2(s)), f(get3(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), map(get3(source)), source) } public operator fun invoke( @@ -224,11 +224,11 @@ public interface PTraversal { set: (B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = - combine(combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), f(get4(s))) + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = + combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get4(source))) - override fun modify(s: S, f: (focus: A) -> B): T = - set(f(get1(s)), f(get2(s)), f(get3(s)), f(get4(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), source) } public operator fun invoke( @@ -240,11 +240,11 @@ public interface PTraversal { set: (B, B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = - combine(combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), f(get5(s))) + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = + combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))) - override fun modify(s: S, f: (focus: A) -> B): T = - set(f(get1(s)), f(get2(s)), f(get3(s)), f(get4(s)), f(get5(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), map(get5(source)), source) } public operator fun invoke( @@ -257,11 +257,11 @@ public interface PTraversal { set: (B, B, B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = - combine(combine(combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), f(get5(s))), f(get6(s))) + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = + combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))), map(get6(source))) - override fun modify(s: S, f: (focus: A) -> B): T = - set(f(get1(s)), f(get2(s)), f(get3(s)), f(get4(s)), f(get5(s)), f(get6(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), map(get5(source)), map(get6(source)), source) } public operator fun invoke( @@ -275,14 +275,14 @@ public interface PTraversal { set: (B, B, B, B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = combine( - combine(combine(combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), f(get5(s))), f(get6(s))), - f(get7(s)) + combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))), map(get6(source))), + map(get7(source)) ) - override fun modify(s: S, f: (focus: A) -> B): T = - set(f(get1(s)), f(get2(s)), f(get3(s)), f(get4(s)), f(get5(s)), f(get6(s)), f(get7(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), map(get5(source)), map(get6(source)), map(get7(source)), source) } public operator fun invoke( @@ -297,18 +297,18 @@ public interface PTraversal { set: (B, B, B, B, B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = combine( combine( combine( - combine(combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), f(get5(s))), - f(get6(s)) - ), f(get7(s)) - ), f(get8(s)) + combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))), + map(get6(source)) + ), map(get7(source)) + ), map(get8(source)) ) - override fun modify(s: S, f: (focus: A) -> B): T = - set(f(get1(s)), f(get2(s)), f(get3(s)), f(get4(s)), f(get5(s)), f(get6(s)), f(get7(s)), f(get8(s)), s) + override fun modify(source: S, map: (focus: A) -> B): T = + set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), map(get5(source)), map(get6(source)), map(get7(source)), map(get8(source)), source) } public operator fun invoke( @@ -324,30 +324,30 @@ public interface PTraversal { set: (B, B, B, B, B, B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = combine( combine( combine( combine( - combine(combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), f(get5(s))), - f(get6(s)) - ), f(get7(s)) - ), f(get8(s)) - ), f(get9(s)) + combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))), + map(get6(source)) + ), map(get7(source)) + ), map(get8(source)) + ), map(get9(source)) ) - override fun modify(s: S, f: (focus: A) -> B): T = + override fun modify(source: S, map: (focus: A) -> B): T = set( - f(get1(s)), - f(get2(s)), - f(get3(s)), - f(get4(s)), - f(get5(s)), - f(get6(s)), - f(get7(s)), - f(get8(s)), - f(get9(s)), - s + map(get1(source)), + map(get2(source)), + map(get3(source)), + map(get4(source)), + map(get5(source)), + map(get6(source)), + map(get7(source)), + map(get8(source)), + map(get9(source)), + source ) } @@ -365,35 +365,35 @@ public interface PTraversal { set: (B, B, B, B, B, B, B, B, B, B, S) -> T ): PTraversal = object : PTraversal { - override fun foldMap(initial: R, combine: (R, R) -> R, s: S, f: (focus: A) -> R): R = + override fun foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R = combine( combine( combine( combine( combine( combine( - combine(combine(f(get1(s)), f(get2(s))), f(get3(s))), - f(get5(s)) - ), f(get6(s)) - ), f(get7(s)) - ), f(get8(s)) - ), f(get9(s)) - ), f(get10(s)) + combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), + map(get5(source)) + ), map(get6(source)) + ), map(get7(source)) + ), map(get8(source)) + ), map(get9(source)) + ), map(get10(source)) ) - override fun modify(s: S, f: (focus: A) -> B): T = + override fun modify(source: S, map: (focus: A) -> B): T = set( - f(get1(s)), - f(get2(s)), - f(get3(s)), - f(get4(s)), - f(get5(s)), - f(get6(s)), - f(get7(s)), - f(get8(s)), - f(get9(s)), - f(get10(s)), - s + map(get1(source)), + map(get2(source)), + map(get3(source)), + map(get4(source)), + map(get5(source)), + map(get6(source)), + map(get7(source)), + map(get8(source)), + map(get9(source)), + map(get10(source)), + source ) } diff --git a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/predef.kt b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/predef.kt index 12164872f23..1887aec247b 100644 --- a/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/predef.kt +++ b/arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/predef.kt @@ -2,7 +2,7 @@ package arrow.optics @Suppress("ClassName") internal object EMPTY_VALUE { - @Suppress("UNCHECKED_CAST") + @Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE") inline fun unbox(value: Any?): T = if (value === this) null as T else value as T } diff --git a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/examples/example-optional-01.kt b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/examples/example-optional-01.kt index f9d299003a7..5cd0e6feab2 100644 --- a/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/examples/example-optional-01.kt +++ b/arrow-libs/optics/arrow-optics/src/commonTest/kotlin/examples/example-optional-01.kt @@ -15,9 +15,9 @@ data class User(val username: String, val email: Option) { } } -fun main(args: Array) { +fun main() { val original = User("arrow-user", None) val set = User.email.set(original, "arRoW-UsEr@arrow-Kt.IO") - val modified = User.email.modify(set, String::toLowerCase) + val modified = User.email.modify(set, String::lowercase) println("original: $original, set: $set, modified: $modified") } diff --git a/arrow-libs/resilience/arrow-resilience/build.gradle.kts b/arrow-libs/resilience/arrow-resilience/build.gradle.kts index 4517c8504a9..678b74b3a37 100644 --- a/arrow-libs/resilience/arrow-resilience/build.gradle.kts +++ b/arrow-libs/resilience/arrow-resilience/build.gradle.kts @@ -41,6 +41,6 @@ kotlin { } } -tasks.withType { +tasks.withType().configureEach { useJUnitPlatform() } diff --git a/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/Saga.kt b/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/Saga.kt index c4a427b5927..c38831bdd0a 100644 --- a/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/Saga.kt +++ b/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/Saga.kt @@ -84,6 +84,7 @@ public interface SagaScope { * By doing so we can guarantee that any transactional like operations made by the [Saga] will * guarantee that it results in the correct state. */ +@Suppress("NOTHING_TO_INLINE") public inline fun saga(noinline block: suspend SagaScope.() -> A): Saga = block /** Create a lazy [Saga] that will only run when the [Saga] is invoked. */ diff --git a/arrow-libs/stack/build.gradle.kts b/arrow-libs/stack/build.gradle.kts index 4ef59eb748a..e1d70965c07 100644 --- a/arrow-libs/stack/build.gradle.kts +++ b/arrow-libs/stack/build.gradle.kts @@ -15,6 +15,7 @@ dependencies { api("io.arrow-kt:arrow-core:$version") api("io.arrow-kt:arrow-functions:$version") api("io.arrow-kt:arrow-core-retrofit:$version") + api("io.arrow-kt:arrow-core-serialization:$version") api("io.arrow-kt:arrow-fx-coroutines:$version") api("io.arrow-kt:arrow-fx-stm:$version") api("io.arrow-kt:arrow-resilience:$version")