Skip to content

Role annotation for TypeRepMap #113

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

Merged
merged 1 commit into from
Nov 8, 2021
Merged

Role annotation for TypeRepMap #113

merged 1 commit into from
Nov 8, 2021

Conversation

int-index
Copy link
Collaborator

Before this patch, GHC inferred the phantom role and allowed the user to implement unsafeCoerce via TypeRepMap:

unsafeCoerceTRM :: a -> b
unsafeCoerceTRM a = b
  where
    Just (Const b) = TRM.lookup @() (coerce (TRM.one @() (Const a)))

Fixes #112

Before this patch, GHC inferred the phantom role and allowed
the user to implement unsafeCoerce via TypeRepMap:

  unsafeCoerceTRM :: a -> b
  unsafeCoerceTRM a = b
    where
      Just (Const b) = TRM.lookup @() (coerce (TRM.one @() (Const a)))
@int-index
Copy link
Collaborator Author

With the annotation, GHC produces this error (as intended)

    • Couldn't match representation of type ‘b’ with that of ‘a’
        arising from a use of ‘coerce’
      ‘b’ is a rigid type variable bound by
        the type signature for:
          unsafeCoerceTRM :: forall a b. a -> b
        at test/Test.hs:29:1-25
      ‘a’ is a rigid type variable bound by
        the type signature for:
          unsafeCoerceTRM :: forall a b. a -> b
        at test/Test.hs:29:1-25

@chshersh chshersh added enhancement hacktoberfest-accepted Accept contributions during Hacktoberfest labels Oct 7, 2021
Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍🏻

@int-index
Copy link
Collaborator Author

@chshersh Perhaps you assumed I have merge permissions, but I do not.

@vrom911 vrom911 merged commit f453452 into main Nov 8, 2021
@vrom911 vrom911 deleted the role branch November 8, 2021 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement hacktoberfest-accepted Accept contributions during Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeRepMap should have role representational
3 participants