Add support for unboxed datatypes, singletons #348
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.
WIP
Wanted to add support for the following
Singleton
datatype:Pattern-matching on a singleton witnesses that the value contained inside it mirrors the type-level (erased) index. So, what's the difference with
Rezz
? None really, they suit the same purpose, with the difference thatRezz
requires you to think about propositional equality. And operations defined onRezz
that we want inlineable cannot pattern-match onrefl
(which they should be able to, more on that later) so they are quite annoying to write.As is the tradition with agda2hs features, rather than just add
Singleton
as a builtin, I wanted to add support for unboxed datatypes, which must abide by the same rules as unboxed records, that is:This sounded nice and all, until I remembered how we compile inline functions: reduce and unfold defs and pray that Agda does the record-pattern translation. So I eventually went ahead and reimplemented the inlining functionality without relying on Agda's unfolding. Seems to work okay for now, and should enable us to support pattern-matching on
refl
and such.