News for hackers. Stuff that matters.
Re:Haskell in ES6: Part 1 by olalonde on Saturday November 14, 2015 @05:24AM (#10565208)
Pretty cool. Few suggestions (which may or may not require babel):

- `f.apply(null, args)` calls can be replaced with `f(...args)`

- Your head function returns the first argument while your last function returns an array containing the last argument. I'd rewrite those functions as:

    const head = (x) => x;
    const last = (...xs) => xs[xs.length-1];
    const tail = (x, ...xs) => xs;
    const init = (...xs) => xs.slice(0, -1);
(Unfortunately it seems the rest operator can only appear as the last argument.)

- 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.

Looking forward to part 2.

Re:Haskell in ES6: Part 1 by nunull on Saturday November 14, 2015 @07:33AM (#10565441)
> head extracts the first element of a list, which must be non-empty.

Those functions operate on lists. I think it should read as follows.

    const head = (xs) => xs[0];
    const last = (xs) => xs[xs.length-1];
    const tail = (xs) => xs.slice(1);
    const init = (xs) => xs.slice(0, -1);
Am I missing something?
Re:Haskell in ES6: Part 1 by olalonde on Saturday November 14, 2015 @04:23PM (#10567319)
For some reason, the original author decided the arguments themselves were the "list" to operate on which is indeed a bit weird and non idiomatic.
Re:Haskell in ES6: Part 1 by heydenberk on Saturday November 14, 2015 @10:24AM (#10565935)
You can also avoid reversing the arrays before reducing them by calling the method `reduceRight`.