Very cool! You might also want to check out sparkler, which uses macros to let you do this with a little better syntax: https://github.com/natefaubion/sparkler
What I'd like is a small library to complement lodash/underscore with utility functions required when using high-level ones. It's very annoying to have verbose
It seems like the current solution is to use _.pluck() or similar functions for common use-cases, or use _.partial which I find even more verbose than standard functions.
No, seriously, LiveScript is great and I used it in production already, without any problems. Your first example would look like this in LS:
_.each [1 to 3], (something _, 'param')
where "_" in this context means partial application.
Even better, LS has special syntax for accessing an object method and binding it at the same time, this is a bit of code I wrote recently:
httpify-promise = (promise) ->
# add `success` and `error` methods to the promise, making it into
# $http-compatible one
promise with
success: (promise~then _, null)
error: (promise~then null, _)
Now this is really beautiful and powerful.
I also played with promises some time ago, in Node, where I used q library and LiveScript. Partial application and curried functions from prelude-ls let me write code like this:
In other words it's an identity function which additionally executes some other function for side-effects. In the shell the `tee` command always writes to the file, while my version can execute any side-effect, but I think my version is just a generalization of the standard Unix command and so I named it like this.
I'm sure this function has its own, formal name, with the word "monad" or "combinator" (maybe K combinator?) in it, but I wasn't patient enough to research it :)
In other words, `thenResolve` appends a success callback which discards previous value and always returns another value.
Once again, take a look at the full source at http://klibert.pl/walkfiles.html - I'm going to update it with a full explanation of what's going on, but even right now it's only 90 lines with including comments, and should be a good example of main LS strengths. I'm probably going to write another example which makes use of even more (and more advanced) LS features when I'm done with explaining this one.
Actually my reflection started with using tee and pipes in bash, having a desire to sync/join on the multiple paths created by tees. Interesting job that you did.