Skip to content

‘Identity instance’: Outputable SDoc

Is there reason why there isn't an ‘identity instance’¹ for Outputable?

class Outputable a where
  ppr :: a -> SDoc

instance Outputabe SDoc where
  ppr :: SDoc -> SDoc
  ppr = id

A benefit: lets me always use pprTraceIt :: Outputable a => String -> a -> a, I know I can use pprTrace but I like not having to think about the type of what I'm tracing and neither functions work to debug something like Either SDoc Name.


¹ For lack of a better term, something like

class Foo a where
  foo :: a -> A

instance Foo A where
  foo :: A -> A
  foo = id @A
Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHC API
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information