errata-0.3.0.0: Source code error pretty printing
Copyright(c) 2020 comp
LicenseMIT
Maintaineronecomputer00@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Errata.Types

Description

Type definitions. Most of these are re-exported in Errata, so you should not need to import this module, unless you need some of the helper functions for making new functionality on top of Errata.

Synopsis

Type synonyms

type Line = Int Source #

Line number, starts at 1.

type Column = Int Source #

Column number, starts at 1.

type Header = Text Source #

Header text. Generally goes above things.

type Body = Text Source #

Body text. Generally goes below things.

type Label = Text Source #

Label text. Generally goes inline with things.

Error format data

data Errata Source #

A collection of information for pretty printing an error.

Constructors

Errata 

Fields

Blocks and pointers

data Block Source #

Information about a block in the source code, such as pointers and messages.

Each block has a style associated with it.

Constructors

Block 

Fields

  • blockStyle :: Style

    The style of the block.

  • blockLocation :: (FilePath, Line, Column)

    The filepath, line, and column of the block. These start at 1.

    This is used to create the text that details the location.

  • blockHeader :: Maybe Header

    The header message for the block.

    This will appear below the location and above the source lines.

  • blockPointers :: [Pointer]

    The block's pointers. These are used to "point out" parts of the source code in this block.

    The locations of each of these pointers must be non-overlapping. If the pointers are touching at a boundary however, that is allowed.

  • blockBody :: Maybe Body

    The body message for the block.

    This will appear below the source lines.

data Pointer Source #

A pointer is the span of the source code at a line, from one column to another. Each of the positions start at 1.

A pointer may also have a label that will display inline.

A pointer may also be connected to all the other pointers within the same block.

Constructors

Pointer 

Fields

Instances

Instances details
Eq Pointer Source # 
Instance details

Defined in Errata.Types

Methods

(==) :: Pointer -> Pointer -> Bool #

(/=) :: Pointer -> Pointer -> Bool #

Show Pointer Source # 
Instance details

Defined in Errata.Types

pointerColumns :: Pointer -> (Column, Column) Source #

Gets the column span for a Pointer.

Styling options

data Style Source #

Stylization options for a block, e.g. characters to use.

Constructors

Style 

Fields

  • styleLocation :: (FilePath, Line, Column) -> Text

    Shows the location of a block at a file, line, and column.

    This is put on its own line just above the source lines.

  • styleNumber :: Line -> Text

    Shows the line number n for a source line.

    The result should visually be the same length as just show n.

  • styleLine :: [(Column, Column)] -> Text -> Text

    Stylize a source line.

    Column pointers of the text that are being underlined are given for highlighting purposes. The result of this should visually take up the same space as the original line.

  • styleEllipsis :: Text

    The text to use as an ellipsis in the position of line numbers for when lines are omitted.

    This should visually be one character.

  • styleLinePrefix :: Text

    The prefix before the source lines.

    Before it may be the line number, and after it the source line.

  • styleUnderline :: Text

    The text to underline a character in a pointer.

    This should visually be one character.

  • styleVertical :: Text

    The text to use as a vertical bar when connecting pointers.

    This should visually be one character.

  • styleHorizontal :: Text

    The text to use as a horizontal bar when connecting pointers.

    This should visually be one character.

  • styleDownRight :: Text

    The text to use as a connector downwards and rightwards when connecting pointers.

    This should visually be one character.

  • styleUpRight :: Text

    The text to use as a connector upwards and rightwards when connecting pointers.

    This should visually be one character.

  • styleUpDownRight :: Text

    The text to use as a connector upwards, downwards, and rightwards when connecting pointers.

    This should visually be one character.

highlight Source #

Arguments

:: Text

Text to add before.

-> Text

Text to add after.

-> [(Column, Column)]

Indices to enclose. These are column spans, starting at 1. They must not overlap.

-> Text

Text to highlight.

-> Text 

Adds highlighting to spans of text by enclosing it with some text e.g ANSI escape codes.