Skip to content

Commit

Permalink
Role annotation for TypeRepMap (#113)
Browse files Browse the repository at this point in the history
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)))
  • Loading branch information
int-index authored Nov 8, 2021
1 parent 420608b commit f453452
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Data/TypeRepMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE RoleAnnotations #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE ViewPatterns #-}
Expand Down Expand Up @@ -92,6 +93,7 @@ The runtime representation of 'TypeRepMap' is an array, not a tree. This makes
'lookup' significantly more efficient.
-}
type role TypeRepMap representational
data TypeRepMap (f :: k -> Type) =
TypeRepMap
{ fingerprintAs :: {-# UNPACK #-} !(PrimArray Word64) -- ^ first components of key fingerprints
Expand Down

0 comments on commit f453452

Please sign in to comment.