HaXml-1.25.14: Utilities for manipulating XML documents

Safe Haskell | Safe-Inferred
Language | Haskell98

Text.XML.HaXml.Posn

Contents

- Position type
  - Constructors of a new position
  - Strictifier
  - Modifiers
  - Accessors

Description

Define a position datatype for giving locations in error messages.

Synopsis

- data Posn
- posInNewCxt :: String -> Maybe Posn -> Posn
- noPos :: Posn
- forcep :: Posn -> Int
- addcol :: Int -> Posn -> Posn
- newline :: Posn -> Posn
- tab :: Posn -> Posn
- white :: Char -> Posn -> Posn
- posnFilename :: Posn -> FilePath
- posnLine :: Posn -> Int
- posnColumn :: Posn -> Int

# Position type

data Posn Source #

Source positions contain a filename, line, column, and an inclusion point, which is itself another source position, recursively.

#### Instances

Instances details

Show Posn Source # |
Instance details Defined in Text.XML.HaXml.Posn Methods showsPrec :: Int -> Posn -> ShowS Source # show :: Posn -> String Source # showList :: [Posn] -> ShowS Source #
Eq Posn Source # |
Instance details Defined in Text.XML.HaXml.Posn Methods (==) :: Posn -> Posn -> Bool Source # (/=) :: Posn -> Posn -> Bool Source #

## Constructors of a new position

posInNewCxt :: String -> Maybe Posn -> Posn Source #

`posInNewCxt name pos` creates a new source position from an old one. It is used when opening a new file (e.g. a DTD inclusion), to denote the start of the file `name`, but retain the stacked information that it was included from the old `pos`.

noPos :: Posn Source #

Dummy value for generated data, where a true source position does not exist.

## Strictifier

forcep :: Posn -> Int Source #

Just used to strictify the internal values of a position, to avoid space leaks.

## Modifiers

addcol :: Int -> Posn -> Posn Source #

Add n character positions to the given position.

newline :: Posn -> Posn Source #

Add a newline or tab to the given position.

tab :: Posn -> Posn Source #

Add a newline or tab to the given position.

white :: Char -> Posn -> Posn Source #

Add the given whitespace char to the given position. Precondition: `white c | isSpace c = True`

## Accessors

posnFilename :: Posn -> FilePath Source #

posnLine :: Posn -> Int Source #

posnColumn :: Posn -> Int Source #