[commit: ghc] master: Typeable: Generalize kind of represented type (9e46d88)
git at git.haskell.org
git at git.haskell.org
Thu Sep 21 16:09:57 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/9e46d88adeea1fd399dff1208aa5710d696c542c/ghc
>---------------------------------------------------------------
commit 9e46d88adeea1fd399dff1208aa5710d696c542c
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Tue Sep 19 18:59:18 2017 -0400
Typeable: Generalize kind of represented type
This allows withTypeable to be used with things that are of kind other
than Type.
Test Plan: Validate
Reviewers: austin, hvr, dfeuer
Reviewed By: dfeuer
Subscribers: rwbarton, thomie, dfeuer
Differential Revision: https://phabricator.haskell.org/D3996
>---------------------------------------------------------------
9e46d88adeea1fd399dff1208aa5710d696c542c
libraries/base/Data/Typeable/Internal.hs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index bc36fb1..f97a804 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -323,13 +323,14 @@ splitApp rep@(TrFun _ a b) = Just (IsApp (mkTrApp arr a) b)
splitApp (TrTyCon{}) = Nothing
-- | Use a 'TypeRep' as 'Typeable' evidence.
-withTypeable :: forall a r. TypeRep a -> (Typeable a => r) -> r
+withTypeable :: forall (a :: k) (r :: TYPE rep). ()
+ => TypeRep a -> (Typeable a => r) -> r
withTypeable rep k = unsafeCoerce k' rep
where k' :: Gift a r
k' = Gift k
-- | A helper to satisfy the type checker in 'withTypeable'.
-newtype Gift a r = Gift (Typeable a => r)
+newtype Gift a (r :: TYPE rep) = Gift (Typeable a => r)
-- | Pattern match on a type constructor
pattern Con :: forall k (a :: k). TyCon -> TypeRep a
More information about the ghc-commits
mailing list