show-combinators: Combinators to write Show instances

[ library, mit, text ] [ Propose Tags ]

A minimal pretty-printing library for Show instances in Haskell.

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,
Change log
Dependencies base (>=4.8 && <5) [details]
License MIT
Copyright 2018 Li-yao Xia
Author Li-yao Xia
Revised Revision 2 made by lyxia at 2021-02-16T14:35:40Z
Category Text
Home page
Source repo head: git clone
Uploaded by lyxia at 2020-03-22T21:10:10Z
Distributions Arch:, Debian:, LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 6 direct, 249 indirect [details]
Downloads 15087 total (104 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-03-22 [all 1 reports]

Readme for show-combinators-

[back to package description]

Show combinators Hackage Build Status

A minimal set of convenient combinators to write Show instances.

data MyType a
  = C a a                   -- a regular constructor
  | a :+: a                 -- an infix constructor
  | R { f1 :: a, f2 :: a }  -- a record

infixl 4 :+:

instance Show a => Show (MyType a) where
  showsPrec = flip precShows where
    precShows (C a b) = showCon "C" @| a @| b
    precShows (c :+: d) = showInfix ":+:" 4 c d
    precShows (R {f1 = e, f2 = f}) =
      showRecord "R" ("f1" .=. e &| "f2" .=. f)