kierans777
03/09/2022, 12:52 AMList<Map<String, String>> and I want to fold it down to Map<String, String> . How could I do this using a Monoid in Arrow?simon.vergauwen
03/09/2022, 7:32 AMIterable has an extension combineAll that takes an Monoid argument, and if you look at the Monoid.Companion you will find all instances.
On the Monoid.Companion we find Monoid.map()
https://arrow-kt.io/docs/apidocs/arrow-core/arrow.typeclasses/-monoid/-companion/index.htmlsimon.vergauwen
03/09/2022, 7:33 AMcombineAll which you can find on the Extensions page of Arrow Core.
https://arrow-kt.io/docs/apidocs/arrow-core/arrow.core/index.html#functions
https://arrow-kt.io/docs/apidocs/arrow-core/arrow.core/combine-all.htmlsimon.vergauwen
03/09/2022, 7:34 AMMonoid.
I'm always happy to help if you have any questions in regards to contributing! So feel free to reach out here or in DM.kierans777
03/09/2022, 9:09 AMList<Map<String, String>> to a`Map<String, String>` using a Monoid? I don't understand why Monoid.map requires an argument.
val x = listOf(mapOf("one", "1"), mapOf("two", "2"), mapOf("three", "3"))
val y = ???
// I want y to look like
y = {
"one": "1"
"two": "2"
"three": "3"
}simon.vergauwen
03/09/2022, 9:27 AMmap is because you need to be able to combine values for duplicated keys.
val x = listOf(mapOf("one" to "1"), mapOf("two" to "2"), mapOf("three" to "3"), mapOf("three" to "3"))
val y = x.combineAll(Semigroup.map(Semigroup.string())) // mapOf("one" to "1", "two" to "2", "three" to "33")kierans777
03/09/2022, 9:29 AM