summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-05-12 10:53:09 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-08-28 11:14:09 +0100
commit4c03791f986509c5d95adf50de555876ed05522e (patch)
tree00ce8214b4094dde855ae01d4279bc680dc0a8b2 /libraries
parent9cf5906b692c31b7ec67856b0859cb0e33770651 (diff)
downloadhaskell-4c03791f986509c5d95adf50de555876ed05522e.tar.gz
Specialise Eq, Ord, Read, Show at Int, Char, String
These instances are quite common, so it's good to have pre-specialised versions available
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/GHC/Read.lhs3
-rw-r--r--libraries/base/GHC/Show.lhs5
-rw-r--r--libraries/ghc-prim/GHC/Classes.hs4
3 files changed, 11 insertions, 1 deletions
diff --git a/libraries/base/GHC/Read.lhs b/libraries/base/GHC/Read.lhs
index ab730e6652..2fd9f305b6 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 45338e8845..09c3c56cd9 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 5bb4cb681c..9028f6edcd 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