[commit: ghc] master: Specialise Eq, Ord, Read, Show at Int, Char, String (4c03791)

git at git.haskell.org git at git.haskell.org
Thu Aug 28 11:11:58 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4c03791f986509c5d95adf50de555876ed05522e/ghc

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

commit 4c03791f986509c5d95adf50de555876ed05522e
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon May 12 10:53:09 2014 +0100

    Specialise Eq, Ord, Read, Show at Int, Char, String
    
    These instances are quite common, so it's good to have
    pre-specialised versions available


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

4c03791f986509c5d95adf50de555876ed05522e
 libraries/base/GHC/Read.lhs       | 3 +++
 libraries/base/GHC/Show.lhs       | 5 ++++-
 libraries/ghc-prim/GHC/Classes.hs | 4 ++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libraries/base/GHC/Read.lhs b/libraries/base/GHC/Read.lhs
index ab730e6..2fd9f30 100644
--- a/libraries/base/GHC/Read.lhs
+++ b/libraries/base/GHC/Read.lhs
@@ -423,6 +423,9 @@ instance Read a => Read (Maybe a) where
   readList     = readListDefault
 
 instance Read a => Read [a] where
+  {-# SPECIALISE instance Read [String] #-}
+  {-# SPECIALISE instance Read [Char] #-}
+  {-# SPECIALISE instance Read [Int] #-}
   readPrec     = readListPrec
   readListPrec = readListPrecDefault
   readList     = readListDefault
diff --git a/libraries/base/GHC/Show.lhs b/libraries/base/GHC/Show.lhs
index 45338e8..09c3c56 100644
--- a/libraries/base/GHC/Show.lhs
+++ b/libraries/base/GHC/Show.lhs
@@ -184,7 +184,10 @@ instance  Show ()  where
     showsPrec _ () = showString "()"
 
 instance Show a => Show [a]  where
-    showsPrec _         = showList
+  {-# SPECIALISE instance Show [String] #-}
+  {-# SPECIALISE instance Show [Char] #-}
+  {-# SPECIALISE instance Show [Int] #-}
+  showsPrec _         = showList
 
 instance Show Bool where
   showsPrec _ True  = showString "True"
diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs
index 5bb4cb6..9028f6e 100644
--- a/libraries/ghc-prim/GHC/Classes.hs
+++ b/libraries/ghc-prim/GHC/Classes.hs
@@ -83,7 +83,9 @@ deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
                => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
 
 instance (Eq a) => Eq [a] where
+    {-# SPECIALISE instance Eq [[Char]] #-}
     {-# SPECIALISE instance Eq [Char] #-}
+    {-# SPECIALISE instance Eq [Int] #-}
     []     == []     = True
     (x:xs) == (y:ys) = x == y && xs == ys
     _xs    == _ys    = False
@@ -181,7 +183,9 @@ deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
                => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
 
 instance (Ord a) => Ord [a] where
+    {-# SPECIALISE instance Ord [[Char]] #-}
     {-# SPECIALISE instance Ord [Char] #-}
+    {-# SPECIALISE instance Ord [Int] #-}
     compare []     []     = EQ
     compare []     (_:_)  = LT
     compare (_:_)  []     = GT



More information about the ghc-commits mailing list