prettyprinter-combinators-0.1: Some useful combinators for the prettyprinter package
Copyright(c) Sergey Vinokurov 2018
LicenseApache-2.0 (see LICENSE)
Maintainerserg.foo@gmail.com
Safe HaskellNone
LanguageHaskell2010

Prettyprinter.Data

Description

 
Synopsis

Documentation

ppData :: Data a => a -> Doc ann Source #

Prettyprint using Data instance.

>>> :{
test =
  Bar
    ("foo", 10, 20)
    (Map.fromList (zip ["foo", "bar", "baz"] [1..]))
    (Map.fromList (zip ["foo", "bar", "baz", "quux", "fizz", "buzz", "frob", "wat"] [1..]))
    (Just
      (Foo
         1
         []
         3.14159265358979323846264338327950288
         (Just
            (Foo
               1
               [2]
               2.71828182
               (Just (Bar ("x", 1, 2) mempty mempty Nothing (NonEmpty.fromList [42])))))))
    (NonEmpty.fromList [1..42])
:}
>>> ppData test
Bar
  (foo, 10, 20)
  {bar -> 2, baz -> 3, foo -> 1}
  { bar -> 2
  , baz -> 3
  , buzz -> 6
  , fizz -> 5
  , foo -> 1
  , frob -> 7
  , quux -> 4
  , wat -> 8
  }
  Just Foo
         1
         {}
         3.141592653589793
         Just (Foo 1 [2] 2.71828182 (Just (Bar (x, 1, 2) {} {} Nothing [42])))
  [ 1
  , 2
  , 3
  , 4
  , 5
  , 6
  , 7
  , 8
  , 9
  , 10
  , 11
  , 12
  , 13
  , 14
  , 15
  , 16
  , 17
  , 18
  , 19
  , 20
  , 21
  , 22
  , 23
  , 24
  , 25
  , 26
  , 27
  , 28
  , 29
  , 30
  , 31
  , 32
  , 33
  , 34
  , 35
  , 36
  , 37
  , 38
  , 39
  , 40
  , 41
  , 42
  ]

ppDataSimple :: Data a => a -> Doc ann Source #