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

Can't this be done using |> instead? #1

Open
imranismail opened this issue Mar 17, 2016 · 8 comments
Open

Can't this be done using |> instead? #1

imranismail opened this issue Mar 17, 2016 · 8 comments

Comments

@imranismail
Copy link

No description provided.

@miraks
Copy link
Owner

miraks commented Mar 17, 2016

Unfortunately, no. Constructions like this

a |> b

will give syntax error in JavaScript. It will be possible if Babel team provide API for parser plugins, but I don't know if they're planning to do that.

@Swizz
Copy link

Swizz commented Jun 16, 2016

To avoid syntax error, Babel seem to use two kinds of plugins : syntax and transform.

I think syntax allow the parser to work well with non standard syntax.
And transform, made the new syntax to JS one.

More informations.

@miraks
Copy link
Owner

miraks commented Jun 16, 2016

Yes, but API for parser (syntax) plugins isn't public and really poor. Actually babels "official" syntax plugins are hardcoded into babylon. For example, function bind syntax plugin: plugin code and babylon check.

@Swizz
Copy link

Swizz commented Jun 16, 2016

Oh.
I am just starting with Babel plugins.

So, the best way is to play with mrapogee/babel-plugin-syntax-pipeline-operator and mrapogee/babel-plugin-transform-pipeline-operator and to made a PR on babel/babylon to work well with the pipelineOperator option ?

Someone is interested about this functionality or this one work well for your needs ?

( cc @mrapogee )

@miraks
Copy link
Owner

miraks commented Jun 16, 2016

Looks like there's already been PR from @mrapogee but it never was merged.

@Swizz
Copy link

Swizz commented Jun 16, 2016

Oh. Got it !
Thanks for all your answers.

@samdesota
Copy link

samdesota commented Jun 16, 2016

Hey all,

I was playing around with this a few months ago and I forked babel to get this working on my setup, but the PR and code referenced above is actually from @mindeavor

I did make babylon branch mrapogee/babylon/tree/feature-pipeline that adds the pipeline operator to the syntax. If you get babel-core to import the source from that branch, you may be able to compile the pipeline operator if you include babel-plugin-transform-pipeline-operator in your .babelrc, though I haven't fully tested.

@Swizz
Copy link

Swizz commented Jun 17, 2016

I want to keep my hands on the official babylon.

This plugin works well, and finally the | operator is sweet.
I do not need bitwise operators in javascript.


But.. In the esnext proposal about pipeline, @mindeavor works with currying.

So ...

let result = "hello"
  |> doubleSay

become

let result = doubleSay("hello")

Here, you choose to unshift it in the arguments array like Elm.

So ...

let result = "hello"
  |> doubleSay(null)

become

let result = doubleSay("hello", null)

I think currying is a better way to do that stuff.
I will work on an alternative which implements currying stuffs.

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

No branches or pull requests

4 participants