Safe Haskell | Safe-Inferred |
---|
Utility for attaching source code positions to AST nodes
- data Pos a = Pos {}
- data SourcePos
- sourceLine :: SourcePos -> Line
- sourceColumn :: SourcePos -> Column
- sourceName :: SourcePos -> SourceName
- noPos :: SourcePos
- attachPos :: SourcePos -> a -> Pos a
- gen :: a -> Pos a
- attachPosBefore :: Parser a -> Parser (Pos a)
- inheritPos :: (Pos a -> b) -> Pos a -> Pos b
- inheritPos2 :: (Pos a -> Pos b -> c) -> Pos a -> Pos b -> Pos c
Documentation
Anything with a source position attached
data SourcePos
sourceLine :: SourcePos -> Line
Extracts the line number from a source position.
sourceColumn :: SourcePos -> Column
Extracts the column number from a source position.
sourceName :: SourcePos -> SourceName
Extracts the name of the source from a source position.
attachPosBefore :: Parser a -> Parser (Pos a)Source
attachPosBefore
p
: parser that behaves like p
, but also attaches the source position before the first token it parsed to the result
inheritPos :: (Pos a -> b) -> Pos a -> Pos bSource
inheritPos
f a
: apply f
to a
and attach a
's position to the result
inheritPos2 :: (Pos a -> Pos b -> c) -> Pos a -> Pos b -> Pos cSource
inheritPos2
f a b
: apply f
to a
and b
and attach a
's position to the result