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: Update Zip operation in point free style. #181

Merged
merged 5 commits into from
Aug 22, 2021

Conversation

drupol
Copy link
Collaborator

@drupol drupol commented Aug 15, 2021

This PR:

  • Update Zip in point free style.

@drupol drupol added the enhancement New feature or request label Aug 15, 2021
@drupol drupol force-pushed the refactor/update-zip-operation branch from 979865f to 8055c07 Compare August 16, 2021 20:06
@drupol drupol marked this pull request as ready for review August 16, 2021 20:15
@drupol drupol enabled auto-merge (squash) August 17, 2021 21:21
Copy link
Collaborator

@AlexandruGG AlexandruGG left a comment

Choose a reason for hiding this comment

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

@drupol this one feels like another case where things are increasing in complexity and more dependencies added (Pipe, Reduce, Flatten), especially if we compare to the previous form which was relatively simple.

What's the benefit of doing this? And is there any way to make things a bit more readable?

@drupol
Copy link
Collaborator Author

drupol commented Aug 19, 2021

The point-free style is considered by some author as the ultimate functional programming style.

To put things simply, a function of type t1 -> t2 describes a transformation from one element of type t1 into another element of type t2. The idea is that "pointful" functions (written using variables) emphasize elements (when you write function (Iterator $iterator) => ..., you're describing what's happening to the element $iterator), while "point-free" functions (expressed without using variables) emphasize the transformation itself, as a composition of simpler transforms.

Advocates of the point-free style argue that transformations should indeed be the central concept, and that the pointful notation, while easy to use, distracts us from this noble ideal.

This library is about transformations, and I think we should emphasize that in the code.

I also consider this as a challenge in order to be succinct and to express pipelined computations as a composition of functions rather than thinking of threading arguments through each other.

Actually I found this very readable, it's just a matter of habits, that said, I will make a slight modification tonight that will make it a bit more easier to read :)

@drupol drupol marked this pull request as draft August 19, 2021 15:32
auto-merge was automatically disabled August 19, 2021 15:32

Pull request was converted to draft

@drupol drupol marked this pull request as ready for review August 19, 2021 17:14
@drupol drupol enabled auto-merge (squash) August 19, 2021 17:14
@drupol drupol marked this pull request as draft August 19, 2021 17:36
auto-merge was automatically disabled August 19, 2021 17:36

Pull request was converted to draft

@drupol drupol force-pushed the refactor/update-zip-operation branch from 0710540 to e3cceed Compare August 19, 2021 17:48
@drupol drupol marked this pull request as ready for review August 19, 2021 17:49
Copy link
Collaborator

@AlexandruGG AlexandruGG left a comment

Choose a reason for hiding this comment

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

@drupol Thanks for the explanation and the little refactor!

I completely understand your view of the transformations and the beauty of composing functions to achieve them. I think the new form is definitely clearer in what it's doing 😁

Feel free to merge this, I'm not hitting "approve" so you get the chance to check the other comment 😄

Co-authored-by: Alex Gidei <34811569+AlexandruGG@users.noreply.github.com>
@drupol drupol merged commit 8fea387 into master Aug 22, 2021
@drupol drupol deleted the refactor/update-zip-operation branch August 22, 2021 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants