Function composition syntax

Bergi a.d.bergi at
Thu Sep 29 00:35:41 UTC 2016

interesting proposal!

> Here's what I propose: a new infix operator `>=>` (operator and direction
> can change) for composing two functions.

Sweet, reminds me of Kleisli composition in Haskell 
(which does something different to functions though).

> 2. It allows engines to statically optimize functions in the middle (avoid
> an extra function allocation), like with `f >=> x => console.log("x:" + x)`.

I don't understand that one. Wouldn't `x => console.log("x:" + f(x))` be 
optimised better (and also be easier to read)?

> 3. It can simplify the internal model some to deal with a binary pair instead
> of an array, especially when pipelining gets involved.
> 4. Composition isn't usually combined as a function in JS.

Can you clarify what you mean with this?

My questions would be
* What precedence would the operator have? Clearly something between 
member access and assignment, but what exactly?
   Particularly interesting cases:
   f >=> g (x)
   f >=> p ? g : h
   f >=> x => x >=> g
* Do we also need a partial application operator to make this syntax useful?
   I guess the discussions from and are relevant here.

Kind regards,

More information about the es-discuss mailing list