Skip to content
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

Merged
merged 6 commits into from Mar 3, 2021
Merged

Conversation

nomisRev
Copy link
Member

@nomisRev nomisRev commented Mar 2, 2021

This PR removes the K Wrappers ListK, MapK, SetK and SequenceK.

It leaves behind the type as object to expose mapN, 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 for Nullable. This will be step 2, so in the follow-up PR we also need to remove the top-level functionality for nullable.

@franciscodr
Copy link
Collaborator

@nomisRev nomisRev requested a review from a team March 2, 2021 15:46
Copy link
Member

@aballano aballano left a 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])
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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 😂

Copy link
Member Author

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]) },
Copy link
Member

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 😆

Copy link
Member Author

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.

Copy link
Member

@pakoito pakoito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wooo new encoding!

Copy link
Collaborator

@franciscodr franciscodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @nomisRev!

@nomisRev nomisRev merged commit 511121b into release/0.13.0 Mar 3, 2021
@nomisRev nomisRev deleted the paco-remove-k-wrappers branch March 3, 2021 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants