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

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 #

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

Eq Value # 

Methods

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

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

Show Value # 

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

type Name = String #

A name.

valToStr :: Value -> String #

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 #

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

Make an Html page representing the given value.

Values using the Show class

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

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

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 #

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

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

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

Values using the PrettyVal class

dumpDoc :: PrettyVal a => a -> Doc #

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

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 where #

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 -> Value #

prettyVal :: (GDump (Rep a), Generic a) => a -> Value #

Instances

PrettyVal Bool # 

Methods

prettyVal :: Bool -> Value #

listValue :: [Bool] -> Value

PrettyVal Char # 

Methods

prettyVal :: Char -> Value #

listValue :: [Char] -> Value

PrettyVal Double # 
PrettyVal Float # 

Methods

prettyVal :: Float -> Value #

listValue :: [Float] -> Value

PrettyVal Int # 

Methods

prettyVal :: Int -> Value #

listValue :: [Int] -> Value

PrettyVal Int8 # 

Methods

prettyVal :: Int8 -> Value #

listValue :: [Int8] -> Value

PrettyVal Int16 # 

Methods

prettyVal :: Int16 -> Value #

listValue :: [Int16] -> Value

PrettyVal Int32 # 

Methods

prettyVal :: Int32 -> Value #

listValue :: [Int32] -> Value

PrettyVal Int64 # 

Methods

prettyVal :: Int64 -> Value #

listValue :: [Int64] -> Value

PrettyVal Integer # 
PrettyVal Ordering # 
PrettyVal Word8 # 

Methods

prettyVal :: Word8 -> Value #

listValue :: [Word8] -> Value

PrettyVal Word16 # 
PrettyVal Word32 # 
PrettyVal Word64 # 
PrettyVal a => PrettyVal [a] # 

Methods

prettyVal :: [a] -> Value #

listValue :: [[a]] -> Value

PrettyVal a => PrettyVal (Maybe a) # 

Methods

prettyVal :: Maybe a -> Value #

listValue :: [Maybe a] -> Value

(PrettyVal a, Integral a) => PrettyVal (Ratio a) # 

Methods

prettyVal :: Ratio a -> Value #

listValue :: [Ratio a] -> Value

(PrettyVal a, PrettyVal b) => PrettyVal (Either a b) # 

Methods

prettyVal :: Either a b -> Value #

listValue :: [Either a b] -> Value

(PrettyVal a1, PrettyVal a2) => PrettyVal (a1, a2) # 

Methods

prettyVal :: (a1, a2) -> Value #

listValue :: [(a1, a2)] -> Value

(PrettyVal a1, PrettyVal a2, PrettyVal a3) => PrettyVal (a1, a2, a3) # 

Methods

prettyVal :: (a1, a2, a3) -> Value #

listValue :: [(a1, a2, a3)] -> Value

(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4) => PrettyVal (a1, a2, a3, a4) # 

Methods

prettyVal :: (a1, a2, a3, a4) -> Value #

listValue :: [(a1, a2, a3, a4)] -> Value

(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4, PrettyVal a5) => PrettyVal (a1, a2, a3, a4, a5) # 

Methods

prettyVal :: (a1, a2, a3, a4, a5) -> Value #

listValue :: [(a1, a2, a3, a4, a5)] -> Value

(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4, PrettyVal a5, PrettyVal a6) => PrettyVal (a1, a2, a3, a4, a5, a6) # 

Methods

prettyVal :: (a1, a2, a3, a4, a5, a6) -> Value #

listValue :: [(a1, a2, a3, a4, a5, a6)] -> Value

(PrettyVal a1, PrettyVal a2, PrettyVal a3, PrettyVal a4, PrettyVal a5, PrettyVal a6, PrettyVal a7) => PrettyVal (a1, a2, a3, a4, a5, a6, a7) # 

Methods

prettyVal :: (a1, a2, a3, a4, a5, a6, a7) -> Value #

listValue :: [(a1, a2, a3, a4, a5, a6, a7)] -> Value

Rendering values to Html

valToHtml :: HtmlOpts -> Value -> Html #

Convert a value into an Html fragment.

data HtmlOpts #

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 :: HtmlOpts #

Default options.

htmlPage :: HtmlOpts -> Html -> String #

Wrap an Html fragment to make an Html page.

newtype Html #

Constructors

Html 

Fields

Get location of data files

Deprecated

ppValue :: Value -> Doc #

Deprecated: Please use valToDoc instead.