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

Pipeline Operator (Stage 1) #29

Open
2 tasks done
hzoo opened this issue Sep 26, 2017 · 26 comments
Open
2 tasks done

Pipeline Operator (Stage 1) #29

hzoo opened this issue Sep 26, 2017 · 26 comments

Comments

@hzoo
Copy link
Member

hzoo commented Sep 26, 2017

Champion: @littledan
Spec Repo: https://github.com/tc39/proposal-pipeline-operator
First presented at Sept 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/09.md
Slides: https://docs.google.com/presentation/d/1qiWFzi5dkjuUVGcFXwypuQbEbZk-BV7unX0bYurcQsA/edit#slide=id.p
Related proposal: Partial Application https://github.com/rbuckton/proposal-partial-application by @rbuckton
Related proposal: Function Bind Operator https://github.com/tc39/proposal-bind-operator

Basic Example

Input

let result = "hello"
  |> doubleSay
  |> capitalize
  |> exclaim;
result //=> "Hello, hello!"

Output

let result = exclaim(capitalize(doubleSay("hello")));
result //=> "Hello, hello!"

Initial Implementation (would need updating to v7)

Old/Alternative Implementations

cc @gilbert, @SuperPaintman

Implementation

@nicolo-ribaudo
Copy link
Member

There is also another Babylon implementation (https://github.com/airdwing/babylon), which could be already mergeable because the fork was updated one month ago.

@hzoo
Copy link
Member Author

hzoo commented Sep 26, 2017

didn't know it was that simple ha - needs hasPlugin, tests, readme, etc though

@nicolo-ribaudo
Copy link
Member

Oh right 😅

@hzoo
Copy link
Member Author

hzoo commented Sep 29, 2017

Merged the parser PR

@hzoo
Copy link
Member Author

hzoo commented Sep 30, 2017

Transform PR: babel/babel#6335, test at https://babeljs.io/repl/build/5099/

@hzoo
Copy link
Member Author

hzoo commented Sep 30, 2017

Linking to Dan's syntax concern (not specced) tc39/proposal-pipeline-operator#60

@hzoo
Copy link
Member Author

hzoo commented Oct 2, 2017

Some syntax used in the spec repo examples that doesn't parse currently: are these supposed to be?

class Comment extends Model |> Editable |> Sharable {}

@ljharb
Copy link
Member

ljharb commented Oct 2, 2017

I would expect that to parse as long as Model |> Editable |> Sharable parses, since the RHS of extends is an expression.

@littledan
Copy link

@hzoo You are right, the explained does not match the spec. Sorry for this state of things. I hope to address it soon.

@littledan
Copy link

Address in the sense of adding more parens in the explainer; I don't have a clear idea of alternative syntax.

@littledan
Copy link

@js-choi @mAAdhaTTah Could you summarize the current plans here for future reference?

@js-choi
Copy link

js-choi commented Mar 13, 2018

@littledan I’ll write one.

Edit: Dang, beaten to it.

@mAAdhaTTah
Copy link

mAAdhaTTah commented Mar 13, 2018

@littledan We're working in parallel on a configuration option for two proposals: F# Pipelines & Smart Pipelines. @js-choi is currently working on the babylon changes required to parse the Smart Pipelines, behind a smartPipelines plugin / flag. Once his is finished, I'm going to follow up with changes of my own behind a fsharpPipelines flag. All of that will be captured in babel/babel#7458

As part of this work, I'll be submitting a PR to the pipeline proposal itself to update the spec to remove any current handling of await, and update the parser to match the current spec, with await being an early error and fixing the current handling of unparen'd arrows. Depending on where we land in tc39/proposal-pipeline-operator#104, F# will either match this behavior or implement the new behavior.

Once the parser changes are complete, we'll then be updating the babel pipeline plugin with a configuration options for these proposals. I don't think we've specified what that flag is just yet, but the intention is to have three "modes": spec, fsharp, & smart, with spec matching whatever's accepted in the current spec.

I'll also eventually be writing up a spec & explainer for F# pipelines. The current spec & explainer for smart pipelines is here: https://github.com/js-choi/proposal-smart-pipelines

@danielo515
Copy link

Is this available to test on the REPL ? I can't get it to work

@mAAdhaTTah
Copy link

@danielo515 The minimal proposal is in babel right now, but the rest of what I explained is still in progress. Past 2 months have been busy for both JS Choi & me, so we haven't made as much progress as we'd like.

Also, the plan has changed from what was described above; we're going to add all those flags in a fork of babylon (now @babel/parser) and only merge back the version that advances to Stage 2. During that time, the various flags / configurations won't be in babel proper.

@nicolo-ribaudo
Copy link
Member

I think that we could merge them even before stage 2, since now Babylon supports plugin options

@mAAdhaTTah
Copy link

Couple updates I want to drop in here:

  1. Initially, we were going to make the changes in a babylon fork, but as @nicolo-ribaudo helpfully points out, we have options in the parser now, so we can use a single flag for the pipeline operator with options, which will be cleaner than multiple flags.
  2. Suggested by @ljharb, the default for the pipeline operator will be "Throw an error unless you specified which proposal you want," which enables us to go from "no defaults allowed" -> "default is accepted spec" whenever pipeline settles on a particular proposal.

I'll be working on point 2 ASAP, as that needs to land before babel 7 leaves beta.

@zfrisch
Copy link

zfrisch commented Dec 19, 2018

I was curious what was up with the pipeline operator in babel? Every plugin I've tried hasn't worked, and even in the repl with the specified package it won't compile.

I'm excited by this proposal and I recently wrote an article about the pipeline operator (Medium: JS Pipeline Operator Article) and created my own pipeline operator playground: (CodePen: PipeLine Operator Playground).

I was hoping that by now babel would have an official working plugin available for it, but nothing seems to be checking out.

@mAAdhaTTah
Copy link

@zfrisch There's a Project on babel with the current status: https://github.com/babel/babel/projects/9 - we have several proposals we're trying to land, so a lot going on before we're done.

@js-choi
Copy link

js-choi commented Dec 19, 2018

See also @mAAdhaTTah’s article “What’s Happening with the Pipeline Proposal?”. We’re working on implementing a bunch of preliminary proposals, each with their own trade-offs, so that TC39 and others can try them out, hands on.

@gajus
Copy link

gajus commented Jul 6, 2019

What is the current stage of this proposal?

CC facebook/flow#5443

@chicoxyzzy
Copy link
Member

chicoxyzzy commented Jul 6, 2019

Stage 1, last presented in March 2018

@goodmind
Copy link

goodmind commented Jul 7, 2019

Is this minimal or F#?

@ljharb
Copy link
Member

ljharb commented Jul 7, 2019

@goodmind none has been selected. It's not until stage 2 that the shape of the solution is mostly settled.

@jazithedev
Copy link

@ljharb When will be the "stage 2"?

@ljharb
Copy link
Member

ljharb commented Nov 11, 2020

@ktrzos no idea - the champions of the proposal would have to decide its ready, and add it to a meeting agenda in advance of the deadline for doing so, and then the committee would have to agree. The next such opportunity is at the end of January, but it remains up to the proposal champions to decide when that next step is warranted.

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