New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CU-9rr4w5 remove K Wrappers #2281
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
fun <K, A> List<Map.Entry<K, A>>.k(): MapK<K, A> = this.map { it.key to it.value }.toMap().k() | ||
|
||
@Deprecated("Deprecated, use nullable instead", ReplaceWith("map[k]?.let { ... }")) | ||
fun <K, A> Map<K, A>.getOption(k: K): Option<A> = Option.fromNullable(this[k]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might have been prematurely deprecated, since Option is still available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering that myself, but that would mean we should duplicate all APIs for null
and Option
which I also don't think is great.
Especially since the idea of Option
is only to use it in certain use-cases, and you can always lift nullable to Option
whenever you need to like you have to do with Kotlin's Std today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having that in the balance I think we could all live without this tiny extension 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do need to fix the incorrect ReplaceWith
tho 🙈
@@ -46,7 +45,7 @@ fun <K, V> PTraversal.Companion.map(): Traversal<Map<K, V>, V> = | |||
fun <K, V> At.Companion.map(): At<Map<K, V>, K, Option<V>> = | |||
At { i -> | |||
PLens( | |||
get = { it.getOption(i) }, | |||
get = { Option.fromNullable(it[i]) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked more the previous version 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually thinking if this should be At<Map<K, V>, K, V?>
but the V
should be restricted to Any
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wooo new encoding!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @nomisRev!
This PR removes the K Wrappers
ListK
,MapK
,SetK
andSequenceK
.It leaves behind the type as
object
to exposemapN
, but that needs to@Deprecated
and needs to become top-level.This required a 2 step deprecation since it conflicts with the top-level
mapN
forNullable
. This will be step 2, so in the follow-up PR we also need to remove the top-level functionality for nullable.