Skip to content

Commit 0a31c02

Browse files
committed
AnyMessage: show instance
Show instance which shows parens if needed.
1 parent 264717f commit 0a31c02

File tree

1 file changed

+4
-2
lines changed
  • typed-protocols/src/Network/TypedProtocol

1 file changed

+4
-2
lines changed

typed-protocols/src/Network/TypedProtocol/Codec.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,10 @@ data AnyMessage ps where
322322
-- requires @UndecidableInstances@ and @QuantifiedConstraints@.
323323
instance (forall (st :: ps) (st' :: ps). Show (Message ps st st'))
324324
=> Show (AnyMessage ps) where
325-
show (AnyMessage (msg :: Message ps st st')) =
326-
"AnyMessage " ++ show msg
325+
showsPrec d (AnyMessage (msg :: Message ps st st')) =
326+
showParen (d > app_prec) (showString "AnyMessage " . showsPrec (app_prec + 1) msg)
327+
where
328+
app_prec = 10
327329

328330

329331
-- | A convenient pattern synonym which unwrap 'AnyMessage' giving both the

0 commit comments

Comments
 (0)