prettyprinter-combinators

Some useful combinators for the prettyprinter package

https://github.com/sergv/prettyprinter-combinators

Version on this page:0.1.1.1
LTS Haskell 22.36:0.1.3
Stackage Nightly 2024-10-03:0.1.3
Latest on Hackage:0.1.3

See all snapshots prettyprinter-combinators appears in

Apache-2.0 licensed by Sergey Vinokurov
Maintained by Sergey Vinokurov
This version can be pinned in stack with:prettyprinter-combinators-0.1.1.1@sha256:8ee291dfb0039d9fadfd192106cdc4962c0c5ebfa06972b45d20b9937bdf9d7e,1836

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 ]

Changes

0.1.1.1

  • ppVector and ppVectorWith now accept generic vectors
  • Add lower bound pretty-show >= 1.6