Declarative JavaScript With Functional Programming Tools(github.com)
github.com
Declarative JavaScript With Functional Programming Tools
https://github.com/azer/declarative-js
5 comments
> You need to explain more - for example what do you mean by a "partial"? A quick search for "partial functions" gave me several links to mathematics articles.
The magic phrase you were looking for is "partial application." (Partial functions are a different, even more esoteric thing.) Basically, partially applying a function means you create a new function that calls the original with some of the arguments already filled in. For example, you could write this:
The magic phrase you were looking for is "partial application." (Partial functions are a different, even more esoteric thing.) Basically, partially applying a function means you create a new function that calls the original with some of the arguments already filled in. For example, you could write this:
var getUserList = partiallyApply(jQuery.getJSON, 'http://example.com/user-list');
and getUserList would then be a function that takes a callback and calls jQuery.getJSON('http://example.com/user-list', yourCallback)I believe that using basic functional programming tools is a much more powerful way than using promises. The main issue with promises is that the code you write will be less replaceable, and less compatible with other code.
I think this kind of approach can reduce complexity in JS. Witch is for me by far the biggest problem. Will give it a try.
Is this from you, combataircraft? Always curious about your style because you always post that EditGrid example :)
Yeah that's me and https://twitter.com/4zjs/status/319970549910614016 :)
What about going a little further and writing in a purely functional language like Elm?
hi nice work. it's always nice to have functional programming paradigms in javascript.
is there any (technical or political) reason, why this is or will not be part of underscorejs?
is there any (technical or political) reason, why this is or will not be part of underscorejs?
underscore isn't async as I know. the libraries I use:
- comp: http://github.com/azer/comp
- andthen: http://github.com/azer/andthen
- join-params: http://github.com/azer/join-params
- map: http://github.com/azer/map.js
- new-partial: http://github.com/azer/new-partial
- comp: http://github.com/azer/comp
- andthen: http://github.com/azer/andthen
- join-params: http://github.com/azer/join-params
- map: http://github.com/azer/map.js
- new-partial: http://github.com/azer/new-partial
What I did get from the article is something that works a lot like promises:
- async functions return type of "eventual" data (in your case, a function you pass a callback to)
- various other functions that can operate on that eventual data type to return more eventual data
What does this style offer that standard promises doesn't?