-
-
Save jgarte/b3e1a037e98a0a3e7dc2bb55a5fe8b77 to your computer and use it in GitHub Desktop.
Minimal UnderscoreJS Binding for PureScript
This file contains 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
"use strict"; | |
// module UnderscoreFFI | |
exports.map = function(f) { | |
return function (arr) { | |
return require('underscore').map(arr, f); | |
}; | |
}; | |
exports.reduce = function(f) { | |
return function (memo) { | |
return function (arr) { | |
return require('underscore').reduce(arr, function(memo, a) { | |
return f(memo)(a); | |
}, memo); | |
}; | |
}; | |
}; | |
function reduceRight(f) { | |
return function (memo) { | |
return function (arr) { | |
return require('underscore').reduceRight(arr, function(memo, a) { | |
return f(memo)(a); | |
}, memo); | |
}; | |
}; | |
}; | |
exports.sortBy = function(f) { | |
return function (arr) { | |
return require('underscore').sortBy(arr, f); | |
}; | |
}; | |
exports.shuffle = function(arr) { | |
return require('underscore').shuffle(arr); | |
}; | |
exports.uniq = function (arr) { | |
return require('underscore').uniq(arr); | |
}; |
This file contains 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
module UnderscoreFFI where | |
foreign import map :: forall a b. (a -> b) -> Array a -> Array b | |
foreign import reduce :: forall a b. (a -> b -> a) -> a -> Array b -> a | |
foreign import reduceRight :: forall a b. (a -> b -> a) -> a -> Array b -> a | |
foreign import sortBy :: forall a. (a -> Number) -> Array a -> Array a | |
foreign import shuffle :: forall a. Array a -> Array a | |
foreign import uniq :: forall a. Array a -> Array a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment