Hi All, is there any way to remove the `.k()` as m...
# arrow
x
Hi All, is there any way to remove the
.k()
as much as possible in the following example:
Copy code
val m = mapOf("a" to listOf(1, 2).k(), "b" to listOf(3).k()).k()
val n = mapOf("a" to listOf(4).k(), "c" to listOf(5, 6).k()).k()
val p = MapK.semigroup<String, ListK<Int>>(ListK.semigroup()).run { m + n }
a
hi there! Have you tried just removing all
.k()
? I believe it should work
hmmm actually it doesn’t output the same, but it should AFAIK, i’ll investigate 👀
p
+
for maps in the standard library doesn't add the values together
someone asked that on twitter yesterday hahaha
a
indeed, using combine works with the
.k()
but not for plain list and a Map. Ideally this should work
Copy code
val m = mapOf("a" to listOf(1, 2), "b" to listOf(3))
val n = mapOf("a" to listOf(4), "c" to listOf(5, 6))
val p = Map.semigroup<String, List<Int>>(List.semigroup()).run { m.combine(n) }
but it seems there’s no Semigroup generated for map although it exists for list 🤔
maybe @pakoito knows more about this 😄
x
Hi @aballano (or anybody), could you post the
import <http://arrow.xxx|arrow.xxx>
when you use standard kotlin
map
,
list
and
combine
? My IntelliJ suggested
import arrow.core.extensions.list.semigroup.List.semigroup
but there's still compilation error.
a
with the code I pasted it doesn’t work because it cannot find Map.semigroup() 😕
I created a bug ticket to investigate 👌 https://github.com/arrow-kt/arrow-core/issues/140 thank you @Xuc Xiem you can follow it to know when is fixed
x
Thank you very much 🙂