From 4562d1f0dc6371b0441ee6e58c7a00b210ee711d Mon Sep 17 00:00:00 2001 From: Imran Malic Settuba <46971368+i-walker@users.noreply.github.com> Date: Wed, 25 May 2022 10:13:09 +0200 Subject: [PATCH] deprecate flatMap and map in EagerEffect (#2726) * deprecate flatMap and map in EagerEffect * improve replaceWith --- .../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 6af3702ba07..557b398e672 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<@UnsafeVariance A>): Option = fold(orElse, ::Some) + @Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("flatMap { eagerEffect { f(it) } }")) public fun map(f: (A) -> B): EagerEffect = flatMap { a -> eagerEffect { f(a) } } + @Deprecated(deprecateMonadAppFunctorOperators) public fun flatMap(f: (A) -> EagerEffect<@UnsafeVariance R, B>): 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"