quiet: Generic deriving of Read/Show with no record labels.

[ bsd3, generics, library ] [ Propose Tags ]

Please see the README on GitHub at https://github.com/jacobstanley/quiet#readme


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.2
Change log ChangeLog.md
Dependencies base (>=4.7 && <5) [details]
License BSD-3-Clause
Copyright Copyright (c) 2016-2020
Author Jacob Stanley
Maintainer jacob@stanley.io
Category Generics
Home page https://github.com/jacobstanley/quiet#readme
Bug tracker https://github.com/jacobstanley/quiet/issues
Source repo head: git clone https://github.com/jacobstanley/quiet
Uploaded by JacobStanley at 2020-02-01T12:19:46Z
Distributions LTSHaskell:0.2, NixOS:0.2, Stackage:0.2
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 13684 total (131 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-02-01 [all 1 reports]

Readme for quiet-0.1

[back to package description]

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