toml-parser-1.3.0.0: TOML 1.0.0 parser

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

Toml.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 Position = Position {
  - posIndex :: !Int
  - posLine :: !Int
  - posColumn :: !Int
  }
- startPos :: Position
- move :: Char -> Position -> Position

# Documentation

data Position #

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

startPos :: Position #

The initial `Position` for the start of a file

move :: Char -> Position -> Position #

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