Skip to content

Instantly share code, notes, and snippets.

@diasandre
Last active April 21, 2021 00:32
Show Gist options
  • Save diasandre/42db29f7c7ef1fda551e0099498f079e to your computer and use it in GitHub Desktop.
Save diasandre/42db29f7c7ef1fda551e0099498f079e to your computer and use it in GitHub Desktop.
arrow-kt partial method reference using partially1 and curried
import arrow.core.curried
import arrow.core.partially1
fun main() {
val application = Application()
val value = "value"
val usePartially1 = value
.let((application::functionWith2parameters::partially1)("first"))
println(usePartially1) //first-value
val useCurriedWith2Parameter = value
.let((application::functionWith2parameters.curried())("first"))
println(useCurriedWith2Parameter) //first-value
val useCurriedWith3Parameter = value
.let((application::functionWith3parameters.curried())("first")("second"))
println(useCurriedWith3Parameter) //first-second-value
}
class Application {
fun functionWith2parameters(first: String, value: String) = "$first-$value"
fun functionWith3parameters(first: String, second: String, value: String) = "$first-$second-$value"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment