show-combinators: Combinators to write Show instances

[ library, mit, text ] [ Propose Tags ] [ Report a vulnerability ]

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


[Skip to Readme]

Downloads

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

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0
Change log CHANGELOG.md
Dependencies base (>=4.8 && <4.14) [details]
Tested with ghc ==7.10.3, ghc ==8.0.2, ghc ==8.2.2, ghc ==8.6.3
License MIT
Copyright 2018 Li-yao Xia
Author Li-yao Xia
Maintainer lysxia@gmail.com
Revised Revision 1 made by lyxia at 2019-09-20T13:56:09Z
Category Text
Home page https://github.com/Lysxia/show-combinators#readme
Source repo head: git clone https://github.com/Lysxia/show-combinators
Uploaded by lyxia at 2019-01-11T12:29:05Z
Distributions Arch:0.2.0.0, Debian:0.2.0.0, LTSHaskell:0.2.0.0, NixOS:0.2.0.0, Stackage:0.2.0.0
Reverse Dependencies 6 direct, 250 indirect [details]
Downloads 15617 total (117 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-01-11 [all 1 reports]

Readme for show-combinators-0.1.1.0

[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)