[commit: ghc] master: Fix recomputation of TypeRep in the instance for Typeable (s a) (#9203) (5ffc68b)

git at git.haskell.org git at git.haskell.org
Mon Jun 16 12:57:07 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/5ffc68bb75d34414987b5d1e5aa4f9061a7a7383/ghc

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

commit 5ffc68bb75d34414987b5d1e5aa4f9061a7a7383
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Fri Jun 13 16:57:16 2014 +0100

    Fix recomputation of TypeRep in the instance for Typeable (s a) (#9203)
    
    Summary:
    Every time we called typeRep on a type application, we were
    recomputing the TypeRep.  This showed up in a benchmark I had: #9203.
    
    Test Plan: Benchmark from #9203.
    
    Reviewers: simonpj, austin
    
    Subscribers: simonmar, relrod
    
    Differential Revision: https://phabricator.haskell.org/D19


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

5ffc68bb75d34414987b5d1e5aa4f9061a7a7383
 libraries/base/Data/Typeable/Internal.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index 0e42bcd..eae2109 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -263,7 +263,9 @@ type Typeable7 (a :: * -> * -> * -> * -> * -> * -> * -> *) = Typeable a
 
 -- | Kind-polymorphic Typeable instance for type application
 instance (Typeable s, Typeable a) => Typeable (s a) where
-  typeRep# _ = typeRep# (proxy# :: Proxy# s) `mkAppTy` typeRep# (proxy# :: Proxy# a)
+  typeRep# = \_ -> rep
+    where rep = typeRep# (proxy# :: Proxy# s)
+                   `mkAppTy` typeRep# (proxy# :: Proxy# a)
 
 ----------------- Showing TypeReps --------------------
 



More information about the ghc-commits mailing list