Skip to content

Instantly share code, notes, and snippets.

@L8D
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save L8D/7da36e2a909f8fde363e to your computer and use it in GitHub Desktop.

Select an option

Save L8D/7da36e2a909f8fde363e to your computer and use it in GitHub Desktop.
The 'Data' monad/tuple thingy in JavaScript
var Data = function(first, second, third, fourth, fifth, sixth, seventh) {
return function(iterator) {
return iterator(first, second, third, fourth, fifth, sixth, seventh);
};
};
// or more elegantly
var Data = function(a, b, c, d, e, f, g) {
return function(fn) {
return fn(a, b, c, e, f, g);
};
};
var Data = (a, b, c, d, e, f, g) => fn => fn(a, b, c, d, e, f, g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment