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.
- 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)])]
.
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
.
Nothing
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
Options on how to generate Html (more to come).
HtmlOpts | |
|
defaultHtmlOpts :: HtmlOpts Source
Default options.
Html | |
|