From c00ad4213db311d37c8e7a0867ad1853178636ee Mon Sep 17 00:00:00 2001 From: Nathan Collins Date: Tue, 21 May 2019 13:44:55 -0400 Subject: 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"`. --- libraries/base/GHC/Conc/Sync.hs | 4 ++-- 1 file 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)) -- cgit v1.2.1