Comments (4)
I've tried to model this library using the mechanism that Kotlin themselves ended up implementing (an inline class) but concluded that it isn't possible to achieve the majority of what this library achieves. A substantial amount of the extended functions, some of which you've listed, simply don't work when I tried. kotlin.Result
is also bounded by Exception, which I am in strong disagreement with, and adopting it would break backwards compatibility for this library.
The Result
type in the stdlib was initially implemented purely to accommodate behaviour for the kotlinx-coroutines
library, and has only really been alleviated as a return type after many people requested it. I am not convinced much thought has actually been put into making it a first-class citizen within the language when you compare it to implementations provided by stdlib's from other functional languages (Scala, Rust, Haskell, etc).
Kotlin developers themselves have in-fact been on record in admitting that the kotlin.Result
type is "half-baked"[1] and is likely to change in future (and therefore I would not be pushing to move a library to extend it). Barely a week after they announced that, their plans changed again and they had decided to allow people to use it as a return type[2] with no mention of increasing its scope, but instead they are exploring checked exceptions in the form of contextual receivers.
[1] https://discuss.kotlinlang.org/t/state-of-kotlin-result-vs-kotlin-result/21103/4
[2] https://discuss.kotlinlang.org/t/state-of-kotlin-result-vs-kotlin-result/21103/5
However, a lot of the signatures class with Kotlin's (ie, their Result vs your Result) clash, so to use your library I typealias everything (ie, KtResult).
You can configure your IDE to explicitly prevent suggesting importing things like kotlin.Result
.
from kotlin-result.
To add to Michael's comments, I'd recommend a read of the result KEEP doc.
In particular the linked section mentions that the usage pattern for this library (railway oriented programming) is not something they want to pursue as part of the language design.
It doesnt seem to make sense to base this 3rd party library off their class that differs fundamentally
from kotlin-result.
Could you point to some instructions for the IDE setting you mentioned to help with the naming conflict. I tried to google but not quite getting it!
from kotlin-result.
https://www.jetbrains.com/help/idea/auto-completing-code.html#exclude
from kotlin-result.
Related Issues (20)
- Kotlin bugs with value classes HOT 4
- How to use the new inlined Result in non-Kotlin code? HOT 9
- Issues with @JvmStatic code HOT 4
- Migrate to new kotlinx-coroutines-test API
- iosSimulatorArm64 and macOsArm64 support HOT 22
- Rename Result to Either HOT 7
- Assertion helpers for tests HOT 3
- Feature request: mingwX86 target HOT 2
- Extensions for Kotlin Flow? HOT 7
- About component1() and 2 HOT 2
- Best practices for integrating with Flow<T> HOT 1
- ensureNotNull-alike binding scope extensions HOT 15
- e: Could not load module <Error module> HOT 6
- Recovery extension HOT 3
- Consider using consistent "error" naming over "failure"? HOT 2
- Consider adding zipOrAccumulate? HOT 13
- Documentation of order of elements in Iterable.kt HOT 2
- Discuss: Use coroutines instead of exceptions for binding HOT 2
- `orElse` for Error Type Transformation HOT 2
- Make BindException public HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-result.