In Kotlin there is the concept of “co-pure”. The Kotlin compiler has a powerful inliner, which is very commonly used in Kotlin. An inliner takes the code from an inline fun, and puts it in the place of the call-site. So if an inline fun is pure in it’s definition, and it takes a lambda then the resulting code is pure if and only if the passed lambda is also pure. Otherwise the resulting code is impure. So the whether the resulting code pure or not depends 100% on the passed lambda.
fun pureExample(): Unit =
listOf(1, 2, 3).map { it + 1 } // [2, 3, 4] & pure
suspend fun impureExample(): Unit =
listOf(1, 2, 3).map { delay(it * 100) } //[Unit, Unit, Unit] & impure