toml-parser-2.0.2.0: TOML 1.1.0 parser

Copyright | (c) Eric Mertens 2023
License | ISC
Maintainer | emertens@gmail.com
Safe Haskell | None
Language | Haskell2010

Toml.Syntax.Position

Description

This module provides the `Position` type for tracking locations in files while doing lexing and parsing for providing more useful error messages.

This module assumes 8 column wide tab stops.

Synopsis

- data Located a = Located {
  - locPosition :: !Position
  - locThing :: !a
  }
- data Position = Position {
  - posIndex :: !Int
  - posLine :: !Int
  - posColumn :: !Int
  }
- startPos :: Position
- move :: Char -> Position -> Position

# Documentation

data Located a Source #

A value annotated with its text file position

Constructors

Located |

Fields

- locPosition :: !Position

  position

- locThing :: !a

  thing at position

#### Instances

Instances details

Functor Located Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods fmap :: (a -> b) -> Located a -> Located b Source # (<$) :: a -> Located b -> Located a Source #
Foldable Located Source # | Default instance

Instance details

Defined in Toml.Syntax.Position

Methods

fold :: Monoid m => Located m -> m Source #

foldMap :: Monoid m => (a -> m) -> Located a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Located a -> m Source #

foldr :: (a -> b -> b) -> b -> Located a -> b Source #

foldr' :: (a -> b -> b) -> b -> Located a -> b Source #

foldl :: (b -> a -> b) -> b -> Located a -> b Source #

foldl' :: (b -> a -> b) -> b -> Located a -> b Source #

foldr1 :: (a -> a -> a) -> Located a -> a Source #

foldl1 :: (a -> a -> a) -> Located a -> a Source #

toList :: Located a -> [a] Source #

null :: Located a -> Bool Source #

length :: Located a -> Int Source #

elem :: Eq a => a -> Located a -> Bool Source #

maximum :: Ord a => Located a -> a Source #

minimum :: Ord a => Located a -> a Source #

sum :: Num a => Located a -> a Source #

product :: Num a => Located a -> a Source #

Traversable Located Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods traverse :: Applicative f => (a -> f b) -> Located a -> f (Located b) Source # sequenceA :: Applicative f => Located (f a) -> f (Located a) Source # mapM :: Monad m => (a -> m b) -> Located a -> m (Located b) Source # sequence :: Monad m => Located (m a) -> m (Located a) Source #
Read a => Read (Located a) Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods readsPrec :: Int -> ReadS (Located a) Source # readList :: ReadS [Located a] Source # readPrec :: ReadPrec (Located a) Source # readListPrec :: ReadPrec [Located a] Source #
Show a => Show (Located a) Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods showsPrec :: Int -> Located a -> ShowS Source # show :: Located a -> String Source # showList :: [Located a] -> ShowS Source #

data Position Source #

A position in a text file

Constructors

Position |

Fields

- posIndex :: !Int

  code-point index (zero-based)

- posLine :: !Int

  line index (one-based)

- posColumn :: !Int

  column index (one-based)

#### Instances

Instances details

Read Position Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods readsPrec :: Int -> ReadS Position Source # readList :: ReadS [Position] Source # readPrec :: ReadPrec Position Source # readListPrec :: ReadPrec [Position] Source #
Show Position Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods showsPrec :: Int -> Position -> ShowS Source # show :: Position -> String Source # showList :: [Position] -> ShowS Source #
Eq Position Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods (==) :: Position -> Position -> Bool Source # (/=) :: Position -> Position -> Bool Source #
Ord Position Source # | Default instance
Instance details Defined in Toml.Syntax.Position Methods compare :: Position -> Position -> Ordering Source # (<) :: Position -> Position -> Bool Source # (<=) :: Position -> Position -> Bool Source # (>) :: Position -> Position -> Bool Source # (>=) :: Position -> Position -> Bool Source # max :: Position -> Position -> Position Source # min :: Position -> Position -> Position Source #

startPos :: Position Source #

The initial `Position` for the start of a file

move :: Char -> Position -> Position Source #

Adjust a file position given a single character handling newlines and tabs. All other characters are considered to fill exactly one column.