[Git][ghc/ghc][master] Improve ThreadId Show instance

Marge Bot gitlab at gitlab.haskell.org
Sat Jun 1 03:55:54 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
1d43d4a3 by Nathan Collins at 2019-06-01T03:55:49Z
Improve ThreadId Show instance

By making it include parens when a derived instance would. For example, this changes the (hypothetical) code `show (Just (ThreadId 3))` to produce `"Just (ThreadId 3)"` instead of the current `"Just ThreadId 3"`.

- - - - -


1 changed file:

- libraries/base/GHC/Conc/Sync.hs


Changes:

=====================================
libraries/base/GHC/Conc/Sync.hs
=====================================
@@ -113,7 +113,7 @@ import GHC.IORef
 import GHC.MVar
 import GHC.Ptr
 import GHC.Real         ( fromIntegral )
-import GHC.Show         ( Show(..), showString )
+import GHC.Show         ( Show(..), showParen, showString )
 import GHC.Stable       ( StablePtr(..) )
 import GHC.Weak
 
@@ -145,7 +145,7 @@ This misfeature will hopefully be corrected at a later date.
 
 -- | @since 4.2.0.0
 instance Show ThreadId where
-   showsPrec d t =
+   showsPrec d t = showParen (d >= 11) $
         showString "ThreadId " .
         showsPrec d (getThreadId (id2TSO t))
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/1d43d4a3e45d86261fa63591e99749cb7d3f68ed

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/1d43d4a3e45d86261fa63591e99749cb7d3f68ed
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190531/5451481b/attachment.html>


More information about the ghc-commits mailing list