pipeline.macro icon indicating copy to clipboard operation
pipeline.macro copied to clipboard

Add option to generate a function

Open danielo515 opened this issue 7 years ago • 6 comments

Hello, thank you for this macro. It is very useful because I really think that there is no need for a new syntax for something as simple as this. However, there is a feature that I wish this macro has: being able to define new functions using the pipe macro. I use functional programming a lot, and one way to create point free functions is by piping several of them. If this macro provides that it will be perfect for almost any use case.

Regards

danielo515 avatar Dec 20 '18 08:12 danielo515

Could u give an example of the input & output?

Andarist avatar Dec 20 '18 09:12 Andarist

Sure! Basically for point free function composition

Input

const normalize = pipe(capitalize, camelCase, trim) 

Output

const normalize = (... args) => 
trim(camelCase(capitalize(... args))) 

danielo515 avatar Dec 20 '18 12:12 danielo515

That would make a good pipe.macro. At first it was going to be this macro's name but then I thought about your use case and thought I'd better name it pipeline.macro.

When I get some free time in following days I might create the other one.

Andarist avatar Dec 20 '18 16:12 Andarist

Oh, Thank you for thinking on the future ourselves! :smile: To be honest, I didn't even noticed your macro was pipeline instead of pipe!

danielo515 avatar Dec 21 '18 07:12 danielo515

Hello again @Andarist , I just created a small macro that does what we have been discussing. Is basically a fork of yours with some small changes. If you want to publish if yourself (at the end is based on your work) I can provide you the code. If you are Ok with it, I can fork your project and publish it under the pipe name.

Whatever you prefer.

Regards

danielo515 avatar Jan 02 '19 19:01 danielo515

I don't mind you forking this project and adjusting it to create pipe.macro - you could even fork it once again later to create compose.macro 😅

Andarist avatar Jan 14 '19 19:01 Andarist