Safe Haskell | None |
---|---|
Language | Haskell98 |
This module contains types that relate to the positions of things in source files, and allow tagging of those things with locations
- data RealSrcLoc
- data SrcLoc
- mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
- mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLoc
- mkGeneralSrcLoc :: FastString -> SrcLoc
- noSrcLoc :: SrcLoc
- generatedSrcLoc :: SrcLoc
- interactiveSrcLoc :: SrcLoc
- advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLoc
- srcLocFile :: RealSrcLoc -> FastString
- srcLocLine :: RealSrcLoc -> Int
- srcLocCol :: RealSrcLoc -> Int
- data RealSrcSpan
- data SrcSpan
- mkGeneralSrcSpan :: FastString -> SrcSpan
- mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
- mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpan
- noSrcSpan :: SrcSpan
- wiredInSrcSpan :: SrcSpan
- srcLocSpan :: SrcLoc -> SrcSpan
- realSrcLocSpan :: RealSrcLoc -> RealSrcSpan
- combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
- srcSpanStart :: SrcSpan -> SrcLoc
- srcSpanEnd :: SrcSpan -> SrcLoc
- realSrcSpanStart :: RealSrcSpan -> RealSrcLoc
- realSrcSpanEnd :: RealSrcSpan -> RealSrcLoc
- srcSpanFileName_maybe :: SrcSpan -> Maybe FastString
- showUserSpan :: Bool -> SrcSpan -> String
- srcSpanFile :: RealSrcSpan -> FastString
- srcSpanStartLine :: RealSrcSpan -> Int
- srcSpanEndLine :: RealSrcSpan -> Int
- srcSpanStartCol :: RealSrcSpan -> Int
- srcSpanEndCol :: RealSrcSpan -> Int
- isGoodSrcSpan :: SrcSpan -> Bool
- isOneLineSpan :: SrcSpan -> Bool
- type Located e = GenLocated SrcSpan e
- type RealLocated e = GenLocated RealSrcSpan e
- data GenLocated l e = L l e
- noLoc :: e -> Located e
- mkGeneralLocated :: String -> e -> Located e
- getLoc :: GenLocated l e -> l
- unLoc :: GenLocated l e -> e
- eqLocated :: Eq a => Located a -> Located a -> Bool
- cmpLocated :: Ord a => Located a -> Located a -> Ordering
- combineLocs :: Located a -> Located b -> SrcSpan
- addCLoc :: Located a -> Located b -> c -> Located c
- leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering
- leftmost_largest :: SrcSpan -> SrcSpan -> Ordering
- rightmost :: SrcSpan -> SrcSpan -> Ordering
- spans :: SrcSpan -> (Int, Int) -> Bool
- isSubspanOf :: SrcSpan -> SrcSpan -> Bool
- sortLocated :: [Located a] -> [Located a]
SrcLoc
data RealSrcLocSource
Represents a single point within a file
Constructing SrcLoc
mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLocSource
mkGeneralSrcLoc :: FastString -> SrcLocSource
Creates a "bad" SrcLoc
that has no detailed information about its location
generatedSrcLoc :: SrcLocSource
Built-in "bad" SrcLoc
values for particular locations
interactiveSrcLoc :: SrcLocSource
Built-in "bad" SrcLoc
values for particular locations
advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLocSource
Move the SrcLoc
down by one line if the character is a newline,
to the next 8-char tabstop if it is a tab, and across by one
character in any other case
Unsafely deconstructing SrcLoc
srcLocFile :: RealSrcLoc -> FastStringSource
Gives the filename of the RealSrcLoc
srcLocLine :: RealSrcLoc -> IntSource
Raises an error when used on a "bad" SrcLoc
srcLocCol :: RealSrcLoc -> IntSource
Raises an error when used on a "bad" SrcLoc
SrcSpan
data RealSrcSpanSource
A SrcSpan delimits a portion of a text file. It could be represented by a pair of (line,column) coordinates, but in fact we optimise slightly by using more compact representations for single-line and zero-length spans, both of which are quite common.
The end position is defined to be the column after the end of the span. That is, a span of (1,1)-(1,2) is one character long, and a span of (1,1)-(1,1) is zero characters long.
Constructing SrcSpan
mkGeneralSrcSpan :: FastString -> SrcSpanSource
Create a "bad" SrcSpan
that has not location information
mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpanSource
Create a SrcSpan
between two points in a file
wiredInSrcSpan :: SrcSpanSource
Built-in "bad" SrcSpan
s for common sources of location uncertainty
srcLocSpan :: SrcLoc -> SrcSpanSource
Create a SrcSpan
corresponding to a single point
combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpanSource
Combines two SrcSpan
into one that spans at least all the characters
within both spans. Assumes the "file" part is the same in both inputs
Deconstructing SrcSpan
srcSpanStart :: SrcSpan -> SrcLocSource
srcSpanEnd :: SrcSpan -> SrcLocSource
srcSpanFileName_maybe :: SrcSpan -> Maybe FastStringSource
Obtains the filename for a SrcSpan
if it is "good"
showUserSpan :: Bool -> SrcSpan -> StringSource
Unsafely deconstructing SrcSpan
Predicates on SrcSpan
isGoodSrcSpan :: SrcSpan -> BoolSource
Test if a SrcSpan
is "good", i.e. has precise location information
isOneLineSpan :: SrcSpan -> BoolSource
True if the span is known to straddle only one line.
For "bad" SrcSpan
, it returns False
Located
type Located e = GenLocated SrcSpan eSource
type RealLocated e = GenLocated RealSrcSpan eSource
data GenLocated l eSource
We attach SrcSpans to lots of things, so let's have a datatype for it.
L l e |
Functor (GenLocated l) | |
(Eq l, Eq e) => Eq (GenLocated l e) | |
(Data l, Data e) => Data (GenLocated l e) | |
(Ord l, Ord e) => Ord (GenLocated l e) | |
(Outputable l, Outputable e) => Outputable (GenLocated l e) | |
Typeable (* -> * -> *) GenLocated |
Constructing Located
mkGeneralLocated :: String -> e -> Located eSource
Deconstructing Located
getLoc :: GenLocated l e -> lSource
unLoc :: GenLocated l e -> eSource
Combining and comparing Located values
eqLocated :: Eq a => Located a -> Located a -> BoolSource
Tests whether the two located things are equal
cmpLocated :: Ord a => Located a -> Located a -> OrderingSource
Tests the ordering of the two located things
combineLocs :: Located a -> Located b -> SrcSpanSource
addCLoc :: Located a -> Located b -> c -> Located cSource
Combine locations from two Located
things and add them to a third thing
leftmost_smallest :: SrcSpan -> SrcSpan -> OrderingSource
Alternative strategies for ordering SrcSpan
s
leftmost_largest :: SrcSpan -> SrcSpan -> OrderingSource
Alternative strategies for ordering SrcSpan
s
spans :: SrcSpan -> (Int, Int) -> BoolSource
Determines whether a span encloses a given line and column index
Determines whether a span is enclosed by another one
sortLocated :: [Located a] -> [Located a]Source