prettyprinter-combinators: Some useful combinators for the prettyprinter package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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]

Properties

Versions 0.1, 0.1.0.1, 0.1.1, 0.1.1.1, 0.1.1.1, 0.1.2
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:36:37Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


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 ]