Pairs

let cons = (a, b) => (pick) => ({1: a, 2: b}[pick]); let car = (x) => x(1); let cdr = (x) => x(2); What if we could build pairs out of nothing at all?…

The perfect API

Imagine for a second that everything had the same interface. Everything. If this API is going to handle every situation, its surface area can't be used conditionally. E.g. we don't use certain parts for certain problem domains. Every part must be useful for every problem domain. It sounds like…

`yield` vs `yield*` in Koa.js

Although Koa.js does not advocate the use of yield*, it is good there is an article explaining the difference among the two.…

Promises and Generators: control flow utopia

Forbes Lindesay talks about how ES6 generators can help you make your asynchronous code easier to understand in terms of synchronous concepts. He discusses the alternative values you can use to represent a future and how they are all ultimately promises. Slides here.…

From impurity to purity

Something to note is that you can transform some impure functions into pure ones by delaying evaluation var pureHttpCall = function (url, params){ return function() { return $.getJSON(url, params); }; }; We don't actually make the HTTP call - we instead return a function that will do so when called. This function is…