prettyprinter-combinators: Some useful combinators for the prettyprinter package

[ apache, library, text, user-interfaces ] [ Propose Tags ] [ Report a vulnerability ]

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]

Flags

Manual Flags

NameDescriptionDefault
enummapset

Depend on enummapset package to provide instances and functions for it

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

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, 0.1.2, 0.1.3
Change log Changelog.md
Dependencies base (>=4.16 && <5), bimap, bytestring, containers, dlist, enummapset, pretty-show (>=1.6), prettyprinter (>=1.7), syb, template-haskell (>=2.18), text, unordered-containers, vector [details]
Tested with ghc ==9.2.8, ghc ==9.4.7, ghc ==9.6.3, ghc ==9.8.1, ghc ==9.10.1
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 2024-05-12T15:22:16Z
Distributions LTSHaskell:0.1.3, NixOS:0.1.3, Stackage:0.1.3
Reverse Dependencies 3 direct, 1 indirect [details]
Downloads 579 total (25 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for prettyprinter-combinators-0.1.3

[back to package description]

build

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 ]