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

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
Change log Changelog.md
Dependencies base (>=4.14 && <5), 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>
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.1.1, NixOS:0.1.1, Stackage:0.1.1.1
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 184 total (48 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 ]