SrcLoc
Description
This module contains types that relate to the positions of things in source files, and allow tagging of those things with locations
- data SrcLoc
- mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
- mkGeneralSrcLoc :: FastString -> SrcLoc
- noSrcLoc :: SrcLoc
- generatedSrcLoc :: SrcLoc
- interactiveSrcLoc :: SrcLoc
- advanceSrcLoc :: SrcLoc -> Char -> SrcLoc
- srcLocFile :: SrcLoc -> FastString
- srcLocLine :: SrcLoc -> Int
- srcLocCol :: SrcLoc -> Int
- pprDefnLoc :: SrcSpan -> SDoc
- isGoodSrcLoc :: SrcLoc -> Bool
- data SrcSpan
- mkGeneralSrcSpan :: FastString -> SrcSpan
- mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
- noSrcSpan :: SrcSpan
- wiredInSrcSpan :: SrcSpan
- srcLocSpan :: SrcLoc -> SrcSpan
- combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
- srcSpanStart :: SrcSpan -> SrcLoc
- srcSpanEnd :: SrcSpan -> SrcLoc
- srcSpanFileName_maybe :: SrcSpan -> Maybe FastString
- srcSpanFile :: SrcSpan -> FastString
- srcSpanStartLine :: SrcSpan -> Int
- srcSpanEndLine :: SrcSpan -> Int
- srcSpanStartCol :: SrcSpan -> Int
- srcSpanEndCol :: SrcSpan -> Int
- isGoodSrcSpan :: SrcSpan -> Bool
- isOneLineSpan :: SrcSpan -> Bool
- data Located e = L SrcSpan e
- noLoc :: e -> Located e
- mkGeneralLocated :: String -> e -> Located e
- getLoc :: Located e -> SrcSpan
- unLoc :: Located 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
SrcLoc
Constructing SrcLoc
mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
mkGeneralSrcLoc :: FastString -> SrcLoc
advanceSrcLoc :: SrcLoc -> Char -> SrcLoc
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 :: SrcLoc -> FastString
Gives the filename of the SrcLoc
if it is available, otherwise returns a dummy value
srcLocLine :: SrcLoc -> Int
Misc. operations on SrcLoc
pprDefnLoc :: SrcSpan -> SDoc
Pretty prints information about the SrcSpan
in the style defined at ...
Predicates on SrcLoc
isGoodSrcLoc :: SrcLoc -> Bool
SrcSpan
data SrcSpan
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
srcLocSpan :: SrcLoc -> SrcSpan
Create a SrcSpan
corresponding to a single point
combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
Deconstructing SrcSpan
srcSpanStart :: SrcSpan -> SrcLoc
srcSpanEnd :: SrcSpan -> SrcLoc
Unsafely deconstructing SrcSpan
srcSpanFile :: SrcSpan -> FastString
srcSpanStartLine :: SrcSpan -> Int
srcSpanEndLine :: SrcSpan -> Int
srcSpanStartCol :: SrcSpan -> Int
srcSpanEndCol :: SrcSpan -> Int
Predicates on SrcSpan
isGoodSrcSpan :: SrcSpan -> Bool
isOneLineSpan :: SrcSpan -> Bool
Located
data Located e
We attach SrcSpans to lots of things, so let's have a datatype for it.
Constructing Located
mkGeneralLocated :: String -> e -> Located e
Deconstructing Located
Combining and comparing Located values
cmpLocated :: Ord a => Located a -> Located a -> Ordering
Tests the ordering of the two located things
combineLocs :: Located a -> Located b -> SrcSpan
addCLoc :: Located a -> Located b -> c -> Located c
Combine locations from two Located
things and add them to a third thing
leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering
leftmost_largest :: SrcSpan -> SrcSpan -> Ordering
Alternative strategies for ordering SrcSpan
s
spans :: SrcSpan -> (Int, Int) -> Bool
Determines whether a span encloses a given line and column index