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]
Versions [faq] 0.1.0.0, 0.1.1.0
Change log CHANGELOG.md
Dependencies base (>=4.8 && <4.13) [details]
License MIT
Copyright 2018 Li-yao Xia
Author Li-yao Xia
Maintainer lysxia@gmail.com
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 Fri Jan 11 12:29:05 UTC 2019
Distributions LTSHaskell:0.1.1.0, NixOS:0.1.1.0, Stackage:0.1.1.0
Downloads 254 total (36 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-01-11 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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)