| Copyright | (c) Mesabloo 2021-2022 |
|---|---|
| License | BSD3 |
| Stability | experimental |
| Portability | Portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Error.Diagnose.Style
Description
Synopsis
- data Annotation
- type Style = Doc Annotation -> Doc AnsiStyle
- defaultStyle :: Style
- reAnnotate :: (ann -> ann') -> Doc ann -> Doc ann'
Defining new style
data Annotation Source #
Some annotations as placeholders for colors in a Doc.
Constructors
| ThisColor Bool | The color of |
| MaybeColor | The color of |
| WhereColor | The color of |
| HintColor | The color for hints. Note that the beginning |
| FileColor | The color for file names. |
| RuleColor | The color of the rule separating the code/markers from the line numbers. |
| KindColor Bool | The color of the |
| NoLineColor | The color in which to output the |
| MarkerStyle Annotation | Additional style to apply to marker rules (e.g. bold) on top of some already processed color annotation. |
type Style = Doc Annotation -> Doc AnsiStyle Source #
A style is a function which can be applied using reAnnotate.
It transforms a Document containing Annotations into a Document containing
color information.
Defining new color styles (one may call them "themes") is actually rather easy.
A Style is a function from an annotated Document to another annotated Document.
Note that only the annotation type changes, hence the need of only providing a unidirectional mapping between those.
Annotations are used when creating a Document and are simply placeholders to specify custom colors.
AnsiStyle is the concrete annotation to specify custom colors when rendering a Document.
One may define additional styles as follows:
myNewCustomStyle :: Style myNewCustomStyle = reAnnotate \case -- all cases for all annotations
For simplicity's sake, a default style is given as defaultStyle.
Default style specification
defaultStyle :: Style Source #
The default style for diagnostics, where:
Thismarkers are colored in red for errors and yellow for warningsWheremarkers are colored in dull blueMaybemarkers are colored in magenta- Marker rules are of the same color of the marker, but also in bold
- Hints are output in cyan
- The left rules are colored in bold black
- File names are output in dull green
- The
[error]/[warning]at the top is colored in red for errors and yellow for warnings
Re-exports
reAnnotate :: (ann -> ann') -> Doc ann -> Doc ann' #
Change the annotation of a Document.
Useful in particular to embed documents with one form of annotation in a more generally annotated document.
Since this traverses the entire tree, including parts that are not
rendered due to other layouts fitting better, it is preferrable to reannotate
after producing the layout by using Doc.reAnnotateS
Since has the right type and satisfies reAnnotate'reAnnotate id = id',
it is used to define the instance of Functor.Doc