
funKtional
A lightweight Kotlin Multiplatform library providing functional programming extensions and utilities for nullable handling, type casting, flow lifting, and more.
Targets: Android · iOS · JVM
Features
Installation
dependencies {
implementation("io.github.ktomek:funKtional:1.2.0")
}
Usage
runBlocking {
val length = "Hello".letCo { it.length }
println(length)
}
val value: String? =
default = value.orDefault { }
println(default)
any: Any =
text: String? = any.asTypeOrNull<String>()
println(text)
sum: ? = lift() { a, b -> a + b }
println(sum)
Advanced Usage: Chaining Functional Extensions
runBlocking {
val x: Int? = null
val y: Int? = 5
z: ? =
result = x.lift(y, z) { a, b, c -> a + b + c }
.orDefault { }
.letCo { it * }
println(result)
}
branch =
.match(
some = { it.length },
none = { }
)
.let { length -> }
.also { println(it) }
Contributing
Contributions are welcome! Please open issues or submit pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.