Copyright | (c) Iavor S. Diatchki 2009 |
---|---|
License | MIT |
Maintainer | iavor.diatchki@gmail.com |
Stability | provisional |
Portability | Haskell 98 |
Safe Haskell | Safe |
Language | Haskell98 |
Functions for human-readable derived Show
instances.
Synopsis
- 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
- pPrint :: Show a => a -> IO ()
- ppDocList :: (Foldable f, Show a) => f a -> Doc
- ppShowList :: (Foldable f, Show a) => f a -> String
- pPrintList :: (Foldable f, Show a) => f a -> IO ()
- 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)])]
.
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
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.
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.
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
.
Instances
Rendering values to Html
Options on how to generate Html (more to come).
HtmlOpts | |
|
defaultHtmlOpts :: HtmlOpts Source #
Default options.
Get location of data files
getDataDir :: IO FilePath Source #