pretty-show-1.6.6: Tools for working with derived `Show` instances and generic inspection of values.

PortabilityHaskell 98
Stabilityprovisional
Maintaineriavor.diatchki@gmail.com
Safe HaskellSafe

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 String 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

type Name = StringSource

A name.

valToStr :: Value -> StringSource

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 -> DocSource

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.

valToHtmlPage :: HtmlOpts -> Value -> StringSource

Make an Html page representing the given value.

Values using the Show class

ppDoc :: Show a => a -> DocSource

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 -> StringSource

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

Values using the PrettyVal class

dumpDoc :: PrettyVal a => a -> DocSource

Render a value in the PrettyVal class to a Doc. The benefit of this function is that PrettyVal instances may be derived automatically using generics.

dumpStr :: PrettyVal a => a -> StringSource

Render a value in the PrettyVal class to a String. The benefit of this function is that PrettyVal instances may be derived automatically using generics.

class PrettyVal a whereSource

A class for types that may be reified into a value. Instances of this class may be derived automatically, for datatypes that support Generics.

Methods

prettyVal :: a -> ValueSource

Instances

PrettyVal Char 
PrettyVal Double 
PrettyVal Float 
PrettyVal Int 
PrettyVal Int8 
PrettyVal Int16 
PrettyVal Int32 
PrettyVal Int64 
PrettyVal Integer 
PrettyVal Word8 
PrettyVal Word16 
PrettyVal Word32 
PrettyVal Word64 
PrettyVal a => PrettyVal [a] 
(PrettyVal a, Integral a) => PrettyVal (Ratio a) 
(PrettyVal a1, PrettyVal a2) => PrettyVal (a1, a2) 
(PrettyVal a1, PrettyVal a2, PrettyVal a3) => PrettyVal (a1, a2, a3) 
(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4) => PrettyVal (a1, a2, a3, a4) 
(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4, PrettyVal a5) => PrettyVal (a1, a2, a3, a4, a5) 
(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4, PrettyVal a5, PrettyVal a6) => PrettyVal (a1, a2, a3, a4, a5, a6) 
(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4, PrettyVal a5, PrettyVal a6, PrettyVal a7) => PrettyVal (a1, a2, a3, a4, a5, a6, a7) 

Rendering values to Html

valToHtml :: HtmlOpts -> Value -> HtmlSource

Convert a value into an Html fragment.

data HtmlOpts Source

Options on how to generate Html (more to come).

Constructors

HtmlOpts 

Fields

dataDir :: FilePath

Path for extra files. If empty, we look in directory style, relative to document.

wideListWidth :: Int

Max. number of columns in wide lists.

Instances

defaultHtmlOpts :: HtmlOptsSource

Default options.

htmlPage :: HtmlOpts -> Html -> StringSource

Wrap an Html fragment to make an Html page.

newtype Html Source

Constructors

Html 

Fields

exportHtml :: String
 

Get location of data files

Deprecated

ppValue :: Value -> DocSource

Deprecated: Please use valToDoc instead.