I'm not quite sure what the end-game is, here?<p>Several of the functions listed here are quite different from their Haskell counterparts in ways that make them subtly less useful — and in ways that make them not have the same types as the Haskell originals, which is interesting considering we're barely given more than the type of each of the functions. flip and zipWith are the ones that were quite obvious to me, others might have the same problems (with flip being outright wrong due to it inverting all the arguments instead of flipping the first two, and zipWith working fine with two lists, but generalising to multiple lists in a way that can't be a generalisation of the two-list zipWith). Composition also works in reverse to what one would expect in Haskell, for no reason I can fathom.
The biggest power of Haskell (and other functional programming languages) is in the type system and the ability to abstract well (e.g. equals()), and these functional functions are secondary. How do you suppose to replicate that in JS?
Haskell's strengths are it's laziness, currying, and type stystem. Implementing a few higher order functions != haskell. This is HN clickbait.
Pretty cool. Few suggestions (which may or may not require babel):<p>- `f.apply(null, args)` calls can be replaced with `f(...args)`<p>- Your head function returns the first argument while your last function returns an <i>array containing</i> the last argument. I'd rewrite those functions as:<p><pre><code> const head = (x) => x;
const last = (...xs) => xs[xs.length-1];
const tail = (x, ...xs) => xs;
const init = (...xs) => xs.slice(0, -1);
</code></pre>
(Unfortunately it seems the rest operator can only appear as the last argument.)<p>- Why put everything on the prototype? It doesn't seem necessary since you are not using the `this` keyword. I would just stick the `export` keyword in front of functions to be exported.<p>Looking forward to part 2.
I found the way the examples are written confusing at first glance.
I think the norm is to call the function and then show the returned output.<p>e.g.
instead of<p>1/4 === comp(1)<p>do<p>comp(1)<p>// returns 1/4<p>This might be my personal preference but it's the way it's written in the Mozilla javascript reference pages.<p>Other than that it looks great!
Here's another way of phrasing that.<p>"Functional programming isn't an end unto itself, it's one of several strategies for breaking programs down into manageable chunks. I would have found the article more interesting if it showed how this type of tiny function is used in journeyman Haskell code, or how the translation to ES6 would apply to real world JavaScript."<p><a href="http://blog.ycombinator.com/new-hacker-news-guideline" rel="nofollow">http://blog.ycombinator.com/new-hacker-news-guideline</a>