From 5942385e219c9a5aa6b8515885416e439841ee83 Mon Sep 17 00:00:00 2001 From: Pavlos Tzegiannakis Date: Tue, 10 Dec 2024 18:37:11 +0200 Subject: [PATCH 1/2] Add inline modifier in handleErrorWith function --- .../arrow-core/src/commonMain/kotlin/arrow/core/Either.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 7395908927..7d6f69ad69 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 @@ -1309,7 +1309,7 @@ public inline fun Either.flatMap(f: (right: B) -> Either): * * @param f The function to bind across [Left]. */ -public fun Either.handleErrorWith(f: (A) -> Either): Either { +public inline fun Either.handleErrorWith(f: (A) -> Either): Either { contract { callsInPlace(f, InvocationKind.AT_MOST_ONCE) } return when (this) { is Left -> f(this.value) @@ -1338,7 +1338,7 @@ public fun Either>.flatten(): Either = */ public inline infix fun Either.getOrElse(default: (A) -> B): B { contract { callsInPlace(default, InvocationKind.AT_MOST_ONCE) } - return when(this) { + return when (this) { is Left -> default(this.value) is Right -> this.value } From 91c2527ee42a3c7b70d83f5f21b3761e4be3a2e7 Mon Sep 17 00:00:00 2001 From: Pavlos Tzegiannakis Date: Wed, 11 Dec 2024 11:22:34 +0200 Subject: [PATCH 2/2] Fix after apiDump --- arrow-libs/core/arrow-core/api/arrow-core.klib.api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrow-libs/core/arrow-core/api/arrow-core.klib.api b/arrow-libs/core/arrow-core/api/arrow-core.klib.api index 59815911b2..d6c41037b1 100644 --- a/arrow-libs/core/arrow-core/api/arrow-core.klib.api +++ b/arrow-libs/core/arrow-core/api/arrow-core.klib.api @@ -729,7 +729,6 @@ final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotlin/Any?> ( final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotlin/Any?> (kotlin.collections/Map<#A, #B>).arrow.core/padZip(kotlin.collections/Map<#A, #C>, kotlin/Function3<#A, #B?, #C?, #D>): kotlin.collections/Map<#A, #D> // arrow.core/padZip|padZip@kotlin.collections.Map<0:0,0:1>(kotlin.collections.Map<0:0,0:2>;kotlin.Function3<0:0,0:1?,0:2?,0:3>){0§;1§;2§;3§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotlin/Any?> (kotlin.sequences/Sequence<#A>).arrow.core/zip(kotlin.sequences/Sequence<#B>, kotlin.sequences/Sequence<#C>, kotlin/Function3<#A, #B, #C, #D>): kotlin.sequences/Sequence<#D> // arrow.core/zip|zip@kotlin.sequences.Sequence<0:0>(kotlin.sequences.Sequence<0:1>;kotlin.sequences.Sequence<0:2>;kotlin.Function3<0:0,0:1,0:2,0:3>){0§;1§;2§;3§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotlin/Any?> (kotlin/Triple<#A, #B, #C>).arrow.core/plus(#D): arrow.core/Tuple4<#A, #B, #C, #D> // arrow.core/plus|plus@kotlin.Triple<0:0,0:1,0:2>(0:3){0§;1§;2§;3§}[0] -final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core/Either<#A, #B>).arrow.core/handleErrorWith(kotlin/Function1<#A, arrow.core/Either<#C, #B>>): arrow.core/Either<#C, #B> // arrow.core/handleErrorWith|handleErrorWith@arrow.core.Either<0:0,0:1>(kotlin.Function1<0:0,arrow.core.Either<0:2,0:1>>){0§;1§;2§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (kotlin.collections/Iterable<#A>).arrow.core/crosswalkMap(kotlin/Function1<#A, kotlin.collections/Map<#B, #C>>): kotlin.collections/Map<#B, kotlin.collections/List<#C>> // arrow.core/crosswalkMap|crosswalkMap@kotlin.collections.Iterable<0:0>(kotlin.Function1<0:0,kotlin.collections.Map<0:1,0:2>>){0§;1§;2§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (kotlin.collections/Map<#A, #B>).arrow.core/align(kotlin.collections/Map<#A, #C>): kotlin.collections/Map<#A, arrow.core/Ior<#B, #C>> // arrow.core/align|align@kotlin.collections.Map<0:0,0:1>(kotlin.collections.Map<0:0,0:2>){0§;1§;2§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (kotlin.collections/Map<#A, #B>).arrow.core/flatMapValues(kotlin/Function1, kotlin.collections/Map<#A, #C>>): kotlin.collections/Map<#A, #C> // arrow.core/flatMapValues|flatMapValues@kotlin.collections.Map<0:0,0:1>(kotlin.Function1,kotlin.collections.Map<0:0,0:2>>){0§;1§;2§}[0] @@ -920,6 +919,7 @@ final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core.raise/Raise>).arrow.core.raise/mapOrAccumulate(kotlin.collections/Iterable<#B>, kotlin/Function2, #B, #C>): kotlin.collections/List<#C> // arrow.core.raise/mapOrAccumulate|mapOrAccumulate@arrow.core.raise.Raise>(kotlin.collections.Iterable<0:1>;kotlin.Function2,0:1,0:2>){0§;1§;2§}[0] final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core.raise/Raise>).arrow.core.raise/mapOrAccumulate(kotlin.sequences/Sequence<#B>, kotlin/Function2, #B, #C>): kotlin.collections/List<#C> // arrow.core.raise/mapOrAccumulate|mapOrAccumulate@arrow.core.raise.Raise>(kotlin.sequences.Sequence<0:1>;kotlin.Function2,0:1,0:2>){0§;1§;2§}[0] final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core/Either<#A, #B>).arrow.core/flatMap(kotlin/Function1<#B, arrow.core/Either<#A, #C>>): arrow.core/Either<#A, #C> // arrow.core/flatMap|flatMap@arrow.core.Either<0:0,0:1>(kotlin.Function1<0:1,arrow.core.Either<0:0,0:2>>){0§;1§;2§}[0] +final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core/Either<#A, #B>).arrow.core/handleErrorWith(kotlin/Function1<#A, arrow.core/Either<#C, #B>>): arrow.core/Either<#C, #B> // arrow.core/handleErrorWith|handleErrorWith@arrow.core.Either<0:0,0:1>(kotlin.Function1<0:0,arrow.core.Either<0:2,0:1>>){0§;1§;2§}[0] final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core/Either<#A, #C>).arrow.core/recover(kotlin/Function2, #A, #C>): arrow.core/Either<#B, #C> // arrow.core/recover|recover@arrow.core.Either<0:0,0:2>(kotlin.Function2,0:0,0:2>){0§;1§;2§}[0] final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core/Ior<#A, #B>).arrow.core/flatMap(kotlin/Function2<#A, #A, #A>, kotlin/Function1<#B, arrow.core/Ior<#A, #C>>): arrow.core/Ior<#A, #C> // arrow.core/flatMap|flatMap@arrow.core.Ior<0:0,0:1>(kotlin.Function2<0:0,0:0,0:0>;kotlin.Function1<0:1,arrow.core.Ior<0:0,0:2>>){0§;1§;2§}[0] final inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.core/Ior<#A, #B>).arrow.core/handleErrorWith(kotlin/Function2<#B, #B, #B>, kotlin/Function1<#A, arrow.core/Ior<#C, #B>>): arrow.core/Ior<#C, #B> // arrow.core/handleErrorWith|handleErrorWith@arrow.core.Ior<0:0,0:1>(kotlin.Function2<0:1,0:1,0:1>;kotlin.Function1<0:0,arrow.core.Ior<0:2,0:1>>){0§;1§;2§}[0]