//Lambdas.kt in module A package lambdas fun toLong(d: Double) = d.toLong() //Main.kt in module B (This module has module A as dependency) package moduleb import lambdas.toLong private fun Function<*>.serializeToBytes(): ByteArray = ByteArrayOutputStream().use { ObjectOutputStream(it).writeObject(this) it }.toByteArray() fun main() { //Send the function to be applied to C send(::toLong.serializeToBytes()) } //Main.kt in module C (This module has also module A as dependency) package modulec private inline fun ByteArray.deserialize(): T = ObjectInputStream(inputStream()).readObject() as T fun main() { //Start listening //Receive the bytes array val bytes = receive() val function = bytes.deserialize<(Double) -> Long>() val ld = listOf(1.0, 2.0, 3.0, 4.0) val ll = ld.map(::function) println(ll) }