ansi-wl-pprint-1.0.2/0000755000000000000000000000000007346545000012567 5ustar0000000000000000ansi-wl-pprint-1.0.2/Changelog.md0000644000000000000000000000130707346545000015001 0ustar0000000000000000## 1.0.2 - Change the implementation to the `prettyprinter` package, using the `prettyprinter-compat-ansi-wl-pprint` compatibility package. Migrate to `prettyprinter`. Note: Using `show` won't preserve formatting anymore, as `prettyprinter`s `Show Doc` instance is annotation invariant. You can convert to `String` using `Data.Text.Lazy.unpack . Prettyprinter.Render.Terminal.renderLazy . Prettyprinter.layoutPretty Prettyprinter.defaultLayoutOptions`, from the `text`, `prettyprinter-ansi-terminal`, `prettyprinter` packages respectively. - The `Text.PrettyPrint.ANSI.Leijen.Internal` module is gone. ## 0.6.9 - All modules are explicitly `Safe`. - Support GHC-7.0 ... GHC-8.8 ## 0.6.8.2 ansi-wl-pprint-1.0.2/LICENSE0000644000000000000000000000241507346545000013576 0ustar0000000000000000Copyright 2008, Daan Leijen and Max Bolingbroke. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. This software is provided by the copyright holders "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holders be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. ansi-wl-pprint-1.0.2/README.md0000644000000000000000000000055307346545000014051 0ustar0000000000000000ANSI Wadler/Leijen Pretty Printer ================================= For all information on this package, please consult the [homepage][hp]. [![Build Status](https://img.shields.io/travis/ekmett/ansi-wl-pprint/master.svg?label=current%20master%20build)](https://travis-ci.org/ekmett/ansi-wl-pprint) [hp]: http://batterseapower.github.com/ansi-wl-pprint ansi-wl-pprint-1.0.2/Setup.lhs0000644000000000000000000000011307346545000014372 0ustar0000000000000000#!/usr/bin/env runhaskell > import Distribution.Simple > main = defaultMainansi-wl-pprint-1.0.2/Text/PrettyPrint/ANSI/0000755000000000000000000000000007346545000016551 5ustar0000000000000000ansi-wl-pprint-1.0.2/Text/PrettyPrint/ANSI/Leijen.hs0000644000000000000000000001765507346545000020331 0ustar0000000000000000{-# LANGUAGE PackageImports #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- -- | -- Module : Text.PrettyPrint.ANSI.Leijen -- Copyright : Daan Leijen (c) 2000, http://www.cs.uu.nl/~daan -- Max Bolingbroke (c) 2008, http://blog.omega-prime.co.uk -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett -- Stability : provisional -- Portability : portable -- -- -- This module is an extended implementation of the functional pretty printer -- given by Philip Wadler (1997): -- -- @ -- \"A prettier printer\" -- Draft paper, April 1997, revised March 1998. -- -- @ -- -- In their bare essence, the combinators given by Wadler are -- not expressive enough to describe some commonly occurring layouts. -- This library adds new primitives to describe these layouts and -- works well in practice. -- -- The library is based on a single way to concatenate documents, -- which is associative and has both a left and right unit. This -- simple design leads to an efficient and short implementation. The -- simplicity is reflected in the predictable behaviour of the -- combinators which make them easy to use in practice. -- -- A thorough description of the primitive combinators and their -- implementation can be found in Philip Wadler's paper. -- The main differences with his original paper are: -- -- * The nil document is called 'empty'. -- -- * The above combinator is called '<$>'. The operator '' is used -- for soft line breaks. -- -- * There are three new primitives: 'align', 'fill' and -- 'fillBreak'. These are very useful in practice. -- -- * There are many additional useful combinators, like 'fillSep' and 'list'. -- -- * There are two renderers: 'renderPretty' for pretty printing, and -- 'renderCompact' for quickly rendered, compact output more suitable -- for generating input to other programs. -- -- * The pretty printing algorithm used by 'renderPretty' extends the algorithm -- given by Wadler to take into account a \"ribbon width\", i.e., a desired -- maximum number of non-indentation characters to output on any one line. -- -- * There are two displayers, 'displayS' for strings and 'displayIO' for -- file-based output. -- -- * There is a 'Pretty' class. -- -- * The implementation uses optimised representations and strictness -- annotations. -- -- * The library has been extended to allow formatting text for output -- to ANSI style consoles. New combinators allow control of foreground and -- background color and the ability to make parts of the text bold or -- underlined. ----------------------------------------------------------- module Text.PrettyPrint.ANSI.Leijen {-# DEPRECATED "Compatibility module for users of ansi-wl-pprint - use \"Prettyprinter\" instead" #-} ( -- * The algebra of pretty-printing -- $DocumentAlgebra -- * Documents Doc, -- * Basic combinators empty, char, text, string, int, integer, float, double, rational, bool, (<>), nest, line, linebreak, group, softline, softbreak, hardline, flatAlt, -- * Alignment combinators -- -- | The combinators in this section cannot be described by Wadler's -- original combinators. They align their output relative to the -- current output position — in contrast to @nest@ which always -- aligns to the current nesting level. This deprives these -- combinators from being \`optimal\'. In practice however they -- prove to be very useful. The combinators in this section should -- be used with care, since they are more expensive than the other -- combinators. For example, @align@ shouldn't be used to pretty -- print all top-level declarations of a language, but using @hang@ -- for let expressions is fine. align, hang, indent, encloseSep, list, tupled, semiBraces, -- * Operators (<+>), (<$>), (), (<$$>), (), -- * List combinators hsep, vsep, fillSep, sep, hcat, vcat, fillCat, cat, punctuate, -- * Filler combinators fill, fillBreak, -- * Bracketing combinators enclose, squotes, dquotes, parens, angles, braces, brackets, -- * Named character combinators lparen, rparen, langle, rangle, lbrace, rbrace, lbracket, rbracket, squote, dquote, semi, colon, comma, space, dot, backslash, equals, -- * ANSI formatting combinators -- -- | This terminal formatting functionality is, as far as possible, -- portable across platforms with their varying terminals. However, -- note that to display ANSI colors and formatting will only be displayed -- on Windows consoles if the 'Doc' value is output using the 'putDoc' -- function or one of its friends. Rendering the 'Doc' to a 'String' -- and then outputing /that/ will only work on Unix-style operating systems. -- ** Forecolor combinators black, red, green, yellow, blue, magenta, cyan, white, dullblack, dullred, dullgreen, dullyellow, dullblue, dullmagenta, dullcyan, dullwhite, -- ** Backcolor combinators onblack, onred, ongreen, onyellow, onblue, onmagenta, oncyan, onwhite, ondullblack, ondullred, ondullgreen, ondullyellow, ondullblue, ondullmagenta, ondullcyan, ondullwhite, -- ** Emboldening combinators bold, debold, -- ** Underlining combinators underline, deunderline, -- ** Formatting elimination combinators plain, -- * Pretty class Pretty(..), -- * Rendering and displaying documents -- ** Simple (i.e., rendered) documents SimpleDoc(..), renderPretty, renderCompact, renderSmart, displayS, displayIO, -- ** Simultaneous rendering and displaying of documents putDoc, hPutDoc, -- * Undocumented column, columns, nesting, width ) where import Prelude () import "prettyprinter-compat-ansi-wl-pprint" Text.PrettyPrint.ANSI.Leijen -- $DocumentAlgebra -- The combinators in this library satisfy many algebraic laws. -- -- The concatenation operator '<>' is associative and has 'empty' as a left -- and right unit: -- -- > x <> (y <> z) = (x <> y) <> z -- > x <> empty = x -- > empty <> x = x -- -- The 'text' combinator is a homomorphism from string concatenation to -- document concatenation: -- -- > text (s ++ t) = text s <> text t -- > text "" = empty -- -- The 'char' combinator behaves like one-element text: -- -- > char c = text [c] -- -- The 'nest' combinator is a homomorphism from addition to document -- composition. 'nest' also distributes through document concatenation and is -- absorbed by 'text' and 'align': -- -- > nest (i + j) x = nest i (nest j x) -- > nest 0 x = x -- > nest i (x <> y) = nest i x <> nest i y -- > nest i empty = empty -- > nest i (text s) = text s -- > nest i (align x) = align x -- -- The 'group' combinator is absorbed by 'empty'. 'group' is commutative with -- 'nest' and 'align': -- -- > group empty = empty -- > group (text s <> x) = text s <> group x -- > group (nest i x) = nest i (group x) -- > group (align x) = align (group x) -- -- The 'align' combinator is absorbed by 'empty' and 'text'. -- 'align' is idempotent: -- -- > align empty = empty -- > align (text s) = text s -- > align (align x) = align x -- -- From the laws of the primitive combinators, we can derive many other laws -- for the derived combinators. For example, the /above/ operator '<$>' is -- defined as: -- -- > x <$> y = x <> line <> y -- -- It follows that '<$>' is associative and that '<$>' and '<>' associate -- with each other: -- -- > x <$> (y <$> z) = (x <$> y) <$> z -- > x <> (y <$> z) = (x <> y) <$> z -- > x <$> (y <> z) = (x <$> y) <> z -- -- Similar laws also hold for the other line break operators '', '<$$>', -- and ''. ansi-wl-pprint-1.0.2/ansi-wl-pprint.cabal0000644000000000000000000000357307346545000016447 0ustar0000000000000000cabal-version: >= 1.10 name: ansi-wl-pprint version: 1.0.2 category: User Interfaces, Text synopsis: The Wadler/Leijen Pretty Printer for colored ANSI terminal output description: { This is a pretty printing library based on Wadler's paper ["A Prettier Printer"](https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf). It has been enhanced with support for ANSI terminal colored output using the [ansi-terminal](https://hackage.haskell.org/package/ansi-terminal) package. } license: BSD3 license-file: LICENSE extra-source-files: README.md Changelog.md author: Daan Leijen, Max Bolingbroke maintainer: Edward Kmett bug-reports: http://github.com/ekmett/ansi-wl-pprint/issues homepage: http://github.com/ekmett/ansi-wl-pprint build-type: Simple tested-with: GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.5, GHC==8.8.4, GHC==8.10.7, GHC==9.0.2, GHC==9.2.7, GHC==9.4.5, GHC==9.6.1 source-repository head type: git location: https://github.com/ekmett/ansi-wl-pprint.git flag Example description: Build the example application default: False manual: True library default-language: Haskell2010 hs-source-dirs: . exposed-modules: Text.PrettyPrint.ANSI.Leijen other-extensions: PackageImports build-depends: base >=4.5 && <5 , prettyprinter-compat-ansi-wl-pprint >=1.0.2 && <1.0.3 executable ansi-wl-pprint-example default-language: Haskell2010 hs-source-dirs: src-exe main-is: Example.hs if flag(example) build-depends: ansi-wl-pprint -- dependencies whose constraints are inherited via lib:ansi-wl-pprint build-depends: base, ansi-terminal, prettyprinter, prettyprinter-ansi-terminal, text else buildable: False ansi-wl-pprint-1.0.2/src-exe/0000755000000000000000000000000007346545000014135 5ustar0000000000000000ansi-wl-pprint-1.0.2/src-exe/Example.hs0000644000000000000000000000276607346545000016077 0ustar0000000000000000module Main (main) where import Text.PrettyPrint.ANSI.Leijen import System.IO import Prettyprinter (layoutPretty, defaultLayoutOptions) import Prettyprinter.Render.Terminal (renderLazy) import Data.Text.Lazy (unpack) main :: IO () main = do -- Going directly to the console is portable across Unix and Windows... putDoc $ red (text "Red") <> comma <+> white (text "white") <+> text "and" <+> blue (text "blue") <> char '!' <> linebreak putDoc $ blue (text "Nested" <+> dullyellow (text "colors") <+> text "example") <> linebreak hPutDoc stdout $ onred (text "Red") <> comma <+> onwhite (text "white") <+> text "and" <+> onblue (text "blue") <> char '!' <> linebreak hPutDoc stdout $ onblue (text "Nested" <+> ondullyellow (text "colors") <+> text "example") <> linebreak -- ...but going via a string will only preserve formatting information information on Unix putStr $ unpack . renderLazy . layoutPretty defaultLayoutOptions $ 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") <> 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")