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

Add HZippable for zipping two HLists #160

Merged
merged 1 commit into from
Sep 22, 2019
Merged

Conversation

mwillsey
Copy link
Contributor

@mwillsey mwillsey commented Sep 20, 2019

Hello! Cool crate you've got here.

I found myself needing to zip HLists, so I implemented it. This is pretty much the easiest, simplest version of HList zipping out there. You could imagine making it more general in a couple ways:

  • Make it work over HLists of HLists!
    So zip(h1, h2) == hlist![ hlist![h1.head, h2.head], ...]
  • Maybe make it iterable instead of materializing the whole zipped HList, since zips are frequently only used to build up intermediate state, and are typically followed by map or fold. Although, there's a solid chance the optimizer can see through this.
  • This version only supports zipping lists of equal length. That seems right for the simplest version, but perhaps you could possibly want more flexibility?

This implements the trait, the inherent method, and a couple simple tests.

Comments welcome. Enjoy!

Copy link
Owner

@lloydmeta lloydmeta left a comment

Choose a reason for hiding this comment

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

This is awesome. Definitely fills a missing gap :) thanks!

@lloydmeta lloydmeta merged commit 13e4b6a into lloydmeta:master Sep 22, 2019
lloydmeta added a commit that referenced this pull request Dec 21, 2019
## [0.3.1] - 2019-12-21
- Refactoring derives (#157)
- Add support for deriving LabelledGeneric on enums (#158)
- Added HZippable (#160)
- Add a type macro for paths (#161)
@lloydmeta lloydmeta mentioned this pull request Dec 21, 2019
lloydmeta added a commit that referenced this pull request Dec 21, 2019
## [0.3.1] - 2019-12-21
- Refactoring derives (#157)
- Add support for deriving LabelledGeneric on enums (#158)
- Added HZippable (#160)
- Add a type macro for paths (#161)
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.

None yet

2 participants