[commit: ghc] master: Show: Add ShowS for ", " (615ded1)

git at git.haskell.org git at git.haskell.org
Fri Mar 3 14:25:19 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/615ded12f47d3685606bcfabb4f1980e748be1d9/ghc

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

commit 615ded12f47d3685606bcfabb4f1980e748be1d9
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Thu Mar 2 18:37:23 2017 -0500

    Show: Add ShowS for ", "
    
    This is produced often enough in derived Show instances that it is likely
    worthwhile defining it once.


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

615ded12f47d3685606bcfabb4f1980e748be1d9
 compiler/prelude/PrelNames.hs    | 3 ++-
 compiler/typecheck/TcGenDeriv.hs | 3 ++-
 libraries/base/GHC/Show.hs       | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/compiler/prelude/PrelNames.hs b/compiler/prelude/PrelNames.hs
index 470b736..0ae3867 100644
--- a/compiler/prelude/PrelNames.hs
+++ b/compiler/prelude/PrelNames.hs
@@ -751,13 +751,14 @@ prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
 pfail_RDR               = varQual_RDR  rEAD_PREC (fsLit "pfail")
 
 showList_RDR, showList___RDR, showsPrec_RDR, shows_RDR, showString_RDR,
-    showSpace_RDR, showParen_RDR :: RdrName
+    showSpace_RDR, showCommaSpace_RDR, showParen_RDR :: RdrName
 showList_RDR            = varQual_RDR gHC_SHOW (fsLit "showList")
 showList___RDR          = varQual_RDR gHC_SHOW (fsLit "showList__")
 showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
 shows_RDR               = varQual_RDR gHC_SHOW (fsLit "shows")
 showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
 showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
+showCommaSpace_RDR      = varQual_RDR gHC_SHOW (fsLit "showCommaSpace")
 showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
 
 undefined_RDR :: RdrName
diff --git a/compiler/typecheck/TcGenDeriv.hs b/compiler/typecheck/TcGenDeriv.hs
index 533664e..c46c291 100644
--- a/compiler/typecheck/TcGenDeriv.hs
+++ b/compiler/typecheck/TcGenDeriv.hs
@@ -1125,6 +1125,7 @@ gen_Show_binds get_fixity loc tycon
     -----------------------------------------------------------------------
     data_cons = tyConDataCons tycon
     shows_prec = mk_FunBind loc showsPrec_RDR (map pats_etc data_cons)
+    comma_space = nlHsVar showCommaSpace_RDR
 
     pats_etc data_con
       | nullary_con =  -- skip the showParen junk...
@@ -1174,7 +1175,7 @@ gen_Show_binds get_fixity loc tycon
                 -- Assumption for record syntax: no of fields == no of
                 -- labelled fields (and in same order)
              show_record_args = concat $
-                                intersperse [mk_showString_app ", "] $
+                                intersperse [comma_space] $
                                 [ [show_label lbl, arg]
                                 | (lbl,arg) <- zipEqual "gen_Show_binds"
                                                         labels show_args ]
diff --git a/libraries/base/GHC/Show.hs b/libraries/base/GHC/Show.hs
index c52824b..6965335 100644
--- a/libraries/base/GHC/Show.hs
+++ b/libraries/base/GHC/Show.hs
@@ -39,7 +39,7 @@ module GHC.Show
 
         -- Show support code
         shows, showChar, showString, showMultiLineString,
-        showParen, showList__, showSpace,
+        showParen, showList__, showCommaSpace, showSpace,
         showLitChar, showLitString, protectEsc,
         intToDigit, showSignedInt,
         appPrec, appPrec1,
@@ -344,6 +344,8 @@ showParen b p   =  if b then showChar '(' . p . showChar ')' else p
 showSpace :: ShowS
 showSpace = {-showChar ' '-} \ xs -> ' ' : xs
 
+showCommaSpace :: ShowS
+showCommaSpace = showString ", "
 -- Code specific for characters
 
 -- | Convert a character to a string using only printable characters,



More information about the ghc-commits mailing list