Skip to content

Commit

Permalink
deprecate flatMap and map in EagerEffect (#2726)
Browse files Browse the repository at this point in the history
* deprecate flatMap and map in EagerEffect

* improve replaceWith
  • Loading branch information
i-walker authored May 25, 2022
1 parent dfe0bae commit 4562d1f
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ public interface EagerEffect<out R, out A> {
public fun toOption(orElse: (R) -> Option<@UnsafeVariance A>): Option<A> =
fold(orElse, ::Some)

@Deprecated(deprecateMonadAppFunctorOperators, ReplaceWith("flatMap { eagerEffect { f(it) } }"))
public fun <B> map(f: (A) -> B): EagerEffect<R, B> = flatMap { a -> eagerEffect { f(a) } }

@Deprecated(deprecateMonadAppFunctorOperators)
public fun <B> flatMap(f: (A) -> EagerEffect<@UnsafeVariance R, B>): EagerEffect<R, B> = eagerEffect {
f(bind()).bind()
}
Expand Down Expand Up @@ -195,3 +197,5 @@ public inline fun <R, A> eagerEffect(crossinline f: suspend EagerEffectScope<R>.
}
}
}

private const val deprecateMonadAppFunctorOperators: String = "Operators related to Functor, Applicative or Monad hierarchies are being deprecated in favor of bind"

0 comments on commit 4562d1f

Please sign in to comment.