[commit: ghc] master: Redo instance to be more efficient (see #8778, #9203) (836981c)

git at git.haskell.org git at git.haskell.org
Mon Jun 16 22:59:31 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/836981c7dec5c794ca94408468535cc018dc2e82/ghc

>---------------------------------------------------------------

commit 836981c7dec5c794ca94408468535cc018dc2e82
Author: Iavor S. Diatchki <diatchki at galois.com>
Date:   Mon Jun 16 15:58:49 2014 -0700

    Redo instance to be more efficient (see #8778, #9203)


>---------------------------------------------------------------

836981c7dec5c794ca94408468535cc018dc2e82
 libraries/base/Data/Typeable/Internal.hs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index eae2109..5b1cde4 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -423,8 +423,9 @@ deriving instance Typeable Typeable
 -- Instances for type literals
 
 instance KnownNat n => Typeable (n :: Nat) where
-  typeRep# p = mkTyConApp tc []
+  typeRep# = \_ -> rep
     where
+    rep = mkTyConApp tc []
     tc = TyCon
            { tyConHash     = fingerprintString (mk pack modu nm)
            , tyConPackage  = pack
@@ -433,13 +434,14 @@ instance KnownNat n => Typeable (n :: Nat) where
            }
     pack = "base"
     modu = "GHC.TypeLits"
-    nm   = show (natVal' p)
+    nm   = show (natVal' (proxy# :: Proxy# n))
     mk a b c = a ++ " " ++ b ++ " " ++ c
 
 
 instance KnownSymbol s => Typeable (s :: Symbol) where
-  typeRep# p = mkTyConApp tc []
+  typeRep# = \_ -> rep
     where
+    rep = mkTyConApp tc []
     tc = TyCon
            { tyConHash     = fingerprintString (mk pack modu nm)
            , tyConPackage  = pack
@@ -448,6 +450,6 @@ instance KnownSymbol s => Typeable (s :: Symbol) where
            }
     pack = "base"
     modu = "GHC.TypeLits"
-    nm   = show (symbolVal' p)
+    nm   = show (symbolVal' (proxy# :: Proxy# s))
     mk a b c = a ++ " " ++ b ++ " " ++ c
 



More information about the ghc-commits mailing list