Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Fix Mapk extensions #148

Merged
merged 5 commits into from
Jun 11, 2020
Merged

Fix Mapk extensions #148

merged 5 commits into from
Jun 11, 2020

Conversation

aballano
Copy link
Member

@aballano aballano commented Jun 9, 2020

  • Added listKOf for ListK as equivalent to List's listOf
    -> With this, there's no need to create normal Lists and Maps to then convert them to the wrapped version via .k(), but instead just create the wrapped versions directly as follows:
val m = mapOf("a" toT  listKOf(1, 2), "b" toT listKOf(3)) // Note that the `toT` will use an Arrow's Tuple to create a MapK
val n = mapOf("a" toT listKOf(4), "c" toT listKOf(5, 6))
val p = m.plus(ListK.semigroup(), n)
  • Fix MapK extensions projected over stdlib Map
    -> So now there's no need to convert all maps to MapK because we can use the Map extensions as follows (note that we cannot still use List.semigroup tho):
val m = mapOf("a" to 1, "b" to 3)
val n = mapOf("a" to 5, "c" to 5)
val p = m.plus(Int.semigroup(), n)

Fixes #140

@aballano aballano requested a review from pakoito June 9, 2020 16:24
@@ -600,7 +600,7 @@ interface JvmMetaApi : MetaApi, TypeElementEncoder, ProcessorUtils, TypeDecoder
* ex: SetK<A> to Set<A>
*/
val Type.kindWrapper: Pair<TypeName, TypeName.ParameterizedType>?
get() = if (primaryConstructor?.parameters?.size == 1 && typeVariables.size == 1) {
get() = if (primaryConstructor?.parameters?.size == 1) {
Copy link
Member

Choose a reason for hiding this comment

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

ez pz

@@ -600,7 +600,7 @@ interface JvmMetaApi : MetaApi, TypeElementEncoder, ProcessorUtils, TypeDecoder
* ex: SetK<A> to Set<A>
*/
val Type.kindWrapper: Pair<TypeName, TypeName.ParameterizedType>?
get() = if (primaryConstructor?.parameters?.size == 1 && typeVariables.size == 1) {
get() = if (primaryConstructor?.parameters?.size == 1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@raulraja Hope this is ok tho 😅

@aballano aballano merged commit 3822b92 into master Jun 11, 2020
@aballano aballano deleted the ab/fix-mapk-extensions branch June 11, 2020 16:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

["Request"] Fix Map instances generation
2 participants