pretty-show-ansi-wl-1.9.2: Like pretty-show, but only for ansi-wl-pprint

Copyright(c) Iavor S. Diatchki 2009
LicenseMIT
Maintaineriavor.diatchki@gmail.com
Stabilityprovisional
PortabilityHaskell 98
Safe HaskellSafe
LanguageHaskell98

Text.Show.Pretty

Contents

Description

Functions for human-readable derived Show instances.

Synopsis

Generic representation of values

data Value Source #

Generic Haskell values. NaN and Infinity are represented as constructors. The Value in the literals is the text for the literals "as is".

A chain of infix constructors means that they appeared in the input string without parentheses, i.e

1 :+: 2 :*: 3 is represented with InfixCons 1 [(":+:",2),(":*:",3)], whereas

1 :+: (2 :*: 3) is represented with InfixCons 1 [(":+:",InfixCons 2 [(":*:",3)])].

Constructors

Con Name [Value]

Data constructor

InfixCons Value [(Name, Value)]

Infix data constructor chain

Rec Name [(Name, Value)]

Record value

Tuple [Value]

Tuple

List [Value]

List

Neg Value

Negated value

Ratio Value Value

Rational

Integer String

Non-negative integer

Float String

Non-negative floating num.

Char String

Character

String String

String

Instances
Eq Value Source # 
Instance details

Defined in Text.Show.Value

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value Source # 
Instance details

Defined in Text.Show.Value

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

type Name = String Source #

A name.

valToStr :: Value -> String Source #

Pretty print a generic value. Our intention is that the result is equivalent to the Show instance for the original value, except possibly easier to understand by a human.

valToDoc :: Value -> Doc Source #

Pretty print a generic value. Our intention is that the result is equivalent to the Show instance for the original value, except possibly easier to understand by a human.

Values using the Show class

reify :: Show a => a -> Maybe Value Source #

ppDoc :: Show a => a -> Doc Source #

Try to show a value, prettily. If we do not understand the value, then we just use its standard Show instance.

ppShow :: Show a => a -> String Source #

Convert a generic value into a pretty Value, if possible.

pPrint :: Show a => a -> IO () Source #

Pretty print a generic value to stdout. This is particularly useful in the GHCi interactive environment.

Working with listlike ("foldable") collections

ppDocList :: (Foldable f, Show a) => f a -> Doc Source #

Pretty print something that may be converted to a list as a list. Each entry is on a separate line, which means that we don't do clever pretty printing, and so this works well for large strucutures.

ppShowList :: (Foldable f, Show a) => f a -> String Source #

Pretty print something that may be converted to a list as a list. Each entry is on a separate line, which means that we don't do clever pretty printing, and so this works well for large strucutures.

pPrintList :: (Foldable f, Show a) => f a -> IO () Source #

Pretty print something that may be converted to a list as a list. Each entry is on a separate line, which means that we don't do clever pretty printing, and so this works well for large strucutures.

Preprocessing of values

data PreProc a Source #

This type is used to allow pre-processing of values before showing them.

Constructors

PreProc (Value -> Value) a 
Instances
Show a => Show (PreProc a) Source # 
Instance details

Defined in Text.Show.Pretty

Methods

showsPrec :: Int -> PreProc a -> ShowS #

show :: PreProc a -> String #

showList :: [PreProc a] -> ShowS #

ppHide :: (Name -> Bool) -> a -> PreProc a Source #

Hide the given constructors when showing a value.

ppHideNested :: (Name -> Bool) -> a -> PreProc a Source #

Hide the given constructors when showing a value. In addition, hide values if all of their children were hidden.

hideCon :: Bool -> (Name -> Bool) -> Value -> Value Source #

Hide constrcutros matching the given predicate. If the hidden value is in a record, we also hide the corresponding record field.

If the boolean flag is true, then we also hide constructors all of whose fields were hidden.