Skip to content

Improvement to 'Embeddable' typeclass through 'Embedding' GADT - #21

Merged
RobinWebbers merged 7 commits into
mainfrom
hetero-embed
Jul 31, 2026
Merged

Improvement to 'Embeddable' typeclass through 'Embedding' GADT#21
RobinWebbers merged 7 commits into
mainfrom
hetero-embed

Conversation

@RobinWebbers

Copy link
Copy Markdown
Member

This pull request closes #4. This leaves open the kindedness check of the two types. That is, we may embed two types that have different runtime representations. It is unclear whether two kinds that have type arguments with different runtime reps should also allow for embeddings. My intuition says yes. This check is a little bit annoying to perform however. I will open a new issue to tackle this so we can pull this in for the time being!

To list the changes we made:

  • Renamed PluginAxiom to Embeddings, typeAxioms to typeEmbeddings, etc.
  • Adjusted type embeddings to use the InstEnv for more robust instance lookups.
  • Added new Embeddable typeclass that wraps a Embedding GADT which carries a coercion equality between the heterogenous kinds, as well as the original coercion.
  • Type embeddings now use Embeddable only. Note that Embeddable is unidirectional, so we only support instances one way. Embeddable has a functional dependency where the lhs type decides the rhs.
  • Adjusted type subsumption to use the InstEnvs now.
  • Adjusted fresh variable generation to use InstEnvs now. It is a little bit limited in that it doesn't work with type variables. This is consistent with the old behaviour. We will not work on fixing this directly, instead doing so via Fresh variable generation API #3.

@RobinWebbers RobinWebbers linked an issue Jul 30, 2026 that may be closed by this pull request
@RobinWebbers RobinWebbers self-assigned this Jul 30, 2026
… We have yet to resolve the term embeddings. The fresh variable generation probably also needs to be changed afterwards.
…imply expand. Makes the declarations a lot easier, as everything is now Haskell and we just pass in a Template Haskell name. Implemented the term embeddings. TODO: Propagate the usage of these new embeddings to the symbolic evaluator!
…ixed the 'Embedding' datatype instance, which got the wrong coercion.
…ug in generate Embedding instance where we used the wrong destination type. Added functional dependency on 'Embeddable', locking in to the class being non-symmetric. Though the coercion is symmetric, the direction of the embedding is not!
@RobinWebbers
RobinWebbers merged commit 8658787 into main Jul 31, 2026
1 check passed
@RobinWebbers
RobinWebbers deleted the hetero-embed branch July 31, 2026 09:05
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.

Embeddings using GADT

1 participant