Created
May 27, 2016 22:52
-
-
Save maddie927/263e216f238c3bc0dc39f68167c1769b to your computer and use it in GitHub Desktop.
PureScript: proposed changes to currying
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
exports.sum3Nums = function(a, b, c) { | |
return a + b + c; | |
}; | |
exports.sum3Nums$curried = function(a) { | |
return function(b) { | |
return function(c) { | |
return exports.sum3Nums(a, b, c); | |
}; | |
}; | |
}; | |
exports.add3 = exports.sum3Nums$curried(1.0, 2.0, a); | |
exports.ten = exports.sum3(2, 5, 3); | |
exports.add2Ints = $foreign.add2Ints; | |
exports.add2Ints$curried = function(a) { | |
return function(b) { | |
return exports.add2Ints(a, b); | |
}; | |
}; | |
exports.add7 = exports.add2Ints$curried(7); |
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
exports.add2Ints = function(a, b) { | |
return a + b; | |
}; |
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
-- | A PS function with multiple arguments | |
sum3Nums :: Number -> Number -> Number -> Number | |
sum3Nums a b c = a + b + c | |
add3 :: Number -> Number | |
add3 = sum3 1.0 2.0 | |
ten :: Number | |
ten = sum3 2 5 3 | |
foreign import add2Ints :: Int -> Int -> Int | |
eleven :: Int | |
eleven = add2Ints 5 5 | |
add7 :: Int -> Int | |
add7 = add2Ints 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment