input-parsers-0.2.3: Extension of the parsers library with more capability and efficiency
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Parser.Input.Position

Description

A parser's position in the input.

Synopsis

Documentation

class Ord p => Position p where Source #

A class for representing position values. The methods satisfy these laws:

move (distance pos1 pos2) pos1 == pos2
(pos1 < pos2) == (distance pos1 pos2 > 0)

Methods

distance :: p -> p -> Int Source #

Distance from the first position to the second

move :: Int -> p -> p Source #

Move the position by the given distance.

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

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

Instances

Instances details
Position Int Source # 
Instance details

Defined in Text.Parser.Input.Position

Methods

distance :: Int -> Int -> Int Source #

move :: Int -> Int -> Int Source #

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

Position a => Position (Down a) Source # 
Instance details

Defined in Text.Parser.Input.Position

Methods

distance :: Down a -> Down a -> Int Source #

move :: Int -> Down a -> Down a Source #

offset :: FactorialMonoid s => s -> Down a -> Int Source #

fromStart :: Int -> Int Source #

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

fromEnd :: Int -> Down Int Source #

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

context :: (Eq s, TextualMonoid s, Position p) => s -> p -> 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, Position p) => s -> p -> ([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