srcloc-0.5.0.2: Data types for managing source code locations.

Copyright(c) Harvard University 2006-2011 (c) Geoffrey Mainland 2011-2014
LicenseBSD-style
MaintainerGeoffrey Mainland <mainland@cs.drexel.edu>
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Loc

Description

 

Synopsis

Documentation

data Pos Source

Position type.

Constructors

Pos !FilePath !Int !Int !Int

Source file name, line, column, and character offset.

Line numbering starts at 1, column offset starts at 1, and character offset starts at 0.

posFile :: Pos -> FilePath Source

Position file.

posLine :: Pos -> Int Source

Position line.

posCol :: Pos -> Int Source

Position column.

posCoff :: Pos -> Int Source

Position character offset.

startPos :: FilePath -> Pos Source

Starting position for given file.

linePos :: FilePath -> Int -> Pos Source

Position corresponding to given file and line.

Note that the associated character offset is set to 0.

advancePos :: Pos -> Char -> Pos Source

Advance a position by a single character. Newlines increment the line number, tabs increase the position column following a tab stop width of 8, and all other characters increase the position column by one. All characters, including newlines and tabs, increase the character offset by 1.

Note that advancePos assumes UNIX-style newlines.

displayPos :: Pos -> String Source

Format a position in a human-readable way, returning an ordinary String.

displaySPos :: Pos -> ShowS Source

Format a position in a human-readable way.

data Loc Source

Location type, consisting of a beginning position and an end position.

Constructors

NoLoc 
Loc !Pos !Pos

Beginning and end positions

locStart :: Loc -> Loc Source

Starting position of the location.

locEnd :: Loc -> Loc Source

Ending position of the location.

(<-->) :: (Located a, Located b) => a -> b -> Loc infixl 6 Source

Merge the locations of two Located values.

displayLoc :: Loc -> String Source

Format a location in a human-readable way, returning an ordinary String.

displaySLoc :: Loc -> ShowS Source

Format a location in a human-readable way.

newtype SrcLoc Source

Source location type. Source location are all equal, which allows AST nodes to be compared modulo location information.

Constructors

SrcLoc Loc 

srclocOf :: Located a => a -> SrcLoc Source

The SrcLoc of a Located value.

srcspan :: (Located a, Located b) => a -> b -> SrcLoc infixl 6 Source

A SrcLoc with (minimal) span that includes two Located values.

class IsLocation a where Source

Locations

Minimal complete definition

fromLoc

Methods

fromLoc :: Loc -> a Source

fromPos :: Pos -> a Source

noLoc :: IsLocation a => a Source

No location.

class Located a where Source

Located values have a location.

Minimal complete definition

locOf

Methods

locOf :: a -> Loc Source

locOfList :: [a] -> Loc Source

Instances

class Relocatable a where Source

Values that can be relocated

Methods

reloc :: Loc -> a -> a Source

Instances

data L a Source

A value of type L a is a value of type a with an associated Loc, but this location is ignored when performing comparisons.

Constructors

L Loc a 

Instances

Eq x => Eq (L x) 
Ord x => Ord (L x) 
Show x => Show (L x) 
Relocatable (L a) 
Located (L a) 

unLoc :: L a -> a Source