summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Collins <nathan.collins@gmail.com>2019-05-21 13:44:55 -0400
committerMatthew Pickering <matthewtpickering@gmail.com>2019-05-29 16:29:57 +0100
commitc00ad4213db311d37c8e7a0867ad1853178636ee (patch)
treecef925230763a2a7081a956cf0e5028dc4e93d93
parent2d2aa2031b9abc3bff7b5585ab4201948c8bba7d (diff)
downloadhaskell-wip/thread-show.tar.gz
Improve ThreadId Show instancewip/thread-show
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"`.
-rw-r--r--libraries/base/GHC/Conc/Sync.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs
index 5c3e63a8e3..87491993f8 100644
--- a/libraries/base/GHC/Conc/Sync.hs
+++ b/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))