raulraja
09/05/2017, 9:04 PMA inside. for example this one in Scala is a Tree with a flatMap impl a bit more involved of what you are doing https://github.com/scalaz/scalaz/blob/scalaz-seven/core/src/main/scala/scalaz/Tree.scala , but the idea is that you can define flatMap in many datatypes not just collections. flatten is flatMap over the identity function https://github.com/kategory/kategory/blob/master/kategory/src/main/kotlin/kategory/typeclasses/Monad.kt#L19 .
Not suggesting you change anything in your impl just some info in case you are curious about the nature of those flatMap/flatten operations.