Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Pipeline Operator #5443

Open
k15a opened this issue Dec 1, 2017 · 26 comments
Open

Support Pipeline Operator #5443

k15a opened this issue Dec 1, 2017 · 26 comments

Comments

@k15a
Copy link

k15a commented Dec 1, 2017

The pipeline |> operator is a proposal which is currently in stage 1. It would be great if flow could support this proposal.

I could imagine that this is not too hard because it's basically only syntactic sugar for function calls IIRC.

https://github.com/tc39/proposal-pipeline-operator

@Hypnosphi
Copy link
Contributor

I would like to help implementing that. Where should I start?

@gajus
Copy link

gajus commented Jul 30, 2018

It has landed in Firefox under --enable-pipeline-operator compile flag.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator

@mAAdhaTTah
Copy link

I've commented this elsewhere, but I strongly suggest avoiding implementing the pipeline operator until we've at least selected which of the 3 proposals we're going with. It's been in Firefox for some time behind a flag, but my current understanding is the FF implement doesn't currently conform with any of the 3 proposals' current semantics.

@sartaj
Copy link

sartaj commented Aug 2, 2018

@mAAdhaTTah It seems Proposal 0 fits specs for all other proposals. Couldn't flow at least implement this minimal behavior to start? This would benefit anyone who would love to use piped unary functions with typed data structures.

@mAAdhaTTah
Copy link

Don't assume that will remain the case. We're exploring some ideas to drop parens around arrow functions in F# Pipelines. These proposals are stage 1 because they're still very much in flux.

@Hypnosphi
Copy link
Contributor

Flow is still 0.x so I personally wouldn't mind if this would be supported in some form now and then changed later

@johnsonw
Copy link

I would really like to see this move forward. After spending quite some time in F# I find myself using the pipeline operator routinely. https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator shows that we can use the "minimal" proposal at the moment. Is there any way to suppress the following error:

 21:   const c = xs |> fn1 |> fn2 |> fn3;
                            ^ Unexpected token >

// $FlowFixMe doesn't seem to ignore the error.

@pnevyk
Copy link
Contributor

pnevyk commented Oct 19, 2018

// $FlowFixMe doesn't seem to ignore the error.

That's because $FlowFixMe is for suppressing type errors. However, this is "syntax error" for flow parser so it does not get into the type checking phase at all.

@bsmith-cycorp
Copy link

bsmith-cycorp commented Oct 22, 2018

Please please please fix this. The "minimal" spec (1-arity functions) seems very unlikely to change and relatively easy to parse, and it's pretty much all that people are asking for.

@mAAdhaTTah
Copy link

The "minimal" spec (1-arity functions) seems very unlikely to change

Do not assume this. There are 3 proposals, and the "minimal" spec is unlikely to be accepted as-is.

@Hypnosphi
Copy link
Contributor

Hypnosphi commented Jun 6, 2019

the "minimal" spec is unlikely to be accepted as-is

Its benefit is not that it's the one that will be accepted most likely, but the fact that other proposals are supersets of the minimal one. So if you support the minimal proposal now, there will be no breaking changes required to support whichever of the advanced proposal wins later

@mAAdhaTTah
Copy link

mAAdhaTTah commented Jun 6, 2019

the fact that other proposals are supersets of the minimal one.

They are not. This is valid in minimal:

x |> f(y)

but not currently valid in smart (requires a placeholder token).

@gajus
Copy link

gajus commented Jul 6, 2019

@goodmind
Copy link
Contributor

goodmind commented Jul 6, 2019

@gajus which one? F# or smart?

@gajus
Copy link

gajus commented Jul 6, 2019

F# Pipelines

Based on the conversations I have been seeing, it is extremely unlikely that smart is going to be implemented. F# Pipelines is the way forward.

@goodmind
Copy link
Contributor

goodmind commented Jul 6, 2019

Can't find what stage it is on

@noppa
Copy link
Contributor

noppa commented Jul 6, 2019

There are three different proposals being considered, the two mentioned in the proposal readme and Elixir-style pipelines. It would be pretty amazing if Flow could support all three with a configuration option to select which one (if any) to use in a project. That way people could experiment with the different proposals and give feedback on them. Although of course adding support for all three is a lot more work than for just one.

@goodmind
Copy link
Contributor

goodmind commented Jul 6, 2019

@mAAdhaTTah can you confirm that smart pipelines is unlikely to be implemented?

@goodmind
Copy link
Contributor

goodmind commented Jul 6, 2019

@noppa
this is getting out of hand
s/two/three

@goodmind
Copy link
Contributor

goodmind commented Jul 6, 2019

I might give a try at implementing F# pipeline operator parsing in Flow (without typechecking)

@goodmind goodmind mentioned this issue Jul 6, 2019
3 tasks
@mAAdhaTTah
Copy link

No, I can not confirm that. Until a final decision is made, all options are on the table.

@chicoxyzzy
Copy link
Contributor

The final decision on which proposal to choose most likely won't be made until at least October TC39 meeting or even later

@goodmind
Copy link
Contributor

goodmind commented Jul 8, 2019

@noppa I can't find Elixir proposal itself, only mentions about it

@noppa
Copy link
Contributor

noppa commented Jul 8, 2019

@goodmind I don't think there's anything more at the moment than the issue tc39/proposal-pipeline-operator#143, with some pretty good arguments for it (comment) and against (comment, comment).

I don't think there's actually a Babel plugin for it yet and I'm not sure if the specifics of it are defined well enough to actually implement yet... Sorry if I misled you by calling it a proposal when at the moment it seems to be more like a suggestion.

If you are doing the F#-style proposal, btw, there's also partial application, which is a separate proposal but would go well with the F# style pipelines.

@mAAdhaTTah
Copy link

Yeah, there currently aren't any active plans to implement Elixir-style pipelines in Babel, nor are there specs for it, although Daniel (the proposal champion) has been pushing a "try everything" philosophy, so we may end up doing it.

@goodmind
Copy link
Contributor

goodmind commented Jul 10, 2019

@gajus Well, I guess if you want to try F# pipelines with Flow you can build my branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests