Copyright | (c) Mesabloo 2021-2022 |
---|---|
License | BSD3 |
Stability | experimental |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
.
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 Doc
ument containing Annotation
s into a Doc
ument containing
color information.
Defining new color styles (one may call them "themes") is actually rather easy.
A Style
is a function from an annotated Doc
ument to another annotated Doc
ument.
Note that only the annotation type changes, hence the need of only providing a unidirectional mapping between those.
Annotation
s are used when creating a Doc
ument and are simply placeholders to specify custom colors.
AnsiStyle
is the concrete annotation to specify custom colors when rendering a Doc
ument.
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:
This
markers are colored in red for errors and yellow for warningsWhere
markers are colored in dull blueMaybe
markers 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