From 2ce596f9d861959a7001d1a81b17ac029adf9aa9 Mon Sep 17 00:00:00 2001 From: i-walker <46971368+i-walker@users.noreply.github.com> Date: Mon, 23 May 2022 14:05:15 +0200 Subject: [PATCH 1/2] deprecate flatMap and map in EagerEffect --- .../commonMain/kotlin/arrow/core/continuations/EagerEffect.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt index b140456c51a..5fa0bdfbe91 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt @@ -94,8 +94,10 @@ public interface EagerEffect { public fun toOption(orElse: (R) -> Option): Option = fold(orElse, ::Some) + @Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("flatMap { a -> eagerEffect { f(a) } }")) public fun map(f: (A) -> B): EagerEffect = flatMap { a -> eagerEffect { f(a) } } + @Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("eagerEffect { f(bind()).bind() }")) public fun flatMap(f: (A) -> EagerEffect): EagerEffect = eagerEffect { f(bind()).bind() } @@ -195,3 +197,5 @@ public inline fun eagerEffect(crossinline f: suspend EagerEffectScope. } } } + +private const val deprecateMonadAppFunctorOperators: String = "Operators related to Functor, Applicative or Monad hierarchies are being deprecated in favor of bind" From f58a19406d1473928e3954b76e8b0fed4aeae399 Mon Sep 17 00:00:00 2001 From: i-walker <46971368+i-walker@users.noreply.github.com> Date: Mon, 23 May 2022 14:14:04 +0200 Subject: [PATCH 2/2] improve replaceWith --- .../commonMain/kotlin/arrow/core/continuations/EagerEffect.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt index 5fa0bdfbe91..38ff2e82679 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/EagerEffect.kt @@ -94,10 +94,10 @@ public interface EagerEffect { public fun toOption(orElse: (R) -> Option): Option = fold(orElse, ::Some) - @Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("flatMap { a -> eagerEffect { f(a) } }")) + @Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("flatMap { eagerEffect { f(it) } }")) public fun map(f: (A) -> B): EagerEffect = flatMap { a -> eagerEffect { f(a) } } - @Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("eagerEffect { f(bind()).bind() }")) + @Deprecated(deprecateMonadAppFunctorOperators) public fun flatMap(f: (A) -> EagerEffect): EagerEffect = eagerEffect { f(bind()).bind() }