Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the open union by indexing the type from the tail end of the list. My thinking was that this way
decomp
andweaken
does not need to do any index modification or allocation and can simplyunsafeCoerce
.Basically I liked the idea of a "stable index".
The unfortunate consequence is that
decomp
along with any function using it gets an additionalHasLen
constraint. I implemented it at first using type level literals and a type level computationLen
for type level lists, but this would have meant carrying aKnownNat (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 likecould 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.