Yes, that makes sense. The only way to call it with only error is
launchIOSafe(error = { _: A -> })
. You can never call it with the trailing lambda syntax.
In some cases you can avoid this, but not always. I think in this case this result in any nicer APIs. In fact, it may be even conflicting. Sometimes you can define APIs that are valid in their definition, but ambiguous on the call-site.
fun <A, B> launchIOSafe(
f: suspend () -> Either<A, B>,
error: suspend (A) -> Unit = {},
success: suspend (B) -> Unit
): Job =
launchMain {
IO { f() }.fold(error, success)
}
fun <A, B> launchIOSafe(
f: suspend () -> Either<A, B>,
error: suspend (A) -> Unit
): Job =
launchIOSafe(f, error) { }