[commit: ghc] wip/ttypeable: Implement withTypeable (bbc8525)
git at git.haskell.org
git at git.haskell.org
Wed Apr 13 17:56:02 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ttypeable
Link : http://ghc.haskell.org/trac/ghc/changeset/bbc852581a4e7fddb5efdfe86e6f109121bb2366/ghc
>---------------------------------------------------------------
commit bbc852581a4e7fddb5efdfe86e6f109121bb2366
Author: Ben Gamari <ben at smart-cactus.org>
Date: Wed Apr 13 00:02:51 2016 +0200
Implement withTypeable
>---------------------------------------------------------------
bbc852581a4e7fddb5efdfe86e6f109121bb2366
libraries/base/Data/Typeable/Internal.hs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index 6d8b181..e38607f 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -85,6 +85,7 @@ import Data.Type.Equality
import GHC.Word
import GHC.Show
import GHC.TypeLits( KnownNat, KnownSymbol, natVal', symbolVal' )
+import Unsafe.Coerce
import GHC.Fingerprint.Type
import {-# SOURCE #-} GHC.Fingerprint
@@ -242,8 +243,11 @@ pattern TRApp :: forall k2 (t :: k2). ()
=> TypeRep a -> TypeRep b -> TypeRep t
pattern TRApp f x <- TrApp _ f x
+-- | Use a 'TypeRep' as 'Typeable' evidence.
withTypeable :: TypeRep a -> (Typeable a => b) -> b
-withTypeable = undefined
+withTypeable rep f = f' rep
+ where f' :: TypeRep a -> b
+ f' = unsafeCoerce rep
-- | Pattern match on a type constructor
-- TODO: do we want to expose kinds in these patterns?
More information about the ghc-commits
mailing list