Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Enable F#-Style Pipeline Operator #385

Open
vlasky opened this issue Feb 5, 2020 · 1 comment
Open

Enable F#-Style Pipeline Operator #385

vlasky opened this issue Feb 5, 2020 · 1 comment
Labels
in-discussion We are still discussing how to solve or implement it

Comments

@vlasky
Copy link

vlasky commented Feb 5, 2020

I think many developers would appreciate having the pipeline operator to make code neater, more concise and easier to debug. It is currently an ECMA TC39 Stage 1 proposal.

For those who are unfamiliar with the pipeline operator |>, here is an example. Given the following functions:

const doubleSay = str => str + ", " + str;
const capitalize = str => str[0].toUpperCase() + str.substring(1);
const exclaim = str => str + '!';

The following invocations are equivalent:

//With official Javascript syntax
const result = exclaim(capitalize(doubleSay("hello")));
result //=> "Hello, hello!"

//With pipeline operator
const result = "hello"
  |> doubleSay
  |> capitalize
  |> exclaim;

result //=> "Hello, hello!"

There are currently three variants of the pipeline operator that can be enabled:

  • "minimal" – Minimal Pipeline
  • "smart" - Smart Pipeline
  • "fsharp" - F#-Style Pipeline

The minimal variant would be a poor choice because it does not support the await keyword for asynchronous code.

I consider the fsharp variant to be preferable to the smart variant because of its clearer syntax. Having read some community discussion, other people seem to be leaning towards it.

See these links:

https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator
https://github.com/valtech-nyc/proposal-fsharp-pipelines

@hexsprite
Copy link

Why does this need to be part of Meteor? You can just enable this on a per-project basis using the .babelrc configuration...

@StorytellerCZ StorytellerCZ added the in-discussion We are still discussing how to solve or implement it label Mar 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-discussion We are still discussing how to solve or implement it
Projects
None yet
Development

No branches or pull requests

3 participants