Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active July 4, 2017 22:30
Show Gist options
  • Select an option

  • Save dewey92/8eabed2ca65f32020b094140b6428f91 to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/8eabed2ca65f32020b094140b6428f91 to your computer and use it in GitHub Desktop.
const incr = x => x + 1
const add = curry((x, y)) => x + y
const sum3 = curry((x, y, z)) => x + y + z
const maybe1 = Maybe(1)
const maybe2 = Maybe(2)
const maybe3 = Maybe(3)
/* Pada dasarnya, liftA merupakan kombinasi dari map dan ap */
// 1 parameter
liftA(incr, maybe1) == maybe1.map(incr)
// 2 parameter
liftA2(add, maybe1, maybe2) == maybe1.map(add).ap(maybe2)
// 3 parameter
liftA3(sum3, maybe1, maybe2, maybe3) == maybe1.map(sum3).ap(maybe2).ap(maybe3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment