From f453452940a81d106f5e6fbf29992b994fb33bd0 Mon Sep 17 00:00:00 2001 From: Vladislav Zavialov Date: Mon, 8 Nov 2021 19:17:35 +0300 Subject: [PATCH] Role annotation for TypeRepMap (#113) 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))) --- src/Data/TypeRepMap/Internal.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Data/TypeRepMap/Internal.hs b/src/Data/TypeRepMap/Internal.hs index 1eb82d7..bd7e3a9 100644 --- a/src/Data/TypeRepMap/Internal.hs +++ b/src/Data/TypeRepMap/Internal.hs @@ -9,6 +9,7 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Rank2Types #-} +{-# LANGUAGE RoleAnnotations #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE ViewPatterns #-} @@ -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