Copyright | © 2015–2017 Megaparsec contributors |
---|---|
License | FreeBSD |
Maintainer | Mark Karpov <markkarpov92@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Textual source position. The position includes name of file, line number, and column number. List of such positions can be used to model a stack of include files.
You probably do not want to import this module directly because Text.Megaparsec re-exports it anyway.
- data Pos
- mkPos :: Int -> Pos
- unPos :: Pos -> Int
- pos1 :: Pos
- defaultTabWidth :: Pos
- data InvalidPosException = InvalidPosException Int
- data SourcePos = SourcePos {
- sourceName :: FilePath
- sourceLine :: !Pos
- sourceColumn :: !Pos
- initialPos :: FilePath -> SourcePos
- sourcePosPretty :: SourcePos -> String
Abstract position
Construction of Pos
from Int
. The function throws
InvalidPosException
when given a non-positive argument.
Since: 6.0.0
defaultTabWidth :: Pos Source #
Value of tab width used by default. Always prefer this constant when you want to refer to the default tab width because actual value may change in future.
Since: 5.0.0
data InvalidPosException Source #
The exception is thrown by mkPos
when its argument is not a positive
number.
Since: 5.0.0
InvalidPosException Int | The first value is the minimal allowed value, the second value is the
actual value that was passed to |
Source position
The data type SourcePos
represents source positions. It contains the
name of the source file, a line number, and a column number. Source line
and column positions change intensively during parsing, so we need to
make them strict to avoid memory leaks.
SourcePos | |
|
initialPos :: FilePath -> SourcePos Source #
Construct initial position (line 1, column 1) given name of source file.