@hackage quiet0.1

Generic deriving of Read/Show with no record labels.

quiet

Generic deriving of Read / Show with no record labels.

Hackage Travis

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

For example:

newtype UserId = UserId { unUserId :: String } deriving (Show)

Renders as:

ghci> show (UserId "simon")
UserId {unUserId = "simon"}

With 'qshowsPrec' 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)

instance Show UserId where showsPrec = qshowsPrec
ghci> show (UserId "simon")
UserId "simon"

A compatible Read instance can also be derived using qreadPrec if necessary.

instance Read UserId where showsPrec = qreadPrec