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

refactor: ♻️ add pipeline operator support #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kitos
Copy link
Member

@kitos kitos commented Aug 14, 2018

No description provided.

@kitos kitos self-assigned this Aug 14, 2018

interface IEvent {
date: Date;
}

const viewTags = talk => (talk.tags ? talk.tags : [])

export let eventTags = pipe(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting 🔥
But tt still seems to me that pipe(/***/) using is more informative. Maybe because |> operator is very new and rare for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always strive for using native implementation of functions and methods etc.
🚀🚀🚀🚀

uniq,
)
export let eventTags = e =>
e |> prop('talks') |> map(viewTags) |> flatten |> uniq
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this repetition e => e |>... looks a bit strange, after pretty descriptive curried .pipe :)

Copy link
Member Author

@kitos kitos Aug 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is because rambda's pipe and native pipeline operator do different things, but use same name. So e.g. in Elm you have two options: composition using << operatior and create pipelines using |> operator. Through my humble experience in elm, I learn that it is better use pipeline operator when we need the value now (e.g. in render function in react), because it doesn't support delayed evaluation. In this case it reads super awesome.
As for composition operator - I think it is clear, that it should be used for creating helper functions as in your example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in ReasonML doesn't support composition, and only pipelines. JFYI.

Feels unnatural from the very beginning. But used to it almost instantly

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

Successfully merging this pull request may close these issues.

4 participants