-
Notifications
You must be signed in to change notification settings - Fork 30
["Request"] Undeprecate Option
and move it to a separate module
#238
Comments
Sounds great, thanks Stojan!
…On Wed, Sep 16, 2020, 9:10 AM Stojan Anastasov ***@***.***> wrote:
What version are you currently using?
0.11
What would you like to see?
Option NOT @deprecated
Short summary:
Everything Option can do can be achieved with nullable types in a more
performant way and it's more idiomatic kotlin code. However for Java
compatibility when using frameworks like RxJava (popular on Android) and
Project Reactor (popular in Spring world) that is not possible since they
explicitly prohibit Null values:
https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#nulls
The proposed workaround (with typealiasing Either #114 (comment)
<#114 (comment)>)
is not ideal, confuses FP beginners.
More context in this slack thread:
https://kotlinlang.slack.com/archives/C5UPMM0A0/p1600160092340000
- Create new repository/module arrow-option
- Move Option to new module and remove @deprecated
- Provide interop with Java's Optional
- Explore optimizing Option like Kotlin's Result
@raulraja <https://github.com/raulraja> feel free to add anything I have
missed. Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#238>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADPQXAWFUSTDS5DCMYKXLDSGBQHFANCNFSM4ROLNH2Q>
.
|
It isn't just for java compat: Every framework that uses null for control flow on generics will break when nullable types are used on it. (I've fallen into this quite a bit on the STM implementation...) class MyControlFlowImpl<A>(val result: A?) This will run into problems as soon as someone uses a nullable
inline class Option<A>(val res: Any?) {
object None
fun getOrNull(): A? = res.takeIf { it !== None }
}
fun <A> Some(a: A): Option<A> = Option(a)
fun None(): Option<Nothing> = Option(Option.None)
Regarding deprecation, imo we should leave it deprecated and link to a doc page explaining where it went and when to use/not use it.
|
Not to hijack this issue but is there an idiomatic way to do something akin to monad comprehensions with Kotlin's nullables, ie something that doesn't degrade into nested hell? Currently, that's a strong use case to me for maintaining |
Hi @peterfigure, it is possible and we plan on adding nullable to the list of comprehensions based on the new arrow-continuations module which is gonna fuel the impl of all monad comprehensions and effect like handlers. Jannis, Simon and I already saw two versions of that working and we need to port it to the next release. |
Considering the long history of It appears that there are a reasonable number of people who share these views, and – thankfully – this request appears to have legs. But that inference is all I have to go on, which is not super comforting. Can I reasonably assume that |
@MiriChan it may not be in core and may no longer appear in effect type classes etc but you will have an option data type with most of the API we have even if it's in a separate dependency. @LordRaydenMK was looking into it based on the discussion. |
I am already working on this. Unfortunately it's not as simple as I first assumed. There is a circular dependency between the new arrow-option module and arrow-core. Also there are methods in core that work with Only after all public API methods that have Option in them are removed, we can extract Option to a separate module. |
Awesome, thanks for the info :) |
Just poppin' in from Swift land to say that I'm shocked that
Is nowhere near the same as
And I think that Option should be left in as is and not moved to a different module because if I'm pulling an FP lib I kinda want FP things regardless of performance and people who don't want these things can just not import them. But that's like, just my opinion 👀 |
Well
This move has two benefits:
|
Even more! It isn't true that a nullable type can do everything that an Option can do! I use an Option of a nullable type deliberately because the value, if present, can also be null. This cannot be done with a nullable type as I cannot distinguish between "not there" and "there, but null". Moving the type - okay. But depreciation? That's not okay. |
Thanks for your comments @Zordid . Fortunately the arrow maintainers decide what's ok or not in the arrow data types. Having said that you will have access to Option if you want but it won't be in arrow core. |
@raulraja I do not really understand why you had to put it this way, Raul. No offense, but the reasoning for depraction of Option type is simply not holding to the facts, as I pointed out. There are things, nullable types cannot do - namely distinguish between the absence or presence of a nullable datatype. That said: in FP, Option / Maybe is an essential type - to deprecate it in a release version of an FP library will be confusing for many people. |
You said deprecation is not ok, we are gonna move it and even in that case it most likely won't preserve the namespace so the type needs to be deprecated even if the change is just package imports. Also we should not copy or do what 'FP' is supposed to be but what makes sense of what we think FP in Kotlin should be. If we follow these rationales about IO or Option we are not getting anywhere new with Arrow and falling behind compared to what the lang itself provides. I didn't mean to be rude, my apologies I came out like that, but I'm tired of seeing comments and rants about Option and other that come with no code or rational that can be discussed beside what people think FP is o which data-types should be included without proof. I've already proposed many alternatives to save Option but all it's defense is that we mostly get hot takes and edge cases where it all points to bad decisions made on the other side. For example using null for other purposes on Rx. Not directed to you specifically but If you all want Option in Arrow the way to save it is help @LordRaydenMK make sense out of its location, optimizations and API. Most uses cases we've seen for Option in Kotlin are wrong compared to usage in nullable types. Additionally I don't think having null as a value in the Some case is a good use case to preserve Option but happy to hear a convincing argument against or use case that justifies keeping all this code around. |
@raulraja yeah, I can see how people get frustrated - just like I did. I cannot follow the reasoning that you even care whether people use Option correctly or not. It is implemented correctly like it is and it is useful. I just want to understand why Option is such a big deal for the library not to be able to be evolved further... |
For everyone who plans to keep using As for why:
Library adoption. Less working against kotlin standards and more with them. Hence the switch of Its all a bunch of tradeoffs and we do welcome everyone do keep adding to these discussions to see all sides of it, so thanks for your input! |
Thanks @1Jajen1 for dissecting our view so well.
I personally have other interests in arrow beside educational. The performance even at the micro level matters to me because I'm attempting not just remove Option but lift as many concerns as possible to the compiler before the final stable 1.x release. If you have this level of interest in arrow I'd like to invite you to get involved. There is no geniuses or gods here, just people trying to improve it and I'm sorry for being upset in my earlier comments. Also if you would like to chat in person over meet about Option or any other topic that concerns you of Arrow we are always a call away. Most of the discussion of option has happened in the #arrow-contributors and #arrow channels in slack.kotlinlang.org. |
I don't see how the interop is an argument. A reusable module (being a library or otherwise, it doesn't matter) using Arrow will likely expose other data types as well (e.g.
Promoting nullable by default is a valid argument, but I think it will create more confusion, not less. It's just my opinion though - but it might be more representative of other users' vs maintainers.
(I'm ignoring this one as, as you stated, the impact is minor - it's mostly the justification behind promoting nullable by default, if anything.) I don't have a strong opinion on the matter as I'll just use that additional artifact once it's available and call it a day. But that sounds to me like a lot of noise and effort for little value, if any. |
@Kernald thanks for your opinion and points. I think at this point we are giving people a choice to just change an import and add an additional module and the compromise to maintain it and we won't release again until that is ready. We believe that is a good compromise and still leaves the door open for people wanting to use Option maintained by the arrow authors in the same state it is now and getting improvements down the road. |
Hi Arrow maintainers, I appreciate the work y'all are doing, but this is causing a bit of an issue for our production medical app. IMO, the plan to deprecate and move We would like to upgrade to Arrow 0.11.0 since it's the first release to use Kotlin 1.4 but are blocked from doing so without either a) compromising on code quality by disabling Is there any downside for undeprecating |
Hi @larryng , we are about to release 0.12.0 soon with Option undeprecated and as part of arrow-core. would that solve your issue or would you still need a patch release for the 0.11.x series? |
@raulraja It should solve this particular issue of ours, yes. |
hi @raulraja - if you are going to preserve Option (🎉) - can I ask why Currently, this makes it not possible to use with a suspending transformation if I'm not mistaken? |
Hey @peterfigure, Hey @larryng, |
@nomisRev I'm well aware of Fortunately, upgrading tools isn't an urgent concern, so we can wait. But it was a big disappointment to run into this blocker when I was working on it at the time. |
What version are you currently using?
0.11
What would you like to see?
Option
NOT@Deprecated
Short summary:
Everything
Option
can do can be achieved with nullable types in a more performant way and it's more idiomatic kotlin code. However for Java compatibility when using frameworks like RxJava (popular on Android) and Project Reactor (popular in Spring world) that is not possible since they explicitly prohibit Null values: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#nullsThe proposed workaround (with typealiasing
Either
#114 (comment)) is not ideal, confuses FP beginners.More context in this slack thread: https://kotlinlang.slack.com/archives/C5UPMM0A0/p1600160092340000
arrow-option
Option
to new module and remove@Deprecated
Optional
Option
like Kotlin'sResult
@raulraja feel free to add anything I have missed. Thanks.
The text was updated successfully, but these errors were encountered: