Create a gist now

Instantly share code, notes, and snippets.

Minimal UnderscoreJS Binding for PureScript
"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);
};
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