packages feed

show-prettyprint 0.2 → 0.2.0.1

raw patch · 3 files changed

+66/−36 lines, 3 filesdep ~prettyprinterdep ~trifectaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: prettyprinter, trifecta

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.2.0.1++Tagged the wrong version as 0.2 on Github. Releasing a new version with an+updated tag to remedy this.+ # 0.2  Prettyprint based on the `prettyprinter` library, instead of `ansi-wl-pprint`.
README.md view
@@ -3,54 +3,79 @@  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+that ouput 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: -```haskell-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+## Examples +### Artificial+ ```haskell-fromList [("!",Left (Pair False ())),("hello",Left (Pair True ())),("world",Right (Record {r1 = ('c',-1.2e34), r2 = 123}))]-```+Hello Foo ("(Bar", Haha) (Baz (A { foo = C, bar = D, qux = (E,"He)llo World!",G,+    H,[A,B,c,d,e,Fghi]) } ) (B,C) [Baz A1 B2, (Baz A3 (B4)), (Baz A5 (B6)), (Baz+    (A7) B8)]) (Foo) (Bar) (Baz (A) (B)) -With the functions defined in this module, we can make this output a bit more-readable,+==> -```haskell-fromList [("!"-          ,Left (Pair False ()))-         ,("hello",Left (Pair True ()))-         ,("world"-          ,Right (Record {r1 = ('c'-                               ,-1.2e34)-                         ,r2 = 123}))]+Hello Foo ("(Bar",Haha)+          (Baz (A {foo = C+                  ,bar = D+                  ,qux = (E+                         ,"He)llo World!"+                         ,G+                         ,H+                         ,[A,B,c,d,e,Fghi])})+               (B,C)+               [Baz A1 B2+               ,(Baz A3 (B4))+               ,(Baz A5 (B6))+               ,(Baz (A7) B8)])+          (Foo)+          (Bar)+          (Baz (A) (B)) ``` -Related packages-================--There is a similar package on Hackage called *[pretty-show][1]*, which takes a-more flexible approach to prettyprinting show-formatted strings. This has its-advantages and disadvantages.+### Inspired by a real AST -         | prettyprint-show (this)            | [pretty-show][1] (alternative)-------------- | ---------------------------------- | ------------------------------Use case      | fire and forget, debugging         | flexible, working with the output-API           | One core value (rest: convenience) | Multiple combinable values-Extensibility | low, not intended                  | decent, e.g. HTML rendering-Robustness    | high: only cares about parentheses, bugs in bad output can be hacked around | medium: relies on output that follows Haskell's lexical structure+```haskell+Set  (fromList [(Name "A string with (parenthesis",Ann  (Entry (Quality 1 1)+    (Ann  False) (Ann  (Map [Ann  (Bound (Ann  (Id "lorem"))),Ann  (Variable+    (Ann  (Id "ipsum")))])))),(Name "string",Ann  (Entry (Quality 1 1) (Ann+    True) (Ann  (Internal (Ann  (Reduce (Ann  (Id "dolor")) (Ann  (Id "sit")))))+    ))),(Name "Another } here",Ann  (Entry (Quality 1 1) (Ann  (Or [Ann  (Not+    (Ann  (Is (Ann  Flagged) (Ann  Type) (Ann  (Multi [Ann  (Literal (Ann  One))+    ]))))),Ann  (Is (Ann  Flagged) (Ann  Type) (Ann  (Multi [Ann  (Literal (Ann+    Three))]))),Ann  (Is (Ann  Flagged) (Ann  Type) (Ann  (Multi [Ann  (Literal+    (Ann  Two))])))])) (Ann  (Internal (Ann  (Concat (Ann  (Id "amet"))))))))]) +==> -[1]: http://hackage.haskell.org/package/pretty-show+Set (fromList [(Name "A string with (parenthesis"+               ,Ann (Entry (Quality 1 1)+                           (Ann False)+                           (Ann (Map [Ann (Bound (Ann (Id "lorem")))+                                     ,Ann (Variable (Ann (Id "ipsum")))]))))+              ,(Name "string"+               ,Ann (Entry (Quality 1 1)+                           (Ann True)+                           (Ann (Internal (Ann (Reduce (Ann (Id "dolor"))+                                                       (Ann (Id "sit"))))))))+              ,(Name "Another } here"+               ,Ann (Entry (Quality 1 1)+                           (Ann (Or [Ann (Not (Ann (Is (Ann Flagged)+                                                       (Ann Type)+                                                       (Ann (Multi [Ann (Literal (Ann One))])))))+                                    ,Ann (Is (Ann Flagged)+                                             (Ann Type)+                                             (Ann (Multi [Ann (Literal (Ann Three))])))+                                    ,Ann (Is (Ann Flagged)+                                             (Ann Type)+                                             (Ann (Multi [Ann (Literal (Ann Two))])))]))+                           (Ann (Internal (Ann (Concat (Ann (Id "amet"))))))))])+```
show-prettyprint.cabal view
@@ -1,5 +1,5 @@ name:                show-prettyprint-version:             0.2+version:             0.2.0.1 synopsis:            Robust prettyprinter for output of auto-generated Show                      instances description:         See README.md@@ -23,7 +23,7 @@                      , Text.Show.Prettyprint.Internal   build-depends:       base >= 4.7 && < 5                      , trifecta >= 1.6-                     , prettyprinter < 1.1+                     , prettyprinter >= 1                       -- Transitive dep of Trifecta, figure it out via that one                      , ansi-wl-pprint