the-sett / salix / SourcePos

SourcePos provides a way of defining regions of text to quote or to highlight mainly for the purpose of showing where errors exist within some source code.

The code is treated as lines of text, and positions within that described by row and column number.

Regions of text


type alias Region =
{ start : RowCol
, end : RowCol 
}

Describes a region of text running from a start to an end position.


type alias RowCol =
{ row : Basics.Int, col : Basics.Int }

Describes a position within some lines of text.

Quoted and highlighted blocks of text


type alias SourceLines =
{ lines : Dict Basics.Int String
, highlight : Maybe Region 
}

Captures a set of source code lines which are indexed by their line numbers,

A highlight region may also be specified, and if set is used to indicate where within the source lines an error is located. All lines within the highlight region are expected to be in the line dict.

sourceLinesForRegions : Dict Basics.Int String -> List Region -> List SourceLines

Quotes a region of text as SourceLines.