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 the primitive equality type to Clash.Core.TysPrim #1955

Merged
merged 2 commits into from
Oct 13, 2021

Conversation

alex-mckenna
Copy link
Contributor

@alex-mckenna alex-mckenna commented Oct 12, 2021

This PR adds the primitive equality type (~# ) to the map of primitive type constructors that Clash knows about. The main motivation for adding this is the ability to generate arbitrary GADTs in clash-hedgehog, although it may also be useful in tidying up code in clash-lib that handles type equality (as a lot of ~ in user code become ~# in GHC core).

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

Moving these types out of Clash.Core.Type means there is no longer
a circular import between Clash.Core.TysPrim and Clash.Core.Type.
This means we can access the whole of Clash.Core.Type without
needing to expose anything more in .hs-boot files.

We need this because the equality primitive type constructor (~#)
has a polymoprhic type which we need to manually reconstruct in
the TysPrim module, and currently cannot because not enough things
are available when importing boot modules.
The primitive type equality type is the basis of all typical type
equality types you see in GHC (~ and ~~ are special within GHC but
defined as though they are subclasses of a ~# b). As such this is
the equality that often appears in GHC / Clash core when coercions
are used in code (e.g. GADT pattern matches).
@alex-mckenna alex-mckenna enabled auto-merge (rebase) October 13, 2021 09:13
@alex-mckenna alex-mckenna merged commit 086a8c1 into master Oct 13, 2021
@alex-mckenna alex-mckenna deleted the tysprim-equality branch October 13, 2021 09:41
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.

None yet

2 participants