-
|
What's the idiomatic way to transform effect types? |
Beta Was this translation helpful? Give feedback.
Answered by
ahoy-jon
Sep 13, 2025
Replies: 1 comment 2 replies
-
|
👋 I would go with those solutions: import kyo.*
trait mapErrorOnThrowable[A, S]:
val computation: A < (Abort[Throwable] & S)
// doesn't handle the Panic
val usingCombinators_1: A < (Abort[String] & S) = computation.mapAbort(e => e.getMessage)
val usingCombinators_2: A < (Abort[String] & S) =
computation.result.map:
case Result.Success(value) => value
case Result.Error(e) => Abort.fail(e.getMessage)
// Handling
val usingAborts_1: A < (Abort[String] & S) =
Abort.recoverError[Throwable](e => Abort.fail(e.failureOrPanic.getMessage))(computation) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
DGolubets
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👋 I would go with those solutions: