prettyprinter-combinators: Some useful combinators for the prettyprinter package

[ apache, library, text, user-interfaces ] [ Propose Tags ]

Various utilities that make writing Pretty instances easier.

Notable utilites include automatic deriving of Pretty instance via Generic, Data, or Show instance.


[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

Versions [RSS] 0.1, 0.1.0.1, 0.1.1, 0.1.1.1, 0.1.2
Change log Changelog.md
Dependencies base (>=4.14 && <4.19), bimap, bytestring, containers, dlist, pretty-show (>=1.6), prettyprinter (>=1.7), syb, template-haskell (>=2.10), text, unordered-containers, vector [details]
License Apache-2.0
Author Sergey Vinokurov
Maintainer Sergey Vinokurov <serg.foo@gmail.com>
Revised Revision 1 made by SergeyVinokurov at 2023-11-05T11:41:40Z
Category User Interfaces, Text
Home page https://github.com/sergv/prettyprinter-combinators
Source repo head: git clone https://github.com/sergv/prettyprinter-combinators.git
Uploaded by SergeyVinokurov at 2023-01-27T23:37:20Z
Distributions LTSHaskell:0.1.2, NixOS:0.1.2, Stackage:0.1.2
Reverse Dependencies 3 direct, 1 indirect [details]
Downloads 432 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-01-27 [all 1 reports]

Readme for prettyprinter-combinators-0.1.1.1

[back to package description]

This is a set of utilities for the Haskell prettyrinter package. Most notable is automatic deriving of Pretty instance from the Generic instance, e.g.

{-# LANGUAGE DeriveGeneric #-}

import Prettyprinter.Generics

data Foo a b = Bar Int | Baz a b
  deriving (Generic)

instance (Pretty a, Pretty b) => Pretty (Foo a b) where
  pretty = ppGeneric

printed :: Doc ann
printed = pretty $ Baz (Bar 10 :: Foo () ()) [1..22]

which would put following into printed:

Baz
  Bar 10
  [ 1
  , 2
  , 3
  , 4
  , 5
  , 6
  , 7
  , 8
  , 9
  , 10
  , 11
  , 12
  , 13
  , 14
  , 15
  , 16
  , 17
  , 18
  , 19
  , 20
  , 21
  , 22 ]