input-parsers-0.1: Extension of the parsers library with more capability and efficiency

Safe HaskellSafe
LanguageHaskell2010

Text.Parser.Input.Position

Description

A parser's position in the input.

Synopsis

Documentation

data Position Source #

Opaque data type that represents an input position.

fromStart :: Int -> Position Source #

Construct a Position given the offset from the beginning of the full input.

fromEnd :: Int -> Position Source #

Construct a Position given the length remaining from the position to the end of the input.

offset :: FactorialMonoid s => s -> Position -> Int Source #

Map the position into its offset from the beginning of the full input.

offset input . fromStart === id

context :: (Eq s, TextualMonoid s) => s -> Position -> Int -> s Source #

Given the parser input, a Position within it, and desired number of context lines, returns a description of the offset position in English.

lineAndColumn :: (Eq s, IsString s, FactorialMonoid s) => s -> Position -> ([s], Int) Source #

Given the full input and an offset within it, returns all the input lines up to and including the offset in reverse order, as well as the zero-based column number of the offset