prettyprinter-compat-ansi-wl-pprint-1.0.2: Drop-in compatibility package to migrate from »ansi-wl-pprint« to »prettyprinter«.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.PrettyPrint.ANSI.Leijen

Description

Deprecated: Compatibility module for users of ansi-wl-pprint - use Prettyprinter instead

Synopsis

- type Doc = Doc AnsiStyle
- putDoc :: Doc -> IO ()
- hPutDoc :: Handle -> Doc -> IO ()
- empty :: Doc
- char :: Char -> Doc
- text :: String -> Doc
- (<>) :: Semigroup a => a -> a -> a
- nest :: Int -> Doc -> Doc
- line :: Doc
- linebreak :: Doc
- group :: Doc -> Doc
- softline :: Doc
- softbreak :: Doc
- hardline :: Doc
- flatAlt :: Doc -> Doc -> Doc
- renderSmart :: Float -> Int -> Doc -> SimpleDoc
- align :: Doc -> Doc
- hang :: Int -> Doc -> Doc
- indent :: Int -> Doc -> Doc
- encloseSep :: Doc -> Doc -> Doc -> [Doc] -> Doc
- list :: [Doc] -> Doc
- tupled :: [Doc] -> Doc
- semiBraces :: [Doc] -> Doc
- (<+>) :: Doc -> Doc -> Doc
- (<$>) :: Doc -> Doc -> Doc
- (</>) :: Doc -> Doc -> Doc
- (<$$>) :: Doc -> Doc -> Doc
- (<//>) :: Doc -> Doc -> Doc
- hsep :: [Doc] -> Doc
- vsep :: [Doc] -> Doc
- fillSep :: [Doc] -> Doc
- sep :: [Doc] -> Doc
- hcat :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- fillCat :: [Doc] -> Doc
- cat :: [Doc] -> Doc
- punctuate :: Doc -> [Doc] -> [Doc]
- fill :: Int -> Doc -> Doc
- fillBreak :: Int -> Doc -> Doc
- enclose :: Doc -> Doc -> Doc -> Doc
- squotes :: Doc -> Doc
- dquotes :: Doc -> Doc
- parens :: Doc -> Doc
- angles :: Doc -> Doc
- braces :: Doc -> Doc
- brackets :: Doc -> Doc
- lparen :: Doc
- rparen :: Doc
- langle :: Doc
- rangle :: Doc
- lbrace :: Doc
- rbrace :: Doc
- lbracket :: Doc
- rbracket :: Doc
- squote :: Doc
- dquote :: Doc
- semi :: Doc
- colon :: Doc
- comma :: Doc
- space :: Doc
- dot :: Doc
- backslash :: Doc
- equals :: Doc
- black :: Doc -> Doc
- red :: Doc -> Doc
- green :: Doc -> Doc
- yellow :: Doc -> Doc
- blue :: Doc -> Doc
- magenta :: Doc -> Doc
- cyan :: Doc -> Doc
- white :: Doc -> Doc
- dullblack :: Doc -> Doc
- dullred :: Doc -> Doc
- dullgreen :: Doc -> Doc
- dullyellow :: Doc -> Doc
- dullblue :: Doc -> Doc
- dullmagenta :: Doc -> Doc
- dullcyan :: Doc -> Doc
- dullwhite :: Doc -> Doc
- onblack :: Doc -> Doc
- onred :: Doc -> Doc
- ongreen :: Doc -> Doc
- onyellow :: Doc -> Doc
- onblue :: Doc -> Doc
- onmagenta :: Doc -> Doc
- oncyan :: Doc -> Doc
- onwhite :: Doc -> Doc
- ondullblack :: Doc -> Doc
- ondullred :: Doc -> Doc
- ondullgreen :: Doc -> Doc
- ondullyellow :: Doc -> Doc
- ondullblue :: Doc -> Doc
- ondullmagenta :: Doc -> Doc
- ondullcyan :: Doc -> Doc
- ondullwhite :: Doc -> Doc
- bold :: Doc -> Doc
- debold :: Doc -> Doc
- underline :: Doc -> Doc
- deunderline :: Doc -> Doc
- plain :: Doc -> Doc
- string :: String -> Doc
- int :: Int -> Doc
- integer :: Integer -> Doc
- float :: Float -> Doc
- double :: Double -> Doc
- rational :: Rational -> Doc
- class Pretty a where
  - pretty :: a -> Doc ann
  - prettyList :: [a] -> Doc ann
- type SimpleDoc = SimpleDocStream AnsiStyle
- renderPretty :: Float -> Int -> Doc -> SimpleDoc
- renderCompact :: Doc -> SimpleDoc
- displayS :: SimpleDoc -> ShowS
- displayIO :: Handle -> SimpleDoc -> IO ()
- bool :: Bool -> Doc
- column :: (Int -> Doc) -> Doc
- columns :: (Maybe Int -> Doc) -> Doc
- nesting :: (Int -> Doc) -> Doc
- width :: Doc -> (Int -> Doc) -> Doc

# Documentation

type Doc = Doc AnsiStyle Source #

putDoc :: Doc -> IO () Source #

hPutDoc :: Handle -> Doc -> IO () Source #

empty :: Doc Source #

char :: Char -> Doc Source #

text :: String -> Doc Source #

(<>) :: Semigroup a => a -> a -> a infixr 6 Source #

An associative operation.

#### Examples

Expand

    >>> [1,2,3] <> [4,5,6]
    [1,2,3,4,5,6]

    >>> Just [1, 2, 3] <> Just [4, 5, 6]
    Just [1,2,3,4,5,6]

    >>> putStr "Hello, " <> putStrLn "World!"
    Hello, World!

nest :: Int -> Doc -> Doc Source #

line :: Doc Source #

linebreak :: Doc Source #

group :: Doc -> Doc Source #

softline :: Doc Source #

softbreak :: Doc Source #

hardline :: Doc Source #

flatAlt :: Doc -> Doc -> Doc Source #

renderSmart :: Float -> Int -> Doc -> SimpleDoc Source #

align :: Doc -> Doc Source #

hang :: Int -> Doc -> Doc Source #

indent :: Int -> Doc -> Doc Source #

encloseSep :: Doc -> Doc -> Doc -> [Doc] -> Doc Source #

list :: [Doc] -> Doc Source #

tupled :: [Doc] -> Doc Source #

semiBraces :: [Doc] -> Doc Source #

(<+>) :: Doc -> Doc -> Doc Source #

(<$>) :: Doc -> Doc -> Doc Source #

(</>) :: Doc -> Doc -> Doc Source #

(<$$>) :: Doc -> Doc -> Doc Source #

(<//>) :: Doc -> Doc -> Doc Source #

hsep :: [Doc] -> Doc Source #

vsep :: [Doc] -> Doc Source #

fillSep :: [Doc] -> Doc Source #

sep :: [Doc] -> Doc Source #

hcat :: [Doc] -> Doc Source #

vcat :: [Doc] -> Doc Source #

fillCat :: [Doc] -> Doc Source #

cat :: [Doc] -> Doc Source #

punctuate :: Doc -> [Doc] -> [Doc] Source #

fill :: Int -> Doc -> Doc Source #

fillBreak :: Int -> Doc -> Doc Source #

enclose :: Doc -> Doc -> Doc -> Doc Source #

squotes :: Doc -> Doc Source #

dquotes :: Doc -> Doc Source #

parens :: Doc -> Doc Source #

angles :: Doc -> Doc Source #

braces :: Doc -> Doc Source #

brackets :: Doc -> Doc Source #

lparen :: Doc Source #

rparen :: Doc Source #

langle :: Doc Source #

rangle :: Doc Source #

lbrace :: Doc Source #

rbrace :: Doc Source #

lbracket :: Doc Source #

rbracket :: Doc Source #

squote :: Doc Source #

dquote :: Doc Source #

semi :: Doc Source #

colon :: Doc Source #

comma :: Doc Source #

space :: Doc Source #

dot :: Doc Source #

backslash :: Doc Source #

equals :: Doc Source #

black :: Doc -> Doc Source #

red :: Doc -> Doc Source #

green :: Doc -> Doc Source #

yellow :: Doc -> Doc Source #

blue :: Doc -> Doc Source #

magenta :: Doc -> Doc Source #

cyan :: Doc -> Doc Source #

white :: Doc -> Doc Source #

dullblack :: Doc -> Doc Source #

dullred :: Doc -> Doc Source #

dullgreen :: Doc -> Doc Source #

dullyellow :: Doc -> Doc Source #

dullblue :: Doc -> Doc Source #

dullmagenta :: Doc -> Doc Source #

dullcyan :: Doc -> Doc Source #

dullwhite :: Doc -> Doc Source #

onblack :: Doc -> Doc Source #

onred :: Doc -> Doc Source #

ongreen :: Doc -> Doc Source #

onyellow :: Doc -> Doc Source #

onblue :: Doc -> Doc Source #

onmagenta :: Doc -> Doc Source #

oncyan :: Doc -> Doc Source #

onwhite :: Doc -> Doc Source #

ondullblack :: Doc -> Doc Source #

ondullred :: Doc -> Doc Source #

ondullgreen :: Doc -> Doc Source #

ondullyellow :: Doc -> Doc Source #

ondullblue :: Doc -> Doc Source #

ondullmagenta :: Doc -> Doc Source #

ondullcyan :: Doc -> Doc Source #

ondullwhite :: Doc -> Doc Source #

bold :: Doc -> Doc Source #

debold :: Doc -> Doc Source #

underline :: Doc -> Doc Source #

deunderline :: Doc -> Doc Source #

plain :: Doc -> Doc Source #

string :: String -> Doc Source #

int :: Int -> Doc Source #

integer :: Integer -> Doc Source #

float :: Float -> Doc Source #

double :: Double -> Doc Source #

rational :: Rational -> Doc Source #

class Pretty a where Source #

Overloaded conversion to `Doc`.

Laws:

1. output should be pretty. :-)

Minimal complete definition

pretty

Methods

pretty :: a -> Doc ann Source #

    >>> pretty 1 <+> pretty "hello" <+> pretty 1.234
    1 hello 1.234

default pretty :: Show a => a -> Doc ann Source #

prettyList :: [a] -> Doc ann Source #

``prettyList`` is only used to define the `instance `Pretty` a => `Pretty` [a]`. In normal circumstances only the ``pretty`` function is used.

    >>> prettyList [1, 23, 456]
    [1, 23, 456]

#### Instances

Instances details

Pretty Void

Finding a good example for printing something that does not exist is hard, so here is an example of printing a list full of nothing.

    >>> pretty ([] :: [Void])
    []

Instance details Defined in Prettyprinter.Internal Methods pretty :: Void -> Doc ann Source # prettyList :: [Void] -> Doc ann Source #
Pretty Int16 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Int16 -> Doc ann Source # prettyList :: [Int16] -> Doc ann Source #
Pretty Int32 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Int32 -> Doc ann Source # prettyList :: [Int32] -> Doc ann Source #
Pretty Int64 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Int64 -> Doc ann Source # prettyList :: [Int64] -> Doc ann Source #
Pretty Int8 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Int8 -> Doc ann Source # prettyList :: [Int8] -> Doc ann Source #
Pretty Word16 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Word16 -> Doc ann Source # prettyList :: [Word16] -> Doc ann Source #
Pretty Word32 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Word32 -> Doc ann Source # prettyList :: [Word32] -> Doc ann Source #
Pretty Word64 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Word64 -> Doc ann Source # prettyList :: [Word64] -> Doc ann Source #
Pretty Word8 |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Word8 -> Doc ann Source # prettyList :: [Word8] -> Doc ann Source #

Pretty Text

Automatically converts all newlines to ``line``.

    >>> pretty ("hello\nworld" :: Text)
    hello
    world

Note that ``line`` can be undone by ``group``:

    >>> group (pretty ("hello\nworld" :: Text))
    hello world

Manually use ``hardline`` if you definitely want newlines.

Instance details Defined in Prettyprinter.Internal Methods pretty :: Text -> Doc ann Source # prettyList :: [Text] -> Doc ann Source #
Pretty Text | (lazy `Text` instance, identical to the strict version)
Instance details Defined in Prettyprinter.Internal Methods pretty :: Text -> Doc ann Source # prettyList :: [Text] -> Doc ann Source #

Pretty Integer

    >>> pretty (2^123 :: Integer)
    10633823966279326983230456482242756608

Instance details Defined in Prettyprinter.Internal Methods pretty :: Integer -> Doc ann Source # prettyList :: [Integer] -> Doc ann Source #
Pretty Natural |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Natural -> Doc ann Source # prettyList :: [Natural] -> Doc ann Source #

Pretty ()

    >>> pretty ()
    ()

The argument is not used:

    >>> pretty (error "Strict?" :: ())
    ()

Instance details Defined in Prettyprinter.Internal Methods pretty :: () -> Doc ann Source # prettyList :: [()] -> Doc ann Source #

Pretty Bool

    >>> pretty True
    True

Instance details Defined in Prettyprinter.Internal Methods pretty :: Bool -> Doc ann Source # prettyList :: [Bool] -> Doc ann Source #

Pretty Char

Instead of `(`pretty` 'n')`, consider using ``line`` as a more readable alternative.

    >>> pretty 'f' <> pretty 'o' <> pretty 'o'
    foo
    >>> pretty ("string" :: String)
    string

Instance details Defined in Prettyprinter.Internal Methods pretty :: Char -> Doc ann Source # prettyList :: [Char] -> Doc ann Source #

Pretty Double

    >>> pretty (exp 1 :: Double)
    2.71828182845904...

Instance details Defined in Prettyprinter.Internal Methods pretty :: Double -> Doc ann Source # prettyList :: [Double] -> Doc ann Source #

Pretty Float

    >>> pretty (pi :: Float)
    3.1415927

Instance details Defined in Prettyprinter.Internal Methods pretty :: Float -> Doc ann Source # prettyList :: [Float] -> Doc ann Source #

Pretty Int

    >>> pretty (123 :: Int)
    123

Instance details Defined in Prettyprinter.Internal Methods pretty :: Int -> Doc ann Source # prettyList :: [Int] -> Doc ann Source #
Pretty Word |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Word -> Doc ann Source # prettyList :: [Word] -> Doc ann Source #
Pretty a => Pretty (NonEmpty a) |
Instance details Defined in Prettyprinter.Internal Methods pretty :: NonEmpty a -> Doc ann Source # prettyList :: [NonEmpty a] -> Doc ann Source #

Pretty a => Pretty (Identity a)

    >>> pretty (Identity 1)
    1

Instance details Defined in Prettyprinter.Internal Methods pretty :: Identity a -> Doc ann Source # prettyList :: [Identity a] -> Doc ann Source #

Pretty a => Pretty (Maybe a)

Ignore `Nothing`s, print `Just` contents.

    >>> pretty (Just True)
    True
    >>> braces (pretty (Nothing :: Maybe Bool))
    {}

    >>> pretty [Just 1, Nothing, Just 3, Nothing]
    [1, 3]

Instance details Defined in Prettyprinter.Internal Methods pretty :: Maybe a -> Doc ann Source # prettyList :: [Maybe a] -> Doc ann Source #

Pretty a => Pretty [a]

    >>> pretty [1,2,3]
    [1, 2, 3]

Instance details Defined in Prettyprinter.Internal Methods pretty :: [a] -> Doc ann Source # prettyList :: [[a]] -> Doc ann Source #

(Pretty a1, Pretty a2) => Pretty (a1, a2)

    >>> pretty (123, "hello")
    (123, hello)

Instance details Defined in Prettyprinter.Internal Methods pretty :: (a1, a2) -> Doc ann Source # prettyList :: [(a1, a2)] -> Doc ann Source #
Pretty a => Pretty (Const a b) |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Const a b -> Doc ann Source # prettyList :: [Const a b] -> Doc ann Source #

(Pretty a1, Pretty a2, Pretty a3) => Pretty (a1, a2, a3)

    >>> pretty (123, "hello", False)
    (123, hello, False)

Instance details Defined in Prettyprinter.Internal Methods pretty :: (a1, a2, a3) -> Doc ann Source # prettyList :: [(a1, a2, a3)] -> Doc ann Source #

type SimpleDoc = SimpleDocStream AnsiStyle Source #

renderPretty :: Float -> Int -> Doc -> SimpleDoc Source #

renderCompact :: Doc -> SimpleDoc Source #

displayS :: SimpleDoc -> ShowS Source #

displayIO :: Handle -> SimpleDoc -> IO () Source #

bool :: Bool -> Doc Source #

column :: (Int -> Doc) -> Doc Source #

columns :: (Maybe Int -> Doc) -> Doc Source #

nesting :: (Int -> Doc) -> Doc Source #

width :: Doc -> (Int -> Doc) -> Doc Source #