srcloc-0.4.1: 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

Position type.

Constructors

Pos !String !Int !Int !Int

Source file name, line, column, and character offset

posFile :: Pos -> String

Position file.

posLine :: Pos -> Int

Position line.

posCol :: Pos -> Int

Position column.

posCoff :: Pos -> Int

Position character offset.

data Loc

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

Constructors

NoLoc 
Loc !Pos !Pos

Beginning and end positions

locStart :: Loc -> Loc

Starting position of the location.

locEnd :: Loc -> Loc

Ending position of the location.

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

Merge the locations of two Located values.

newtype SrcLoc

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

The SrcLoc of a Located value.

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

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

class IsLocation a where

Locations

Minimal complete definition

fromLoc

Methods

fromLoc :: Loc -> a

fromPos :: Pos -> a

noLoc :: IsLocation a => a

No location.

class Located a where

Located values have a location.

Minimal complete definition

locOf

Methods

locOf :: a -> Loc

locOfList :: [a] -> Loc

Instances

class Relocatable a where

Values that can be relocated

Methods

reloc :: Loc -> a -> a

Instances

data L a

An 'L a' is an 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