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 support for unboxed datatypes, singletons #348

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

flupe
Copy link
Contributor

@flupe flupe commented Aug 14, 2024

WIP

Wanted to add support for the following Singleton datatype:

data Singleton (a : Set) : @0 a  Set where
  MkSingl :  x  Singleton a x

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 that Rezz requires you to think about propositional equality. And operations defined on Rezz that we want inlineable cannot pattern-match on refl (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:

  • A single constructor with a single (non-erased) argument.
  • Only erased indices.

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.

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