diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-10-22 09:47:52 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-10-22 09:47:52 +0100 |
commit | ec33d03eeb11baa75d69c99959645f83dcab32c8 (patch) | |
tree | 6ef21d5ea5e1e83a7d55479d3856e84032f40546 /libraries | |
parent | 478132fc219d134bc1408f23ad3df348f3180340 (diff) | |
download | haskell-ec33d03eeb11baa75d69c99959645f83dcab32c8.tar.gz |
Make TExp's argument have nominal role (Trac #8459)
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index 9660dcddcf..c4f4435d75 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedTuples, RoleAnnotations #-} ----------------------------------------------------------------------------- -- | @@ -156,6 +156,7 @@ instance Applicative Q where -- ----------------------------------------------------- +type role TExp nominal -- See Note [Role of TExp] newtype TExp a = TExp { unType :: Exp } unTypeQ :: Q (TExp a) -> Q Exp @@ -166,6 +167,19 @@ unsafeTExpCoerce :: Q Exp -> Q (TExp a) unsafeTExpCoerce m = do { e <- m ; return (TExp e) } +{- Note [Role of TExp] +~~~~~~~~~~~~~~~~~~~~~~ +TExp's argument must have a nominal role, not phantom as would +be inferred (Trac #8459). Consider + + e :: TExp Age + e = MkAge 3 + + foo = $(coerce e) + 4::Int + +The splice will evaluate to (MkAge 3) and you can't add that to +4::Int. So you can't coerce a (TExp Age) to a (TExp Int). -} + ---------------------------------------------------- -- Packaged versions for the programmer, hiding the Quasi-ness |