DEV Community

Discussion on: A Fallback for the JavaScript Pipeline Operator

Collapse
 
iquardt profile image
Iven Marquardt • Edited

This discussion doesn't surprise my since JS is hijacked by imperative paradigm disciples for a long time (sorry for being so blunt on this).

Anyway, I think a flat application syntax is the wrong reason to fight for, b/c we can always resort to...

const app_ = x => f => f(x);

const appn = fs => x =>
  arrFold(app_) (x) (fs);
Enter fullscreen mode Exit fullscreen mode

If you really don't care about mathematical functions you can even replace the array with rest syntax.

Anyway, there are three features you cannot properly introduce in userland:

  • do-notation (flat monadic chaining)
  • let expressions
  • pattern matching

You can use generators for deterministic monads and default-arguments to mimic let expressions and church-encoding to get pattern matching, but honestly, these workarounds suck.

If I had these tools at my disposal, I'd never complain again. Okay, maybe a type system based on parametric polymorphism would be nice too.