HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulequiet-0.2Haskell2010

Quiet

Generic deriving of Read / Show with no record labels.

Often one wants to create a newtype which has a convenient field accessor like unUserId below, but that unfortunately makes the Show instance which is derived overly verbose.

For example:

newtype UserId = UserId { unUserId :: String }
  deriving (Read, Show)
Example2 expressions
show (UserId "simon")UserId {unUserId = "simon"}read "UserId {unUserId = \"simon\"}" :: UserIdUserId {unUserId = "simon"}

With DerivingVia Quiet you can have a Show instance which doesn't print the field labels. It will render as if the unUserId accessor wasn't present at all.

newtype UserId = UserId { unUserId :: String }
  deriving (Generic)
  deriving (Read, Show) via (Quiet UserId)
Example2 expressions
show (UserId "simon")UserId "simon"read "UserId \"simon\"" :: UserIdUserId "simon"

If you want to derive Read / Show without using DerivingVia then you can use qreadPrec and qshowsPrec directly.

instance Read UserId where readPrec = qreadPrec
instance Show UserId where showsPrec = qshowsPrec
  • 1 type
  • 2 values
  • Packagequiet-0.2
  • Exports3
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceQuiet.hs
valueqshowsPrec :: (Generic a, QShow (Rep a)) => Int -> a -> ShowS
#

This implements a quiet version of Text.Show.showsPrec which omits labels for record fields when rendering constructors.