Hey guy, it there a way to convert a Kotlin Result...
# arrow
s
Hey guy, it there a way to convert a Kotlin Result to a Arrow Either in the library, like:
Copy code
fun <T : Any?> Result<T>.toEither(): Either<Throwable, T> = this.fold(
    { Either.Right(it) },
    { Either.Left(it) }
)
If not, is there anything that speaks against adding this ?
a
that's perfectly fine; we didn't include it directly because most of the times one has a
Result
is because of a throwing function
but in that case you can just do
Either.catch { theThrowingFunction() }
❤️ 1
s
thats true, for most of the cases. In case you don’t want to or can’t change it (external library), it would be good to have such functionality in the core library.
a
indeed, although I think
result.fold(::Either.Right, ::Either.Left)
is quite small too
s
try it 😅
Do I understand you correctly that you see no added value in providing something like this in core?
a
I personally don't, but feel free to open an issue in the repo to have more community input (I don't want to impose my opinion on you or any other)
👍 2