<@U0ZFBBUBU> commented on <@U3T6LDWTD>’s file <htt...
# language-proposals
u
@groostav commented on @benleggiero’s file https://kotlinlang.slack.com/files/T09229ZC6/F04AVNRBLNP: so I'm using Funktional's
Either
type a fair bit, as a fairly firm believer in "Railway oriented programming" (https://fsharpforfunandprofit.com/rop/). How much of this can be accomplished with a library and/or tuples?
Copy code
~~fun myFunc(willThrow: Boolean) throws: Int = if(willThrow) TODO() else 42~~

data class Try<T, X: Exception>{
  val value: T?
  val exception: X?
}

fun myFunc(): Try<Int, Exception> = Try {
  if(willThrow) TODO() else 42
}

//usage:
val (value, ex) = myFunc(false)
//value or ex is nullable, use standard null-coercion to handle exceptions