Last active
July 4, 2017 22:30
-
-
Save dewey92/8eabed2ca65f32020b094140b6428f91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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