The show-prettyprint package

[Tags:bsd3, library, test]

See README.md


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.2
Dependencies ansi-wl-pprint, base (>=4.7 && <5), trifecta (>=1.6) [details]
License BSD3
Copyright David Luposchainsky, 2016
Author David Luposchainsky <dluposchainsky (λ) google>
Maintainer David Luposchainsky <dluposchainsky (λ) google>
Stability Unknown
Category User Interfaces, Text
Home page https://github.com/quchen/show-prettyprint#readme
Source repository head: git clone https://github.com/quchen/show-prettyprint
Uploaded Mon Nov 14 16:13:17 UTC 2016 by quchen
Distributions NixOS:0.1.2, Stackage:0.1.2, Tumbleweed:0.1.2
Downloads 93 total (7 in the last 30 days)
Votes
0 []
Status Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for show-prettyprint

Readme for show-prettyprint-0.1.2

Prettyprint Show output

Output of nested data structures by Show instances is often very hard to read. This package offers a simple function to insert line breaks and indentation into that output so that the semantics are unchanged, but makes it much easier to read.

The package does not rely on a parser for actual Haskell; instead, it merely reacts on parentheses, commas and the like. This makes it fairly robust even in the face of invalid Show instances, that may not produce valid Haskell code.

For example, consider this nested data structure:

nestedExample = fromList
    [ ("hello", Left  (Pair True ()))
    , ("world", Right (Record { r1 = ('c', -1.2e34), r2 = 123 }))
    , ("!"    , Left  (Pair False ())) ]

Applying show to it results in the fairly dense representation

fromList [("!",Left (Pair False ())),("hello",Left (Pair True ())),("world",Right (Record {r1 = ('c',-1.2e34), r2 = 123}))]

With the functions defined in this module, we can make this output a bit more readable,

fromList [("!"
          ,Left (Pair False ()))
         ,("hello",Left (Pair True ()))
         ,("world"
          ,Right (Record {r1 = ('c'
                               ,-1.2e34)
                         ,r2 = 123}))]