Modules 28
Data.Text.Prettyprint.Doc.Render.Tutorials.StackMachineTutorial
Use \ Prettyprinter.Render.Tutorials.StackMachineTutorial\ instead.
module Prettyprinter.Render.Tutorials.StackMachineTutorial prettyprinter-1.7.2 · 10 declarations
color :: Color -> Doc SimpleHtml -> Doc SimpleHtml
headline :: Doc SimpleHtml -> Doc SimpleHtml
htmlTag :: SimpleHtml -> (TLB.Builder, TLB.Builder)
Convert a SimpleHtml annotation to a pair of opening and closing tags.
This is where the translation of style to raw output happens.
italics :: Doc SimpleHtml -> Doc SimpleHtml
paragraph :: Doc SimpleHtml -> Doc SimpleHtml
render :: SimpleDocStream SimpleHtml -> TL.Text
We can now wrap our stack machine definition from renderStackMachine in a
nicer interface; on successful conversion, we run the builder to give us the
final Text, and before we do that we check that the style stack is empty
(i.e. there are no unmatched style applications) after the machine is run.
This function does only a bit of plumbing around renderStackMachine, and is
the main API function of a stack machine renderer. The tree renderer
equivalent to this is
render.
renderStackMachine :: SimpleDocStream SimpleHtml -> StackMachine TLB.Builder SimpleHtml ()
The StackMachine type defines a stack machine suitable for many rendering
needs. It has two auxiliary parameters: the type of the end result, and the
type of the document’s annotations.
Most StackMachine creations will look like this definition: a recursive
walk through the SimpleDocStream, pushing styles on the stack and popping
them off again, and writing raw output.
The equivalent to this in the tree based rendering approach is
renderTree.
data Color
Red :: Color
Green :: Color
Blue :: Color
data SimpleHtml
Bold :: SimpleHtml
Italics :: SimpleHtml
Color :: Color -> SimpleHtml
Paragraph :: SimpleHtml
Headline :: SimpleHtml
Build record and source files
Community contribution. The service has not verified this documentation. The generator reported 21 diagnostics.
Target: Linux on x86-64. Some inferred types and resolved links are not available.
Generator: aihc-haddock-858b1951-web-1
Metadata snapshot: 19f659e0fd2a9606431ae6a3ec65f9ace725052e19ca6a9f9e9f2759e30fd129
Open the dependency plan · Download the documentation model
- aihc-base-4.21.2.0 · Core library · Cabal file
- aihc-internal-9.1204.0 · Core library · Cabal file
- aihc-prim-0.13.0 · Core library · Cabal file
- aihc-rts-1.0.2 · Core library · Cabal file
- aihc-template-haskell-2.23.0.0 · Core library · Cabal file
- array-0.5.8.0 · Cabal revision 2 · Cabal file · Source archive
- binary-0.8.9.3 · Cabal revision 0 · Cabal file · Source archive
- bytestring-0.12.2.0 · Cabal revision 1 · Cabal file · Source archive
- containers-0.8.1 · Cabal revision 0 · Cabal file · Source archive
- deepseq-1.5.2.0 · Cabal revision 0 · Cabal file · Source archive
- prettyprinter-1.7.2 · Cabal revision 0 · Cabal file · Source archive
- system-cxx-std-lib-1.0 · Core library · Cabal file
- text-2.1.4 · Cabal revision 0 · Cabal file · Source archive