Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created March 13, 2020 11:31
Show Gist options
  • Save surajsau/aae34c93d418f6a6d4f399f6cf4134e9 to your computer and use it in GitHub Desktop.
Save surajsau/aae34c93d418f6a6d4f399f6cf4134e9 to your computer and use it in GitHub Desktop.
fun add(a: Int, b: Int, c: Int) = a + b + c
fun wrap(f: (Int, Int, Int) -> Int) = { x: Int -> { y: Int -> { z: Int -> f(x, y, z) }}}
val result = Functor.Something(1).map(wrap(::add)) // Something({ y -> { z -> add(1, y, z) }})
.apply(Functor.Something(2)) // Something({z -> add(1, 2, z) })
.apply(Functor.Something(3)) // Something(6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment