| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Wrench.Report.View
Description
Report views, the {...} keys of a report template, as data. A view's
Spec says how its key is spelled and what it reads (numbers, a format);
parsing a key against it yields that value, typed, and the renderer takes
it. Usage text, the docs table and key matching all read the same Spec.
The shared views live in Wrench.Report, each ISA's own in
views. A report template is compiled against them
once, before the simulation runs, so rendering cannot meet a bad key.
Synopsis
- data Spec a
- data Format
- lit :: Text -> Spec ()
- arg :: Text -> Spec Int
- optArg :: Text -> Spec (Maybe Int)
- format :: [Format] -> Format -> Spec Format
- formatRequired :: [Format] -> Spec Format
- usage :: Spec a -> Text
- specName :: Spec a -> Text
- data CheckEnv = CheckEnv {
- ceMemorySize :: Int
- ceIoPorts :: [Int]
- data View env = View {}
- mkView :: Spec a -> Text -> (env -> a -> Text) -> View env
- checkedView :: Spec a -> Text -> (CheckEnv -> a -> Either Text ()) -> (env -> a -> Text) -> View env
- withRenames :: [(Text, Text)] -> [View env] -> [View env]
- contramapView :: (b -> a) -> View a -> View b
- viewUsage :: View env -> Text
- viewName :: View env -> Text
- viewsTable :: [View env] -> Text
- renamesTable :: [View env] -> Text
- data Stat env = Stat {}
- statView :: Stat env -> View env
- data Template env
- compileTemplate :: CheckEnv -> [View env] -> Text -> Either [Text] ([Text], Template env)
- renderTemplate :: Template env -> env -> Text
- examples :: View env -> [Text]
Key specs
How a key is spelled, and what it reads: a free applicative over its parts, so it can be both parsed and inspected (for usage and docs).
Views
What a key's arguments are checked against: the configuration.
Constructors
| CheckEnv | |
Fields
| |
checkedView :: Spec a -> Text -> (CheckEnv -> a -> Either Text ()) -> (env -> a -> Text) -> View env Source #
A view whose arguments must also fit the configuration.
contramapView :: (b -> a) -> View a -> View b Source #
The same view over a larger environment.
viewsTable :: [View env] -> Text Source #
A Markdown table of the current views. Neighbours with the same description, such as a register under its two names, share a row.
renamesTable :: [View env] -> Text Source #
A run-wide stat of an ISA: a view of its own and a line of {isa-specific}.
Templates
compileTemplate :: CheckEnv -> [View env] -> Text -> Either [Text] ([Text], Template env) Source #
Split a template into text and {key} holes, matching every key.
renderTemplate :: Template env -> env -> Text Source #