Skip to content

Commit

Permalink
Deprecates Outcome DSL syntax preferring the Raise DSL (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwmyers authored Jan 23, 2025
1 parent e7a5252 commit 82985fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/api/lib.api
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public final class app/cash/quiver/continuations/OutcomeEagerEffectScope : arrow
public final synthetic fun unbox-impl ()Larrow/core/continuations/EagerEffectScope;
}

public final class app/cash/quiver/continuations/OutcomeEagerEffectScopeKt {
public static final field outcomeDSLDeprecation Ljava/lang/String;
}

public final class app/cash/quiver/continuations/OutcomeEffectScope : arrow/core/continuations/EffectScope {
public fun attempt (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static fun attempt-impl (Larrow/core/continuations/EffectScope;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,20 @@ value class OutcomeEffectScope<E>(private val cont: EffectScope<Either<Failure<E
}

@Suppress("ClassName")
@Deprecated(outcomeDSLDeprecation, ReplaceWith("outcome", "app.cash.quiver.raise.outcome"))
object outcome {
@Deprecated(outcomeDSLDeprecation, ReplaceWith("outcome(f)", "app.cash.quiver.raise.outcome"))
inline fun <E, A> eager(crossinline f: suspend OutcomeEagerEffectScope<E>.() -> A): Outcome<E, A> =
eagerEffect {
@Suppress("ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL")
f(OutcomeEagerEffectScope(this))
}.fold({ it.merge() }, ::Present)

@Deprecated(outcomeDSLDeprecation, ReplaceWith("outcome(f)", "app.cash.quiver.raise.outcome"))
suspend inline operator fun <E, A> invoke(crossinline f: suspend OutcomeEffectScope<E>.() -> A): Outcome<E, A> =
effect { f(OutcomeEffectScope(this)) }.fold({ it.merge() }, ::Present)
}

@PublishedApi internal const val outcomeDSLDeprecation =
"The outcome DSL has been moved to app.cash.quiver.raise.outcome.\n" +
"Replace import app.cash.quiver.continuations.outcome with app.cash.quiver.raise.outcome"

0 comments on commit 82985fe

Please sign in to comment.