GHC.Types.SrcLoc

ghc-9.0.0.20200925: The GHC API

Safe Haskell | None
Language | Haskell2010

GHC.Types.SrcLoc

Contents

- SrcLoc
  - Constructing SrcLoc
  - Unsafely deconstructing SrcLoc
- SrcSpan
  - Constructing SrcSpan
  - Deconstructing SrcSpan
  - Unsafely deconstructing SrcSpan
  - Predicates on SrcSpan
- StringBuffer locations
- Located
  - Constructing Located
  - Deconstructing Located
  - Modifying Located
  - Combining and comparing Located values
- Parser locations
- Layout information

Description

This module contains types that relate to the positions of things in source files, and allow tagging of those things with locations

Synopsis

- data RealSrcLoc
- data SrcLoc
  - = RealSrcLoc !RealSrcLoc !(Maybe BufPos)
  - | UnhelpfulLoc FastString
- mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
- mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLoc
- mkGeneralSrcLoc :: FastString -> SrcLoc
- noSrcLoc :: SrcLoc
- generatedSrcLoc :: SrcLoc
- interactiveSrcLoc :: SrcLoc
- advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLoc
- advanceBufPos :: BufPos -> BufPos
- srcLocFile :: RealSrcLoc -> FastString
- srcLocLine :: RealSrcLoc -> Int
- srcLocCol :: RealSrcLoc -> Int
- data RealSrcSpan
- data SrcSpan
  - = RealSrcSpan !RealSrcSpan !(Maybe BufSpan)
  - | UnhelpfulSpan !UnhelpfulSpanReason
- data UnhelpfulSpanReason
  - = UnhelpfulNoLocationInfo
  - | UnhelpfulWiredIn
  - | UnhelpfulInteractive
  - | UnhelpfulGenerated
  - | UnhelpfulOther !FastString
- mkGeneralSrcSpan :: FastString -> SrcSpan
- mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
- mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpan
- noSrcSpan :: SrcSpan
- generatedSrcSpan :: SrcSpan
- isGeneratedSrcSpan :: SrcSpan -> Bool
- wiredInSrcSpan :: SrcSpan
- interactiveSrcSpan :: SrcSpan
- srcLocSpan :: SrcLoc -> SrcSpan
- realSrcLocSpan :: RealSrcLoc -> RealSrcSpan
- combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
- srcSpanFirstCharacter :: SrcSpan -> SrcSpan
- srcSpanStart :: SrcSpan -> SrcLoc
- srcSpanEnd :: SrcSpan -> SrcLoc
- realSrcSpanStart :: RealSrcSpan -> RealSrcLoc
- realSrcSpanEnd :: RealSrcSpan -> RealSrcLoc
- srcSpanFileName_maybe :: SrcSpan -> Maybe FastString
- pprUserRealSpan :: Bool -> RealSrcSpan -> SDoc
- pprUnhelpfulSpanReason :: UnhelpfulSpanReason -> SDoc
- unhelpfulSpanFS :: UnhelpfulSpanReason -> FastString
- srcSpanFile :: RealSrcSpan -> FastString
- srcSpanStartLine :: RealSrcSpan -> Int
- srcSpanEndLine :: RealSrcSpan -> Int
- srcSpanStartCol :: RealSrcSpan -> Int
- srcSpanEndCol :: RealSrcSpan -> Int
- isGoodSrcSpan :: SrcSpan -> Bool
- isOneLineSpan :: SrcSpan -> Bool
- containsSpan :: RealSrcSpan -> RealSrcSpan -> Bool
- newtype BufPos = BufPos {
  - bufPos :: Int
  }
- getBufPos :: SrcLoc -> Maybe BufPos
- data BufSpan = BufSpan {
  - bufSpanStart, bufSpanEnd :: !BufPos
  }
- getBufSpan :: SrcSpan -> Maybe BufSpan
- type Located = GenLocated SrcSpan
- type RealLocated = GenLocated RealSrcSpan
- 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
- unRealSrcSpan :: RealLocated a -> a
- getRealSrcSpan :: RealLocated a -> RealSrcSpan
- mapLoc :: (a -> b) -> GenLocated l a -> GenLocated l b
- eqLocated :: Eq a => GenLocated l a -> GenLocated l a -> Bool
- cmpLocated :: Ord a => GenLocated l a -> GenLocated l a -> Ordering
- cmpBufSpan :: HasDebugCallStack => 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_smallest :: SrcSpan -> SrcSpan -> Ordering
- spans :: SrcSpan -> (Int, Int) -> Bool
- isSubspanOf :: SrcSpan -> SrcSpan -> Bool
- isRealSubspanOf :: RealSrcSpan -> RealSrcSpan -> Bool
- sortLocated :: [Located a] -> [Located a]
- sortRealLocated :: [RealLocated a] -> [RealLocated a]
- lookupSrcLoc :: SrcLoc -> Map RealSrcLoc a -> Maybe a
- lookupSrcSpan :: SrcSpan -> Map RealSrcSpan a -> Maybe a
- liftL :: Monad m => (a -> m b) -> GenLocated l a -> m (GenLocated l b)
- data PsLoc = PsLoc {
  - psRealLoc :: !RealSrcLoc
  - psBufPos :: !BufPos
  }
- data PsSpan = PsSpan {
  - psRealSpan :: !RealSrcSpan
  - psBufSpan :: !BufSpan
  }
- type PsLocated = GenLocated PsSpan
- advancePsLoc :: PsLoc -> Char -> PsLoc
- mkPsSpan :: PsLoc -> PsLoc -> PsSpan
- psSpanStart :: PsSpan -> PsLoc
- psSpanEnd :: PsSpan -> PsLoc
- mkSrcSpanPs :: PsSpan -> SrcSpan
- data LayoutInfo
  - = ExplicitBraces
  - | VirtualBraces !Int
  - | NoLayoutInfo
- leftmostColumn :: Int

# SrcLoc

data RealSrcLoc Source #

Real Source Location

Represents a single point within a file

#### Instances

Instances details

Eq RealSrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: RealSrcLoc -> RealSrcLoc -> Bool # (/=) :: RealSrcLoc -> RealSrcLoc -> Bool #
Ord RealSrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: RealSrcLoc -> RealSrcLoc -> Ordering # (<) :: RealSrcLoc -> RealSrcLoc -> Bool # (<=) :: RealSrcLoc -> RealSrcLoc -> Bool # (>) :: RealSrcLoc -> RealSrcLoc -> Bool # (>=) :: RealSrcLoc -> RealSrcLoc -> Bool # max :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc # min :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc #
Show RealSrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> RealSrcLoc -> ShowS Source # show :: RealSrcLoc -> String Source # showList :: [RealSrcLoc] -> ShowS Source #
Outputable RealSrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods ppr :: RealSrcLoc -> SDoc Source # pprPrec :: Rational -> RealSrcLoc -> SDoc Source #

data SrcLoc Source #

Source Location

Constructors

RealSrcLoc !RealSrcLoc !(Maybe BufPos) |
UnhelpfulLoc FastString |

#### Instances

Instances details

Eq SrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: SrcLoc -> SrcLoc -> Bool # (/=) :: SrcLoc -> SrcLoc -> Bool #
Show SrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> SrcLoc -> ShowS Source # show :: SrcLoc -> String Source # showList :: [SrcLoc] -> ShowS Source #
Outputable SrcLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods ppr :: SrcLoc -> SDoc Source # pprPrec :: Rational -> SrcLoc -> SDoc Source #

## Constructing SrcLoc

mkSrcLoc :: FastString -> Int -> Int -> SrcLoc Source #

mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLoc Source #

mkGeneralSrcLoc :: FastString -> SrcLoc Source #

Creates a "bad" `RealSrcLoc` that has no detailed information about its location

noSrcLoc :: SrcLoc Source #

Built-in "bad" `RealSrcLoc` values for particular locations

generatedSrcLoc :: SrcLoc Source #

Built-in "bad" `RealSrcLoc` values for particular locations

interactiveSrcLoc :: SrcLoc Source #

Built-in "bad" `RealSrcLoc` values for particular locations

advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLoc Source #

Move the `RealSrcLoc` 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

advanceBufPos :: BufPos -> BufPos Source #

## Unsafely deconstructing SrcLoc

srcLocFile :: RealSrcLoc -> FastString Source #

Gives the filename of the `RealSrcLoc`

srcLocLine :: RealSrcLoc -> Int Source #

Raises an error when used on a "bad" `RealSrcLoc`

srcLocCol :: RealSrcLoc -> Int Source #

Raises an error when used on a "bad" `RealSrcLoc`

# SrcSpan

data RealSrcSpan Source #

A `RealSrcSpan` 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.

Real Source Span

#### Instances

Instances details

Eq RealSrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: RealSrcSpan -> RealSrcSpan -> Bool # (/=) :: RealSrcSpan -> RealSrcSpan -> Bool #
Data RealSrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RealSrcSpan -> c RealSrcSpan Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RealSrcSpan Source # toConstr :: RealSrcSpan -> Constr Source # dataTypeOf :: RealSrcSpan -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RealSrcSpan) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RealSrcSpan) Source # gmapT :: (forall b. Data b => b -> b) -> RealSrcSpan -> RealSrcSpan Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RealSrcSpan -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RealSrcSpan -> r Source # gmapQ :: (forall d. Data d => d -> u) -> RealSrcSpan -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> RealSrcSpan -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RealSrcSpan -> m RealSrcSpan Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RealSrcSpan -> m RealSrcSpan Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RealSrcSpan -> m RealSrcSpan Source #
Ord RealSrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: RealSrcSpan -> RealSrcSpan -> Ordering # (<) :: RealSrcSpan -> RealSrcSpan -> Bool # (<=) :: RealSrcSpan -> RealSrcSpan -> Bool # (>) :: RealSrcSpan -> RealSrcSpan -> Bool # (>=) :: RealSrcSpan -> RealSrcSpan -> Bool # max :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan # min :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan #
Show RealSrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> RealSrcSpan -> ShowS Source # show :: RealSrcSpan -> String Source # showList :: [RealSrcSpan] -> ShowS Source #
Outputable RealSrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods ppr :: RealSrcSpan -> SDoc Source # pprPrec :: Rational -> RealSrcSpan -> SDoc Source #
ToJson RealSrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods json :: RealSrcSpan -> JsonDoc Source #
Binary RealSrcSpan # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> RealSrcSpan -> IO () Source # put :: BinHandle -> RealSrcSpan -> IO (Bin RealSrcSpan) Source # get :: BinHandle -> IO RealSrcSpan Source #

data SrcSpan Source #

Source Span

A `SrcSpan` identifies either a specific portion of a text file or a human-readable description of a location.

Constructors

RealSrcSpan !RealSrcSpan !(Maybe BufSpan) |
UnhelpfulSpan !UnhelpfulSpanReason |

#### Instances

Instances details

Eq SrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: SrcSpan -> SrcSpan -> Bool # (/=) :: SrcSpan -> SrcSpan -> Bool #
Data SrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SrcSpan -> c SrcSpan Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcSpan Source # toConstr :: SrcSpan -> Constr Source # dataTypeOf :: SrcSpan -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcSpan) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcSpan) Source # gmapT :: (forall b. Data b => b -> b) -> SrcSpan -> SrcSpan Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r Source # gmapQ :: (forall d. Data d => d -> u) -> SrcSpan -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcSpan -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source #
Show SrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> SrcSpan -> ShowS Source # show :: SrcSpan -> String Source # showList :: [SrcSpan] -> ShowS Source #
NFData SrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods rnf :: SrcSpan -> () Source #
Outputable SrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods ppr :: SrcSpan -> SDoc Source # pprPrec :: Rational -> SrcSpan -> SDoc Source #
ToJson SrcSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods json :: SrcSpan -> JsonDoc Source #
Binary SrcSpan # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> SrcSpan -> IO () Source # put :: BinHandle -> SrcSpan -> IO (Bin SrcSpan) Source # get :: BinHandle -> IO SrcSpan Source #
Data (LHsTypeArg GhcTc) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcTc -> c (LHsTypeArg GhcTc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcTc) Source # toConstr :: LHsTypeArg GhcTc -> Constr Source # dataTypeOf :: LHsTypeArg GhcTc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcTc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcTc)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcTc -> LHsTypeArg GhcTc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source #
Data (LHsTypeArg GhcRn) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcRn -> c (LHsTypeArg GhcRn) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcRn) Source # toConstr :: LHsTypeArg GhcRn -> Constr Source # dataTypeOf :: LHsTypeArg GhcRn -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcRn)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcRn)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcRn -> LHsTypeArg GhcRn Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source #
Data (LHsTypeArg GhcPs) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcPs -> c (LHsTypeArg GhcPs) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcPs) Source # toConstr :: LHsTypeArg GhcPs -> Constr Source # dataTypeOf :: LHsTypeArg GhcPs -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcPs)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcPs)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcPs -> LHsTypeArg GhcPs Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source #
Binary a => Binary (Located a) # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> Located a -> IO () Source # put :: BinHandle -> Located a -> IO (Bin (Located a)) Source # get :: BinHandle -> IO (Located a) Source #
NamedThing e => NamedThing (Located e) # |
Instance details Defined in GHC.Types.Name Methods getOccName :: Located e -> OccName Source # getName :: Located e -> Name Source #

data UnhelpfulSpanReason Source #

Constructors

UnhelpfulNoLocationInfo |
UnhelpfulWiredIn |
UnhelpfulInteractive |
UnhelpfulGenerated |
UnhelpfulOther !FastString |

#### Instances

Instances details

Eq UnhelpfulSpanReason # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool # (/=) :: UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool #
Show UnhelpfulSpanReason # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> UnhelpfulSpanReason -> ShowS Source # show :: UnhelpfulSpanReason -> String Source # showList :: [UnhelpfulSpanReason] -> ShowS Source #
Outputable UnhelpfulSpanReason # |
Instance details Defined in GHC.Types.SrcLoc Methods ppr :: UnhelpfulSpanReason -> SDoc Source # pprPrec :: Rational -> UnhelpfulSpanReason -> SDoc Source #
Binary UnhelpfulSpanReason # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> UnhelpfulSpanReason -> IO () Source # put :: BinHandle -> UnhelpfulSpanReason -> IO (Bin UnhelpfulSpanReason) Source # get :: BinHandle -> IO UnhelpfulSpanReason Source #

## Constructing SrcSpan

mkGeneralSrcSpan :: FastString -> SrcSpan Source #

Create a "bad" `SrcSpan` that has not location information

mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan Source #

Create a `SrcSpan` between two points in a file

mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpan Source #

Create a `SrcSpan` between two points in a file

noSrcSpan :: SrcSpan Source #

Built-in "bad" `SrcSpan`s for common sources of location uncertainty

generatedSrcSpan :: SrcSpan Source #

Built-in "bad" `SrcSpan`s for common sources of location uncertainty

isGeneratedSrcSpan :: SrcSpan -> Bool Source #

wiredInSrcSpan :: SrcSpan Source #

Built-in "bad" `SrcSpan`s for common sources of location uncertainty

interactiveSrcSpan :: SrcSpan Source #

Built-in "bad" `SrcSpan`s for common sources of location uncertainty

srcLocSpan :: SrcLoc -> SrcSpan Source #

Create a `SrcSpan` corresponding to a single point

realSrcLocSpan :: RealSrcLoc -> RealSrcSpan Source #

combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan Source #

Combines two `SrcSpan` into one that spans at least all the characters within both spans. Returns UnhelpfulSpan if the files differ.

srcSpanFirstCharacter :: SrcSpan -> SrcSpan Source #

Convert a SrcSpan into one that represents only its first character

## Deconstructing SrcSpan

srcSpanStart :: SrcSpan -> SrcLoc Source #

Returns the location at the start of the `SrcSpan` or a "bad" `SrcSpan` if that is unavailable

srcSpanEnd :: SrcSpan -> SrcLoc Source #

Returns the location at the end of the `SrcSpan` or a "bad" `SrcSpan` if that is unavailable

realSrcSpanStart :: RealSrcSpan -> RealSrcLoc Source #

realSrcSpanEnd :: RealSrcSpan -> RealSrcLoc Source #

srcSpanFileName_maybe :: SrcSpan -> Maybe FastString Source #

Obtains the filename for a `SrcSpan` if it is "good"

pprUserRealSpan :: Bool -> RealSrcSpan -> SDoc Source #

pprUnhelpfulSpanReason :: UnhelpfulSpanReason -> SDoc Source #

unhelpfulSpanFS :: UnhelpfulSpanReason -> FastString Source #

## Unsafely deconstructing SrcSpan

srcSpanFile :: RealSrcSpan -> FastString Source #

srcSpanStartLine :: RealSrcSpan -> Int Source #

srcSpanEndLine :: RealSrcSpan -> Int Source #

srcSpanStartCol :: RealSrcSpan -> Int Source #

srcSpanEndCol :: RealSrcSpan -> Int Source #

## Predicates on SrcSpan

isGoodSrcSpan :: SrcSpan -> Bool Source #

Test if a `SrcSpan` is "good", i.e. has precise location information

isOneLineSpan :: SrcSpan -> Bool Source #

True if the span is known to straddle only one line. For "bad" `SrcSpan`, it returns False

containsSpan :: RealSrcSpan -> RealSrcSpan -> Bool Source #

Tests whether the first span "contains" the other span, meaning that it covers at least as much source code. True where spans are equal.

# StringBuffer locations

newtype BufPos Source #

0-based offset identifying the raw location in the `StringBuffer`.

The lexer increments the `BufPos` every time a character (UTF-8 code point) is read from the input buffer. As UTF-8 is a variable-length encoding and `StringBuffer` needs a byte offset for indexing, a `BufPos` cannot be used for indexing.

The parser guarantees that `BufPos` are monotonic. See #17632. This means that syntactic constructs that appear later in the `StringBuffer` are guaranteed to have a higher `BufPos`. Constrast that with `RealSrcLoc`, which does *not* make the analogous guarantee about higher line/column numbers.

This is due to LINE ... #-} pragmas that can arbitrarily modify `RealSrcLoc`. Notice how `setSrcLoc` and `resetAlrLastLoc` in GHC.Parser.Lexer update `PsLoc`, modifying `RealSrcLoc` but preserving `BufPos`.

Monotonicity makes `BufPos` useful to determine the order in which syntactic elements appear in the source. Consider this example (haddockA041 in the test suite):

haddockA041.hs {--} -- | Module header documentation module Comments_and_CPP_include where #include "IncludeMe.hs"

IncludeMe.hs: -- | Comment on T data T = MkT -- ^ Comment on MkT

After the C preprocessor runs, the `StringBuffer` will contain a program that looks like this (unimportant lines at the beginning removed):

# 1 "haddockA041.hs" {--} -- | Module header documentation module Comments_and_CPP_include where # 1 "IncludeMe.hs" 1 -- | Comment on T data T = MkT -- ^ Comment on MkT # 7 "haddockA041.hs" 2

The line pragmas inserted by CPP make the error messages more informative. The downside is that we can't use RealSrcLoc to determine the ordering of syntactic elements.

With RealSrcLoc, we have the following location information recorded in the AST: * The module name is located at haddockA041.hs:3:8-31 * The Haddock comment "Comment on T" is located at IncludeMe:1:1-17 * The data declaration is located at IncludeMe.hs:2:1-32

Is the Haddock comment located between the module name and the data declaration? This is impossible to tell because the locations are not comparable; they even refer to different files.

On the other hand, with `BufPos`, we have the following location information: * The module name is located at 846-870 * The Haddock comment "Comment on T" is located at 898-915 * The data declaration is located at 916-928

Aside: if you're wondering why the numbers are so high, try running `ghc -E haddockA041.hs` and see the extra fluff that CPP inserts at the start of the file.

For error messages, `BufPos` is not useful at all. On the other hand, this is exactly what we need to determine the order of syntactic elements: 870 < 898, therefore the Haddock comment appears *after* the module name. 915 < 916, therefore the Haddock comment appears *before* the data declaration.

We use `BufPos` in in GHC.Parser.PostProcess.Haddock to associate Haddock comments with parts of the AST using location information (#17544).

Constructors

BufPos |
Fields bufPos :: Int

#### Instances

Instances details

Eq BufPos # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: BufPos -> BufPos -> Bool # (/=) :: BufPos -> BufPos -> Bool #
Ord BufPos # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: BufPos -> BufPos -> Ordering # (<) :: BufPos -> BufPos -> Bool # (<=) :: BufPos -> BufPos -> Bool # (>) :: BufPos -> BufPos -> Bool # (>=) :: BufPos -> BufPos -> Bool # max :: BufPos -> BufPos -> BufPos # min :: BufPos -> BufPos -> BufPos #
Show BufPos # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> BufPos -> ShowS Source # show :: BufPos -> String Source # showList :: [BufPos] -> ShowS Source #
Binary BufPos # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> BufPos -> IO () Source # put :: BinHandle -> BufPos -> IO (Bin BufPos) Source # get :: BinHandle -> IO BufPos Source #

getBufPos :: SrcLoc -> Maybe BufPos Source #

data BufSpan Source #

StringBuffer Source Span

Constructors

BufSpan |
Fields bufSpanStart, bufSpanEnd :: !BufPos

#### Instances

Instances details

Eq BufSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: BufSpan -> BufSpan -> Bool # (/=) :: BufSpan -> BufSpan -> Bool #
Ord BufSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: BufSpan -> BufSpan -> Ordering # (<) :: BufSpan -> BufSpan -> Bool # (<=) :: BufSpan -> BufSpan -> Bool # (>) :: BufSpan -> BufSpan -> Bool # (>=) :: BufSpan -> BufSpan -> Bool # max :: BufSpan -> BufSpan -> BufSpan # min :: BufSpan -> BufSpan -> BufSpan #
Show BufSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> BufSpan -> ShowS Source # show :: BufSpan -> String Source # showList :: [BufSpan] -> ShowS Source #
Semigroup BufSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods (<>) :: BufSpan -> BufSpan -> BufSpan Source # sconcat :: NonEmpty BufSpan -> BufSpan Source # stimes :: Integral b => b -> BufSpan -> BufSpan Source #
Binary BufSpan # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> BufSpan -> IO () Source # put :: BinHandle -> BufSpan -> IO (Bin BufSpan) Source # get :: BinHandle -> IO BufSpan Source #

getBufSpan :: SrcSpan -> Maybe BufSpan Source #

# Located

type Located = GenLocated SrcSpan Source #

type RealLocated = GenLocated RealSrcSpan Source #

data GenLocated l e Source #

We attach SrcSpans to lots of things, so let's have a datatype for it.

Constructors

L l e |

#### Instances

Instances details

Data (LHsTypeArg GhcTc) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcTc -> c (LHsTypeArg GhcTc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcTc) Source # toConstr :: LHsTypeArg GhcTc -> Constr Source # dataTypeOf :: LHsTypeArg GhcTc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcTc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcTc)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcTc -> LHsTypeArg GhcTc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcTc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcTc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcTc -> m (LHsTypeArg GhcTc) Source #
Data (LHsTypeArg GhcRn) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcRn -> c (LHsTypeArg GhcRn) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcRn) Source # toConstr :: LHsTypeArg GhcRn -> Constr Source # dataTypeOf :: LHsTypeArg GhcRn -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcRn)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcRn)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcRn -> LHsTypeArg GhcRn Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcRn -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcRn -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcRn -> m (LHsTypeArg GhcRn) Source #
Data (LHsTypeArg GhcPs) # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LHsTypeArg GhcPs -> c (LHsTypeArg GhcPs) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LHsTypeArg GhcPs) Source # toConstr :: LHsTypeArg GhcPs -> Constr Source # dataTypeOf :: LHsTypeArg GhcPs -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LHsTypeArg GhcPs)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LHsTypeArg GhcPs)) Source # gmapT :: (forall b. Data b => b -> b) -> LHsTypeArg GhcPs -> LHsTypeArg GhcPs Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LHsTypeArg GhcPs -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LHsTypeArg GhcPs -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LHsTypeArg GhcPs -> m (LHsTypeArg GhcPs) Source #
Functor (GenLocated l) # |
Instance details Defined in GHC.Types.SrcLoc Methods fmap :: (a -> b) -> GenLocated l a -> GenLocated l b Source # (<$) :: a -> GenLocated l b -> GenLocated l a Source #
Foldable (GenLocated l) # |
Instance details Defined in GHC.Types.SrcLoc Methods fold :: Monoid m => GenLocated l m -> m Source # foldMap :: Monoid m => (a -> m) -> GenLocated l a -> m Source # foldMap' :: Monoid m => (a -> m) -> GenLocated l a -> m Source # foldr :: (a -> b -> b) -> b -> GenLocated l a -> b Source # foldr' :: (a -> b -> b) -> b -> GenLocated l a -> b Source # foldl :: (b -> a -> b) -> b -> GenLocated l a -> b Source # foldl' :: (b -> a -> b) -> b -> GenLocated l a -> b Source # foldr1 :: (a -> a -> a) -> GenLocated l a -> a Source # foldl1 :: (a -> a -> a) -> GenLocated l a -> a Source # toList :: GenLocated l a -> [a] Source # null :: GenLocated l a -> Bool Source # length :: GenLocated l a -> Int Source # elem :: Eq a => a -> GenLocated l a -> Bool Source # maximum :: Ord a => GenLocated l a -> a Source # minimum :: Ord a => GenLocated l a -> a Source # sum :: Num a => GenLocated l a -> a Source # product :: Num a => GenLocated l a -> a Source #
Traversable (GenLocated l) # |
Instance details Defined in GHC.Types.SrcLoc Methods traverse :: Applicative f => (a -> f b) -> GenLocated l a -> f (GenLocated l b) Source # sequenceA :: Applicative f => GenLocated l (f a) -> f (GenLocated l a) Source # mapM :: Monad m => (a -> m b) -> GenLocated l a -> m (GenLocated l b) Source # sequence :: Monad m => GenLocated l (m a) -> m (GenLocated l a) Source #
Binary a => Binary (Located a) # |
Instance details Defined in GHC.Utils.Binary Methods put_ :: BinHandle -> Located a -> IO () Source # put :: BinHandle -> Located a -> IO (Bin (Located a)) Source # get :: BinHandle -> IO (Located a) Source #
NamedThing e => NamedThing (Located e) # |
Instance details Defined in GHC.Types.Name Methods getOccName :: Located e -> OccName Source # getName :: Located e -> Name Source #
(Eq l, Eq e) => Eq (GenLocated l e) # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: GenLocated l e -> GenLocated l e -> Bool # (/=) :: GenLocated l e -> GenLocated l e -> Bool #
(Data l, Data e) => Data (GenLocated l e) # |
Instance details Defined in GHC.Types.SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GenLocated l e) Source # toConstr :: GenLocated l e -> Constr Source # dataTypeOf :: GenLocated l e -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e)) Source # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (GenLocated l e)) Source # gmapT :: (forall b. Data b => b -> b) -> GenLocated l e -> GenLocated l e Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r Source # gmapQ :: (forall d. Data d => d -> u) -> GenLocated l e -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GenLocated l e -> m (GenLocated l e) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GenLocated l e -> m (GenLocated l e) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GenLocated l e -> m (GenLocated l e) Source #
(Ord l, Ord e) => Ord (GenLocated l e) # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: GenLocated l e -> GenLocated l e -> Ordering # (<) :: GenLocated l e -> GenLocated l e -> Bool # (<=) :: GenLocated l e -> GenLocated l e -> Bool # (>) :: GenLocated l e -> GenLocated l e -> Bool # (>=) :: GenLocated l e -> GenLocated l e -> Bool # max :: GenLocated l e -> GenLocated l e -> GenLocated l e # min :: GenLocated l e -> GenLocated l e -> GenLocated l e #
(Outputable l, Outputable e) => Outputable (GenLocated l e) # |
Instance details Defined in GHC.Types.SrcLoc Methods ppr :: GenLocated l e -> SDoc Source # pprPrec :: Rational -> GenLocated l e -> SDoc Source #

## Constructing Located

noLoc :: e -> Located e Source #

mkGeneralLocated :: String -> e -> Located e Source #

## Deconstructing Located

getLoc :: GenLocated l e -> l Source #

unLoc :: GenLocated l e -> e Source #

unRealSrcSpan :: RealLocated a -> a Source #

getRealSrcSpan :: RealLocated a -> RealSrcSpan Source #

## Modifying Located

mapLoc :: (a -> b) -> GenLocated l a -> GenLocated l b Source #

## Combining and comparing Located values

eqLocated :: Eq a => GenLocated l a -> GenLocated l a -> Bool Source #

Tests whether the two located things are equal

cmpLocated :: Ord a => GenLocated l a -> GenLocated l a -> Ordering Source #

Tests the ordering of the two located things

cmpBufSpan :: HasDebugCallStack => Located a -> Located a -> Ordering Source #

Compare the `BufSpan` of two located things.

Precondition: both operands have an associated `BufSpan`.

combineLocs :: Located a -> Located b -> SrcSpan Source #

addCLoc :: Located a -> Located b -> c -> Located c Source #

Combine locations from two `Located` things and add them to a third thing

leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering Source #

Strategies for ordering `SrcSpan`s

leftmost_largest :: SrcSpan -> SrcSpan -> Ordering Source #

Strategies for ordering `SrcSpan`s

rightmost_smallest :: SrcSpan -> SrcSpan -> Ordering Source #

Strategies for ordering `SrcSpan`s

spans :: SrcSpan -> (Int, Int) -> Bool Source #

Determines whether a span encloses a given line and column index

isSubspanOf Source #

Arguments

:: SrcSpan | The span that may be enclosed by the other
-> SrcSpan | The span it may be enclosed by
-> Bool |

Determines whether a span is enclosed by another one

isRealSubspanOf Source #

Arguments

:: RealSrcSpan | The span that may be enclosed by the other
-> RealSrcSpan | The span it may be enclosed by
-> Bool |

Determines whether a span is enclosed by another one

sortLocated :: [Located a] -> [Located a] Source #

sortRealLocated :: [RealLocated a] -> [RealLocated a] Source #

lookupSrcLoc :: SrcLoc -> Map RealSrcLoc a -> Maybe a Source #

lookupSrcSpan :: SrcSpan -> Map RealSrcSpan a -> Maybe a Source #

liftL :: Monad m => (a -> m b) -> GenLocated l a -> m (GenLocated l b) Source #

# Parser locations

data PsLoc Source #

A location as produced by the parser. Consists of two components:

- The location in the file, adjusted for LINE ... #-} pragmas (RealSrcLoc)
- The location in the string buffer (BufPos) with monotonicity guarantees (see #17632)

Constructors

PsLoc |
Fields psRealLoc :: !RealSrcLoc psBufPos :: !BufPos

#### Instances

Instances details

Eq PsLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: PsLoc -> PsLoc -> Bool # (/=) :: PsLoc -> PsLoc -> Bool #
Ord PsLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: PsLoc -> PsLoc -> Ordering # (<) :: PsLoc -> PsLoc -> Bool # (<=) :: PsLoc -> PsLoc -> Bool # (>) :: PsLoc -> PsLoc -> Bool # (>=) :: PsLoc -> PsLoc -> Bool # max :: PsLoc -> PsLoc -> PsLoc # min :: PsLoc -> PsLoc -> PsLoc #
Show PsLoc # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> PsLoc -> ShowS Source # show :: PsLoc -> String Source # showList :: [PsLoc] -> ShowS Source #

data PsSpan Source #

Constructors

PsSpan |
Fields psRealSpan :: !RealSrcSpan psBufSpan :: !BufSpan

#### Instances

Instances details

Eq PsSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: PsSpan -> PsSpan -> Bool # (/=) :: PsSpan -> PsSpan -> Bool #
Ord PsSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: PsSpan -> PsSpan -> Ordering # (<) :: PsSpan -> PsSpan -> Bool # (<=) :: PsSpan -> PsSpan -> Bool # (>) :: PsSpan -> PsSpan -> Bool # (>=) :: PsSpan -> PsSpan -> Bool # max :: PsSpan -> PsSpan -> PsSpan # min :: PsSpan -> PsSpan -> PsSpan #
Show PsSpan # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> PsSpan -> ShowS Source # show :: PsSpan -> String Source # showList :: [PsSpan] -> ShowS Source #

type PsLocated = GenLocated PsSpan Source #

advancePsLoc :: PsLoc -> Char -> PsLoc Source #

mkPsSpan :: PsLoc -> PsLoc -> PsSpan Source #

psSpanStart :: PsSpan -> PsLoc Source #

psSpanEnd :: PsSpan -> PsLoc Source #

mkSrcSpanPs :: PsSpan -> SrcSpan Source #

# Layout information

data LayoutInfo Source #

Layout information for declarations.

Constructors

ExplicitBraces | Explicit braces written by the user.
    class C a where { foo :: a; bar :: a }
VirtualBraces | Virtual braces inserted by the layout algorithm.
    class C a where
      foo :: a
      bar :: a
Fields !Int Layout column (indentation level, begins at 1)
NoLayoutInfo | Empty or compiler-generated blocks do not have layout information associated with them.

#### Instances

Instances details

Eq LayoutInfo # |
Instance details Defined in GHC.Types.SrcLoc Methods (==) :: LayoutInfo -> LayoutInfo -> Bool # (/=) :: LayoutInfo -> LayoutInfo -> Bool #
Data LayoutInfo # |
Instance details Defined in GHC.Types.SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LayoutInfo -> c LayoutInfo Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LayoutInfo Source # toConstr :: LayoutInfo -> Constr Source # dataTypeOf :: LayoutInfo -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c LayoutInfo) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LayoutInfo) Source # gmapT :: (forall b. Data b => b -> b) -> LayoutInfo -> LayoutInfo Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LayoutInfo -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LayoutInfo -> r Source # gmapQ :: (forall d. Data d => d -> u) -> LayoutInfo -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> LayoutInfo -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LayoutInfo -> m LayoutInfo Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LayoutInfo -> m LayoutInfo Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LayoutInfo -> m LayoutInfo Source #
Ord LayoutInfo # |
Instance details Defined in GHC.Types.SrcLoc Methods compare :: LayoutInfo -> LayoutInfo -> Ordering # (<) :: LayoutInfo -> LayoutInfo -> Bool # (<=) :: LayoutInfo -> LayoutInfo -> Bool # (>) :: LayoutInfo -> LayoutInfo -> Bool # (>=) :: LayoutInfo -> LayoutInfo -> Bool # max :: LayoutInfo -> LayoutInfo -> LayoutInfo # min :: LayoutInfo -> LayoutInfo -> LayoutInfo #
Show LayoutInfo # |
Instance details Defined in GHC.Types.SrcLoc Methods showsPrec :: Int -> LayoutInfo -> ShowS Source # show :: LayoutInfo -> String Source # showList :: [LayoutInfo] -> ShowS Source #

leftmostColumn :: Int Source #

Indentation level is 1-indexed, so the leftmost column is 1.