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

Language Feature: Pipe Syntax #7

Open
mitchpaulus opened this issue Aug 29, 2021 · 1 comment
Open

Language Feature: Pipe Syntax #7

mitchpaulus opened this issue Aug 29, 2021 · 1 comment

Comments

@mitchpaulus
Copy link
Owner

Currently thinking about adding a feature similar to pipes or fluent syntax such that a pipeline of function transformations can be built from left to right. For me, this is easier to read than nested function application.

data | filter(\ item { item.'something' == 'something' } ) | map(\ item { item.'To Something Else' })
vs.
map(\ item { item.'To Something Else' }, filter(\ item { item.'something' == 'something' }), data) )

For this to be most useful, I'd have to change the order of some of the built in function signatures.

@mitchpaulus
Copy link
Owner Author

This issue can serve to document my thoughts through the design of this.

Ideally, this gets added to the grammar as another simple recursive operator like

expression : expression PIPEOPERATOR expression

This would require type checks at runtime, which is fine. The only issue is how to handle piping into a function that takes more than one argument. For example, I'd like to be able to do something like:

# filter function has 2 parameters, list and function. 
list | filter(\ item { item == 1 }) 

However, as it stands, the function application would throw an exception for not having the required number of arguments.

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

1 participant