Hi,
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 http://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Monad.html#v:-62--61--62- (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 https://github.com/tc39/proposal-bind-operator/issues/35 and https://github.com/tc39/proposal-bind-operator/issues/26 are relevant here.

Kind regards,
 Bergi
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to