errata-0.3.0.0: Source code error pretty printing

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 FieldserrataHeader :: Maybe HeaderThe message that appears above all the blocks.errataBlocks :: [Block]Blocks in the source code to display.errataBody :: Maybe BodyThe message that appears below all the blocks.

# 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 FieldsblockStyle :: StyleThe 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 HeaderThe 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 BodyThe 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 FieldspointerLine :: LineThe line of the pointer.pointerColStart :: ColumnThe starting column of the pointer.pointerColEnd :: ColumnThe ending column of the pointer.pointerConnect :: BoolWhether this pointer connects with other pointers.pointerLabel :: Maybe LabelAn optional label for the pointer.

#### Instances

Instances details
 Source # Instance detailsDefined in Errata.Types Methods(==) :: Pointer -> Pointer -> Bool #(/=) :: Pointer -> Pointer -> Bool # Source # Instance detailsDefined in Errata.Types MethodsshowList :: [Pointer] -> ShowS #

Gets the column span for a Pointer.

# Styling options

data Style Source #

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

Constructors

 Style FieldsstyleLocation :: (FilePath, Line, Column) -> TextShows 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 -> TextShows the line number n for a source line.The result should visually be the same length as just show n.styleLine :: [(Column, Column)] -> Text -> TextStylize 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 :: TextThe text to use as an ellipsis in the position of line numbers for when lines are omitted.This should visually be one character.styleLinePrefix :: TextThe prefix before the source lines.Before it may be the line number, and after it the source line.styleUnderline :: TextThe text to underline a character in a pointer.This should visually be one character.styleVertical :: TextThe text to use as a vertical bar when connecting pointers.This should visually be one character.styleHorizontal :: TextThe text to use as a horizontal bar when connecting pointers.This should visually be one character.styleDownRight :: TextThe text to use as a connector downwards and rightwards when connecting pointers.This should visually be one character.styleUpRight :: TextThe text to use as a connector upwards and rightwards when connecting pointers.This should visually be one character.styleUpDownRight :: TextThe text to use as a connector upwards, downwards, and rightwards when connecting pointers.This should visually be one character.

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.