With function composition, we take two functions to create the third function; with partial application, we create a new function by passing a parameter to an existing function.
Arrow comes with two flavours of partial application—explicit and implicit.
The explicit style uses a series of extension functions called partially1
, partially2
, all the way up to partially22
. The implicit style takes a series of extensions, overloading the invoke
operator:
package com.packtpub.functionalkotlin.chapter11 import arrow.syntax.function.invoke import arrow.syntax.function.partially3 fun main(args: Array<String>) { val strong: (String, String, String) -> String = { body, id, style -> "<strong id=\"$id\" style=\"$style\">$body</strong>" } val redStrong: (String, String) -> String = strong.partially3("font: red") //Explicit val blueStrong: (String, String) -> String = strong(p3 = "font: blue") //Implicit println(redStrong("Red Sonja", "movie1...