Sweet.js macros for lambdas with currying, bound functions, and placeholders.
npm install -g sweet.js npm install lambda-chop sjs -m lambda-chop/macros myfile.js
Lambda-chop provides a macro
λ which you can use to create terse, 'stabby'
lambdas, much like CoffeeScipt and ES6, but with some extra features:
->for unbound functions
=>for bound functions using
// Create unbound functionsvar add = -> x + y;=== 3;// Create bound functionsDB;// Curry functions by leaving off the tupled argumentsvar always = λ x y -> x;12 === 42;// Mix and match for multiple argument listsvar nonsense = s t f -> 42;// Placeholders using square brackets and `#`var str = λ#;var sub = λ# - #;=== 1;// Shorthand property lambdasvar names = arr;
Placeholder partials are never curried or bound, and are always expressions.
Yes! Not everyone likes it or wants to type it. Lambda-chop provides aliases by using a different module to compile your files.
# Use `fun` instead of `λ` sjs -m lambda-chop/macros/fun myfile.js
Available aliases are:
Nathan Faubion (@natefaubion)