[commit: ghc] wip/ttypeable: Fix withTypeable (6573b08)
git at git.haskell.org
git at git.haskell.org
Sat Oct 1 21:34:57 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ttypeable
Link : http://ghc.haskell.org/trac/ghc/changeset/6573b0846964970c1ebddadc783adf9fbb91d385/ghc
>---------------------------------------------------------------
commit 6573b0846964970c1ebddadc783adf9fbb91d385
Author: Ben Gamari <ben at smart-cactus.org>
Date: Fri May 20 18:07:01 2016 +0200
Fix withTypeable
>---------------------------------------------------------------
6573b0846964970c1ebddadc783adf9fbb91d385
libraries/base/Data/Typeable/Internal.hs | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index c72e41a..8c225a7 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -247,10 +247,13 @@ pattern TRApp :: forall k2 (t :: k2). ()
pattern TRApp f x <- TrApp _ f x
-- | Use a 'TypeRep' as 'Typeable' evidence.
-withTypeable :: TypeRep a -> (Typeable a => b) -> b
-withTypeable rep f = f' rep
- where f' :: TypeRep a -> b
- f' = unsafeCoerce rep
+withTypeable :: forall a r. 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)
-- | Pattern match on a type constructor
-- TODO: do we want to expose kinds in these patterns?
More information about the ghc-commits
mailing list