packages feed

ansi-wl-pprint 0.5.0 → 0.5.1

raw patch · 4 files changed

+36/−73 lines, 4 filesdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base

API changes (from Hackage documentation)

- Text.PrettyPrint.ANSI.Leijen: instance (Pretty a) => Pretty (Maybe a)
- Text.PrettyPrint.ANSI.Leijen: instance (Pretty a) => Pretty [a]
+ Text.PrettyPrint.ANSI.Leijen: instance Pretty a => Pretty (Maybe a)
+ Text.PrettyPrint.ANSI.Leijen: instance Pretty a => Pretty [a]
+ Text.PrettyPrint.ANSI.Leijen: plain :: Doc -> Doc
- Text.PrettyPrint.ANSI.Leijen: pretty :: (Pretty a) => a -> Doc
+ Text.PrettyPrint.ANSI.Leijen: pretty :: Pretty a => a -> Doc
- Text.PrettyPrint.ANSI.Leijen: prettyList :: (Pretty a) => [a] -> Doc
+ Text.PrettyPrint.ANSI.Leijen: prettyList :: Pretty a => [a] -> Doc

Files

README.textile view
@@ -1,67 +1,3 @@ h1.  ANSI Wadler/Leijen Pretty Printer
 
-You can help improve this README with extra snippets and advice by using the "GitHub wiki":http://github.com/batterseapower/ansi-wl-pprint/wikis/readme.
-
-
-h2. Installing
-
-To just install the library:
-
-<pre>
-<code>runghc Setup.lhs configure
-runghc Setup.lhs build
-sudo runghc Setup.lhs install</code>
-</pre>
-
-If you want to build the example, to check it's all working:
-
-<pre>
-<code>runghc Setup.lhs configure -fexample
-runghc Setup.lhs build
-dist/build/ansi-wl-pprint-example/ansi-wl-pprint-example</code>
-</pre>
-
-
-h2. Description
-
-A pretty printing library based on Wadler's paper "A Prettier Printer". It has been enhanced with support for ANSI terminal colored output using the "ansi-terminal":http://github.com/batterseapower/ansi-terminal package.
-
-This package is extensively based on Daan Leijen's excellent "wl-pprint":http://hackage.haskell.org/cgi-bin/hackage-scripts/package/wl-pprint library.
-
-
-h2. Example
-
-A full example is provided with the package, and can be compiled by suppling Cabal with the @-fexample@ flag. It is also available online at "GitHub":http://github.com/batterseapower/ansi-wl-pprint/tree/master/Text/PrettyPrint/ANSI/Example.hs.
-
-
-h2. Manual
-
-The library provides the obvious API, which just allows colorization of any @Doc@ value. It looks something like this:
-
-<pre>
-<code>-- | Displays a document with the given forecolor
-black, red, green, yellow, blue, magenta, cyan, white,
-  dullblack, dullred, dullgreen, dullyellow,
-  dullblue, dullmagenta, dullcyan, dullwhite :: Doc -> Doc
- 
--- | Displays a document with a forecolor given in the first parameter
-color, dullcolor :: Color -> Doc -> Doc 
-
--- | Displays a document with the given backcolor
-onblack, onred, ongreen, onyellow, onblue, onmagenta, oncyan, onwhite,
-  ondullblack, ondullred, ondullgreen, ondullyellow,
-  ondullblue, ondullmagenta, ondullcyan, ondullwhite :: Doc -> Doc
- 
--- | Displays a document with a backcolor given in the first parameter
-oncolor, ondullcolor :: Color -> Doc -> Doc</code>
-</pre>
-
-The @putDoc@ and @hPutDoc@ functions are fully portable between Windows and Unix-like operating systems with ANSI terminals.
-
-If you output @Doc@ via a @String@ (i.e. using @show@), no colored text will be displayed on Windows, though it will work fine on Unix. This is to due to a technical limitation on how ANSI colors are implemented on Windows consoles.
-
-h2. Linkage
-
-* "Hackage":http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ansi-wl-pprint/
-* "Bug Tracker":http://bsp.lighthouseapp.com/projects/16293-hs-ansi-wl-pprint/
-* "GitHub":http://github.com/batterseapower/ansi-wl-pprint/+For all information on this package, please consult the "homepage":http://batterseapower.github.com/ansi-wl-pprint
Text/PrettyPrint/ANSI/Example.hs view
@@ -17,4 +17,8 @@     putStr $ show $ green (text "I will be green on Unix but uncolored on Windows") <> linebreak          -- Let's see some non-color formatting:-    putDoc $ text "We can do" <+> bold (text "boldness") <> text ", if your terminal supports it, and even perhaps" <+> underline (text "underlining")+    putDoc $ text "We can do" <+> bold (text "boldness") <> text ", if your terminal supports it, and even perhaps" <+> underline (text "underlining") <> linebreak++    -- Just a little test of the formatting removal:+    putDoc $ text "There is a handy utility called 'plain' to" <+> plain (bold $ text "remove formatting") <+>+              plain (text "if you need to e.g. support" <+> red (text "non-ANSI") <+> text "terminals")
Text/PrettyPrint/ANSI/Leijen.hs view
@@ -123,6 +123,9 @@    -- * Underlining combinators    underline, deunderline, +   -- * Removing formatting+   plain,+    -- * Primitive type documents    string, int, integer, float, double, rational, @@ -993,6 +996,26 @@  -- NB: I don't support DoubleUnderline here because it is not widely supported by terminals. +-----------------------------------------------------------+-- Removing formatting+-----------------------------------------------------------++-- | Removes all colorisation, emboldening and underlining from a document+plain :: Doc -> Doc+plain e@Empty         = e+plain c@(Char _)      = c+plain t@(Text _ _)    = t+plain l@(Line _)      = l+plain (Cat x y)       = Cat (plain x) (plain y)+plain (Nest i x)      = Nest i (plain x)+plain (Union x y)     = Union (plain x) (plain y)+plain (Column f)      = Column (plain . f)+plain (Nesting f)     = Nesting (plain . f)+plain (Color _ _ _ x) = plain x+plain (Intensify _ x) = plain x+plain (Italicize _ x) = plain x+plain (Underline _ x) = plain x+plain (RestoreFormat _ _ _ _ _) = Empty  ----------------------------------------------------------- -- Renderers
ansi-wl-pprint.cabal view
@@ -1,5 +1,5 @@ Name:                ansi-wl-pprint-Version:             0.5.0+Version:             0.5.1 Cabal-Version:       >= 1.2 Category:            User Interfaces, Text Synopsis:            The Wadler/Leijen Pretty Printer for colored ANSI terminal output@@ -12,8 +12,8 @@ Homepage:            http://github.com/batterseapower/ansi-wl-pprint Build-Type:          Simple -Flag SplitBase-        Description:    Choose the new smaller, split-up base package+Flag Base3+        Description:    Choose the new smaller, split-up base package with 6.10         Default:        True  Flag Example@@ -25,8 +25,8 @@         Exposed-Modules:        Text.PrettyPrint.ANSI.Leijen                  Build-Depends:          ansi-terminal >= 0.4.0-        if flag(splitBase)-                Build-Depends:  base >= 3+        if flag(base3)+                Build-Depends:  base >= 3 && < 5         else                 Build-Depends:  base < 3 @@ -34,8 +34,8 @@         Main-Is:                Text/PrettyPrint/ANSI/Example.hs                  Build-Depends:          ansi-terminal >= 0.4.0-        if flag(splitBase)-                Build-Depends:  base >= 3+        if flag(base3)+                Build-Depends:  base >= 3 && < 5         else                 Build-Depends:  base < 3