Created
December 1, 2018 03:49
-
-
Save dangdennis/63274d721ee084abfe0b044560709303 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
/* | |
All functions in Reason are automatically curried | |
Let's use List.map as an example | |
Function signature: let map: ('a => 'b, list('a)) => list('b); | |
*/ | |
let add5 = n => n + 5; /* callback func */ | |
let add5ToList = List.map(add5); | |
let list = [1,2,3,4,5]; | |
let listPlus5 = add5ToList(list); /* [6,7,8,9,10] */ | |
/* Post-Bucklescript compilation | |
function add5(n) { | |
return n + 5 | 0; | |
} | |
function add5ToList(param) { | |
return List.map(add5, param); | |
} | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment