| Copyright | (c) Iavor S. Diatchki 2009 |
|---|---|
| License | MIT |
| Maintainer | iavor.diatchki@gmail.com |
| Stability | provisional |
| Portability | Haskell 98 |
| Safe Haskell | Safe |
| Language | Haskell98 |
Text.Show.Pretty
Contents
Description
Functions for human-readable derived Show instances.
- data Value
- type Name = String
- valToStr :: Value -> String
- valToDoc :: Value -> Doc
- valToHtmlPage :: HtmlOpts -> Value -> String
- parseValue :: String -> Maybe Value
- reify :: Show a => a -> Maybe Value
- ppDoc :: Show a => a -> Doc
- ppShow :: Show a => a -> String
- dumpDoc :: PrettyVal a => a -> Doc
- dumpStr :: PrettyVal a => a -> String
- class PrettyVal a where
- valToHtml :: HtmlOpts -> Value -> Html
- data HtmlOpts = HtmlOpts {
- dataDir :: FilePath
- wideListWidth :: Int
- defaultHtmlOpts :: HtmlOpts
- htmlPage :: HtmlOpts -> Html -> String
- newtype Html = Html {
- exportHtml :: String
- getDataDir :: IO FilePath
- ppValue :: Value -> Doc
Generic representation of values
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 |
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.
valToHtmlPage :: HtmlOpts -> Value -> String Source
Make an Html page representing the given value.
Values using the Show class
parseValue :: String -> 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.
Values using the PrettyVal class
class PrettyVal a where Source
A class for types that may be reified into a value.
Instances of this class may be derived automatically,
for datatypes that support Generics.
Minimal complete definition
Nothing
Instances
Rendering values to Html
Options on how to generate Html (more to come).
Constructors
| HtmlOpts | |
Fields
| |
defaultHtmlOpts :: HtmlOpts Source
Default options.
Constructors
| Html | |
Fields
| |