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

Consider simplifying the digit implementation? #13

Open
turion opened this issue Jun 9, 2021 · 3 comments
Open

Consider simplifying the digit implementation? #13

turion opened this issue Jun 9, 2021 · 3 comments

Comments

@turion
Copy link
Contributor

turion commented Jun 9, 2021

In https://github.com/thalesmg/hallux/blob/master/lib/hallux/internal/digit.ex, the digit type is implemented as having 1 to 4 values. According to https://www.cs.tufts.edu/~nr/cs257/archive/koen-claessen/finger-trees.pdf, you can get rid of the 4-value case. I have a toy implementation doing this: https://github.com/turion/mano

If you want I can submit a PR to hallux deletign the 4-value case.

@thalesmg
Copy link
Owner

Thanks for bringing this other paper up, I didn't know it! I'll have a look at it.

Just setting some expectations: I must say I'm a bit hesitant of doing a change like this (at least with my limited current knowledge at this moment 🙈 ) because I took for "inspiration" the Data.FingerTree and Data.Seq from Haskell's fingertree and base, respectively. (It's a mostly literal translation from fingertree).

Data.Seq from base is quite heavily used, and I just confirmed it still uses the 4-digit version. So, mimicking them gives me more confidence. I'm curious: do you know perchance why it still uses the 4-digit version? Is there a benefit from using the 3-digit one (aside from less cases to consider in pattern matching)?

I'll read the paper, so I can make a better judgement!

Again, thanks for bringing this up! 🍻

@turion
Copy link
Contributor Author

turion commented Jun 10, 2021

The main reason this is not adopted is probably only because finger trees with 4-digits are well-tested since ~20 years by many people, and the version without 4-digits is less than a year old, and "only" submitted as a functional pearl without extensive real-world benchmarks.

@turion
Copy link
Contributor Author

turion commented Jun 10, 2021

Is there a benefit from using the 3-digit one (aside from less cases to consider in pattern matching)?

I don't know of any other benefit, in particular no performance improvement.

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

2 participants