| Copyright | (c) Mesabloo 2021-2022 |
|---|---|
| License | BSD3 |
| Stability | experimental |
| Portability | Portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Error.Diagnose.Style
Contents
Description
Synopsis
- data Annotation a
- = ThisColor Bool
- | MaybeColor
- | WhereColor
- | HintColor
- | FileColor
- | RuleColor
- | KindColor Bool
- | NoLineColor
- | MarkerStyle (Annotation a)
- | CodeStyle
- | OtherStyle a
- type Style a = Annotation a -> AnsiStyle
- defaultStyle :: Style AnsiStyle
- unadornedStyle :: Style a
Defining new style
data Annotation a 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 a) | Additional style to apply to marker rules (e.g. bold) on top of some already processed color annotation. |
| CodeStyle | The color of the code when no marker is present. |
| OtherStyle a | Something else, could be provided by the user |
Instances
type Style a = Annotation a -> 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.
Styles
defaultStyle :: Style AnsiStyle 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 - The code is output in normal white
unadornedStyle :: Style a Source #
A style which disregards all annotations