[commit: ghc] wip/ttypeable: Implement withTypeable (913ccde)
git at git.haskell.org
git at git.haskell.org
Fri Jul 8 14:31:42 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ttypeable
Link : http://ghc.haskell.org/trac/ghc/changeset/913ccde1938ca3704aacb43f1ab37f3ae1a8f110/ghc
>---------------------------------------------------------------
commit 913ccde1938ca3704aacb43f1ab37f3ae1a8f110
Author: Ben Gamari <ben at smart-cactus.org>
Date: Wed Apr 13 00:02:51 2016 +0200
Implement withTypeable
>---------------------------------------------------------------
913ccde1938ca3704aacb43f1ab37f3ae1a8f110
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 b2d7726..c72e41a 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
@@ -245,8 +246,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