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

Reverse Indexed Union #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

JustusAdam
Copy link
Contributor

@JustusAdam JustusAdam commented Jun 4, 2018

This PR implements the open union by indexing the type from the tail end of the list. My thinking was that this way decomp and weaken does not need to do any index modification or allocation and can simply unsafeCoerce.

Basically I liked the idea of a "stable index".

The unfortunate consequence is that decomp along with any function using it gets an additional HasLen constraint. I implemented it at first using type level literals and a type level computation Len for type level lists, but this would have meant carrying a KnownNat (Len effs) constraint and furthermore it does not play nicely with partial lists, as the constraint does not carry through the type level computation, resulting in errors like could not deduce KnownNat (1 + Len effs) from a constraint KnwonNat (Len effs) etc.

Anyhow, this implementation works and passes the test suite. It does however run roughly twice as long 😞. It seems reallocating the union and decementing a Word value is cheaper than an additional, inlineable, compile time constant dict ...

As a result of the performance implications and the interface change I fully expect this PR to be rejected, but I figured I'd open it anyways, since I'd already done the work. Perhaps it'd make sense to park this in a branch somewhere, maybe Iit'll be of use some time in the future, who knows.

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.

1 participant