@hackage prettyprinter-combinators0.1.4
Some useful combinators for the prettyprinter package
Categories
License
Apache-2.0
Maintainer
Sergey Vinokurov <serg.foo@gmail.com>
Links
Versions
Installation
Dependencies (15)
- base >=4.16 && <5
- bimap
- bytestring
- containers
- dlist
- enummapset Show all…
Dependents (3)
@hackage/toml-reader-parse, @hackage/htoml-parse, @hackage/emacs-module
Package Flags
enummapset
(on by default)
Depend on enummapset package to provide instances and functions for it
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 ]