it says i cannot use it as a return type
# announcements
m
it says i cannot use it as a return type
s
The rationale behind these limitations is that future versions of Kotlin may expand and/or change semantics of functions that return 
Result
 type and null-safety operators may change their semantics when used on values of 
Result
 type. In order to avoid breaking existing code in the future releases of Kotlin and leave door open for those changes, the corresponding uses produce an error now. Exceptions to this rule are made for carefully-reviewed declarations in the standard library that are part of the 
Result
 type API itself.
m
ok i see. it's not much of a use no me if i cannot use it in a public api
thanks
m
Checkout 'Either' in Arrow-kt or create your own version for explicit error handling.
1
a
This one also I think is a simpler alternative to
Either
, and has similar API to
kotlin.Result
, I've been using it and it served me well. https://github.com/npryce/result4k
c
you can use
kotlin.Result
if you specify
Copy code
-Xallow-result-return-type
in compiler args. It's experimental though and the way it works and its API could change before it completes its experimental stage, that's why it isn't enabled by default.
m
Either
in Arrow (becoming BIO in 0.11 release) is a good place to start if you want to really get into FP. If you just want the Result type, then result4k looks like a very good option. Or opting into experimental.