hello folks, i am currently trying to learn more ...
# arrow
a
hello folks, i am currently trying to learn more about functional programming using arrow. Right now i am using the Scala Exercises from here https://www.scala-exercises.org/cats/monad and try to implement them using arrow. Here I ran into a problem. Hope someone can help me here. looking at the third example of the first Monad exercise:
Copy code
List(List(1), List(2, 3)).flatten should be(
List(1,2,3)
)
my Kotlin/Arrow version looks like this (part of a KotlinTest):
Copy code
import arrow.core.extensions.list.monad.flatten

...
"flatten" {
            listOf(listOf(1), listOf(2, 3)).flatten() shouldBe listOf(1, 2, 3)
}
However this causes an StackOverflowError:
Copy code
java.lang.StackOverflowError
	at arrow.core.extensions.list.monad.ListKMonadKt.flatten(ListKMonad.kt:76)
	at arrow.core.extensions.list.monad.ListKMonadKt.flatten(ListKMonad.kt:76)
	at arrow.core.extensions.list.monad.ListKMonadKt.flatten(ListKMonad.kt:76)
When i use the flatten() extension function from the kotlin stdlib my test works. This made me wonder wether this might be an issue within arrow or if i am misusing arrow here. thanks in advance, Alphonse