{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
module GHC.Types.SrcLoc (
RealSrcLoc,
SrcLoc(..),
mkSrcLoc, mkRealSrcLoc, mkGeneralSrcLoc,
leftmostColumn,
noSrcLoc,
generatedSrcLoc,
interactiveSrcLoc,
advanceSrcLoc,
advanceBufPos,
srcLocFile,
srcLocLine,
srcLocCol,
RealSrcSpan,
SrcSpan(..),
UnhelpfulSpanReason(..),
mkGeneralSrcSpan, mkSrcSpan, mkRealSrcSpan,
noSrcSpan, generatedSrcSpan, isGeneratedSrcSpan,
wiredInSrcSpan,
interactiveSrcSpan,
srcLocSpan, realSrcLocSpan,
combineSrcSpans,
srcSpanFirstCharacter,
srcSpanStart, srcSpanEnd,
realSrcSpanStart, realSrcSpanEnd,
srcSpanFileName_maybe,
pprUserRealSpan, pprUnhelpfulSpanReason,
pprUserSpan,
unhelpfulSpanFS,
srcSpanToRealSrcSpan,
srcSpanFile,
srcSpanStartLine, srcSpanEndLine,
srcSpanStartCol, srcSpanEndCol,
isGoodSrcSpan, isOneLineSpan, isZeroWidthSpan,
containsSpan, isNoSrcSpan,
isPointRealSpan,
BufPos(..),
getBufPos,
BufSpan(..),
getBufSpan,
removeBufSpan,
combineBufSpans,
Located,
RealLocated,
GenLocated(..),
noLoc,
mkGeneralLocated,
getLoc, unLoc,
unRealSrcSpan, getRealSrcSpan,
pprLocated,
pprLocatedAlways,
eqLocated, cmpLocated, cmpBufSpan,
combineLocs, addCLoc,
leftmost_smallest, leftmost_largest, rightmost_smallest,
spans, isSubspanOf, isRealSubspanOf,
sortLocated, sortRealLocated,
lookupSrcLoc, lookupSrcSpan,
PsLoc(..),
PsSpan(..),
PsLocated,
advancePsLoc,
mkPsSpan,
psSpanStart,
psSpanEnd,
mkSrcSpanPs,
combineRealSrcSpans,
psLocatedToLocated,
) where
import GHC.Prelude
import GHC.Utils.Misc
import GHC.Utils.Json
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Data.FastString
import qualified GHC.Data.Strict as Strict
import Control.DeepSeq
import Data.Data
import Data.List (sortBy, intercalate)
import Data.Function (on)
import qualified Data.Map as Map
import qualified Data.Semigroup as S
data RealSrcLoc
= SrcLoc LexicalFastString
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
deriving (RealSrcLoc -> RealSrcLoc -> Bool
(RealSrcLoc -> RealSrcLoc -> Bool)
-> (RealSrcLoc -> RealSrcLoc -> Bool) -> Eq RealSrcLoc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RealSrcLoc -> RealSrcLoc -> Bool
== :: RealSrcLoc -> RealSrcLoc -> Bool
$c/= :: RealSrcLoc -> RealSrcLoc -> Bool
/= :: RealSrcLoc -> RealSrcLoc -> Bool
Eq, Eq RealSrcLoc
Eq RealSrcLoc =>
(RealSrcLoc -> RealSrcLoc -> Ordering)
-> (RealSrcLoc -> RealSrcLoc -> Bool)
-> (RealSrcLoc -> RealSrcLoc -> Bool)
-> (RealSrcLoc -> RealSrcLoc -> Bool)
-> (RealSrcLoc -> RealSrcLoc -> Bool)
-> (RealSrcLoc -> RealSrcLoc -> RealSrcLoc)
-> (RealSrcLoc -> RealSrcLoc -> RealSrcLoc)
-> Ord RealSrcLoc
RealSrcLoc -> RealSrcLoc -> Bool
RealSrcLoc -> RealSrcLoc -> Ordering
RealSrcLoc -> RealSrcLoc -> RealSrcLoc
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RealSrcLoc -> RealSrcLoc -> Ordering
compare :: RealSrcLoc -> RealSrcLoc -> Ordering
$c< :: RealSrcLoc -> RealSrcLoc -> Bool
< :: RealSrcLoc -> RealSrcLoc -> Bool
$c<= :: RealSrcLoc -> RealSrcLoc -> Bool
<= :: RealSrcLoc -> RealSrcLoc -> Bool
$c> :: RealSrcLoc -> RealSrcLoc -> Bool
> :: RealSrcLoc -> RealSrcLoc -> Bool
$c>= :: RealSrcLoc -> RealSrcLoc -> Bool
>= :: RealSrcLoc -> RealSrcLoc -> Bool
$cmax :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc
max :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc
$cmin :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc
min :: RealSrcLoc -> RealSrcLoc -> RealSrcLoc
Ord)
newtype BufPos = BufPos { BufPos -> Int
bufPos :: Int }
deriving (BufPos -> BufPos -> Bool
(BufPos -> BufPos -> Bool)
-> (BufPos -> BufPos -> Bool) -> Eq BufPos
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BufPos -> BufPos -> Bool
== :: BufPos -> BufPos -> Bool
$c/= :: BufPos -> BufPos -> Bool
/= :: BufPos -> BufPos -> Bool
Eq, Eq BufPos
Eq BufPos =>
(BufPos -> BufPos -> Ordering)
-> (BufPos -> BufPos -> Bool)
-> (BufPos -> BufPos -> Bool)
-> (BufPos -> BufPos -> Bool)
-> (BufPos -> BufPos -> Bool)
-> (BufPos -> BufPos -> BufPos)
-> (BufPos -> BufPos -> BufPos)
-> Ord BufPos
BufPos -> BufPos -> Bool
BufPos -> BufPos -> Ordering
BufPos -> BufPos -> BufPos
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BufPos -> BufPos -> Ordering
compare :: BufPos -> BufPos -> Ordering
$c< :: BufPos -> BufPos -> Bool
< :: BufPos -> BufPos -> Bool
$c<= :: BufPos -> BufPos -> Bool
<= :: BufPos -> BufPos -> Bool
$c> :: BufPos -> BufPos -> Bool
> :: BufPos -> BufPos -> Bool
$c>= :: BufPos -> BufPos -> Bool
>= :: BufPos -> BufPos -> Bool
$cmax :: BufPos -> BufPos -> BufPos
max :: BufPos -> BufPos -> BufPos
$cmin :: BufPos -> BufPos -> BufPos
min :: BufPos -> BufPos -> BufPos
Ord, Int -> BufPos -> ShowS
[BufPos] -> ShowS
BufPos -> String
(Int -> BufPos -> ShowS)
-> (BufPos -> String) -> ([BufPos] -> ShowS) -> Show BufPos
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BufPos -> ShowS
showsPrec :: Int -> BufPos -> ShowS
$cshow :: BufPos -> String
show :: BufPos -> String
$cshowList :: [BufPos] -> ShowS
showList :: [BufPos] -> ShowS
Show, Typeable BufPos
Typeable BufPos =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufPos -> c BufPos)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufPos)
-> (BufPos -> Constr)
-> (BufPos -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufPos))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufPos))
-> ((forall b. Data b => b -> b) -> BufPos -> BufPos)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BufPos -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BufPos -> r)
-> (forall u. (forall d. Data d => d -> u) -> BufPos -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BufPos -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos)
-> Data BufPos
BufPos -> Constr
BufPos -> DataType
(forall b. Data b => b -> b) -> BufPos -> BufPos
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BufPos -> u
forall u. (forall d. Data d => d -> u) -> BufPos -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BufPos -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BufPos -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufPos
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufPos -> c BufPos
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufPos)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufPos)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufPos -> c BufPos
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufPos -> c BufPos
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufPos
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufPos
$ctoConstr :: BufPos -> Constr
toConstr :: BufPos -> Constr
$cdataTypeOf :: BufPos -> DataType
dataTypeOf :: BufPos -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufPos)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufPos)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufPos)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufPos)
$cgmapT :: (forall b. Data b => b -> b) -> BufPos -> BufPos
gmapT :: (forall b. Data b => b -> b) -> BufPos -> BufPos
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BufPos -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BufPos -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BufPos -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BufPos -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BufPos -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> BufPos -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BufPos -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BufPos -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufPos -> m BufPos
Data)
data SrcLoc
= RealSrcLoc !RealSrcLoc !(Strict.Maybe BufPos)
| UnhelpfulLoc !FastString
deriving (SrcLoc -> SrcLoc -> Bool
(SrcLoc -> SrcLoc -> Bool)
-> (SrcLoc -> SrcLoc -> Bool) -> Eq SrcLoc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SrcLoc -> SrcLoc -> Bool
== :: SrcLoc -> SrcLoc -> Bool
$c/= :: SrcLoc -> SrcLoc -> Bool
/= :: SrcLoc -> SrcLoc -> Bool
Eq, Int -> SrcLoc -> ShowS
[SrcLoc] -> ShowS
SrcLoc -> String
(Int -> SrcLoc -> ShowS)
-> (SrcLoc -> String) -> ([SrcLoc] -> ShowS) -> Show SrcLoc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SrcLoc -> ShowS
showsPrec :: Int -> SrcLoc -> ShowS
$cshow :: SrcLoc -> String
show :: SrcLoc -> String
$cshowList :: [SrcLoc] -> ShowS
showList :: [SrcLoc] -> ShowS
Show)
mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
mkSrcLoc FastString
x Int
line Int
col = RealSrcLoc -> Maybe BufPos -> SrcLoc
RealSrcLoc (FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc FastString
x Int
line Int
col) Maybe BufPos
forall a. Maybe a
Strict.Nothing
mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc FastString
x Int
line Int
col = LexicalFastString -> Int -> Int -> RealSrcLoc
SrcLoc (FastString -> LexicalFastString
LexicalFastString FastString
x) Int
line Int
col
leftmostColumn :: Int
leftmostColumn :: Int
leftmostColumn = Int
1
getBufPos :: SrcLoc -> Strict.Maybe BufPos
getBufPos :: SrcLoc -> Maybe BufPos
getBufPos (RealSrcLoc RealSrcLoc
_ Maybe BufPos
mbpos) = Maybe BufPos
mbpos
getBufPos (UnhelpfulLoc FastString
_) = Maybe BufPos
forall a. Maybe a
Strict.Nothing
noSrcLoc, generatedSrcLoc, interactiveSrcLoc :: SrcLoc
noSrcLoc :: SrcLoc
noSrcLoc = FastString -> SrcLoc
UnhelpfulLoc (String -> FastString
fsLit String
"<no location info>")
generatedSrcLoc :: SrcLoc
generatedSrcLoc = FastString -> SrcLoc
UnhelpfulLoc (String -> FastString
fsLit String
"<compiler-generated code>")
interactiveSrcLoc :: SrcLoc
interactiveSrcLoc = FastString -> SrcLoc
UnhelpfulLoc (String -> FastString
fsLit String
"<interactive>")
mkGeneralSrcLoc :: FastString -> SrcLoc
mkGeneralSrcLoc :: FastString -> SrcLoc
mkGeneralSrcLoc = FastString -> SrcLoc
UnhelpfulLoc
srcLocFile :: RealSrcLoc -> FastString
srcLocFile :: RealSrcLoc -> FastString
srcLocFile (SrcLoc (LexicalFastString FastString
fname) Int
_ Int
_) = FastString
fname
srcLocLine :: RealSrcLoc -> Int
srcLocLine :: RealSrcLoc -> Int
srcLocLine (SrcLoc LexicalFastString
_ Int
l Int
_) = Int
l
srcLocCol :: RealSrcLoc -> Int
srcLocCol :: RealSrcLoc -> Int
srcLocCol (SrcLoc LexicalFastString
_ Int
_ Int
c) = Int
c
advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLoc
advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLoc
advanceSrcLoc (SrcLoc LexicalFastString
f Int
l Int
_) Char
'\n' = LexicalFastString -> Int -> Int -> RealSrcLoc
SrcLoc LexicalFastString
f (Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int
1
advanceSrcLoc (SrcLoc LexicalFastString
f Int
l Int
c) Char
'\t' = LexicalFastString -> Int -> Int -> RealSrcLoc
SrcLoc LexicalFastString
f Int
l (Int -> Int
advance_tabstop Int
c)
advanceSrcLoc (SrcLoc LexicalFastString
f Int
l Int
c) Char
_ = LexicalFastString -> Int -> Int -> RealSrcLoc
SrcLoc LexicalFastString
f Int
l (Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
advance_tabstop :: Int -> Int
advance_tabstop :: Int -> Int
advance_tabstop Int
c = ((((Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftR` Int
3) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftL` Int
3) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
advanceBufPos :: BufPos -> BufPos
advanceBufPos :: BufPos -> BufPos
advanceBufPos (BufPos Int
i) = Int -> BufPos
BufPos (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
sortLocated :: [Located a] -> [Located a]
sortLocated :: forall a. [Located a] -> [Located a]
sortLocated = (Located a -> Located a -> Ordering) -> [Located a] -> [Located a]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (SrcSpan -> SrcSpan -> Ordering
leftmost_smallest (SrcSpan -> SrcSpan -> Ordering)
-> (Located a -> SrcSpan) -> Located a -> Located a -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Located a -> SrcSpan
forall l e. GenLocated l e -> l
getLoc)
sortRealLocated :: [RealLocated a] -> [RealLocated a]
sortRealLocated :: forall a. [RealLocated a] -> [RealLocated a]
sortRealLocated = (RealLocated a -> RealLocated a -> Ordering)
-> [RealLocated a] -> [RealLocated a]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (RealSrcSpan -> RealSrcSpan -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (RealSrcSpan -> RealSrcSpan -> Ordering)
-> (RealLocated a -> RealSrcSpan)
-> RealLocated a
-> RealLocated a
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` RealLocated a -> RealSrcSpan
forall l e. GenLocated l e -> l
getLoc)
lookupSrcLoc :: SrcLoc -> Map.Map RealSrcLoc a -> Maybe a
lookupSrcLoc :: forall a. SrcLoc -> Map RealSrcLoc a -> Maybe a
lookupSrcLoc (RealSrcLoc RealSrcLoc
l Maybe BufPos
_) = RealSrcLoc -> Map RealSrcLoc a -> Maybe a
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup RealSrcLoc
l
lookupSrcLoc (UnhelpfulLoc FastString
_) = Maybe a -> Map RealSrcLoc a -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing
lookupSrcSpan :: SrcSpan -> Map.Map RealSrcSpan a -> Maybe a
lookupSrcSpan :: forall a. SrcSpan -> Map RealSrcSpan a -> Maybe a
lookupSrcSpan (RealSrcSpan RealSrcSpan
l Maybe BufSpan
_) = RealSrcSpan -> Map RealSrcSpan a -> Maybe a
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup RealSrcSpan
l
lookupSrcSpan (UnhelpfulSpan UnhelpfulSpanReason
_) = Maybe a -> Map RealSrcSpan a -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing
instance Outputable RealSrcLoc where
ppr :: RealSrcLoc -> SDoc
ppr (SrcLoc (LexicalFastString FastString
src_path) Int
src_line Int
src_col)
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat [ FastString -> SDoc
pprFastFilePath FastString
src_path SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon
, Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
src_line SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon
, Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
src_col ]
instance Outputable SrcLoc where
ppr :: SrcLoc -> SDoc
ppr (RealSrcLoc RealSrcLoc
l Maybe BufPos
_) = RealSrcLoc -> SDoc
forall a. Outputable a => a -> SDoc
ppr RealSrcLoc
l
ppr (UnhelpfulLoc FastString
s) = FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext FastString
s
instance Data RealSrcSpan where
toConstr :: RealSrcSpan -> Constr
toConstr RealSrcSpan
_ = String -> Constr
abstractConstr String
"RealSrcSpan"
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RealSrcSpan
gunfold forall b r. Data b => c (b -> r) -> c r
_ forall r. r -> c r
_ = String -> Constr -> c RealSrcSpan
forall a. HasCallStack => String -> a
error String
"gunfold"
dataTypeOf :: RealSrcSpan -> DataType
dataTypeOf RealSrcSpan
_ = String -> DataType
mkNoRepType String
"RealSrcSpan"
instance Data SrcSpan where
toConstr :: SrcSpan -> Constr
toConstr SrcSpan
_ = String -> Constr
abstractConstr String
"SrcSpan"
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SrcSpan
gunfold forall b r. Data b => c (b -> r) -> c r
_ forall r. r -> c r
_ = String -> Constr -> c SrcSpan
forall a. HasCallStack => String -> a
error String
"gunfold"
dataTypeOf :: SrcSpan -> DataType
dataTypeOf SrcSpan
_ = String -> DataType
mkNoRepType String
"SrcSpan"
data RealSrcSpan
= RealSrcSpan'
{ RealSrcSpan -> FastString
srcSpanFile :: !FastString,
RealSrcSpan -> Int
srcSpanSLine :: {-# UNPACK #-} !Int,
RealSrcSpan -> Int
srcSpanSCol :: {-# UNPACK #-} !Int,
RealSrcSpan -> Int
srcSpanELine :: {-# UNPACK #-} !Int,
RealSrcSpan -> Int
srcSpanECol :: {-# UNPACK #-} !Int
}
deriving RealSrcSpan -> RealSrcSpan -> Bool
(RealSrcSpan -> RealSrcSpan -> Bool)
-> (RealSrcSpan -> RealSrcSpan -> Bool) -> Eq RealSrcSpan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RealSrcSpan -> RealSrcSpan -> Bool
== :: RealSrcSpan -> RealSrcSpan -> Bool
$c/= :: RealSrcSpan -> RealSrcSpan -> Bool
/= :: RealSrcSpan -> RealSrcSpan -> Bool
Eq
data BufSpan =
BufSpan { BufSpan -> BufPos
bufSpanStart, BufSpan -> BufPos
bufSpanEnd :: {-# UNPACK #-} !BufPos }
deriving (BufSpan -> BufSpan -> Bool
(BufSpan -> BufSpan -> Bool)
-> (BufSpan -> BufSpan -> Bool) -> Eq BufSpan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BufSpan -> BufSpan -> Bool
== :: BufSpan -> BufSpan -> Bool
$c/= :: BufSpan -> BufSpan -> Bool
/= :: BufSpan -> BufSpan -> Bool
Eq, Eq BufSpan
Eq BufSpan =>
(BufSpan -> BufSpan -> Ordering)
-> (BufSpan -> BufSpan -> Bool)
-> (BufSpan -> BufSpan -> Bool)
-> (BufSpan -> BufSpan -> Bool)
-> (BufSpan -> BufSpan -> Bool)
-> (BufSpan -> BufSpan -> BufSpan)
-> (BufSpan -> BufSpan -> BufSpan)
-> Ord BufSpan
BufSpan -> BufSpan -> Bool
BufSpan -> BufSpan -> Ordering
BufSpan -> BufSpan -> BufSpan
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BufSpan -> BufSpan -> Ordering
compare :: BufSpan -> BufSpan -> Ordering
$c< :: BufSpan -> BufSpan -> Bool
< :: BufSpan -> BufSpan -> Bool
$c<= :: BufSpan -> BufSpan -> Bool
<= :: BufSpan -> BufSpan -> Bool
$c> :: BufSpan -> BufSpan -> Bool
> :: BufSpan -> BufSpan -> Bool
$c>= :: BufSpan -> BufSpan -> Bool
>= :: BufSpan -> BufSpan -> Bool
$cmax :: BufSpan -> BufSpan -> BufSpan
max :: BufSpan -> BufSpan -> BufSpan
$cmin :: BufSpan -> BufSpan -> BufSpan
min :: BufSpan -> BufSpan -> BufSpan
Ord, Int -> BufSpan -> ShowS
[BufSpan] -> ShowS
BufSpan -> String
(Int -> BufSpan -> ShowS)
-> (BufSpan -> String) -> ([BufSpan] -> ShowS) -> Show BufSpan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BufSpan -> ShowS
showsPrec :: Int -> BufSpan -> ShowS
$cshow :: BufSpan -> String
show :: BufSpan -> String
$cshowList :: [BufSpan] -> ShowS
showList :: [BufSpan] -> ShowS
Show, Typeable BufSpan
Typeable BufSpan =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufSpan -> c BufSpan)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufSpan)
-> (BufSpan -> Constr)
-> (BufSpan -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufSpan))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufSpan))
-> ((forall b. Data b => b -> b) -> BufSpan -> BufSpan)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r)
-> (forall u. (forall d. Data d => d -> u) -> BufSpan -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BufSpan -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan)
-> Data BufSpan
BufSpan -> Constr
BufSpan -> DataType
(forall b. Data b => b -> b) -> BufSpan -> BufSpan
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BufSpan -> u
forall u. (forall d. Data d => d -> u) -> BufSpan -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufSpan
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufSpan -> c BufSpan
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufSpan)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufSpan)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufSpan -> c BufSpan
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BufSpan -> c BufSpan
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufSpan
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BufSpan
$ctoConstr :: BufSpan -> Constr
toConstr :: BufSpan -> Constr
$cdataTypeOf :: BufSpan -> DataType
dataTypeOf :: BufSpan -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufSpan)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BufSpan)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufSpan)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BufSpan)
$cgmapT :: (forall b. Data b => b -> b) -> BufSpan -> BufSpan
gmapT :: (forall b. Data b => b -> b) -> BufSpan -> BufSpan
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BufSpan -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BufSpan -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> BufSpan -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BufSpan -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BufSpan -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BufSpan -> m BufSpan
Data)
instance Semigroup BufSpan where
BufSpan BufPos
start1 BufPos
end1 <> :: BufSpan -> BufSpan -> BufSpan
<> BufSpan BufPos
start2 BufPos
end2 =
BufPos -> BufPos -> BufSpan
BufSpan (BufPos -> BufPos -> BufPos
forall a. Ord a => a -> a -> a
min BufPos
start1 BufPos
start2) (BufPos -> BufPos -> BufPos
forall a. Ord a => a -> a -> a
max BufPos
end1 BufPos
end2)
data SrcSpan =
RealSrcSpan !RealSrcSpan !(Strict.Maybe BufSpan)
| UnhelpfulSpan !UnhelpfulSpanReason
deriving (SrcSpan -> SrcSpan -> Bool
(SrcSpan -> SrcSpan -> Bool)
-> (SrcSpan -> SrcSpan -> Bool) -> Eq SrcSpan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SrcSpan -> SrcSpan -> Bool
== :: SrcSpan -> SrcSpan -> Bool
$c/= :: SrcSpan -> SrcSpan -> Bool
/= :: SrcSpan -> SrcSpan -> Bool
Eq, Int -> SrcSpan -> ShowS
[SrcSpan] -> ShowS
SrcSpan -> String
(Int -> SrcSpan -> ShowS)
-> (SrcSpan -> String) -> ([SrcSpan] -> ShowS) -> Show SrcSpan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SrcSpan -> ShowS
showsPrec :: Int -> SrcSpan -> ShowS
$cshow :: SrcSpan -> String
show :: SrcSpan -> String
$cshowList :: [SrcSpan] -> ShowS
showList :: [SrcSpan] -> ShowS
Show)
data UnhelpfulSpanReason
= UnhelpfulNoLocationInfo
| UnhelpfulWiredIn
| UnhelpfulInteractive
| UnhelpfulGenerated
| UnhelpfulOther !FastString
deriving (UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool
(UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool)
-> (UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool)
-> Eq UnhelpfulSpanReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool
== :: UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool
$c/= :: UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool
/= :: UnhelpfulSpanReason -> UnhelpfulSpanReason -> Bool
Eq, Int -> UnhelpfulSpanReason -> ShowS
[UnhelpfulSpanReason] -> ShowS
UnhelpfulSpanReason -> String
(Int -> UnhelpfulSpanReason -> ShowS)
-> (UnhelpfulSpanReason -> String)
-> ([UnhelpfulSpanReason] -> ShowS)
-> Show UnhelpfulSpanReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnhelpfulSpanReason -> ShowS
showsPrec :: Int -> UnhelpfulSpanReason -> ShowS
$cshow :: UnhelpfulSpanReason -> String
show :: UnhelpfulSpanReason -> String
$cshowList :: [UnhelpfulSpanReason] -> ShowS
showList :: [UnhelpfulSpanReason] -> ShowS
Show)
removeBufSpan :: SrcSpan -> SrcSpan
removeBufSpan :: SrcSpan -> SrcSpan
removeBufSpan (RealSrcSpan RealSrcSpan
s Maybe BufSpan
_) = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan RealSrcSpan
s Maybe BufSpan
forall a. Maybe a
Strict.Nothing
removeBufSpan SrcSpan
s = SrcSpan
s
instance ToJson SrcSpan where
json :: SrcSpan -> JsonDoc
json (UnhelpfulSpan {} ) = JsonDoc
JSNull
json (RealSrcSpan RealSrcSpan
rss Maybe BufSpan
_) = RealSrcSpan -> JsonDoc
forall a. ToJson a => a -> JsonDoc
json RealSrcSpan
rss
instance ToJson RealSrcSpan where
json :: RealSrcSpan -> JsonDoc
json (RealSrcSpan'{Int
FastString
srcSpanFile :: RealSrcSpan -> FastString
srcSpanSLine :: RealSrcSpan -> Int
srcSpanSCol :: RealSrcSpan -> Int
srcSpanELine :: RealSrcSpan -> Int
srcSpanECol :: RealSrcSpan -> Int
srcSpanFile :: FastString
srcSpanSLine :: Int
srcSpanSCol :: Int
srcSpanELine :: Int
srcSpanECol :: Int
..}) = [(String, JsonDoc)] -> JsonDoc
JSObject [ (String
"file", String -> JsonDoc
JSString (FastString -> String
unpackFS FastString
srcSpanFile))
, (String
"startLine", Int -> JsonDoc
JSInt Int
srcSpanSLine)
, (String
"startCol", Int -> JsonDoc
JSInt Int
srcSpanSCol)
, (String
"endLine", Int -> JsonDoc
JSInt Int
srcSpanELine)
, (String
"endCol", Int -> JsonDoc
JSInt Int
srcSpanECol)
]
instance NFData SrcSpan where
rnf :: SrcSpan -> ()
rnf SrcSpan
x = SrcSpan
x SrcSpan -> () -> ()
forall a b. a -> b -> b
`seq` ()
getBufSpan :: SrcSpan -> Strict.Maybe BufSpan
getBufSpan :: SrcSpan -> Maybe BufSpan
getBufSpan (RealSrcSpan RealSrcSpan
_ Maybe BufSpan
mbspan) = Maybe BufSpan
mbspan
getBufSpan (UnhelpfulSpan UnhelpfulSpanReason
_) = Maybe BufSpan
forall a. Maybe a
Strict.Nothing
noSrcSpan, generatedSrcSpan, wiredInSrcSpan, interactiveSrcSpan :: SrcSpan
noSrcSpan :: SrcSpan
noSrcSpan = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan UnhelpfulSpanReason
UnhelpfulNoLocationInfo
wiredInSrcSpan :: SrcSpan
wiredInSrcSpan = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan UnhelpfulSpanReason
UnhelpfulWiredIn
interactiveSrcSpan :: SrcSpan
interactiveSrcSpan = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan UnhelpfulSpanReason
UnhelpfulInteractive
generatedSrcSpan :: SrcSpan
generatedSrcSpan = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan UnhelpfulSpanReason
UnhelpfulGenerated
isGeneratedSrcSpan :: SrcSpan -> Bool
isGeneratedSrcSpan :: SrcSpan -> Bool
isGeneratedSrcSpan (UnhelpfulSpan UnhelpfulSpanReason
UnhelpfulGenerated) = Bool
True
isGeneratedSrcSpan SrcSpan
_ = Bool
False
isNoSrcSpan :: SrcSpan -> Bool
isNoSrcSpan :: SrcSpan -> Bool
isNoSrcSpan (UnhelpfulSpan UnhelpfulSpanReason
UnhelpfulNoLocationInfo) = Bool
True
isNoSrcSpan SrcSpan
_ = Bool
False
mkGeneralSrcSpan :: FastString -> SrcSpan
mkGeneralSrcSpan :: FastString -> SrcSpan
mkGeneralSrcSpan = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan (UnhelpfulSpanReason -> SrcSpan)
-> (FastString -> UnhelpfulSpanReason) -> FastString -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FastString -> UnhelpfulSpanReason
UnhelpfulOther
srcLocSpan :: SrcLoc -> SrcSpan
srcLocSpan :: SrcLoc -> SrcSpan
srcLocSpan (UnhelpfulLoc FastString
str) = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan (FastString -> UnhelpfulSpanReason
UnhelpfulOther FastString
str)
srcLocSpan (RealSrcLoc RealSrcLoc
l Maybe BufPos
mb) = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcLoc -> RealSrcSpan
realSrcLocSpan RealSrcLoc
l) ((BufPos -> BufSpan) -> Maybe BufPos -> Maybe BufSpan
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\BufPos
b -> BufPos -> BufPos -> BufSpan
BufSpan BufPos
b BufPos
b) Maybe BufPos
mb)
realSrcLocSpan :: RealSrcLoc -> RealSrcSpan
realSrcLocSpan :: RealSrcLoc -> RealSrcSpan
realSrcLocSpan (SrcLoc (LexicalFastString FastString
file) Int
line Int
col) = FastString -> Int -> Int -> Int -> Int -> RealSrcSpan
RealSrcSpan' FastString
file Int
line Int
col Int
line Int
col
mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan RealSrcLoc
loc1 RealSrcLoc
loc2 = FastString -> Int -> Int -> Int -> Int -> RealSrcSpan
RealSrcSpan' FastString
file Int
line1 Int
col1 Int
line2 Int
col2
where
line1 :: Int
line1 = RealSrcLoc -> Int
srcLocLine RealSrcLoc
loc1
line2 :: Int
line2 = RealSrcLoc -> Int
srcLocLine RealSrcLoc
loc2
col1 :: Int
col1 = RealSrcLoc -> Int
srcLocCol RealSrcLoc
loc1
col2 :: Int
col2 = RealSrcLoc -> Int
srcLocCol RealSrcLoc
loc2
file :: FastString
file = RealSrcLoc -> FastString
srcLocFile RealSrcLoc
loc1
isOneLineRealSpan :: RealSrcSpan -> Bool
isOneLineRealSpan :: RealSrcSpan -> Bool
isOneLineRealSpan (RealSrcSpan' FastString
_ Int
line1 Int
_ Int
line2 Int
_)
= Int
line1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
line2
isPointRealSpan :: RealSrcSpan -> Bool
isPointRealSpan :: RealSrcSpan -> Bool
isPointRealSpan (RealSrcSpan' FastString
_ Int
line1 Int
col1 Int
line2 Int
col2)
= Int
line1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
line2 Bool -> Bool -> Bool
&& Int
col1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
col2
mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
mkSrcSpan (UnhelpfulLoc FastString
str) SrcLoc
_ = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan (FastString -> UnhelpfulSpanReason
UnhelpfulOther FastString
str)
mkSrcSpan SrcLoc
_ (UnhelpfulLoc FastString
str) = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan (FastString -> UnhelpfulSpanReason
UnhelpfulOther FastString
str)
mkSrcSpan (RealSrcLoc RealSrcLoc
loc1 Maybe BufPos
mbpos1) (RealSrcLoc RealSrcLoc
loc2 Maybe BufPos
mbpos2)
= RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan RealSrcLoc
loc1 RealSrcLoc
loc2) ((BufPos -> BufPos -> BufSpan)
-> Maybe BufPos -> Maybe BufPos -> Maybe BufSpan
forall a b c. (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 BufPos -> BufPos -> BufSpan
BufSpan Maybe BufPos
mbpos1 Maybe BufPos
mbpos2)
combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (UnhelpfulSpan UnhelpfulSpanReason
_) SrcSpan
r = SrcSpan
r
combineSrcSpans SrcSpan
l (UnhelpfulSpan UnhelpfulSpanReason
_) = SrcSpan
l
combineSrcSpans (RealSrcSpan RealSrcSpan
span1 Maybe BufSpan
mbspan1) (RealSrcSpan RealSrcSpan
span2 Maybe BufSpan
mbspan2)
| RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
span1 FastString -> FastString -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
span2
= RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcSpan -> RealSrcSpan -> RealSrcSpan
combineRealSrcSpans RealSrcSpan
span1 RealSrcSpan
span2) ((BufSpan -> BufSpan -> BufSpan)
-> Maybe BufSpan -> Maybe BufSpan -> Maybe BufSpan
forall a b c. (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 BufSpan -> BufSpan -> BufSpan
combineBufSpans Maybe BufSpan
mbspan1 Maybe BufSpan
mbspan2)
| Bool
otherwise = UnhelpfulSpanReason -> SrcSpan
UnhelpfulSpan (UnhelpfulSpanReason -> SrcSpan) -> UnhelpfulSpanReason -> SrcSpan
forall a b. (a -> b) -> a -> b
$
FastString -> UnhelpfulSpanReason
UnhelpfulOther (String -> FastString
fsLit String
"<combineSrcSpans: files differ>")
combineRealSrcSpans :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan
combineRealSrcSpans :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan
combineRealSrcSpans RealSrcSpan
span1 RealSrcSpan
span2
= FastString -> Int -> Int -> Int -> Int -> RealSrcSpan
RealSrcSpan' FastString
file Int
line_start Int
col_start Int
line_end Int
col_end
where
(Int
line_start, Int
col_start) = (Int, Int) -> (Int, Int) -> (Int, Int)
forall a. Ord a => a -> a -> a
min (RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
span1, RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
span1)
(RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
span2, RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
span2)
(Int
line_end, Int
col_end) = (Int, Int) -> (Int, Int) -> (Int, Int)
forall a. Ord a => a -> a -> a
max (RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
span1, RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
span1)
(RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
span2, RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
span2)
file :: FastString
file = RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
span1
combineBufSpans :: BufSpan -> BufSpan -> BufSpan
combineBufSpans :: BufSpan -> BufSpan -> BufSpan
combineBufSpans BufSpan
span1 BufSpan
span2 = BufPos -> BufPos -> BufSpan
BufSpan BufPos
start BufPos
end
where
start :: BufPos
start = BufPos -> BufPos -> BufPos
forall a. Ord a => a -> a -> a
min (BufSpan -> BufPos
bufSpanStart BufSpan
span1) (BufSpan -> BufPos
bufSpanStart BufSpan
span2)
end :: BufPos
end = BufPos -> BufPos -> BufPos
forall a. Ord a => a -> a -> a
max (BufSpan -> BufPos
bufSpanEnd BufSpan
span1) (BufSpan -> BufPos
bufSpanEnd BufSpan
span2)
srcSpanFirstCharacter :: SrcSpan -> SrcSpan
srcSpanFirstCharacter :: SrcSpan -> SrcSpan
srcSpanFirstCharacter l :: SrcSpan
l@(UnhelpfulSpan {}) = SrcSpan
l
srcSpanFirstCharacter (RealSrcSpan RealSrcSpan
span Maybe BufSpan
mbspan) =
RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan RealSrcLoc
loc1 RealSrcLoc
loc2) ((BufSpan -> BufSpan) -> Maybe BufSpan -> Maybe BufSpan
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BufSpan -> BufSpan
mkBufSpan Maybe BufSpan
mbspan)
where
loc1 :: RealSrcLoc
loc1@(SrcLoc LexicalFastString
f Int
l Int
c) = RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
span
loc2 :: RealSrcLoc
loc2 = LexicalFastString -> Int -> Int -> RealSrcLoc
SrcLoc LexicalFastString
f Int
l (Int
cInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
mkBufSpan :: BufSpan -> BufSpan
mkBufSpan BufSpan
bspan =
let bpos1 :: BufPos
bpos1@(BufPos Int
i) = BufSpan -> BufPos
bufSpanStart BufSpan
bspan
bpos2 :: BufPos
bpos2 = Int -> BufPos
BufPos (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
in BufPos -> BufPos -> BufSpan
BufSpan BufPos
bpos1 BufPos
bpos2
isGoodSrcSpan :: SrcSpan -> Bool
isGoodSrcSpan :: SrcSpan -> Bool
isGoodSrcSpan (RealSrcSpan RealSrcSpan
_ Maybe BufSpan
_) = Bool
True
isGoodSrcSpan (UnhelpfulSpan UnhelpfulSpanReason
_) = Bool
False
isOneLineSpan :: SrcSpan -> Bool
isOneLineSpan :: SrcSpan -> Bool
isOneLineSpan (RealSrcSpan RealSrcSpan
s Maybe BufSpan
_) = RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
s Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
s
isOneLineSpan (UnhelpfulSpan UnhelpfulSpanReason
_) = Bool
False
isZeroWidthSpan :: SrcSpan -> Bool
isZeroWidthSpan :: SrcSpan -> Bool
isZeroWidthSpan (RealSrcSpan RealSrcSpan
s Maybe BufSpan
_) = RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
s Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
s
Bool -> Bool -> Bool
&& RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
s Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
s
isZeroWidthSpan (UnhelpfulSpan UnhelpfulSpanReason
_) = Bool
False
containsSpan :: RealSrcSpan -> RealSrcSpan -> Bool
containsSpan :: RealSrcSpan -> RealSrcSpan -> Bool
containsSpan RealSrcSpan
s1 RealSrcSpan
s2
= (RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
s1, RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
s1)
(Int, Int) -> (Int, Int) -> Bool
forall a. Ord a => a -> a -> Bool
<= (RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
s2, RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
s2)
Bool -> Bool -> Bool
&& (RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
s1, RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
s1)
(Int, Int) -> (Int, Int) -> Bool
forall a. Ord a => a -> a -> Bool
>= (RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
s2, RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
s2)
Bool -> Bool -> Bool
&& (RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
s1 FastString -> FastString -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
s2)
srcSpanStartLine :: RealSrcSpan -> Int
srcSpanEndLine :: RealSrcSpan -> Int
srcSpanStartCol :: RealSrcSpan -> Int
srcSpanEndCol :: RealSrcSpan -> Int
srcSpanStartLine :: RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan'{ srcSpanSLine :: RealSrcSpan -> Int
srcSpanSLine=Int
l } = Int
l
srcSpanEndLine :: RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan'{ srcSpanELine :: RealSrcSpan -> Int
srcSpanELine=Int
l } = Int
l
srcSpanStartCol :: RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan'{ srcSpanSCol :: RealSrcSpan -> Int
srcSpanSCol=Int
l } = Int
l
srcSpanEndCol :: RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan'{ srcSpanECol :: RealSrcSpan -> Int
srcSpanECol=Int
c } = Int
c
srcSpanStart :: SrcSpan -> SrcLoc
srcSpanStart :: SrcSpan -> SrcLoc
srcSpanStart (UnhelpfulSpan UnhelpfulSpanReason
r) = FastString -> SrcLoc
UnhelpfulLoc (UnhelpfulSpanReason -> FastString
unhelpfulSpanFS UnhelpfulSpanReason
r)
srcSpanStart (RealSrcSpan RealSrcSpan
s Maybe BufSpan
b) = RealSrcLoc -> Maybe BufPos -> SrcLoc
RealSrcLoc (RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
s) ((BufSpan -> BufPos) -> Maybe BufSpan -> Maybe BufPos
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BufSpan -> BufPos
bufSpanStart Maybe BufSpan
b)
srcSpanEnd :: SrcSpan -> SrcLoc
srcSpanEnd :: SrcSpan -> SrcLoc
srcSpanEnd (UnhelpfulSpan UnhelpfulSpanReason
r) = FastString -> SrcLoc
UnhelpfulLoc (UnhelpfulSpanReason -> FastString
unhelpfulSpanFS UnhelpfulSpanReason
r)
srcSpanEnd (RealSrcSpan RealSrcSpan
s Maybe BufSpan
b) = RealSrcLoc -> Maybe BufPos -> SrcLoc
RealSrcLoc (RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
s) ((BufSpan -> BufPos) -> Maybe BufSpan -> Maybe BufPos
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BufSpan -> BufPos
bufSpanEnd Maybe BufSpan
b)
realSrcSpanStart :: RealSrcSpan -> RealSrcLoc
realSrcSpanStart :: RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
s = FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
s)
(RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
s)
(RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
s)
realSrcSpanEnd :: RealSrcSpan -> RealSrcLoc
realSrcSpanEnd :: RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
s = FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
s)
(RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
s)
(RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
s)
srcSpanFileName_maybe :: SrcSpan -> Maybe FastString
srcSpanFileName_maybe :: SrcSpan -> Maybe FastString
srcSpanFileName_maybe (RealSrcSpan RealSrcSpan
s Maybe BufSpan
_) = FastString -> Maybe FastString
forall a. a -> Maybe a
Just (RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
s)
srcSpanFileName_maybe (UnhelpfulSpan UnhelpfulSpanReason
_) = Maybe FastString
forall a. Maybe a
Nothing
srcSpanToRealSrcSpan :: SrcSpan -> Maybe RealSrcSpan
srcSpanToRealSrcSpan :: SrcSpan -> Maybe RealSrcSpan
srcSpanToRealSrcSpan (RealSrcSpan RealSrcSpan
ss Maybe BufSpan
_) = RealSrcSpan -> Maybe RealSrcSpan
forall a. a -> Maybe a
Just RealSrcSpan
ss
srcSpanToRealSrcSpan SrcSpan
_ = Maybe RealSrcSpan
forall a. Maybe a
Nothing
instance Ord RealSrcSpan where
compare :: RealSrcSpan -> RealSrcSpan -> Ordering
compare = (RealSrcLoc -> RealSrcLoc -> Ordering)
-> (RealSrcSpan -> RealSrcLoc)
-> RealSrcSpan
-> RealSrcSpan
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on RealSrcLoc -> RealSrcLoc -> Ordering
forall a. Ord a => a -> a -> Ordering
compare RealSrcSpan -> RealSrcLoc
realSrcSpanStart (RealSrcSpan -> RealSrcSpan -> Ordering)
-> (RealSrcSpan -> RealSrcSpan -> Ordering)
-> RealSrcSpan
-> RealSrcSpan
-> Ordering
forall a. Semigroup a => a -> a -> a
S.<> (RealSrcLoc -> RealSrcLoc -> Ordering)
-> (RealSrcSpan -> RealSrcLoc)
-> RealSrcSpan
-> RealSrcSpan
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on RealSrcLoc -> RealSrcLoc -> Ordering
forall a. Ord a => a -> a -> Ordering
compare RealSrcSpan -> RealSrcLoc
realSrcSpanEnd
instance Show RealSrcLoc where
show :: RealSrcLoc -> String
show (SrcLoc LexicalFastString
filename Int
row Int
col)
= String
"SrcLoc " String -> ShowS
forall a. [a] -> [a] -> [a]
++ LexicalFastString -> String
forall a. Show a => a -> String
show LexicalFastString
filename String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
row String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
col
instance Show RealSrcSpan where
show :: RealSrcSpan -> String
show span :: RealSrcSpan
span@(RealSrcSpan' FastString
file Int
sl Int
sc Int
el Int
ec)
| RealSrcSpan -> Bool
isPointRealSpan RealSrcSpan
span
= String
"SrcSpanPoint " String -> ShowS
forall a. [a] -> [a] -> [a]
++ FastString -> String
forall a. Show a => a -> String
show FastString
file String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" " ((Int -> String) -> [Int] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Int -> String
forall a. Show a => a -> String
show [Int
sl,Int
sc])
| RealSrcSpan -> Bool
isOneLineRealSpan RealSrcSpan
span
= String
"SrcSpanOneLine " String -> ShowS
forall a. [a] -> [a] -> [a]
++ FastString -> String
forall a. Show a => a -> String
show FastString
file String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" "
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" " ((Int -> String) -> [Int] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Int -> String
forall a. Show a => a -> String
show [Int
sl,Int
sc,Int
ec])
| Bool
otherwise
= String
"SrcSpanMultiLine " String -> ShowS
forall a. [a] -> [a] -> [a]
++ FastString -> String
forall a. Show a => a -> String
show FastString
file String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" "
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" " ((Int -> String) -> [Int] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Int -> String
forall a. Show a => a -> String
show [Int
sl,Int
sc,Int
el,Int
ec])
instance Outputable RealSrcSpan where
ppr :: RealSrcSpan -> SDoc
ppr RealSrcSpan
span = Bool -> RealSrcSpan -> SDoc
pprUserRealSpan Bool
True RealSrcSpan
span
instance Outputable SrcSpan where
ppr :: SrcSpan -> SDoc
ppr SrcSpan
span = Bool -> SrcSpan -> SDoc
pprUserSpan Bool
True SrcSpan
span
instance Outputable UnhelpfulSpanReason where
ppr :: UnhelpfulSpanReason -> SDoc
ppr = UnhelpfulSpanReason -> SDoc
pprUnhelpfulSpanReason
unhelpfulSpanFS :: UnhelpfulSpanReason -> FastString
unhelpfulSpanFS :: UnhelpfulSpanReason -> FastString
unhelpfulSpanFS UnhelpfulSpanReason
r = case UnhelpfulSpanReason
r of
UnhelpfulOther FastString
s -> FastString
s
UnhelpfulSpanReason
UnhelpfulNoLocationInfo -> String -> FastString
fsLit String
"<no location info>"
UnhelpfulSpanReason
UnhelpfulWiredIn -> String -> FastString
fsLit String
"<wired into compiler>"
UnhelpfulSpanReason
UnhelpfulInteractive -> String -> FastString
fsLit String
"<interactive>"
UnhelpfulSpanReason
UnhelpfulGenerated -> String -> FastString
fsLit String
"<generated>"
pprUnhelpfulSpanReason :: UnhelpfulSpanReason -> SDoc
pprUnhelpfulSpanReason :: UnhelpfulSpanReason -> SDoc
pprUnhelpfulSpanReason UnhelpfulSpanReason
r = FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext (UnhelpfulSpanReason -> FastString
unhelpfulSpanFS UnhelpfulSpanReason
r)
pprUserSpan :: Bool -> SrcSpan -> SDoc
pprUserSpan :: Bool -> SrcSpan -> SDoc
pprUserSpan Bool
_ (UnhelpfulSpan UnhelpfulSpanReason
r) = UnhelpfulSpanReason -> SDoc
pprUnhelpfulSpanReason UnhelpfulSpanReason
r
pprUserSpan Bool
show_path (RealSrcSpan RealSrcSpan
s Maybe BufSpan
_) = Bool -> RealSrcSpan -> SDoc
pprUserRealSpan Bool
show_path RealSrcSpan
s
pprUserRealSpan :: Bool -> RealSrcSpan -> SDoc
pprUserRealSpan :: Bool -> RealSrcSpan -> SDoc
pprUserRealSpan Bool
show_path span :: RealSrcSpan
span@(RealSrcSpan' FastString
src_path Int
line Int
col Int
_ Int
_)
| RealSrcSpan -> Bool
isPointRealSpan RealSrcSpan
span
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat [ Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen Bool
show_path (FastString -> SDoc
pprFastFilePath FastString
src_path SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon)
, Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
line SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon
, Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
col ]
pprUserRealSpan Bool
show_path span :: RealSrcSpan
span@(RealSrcSpan' FastString
src_path Int
line Int
scol Int
_ Int
ecol)
| RealSrcSpan -> Bool
isOneLineRealSpan RealSrcSpan
span
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat [ Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen Bool
show_path (FastString -> SDoc
pprFastFilePath FastString
src_path SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon)
, Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
line SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon
, Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
scol
, Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless (Int
ecol Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
scol Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
1) (Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'-' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Int -> SDoc
forall doc. IsLine doc => Int -> doc
int (Int
ecol Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)) ]
pprUserRealSpan Bool
show_path (RealSrcSpan' FastString
src_path Int
sline Int
scol Int
eline Int
ecol)
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat [ Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen Bool
show_path (FastString -> SDoc
pprFastFilePath FastString
src_path SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon)
, SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
sline SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
comma SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
scol)
, Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'-'
, SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
eline SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
comma SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
ecol') ]
where
ecol' :: Int
ecol' = if Int
ecol Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 then Int
ecol else Int
ecol Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
data GenLocated l e = L l e
deriving (GenLocated l e -> GenLocated l e -> Bool
(GenLocated l e -> GenLocated l e -> Bool)
-> (GenLocated l e -> GenLocated l e -> Bool)
-> Eq (GenLocated l e)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall l e.
(Eq l, Eq e) =>
GenLocated l e -> GenLocated l e -> Bool
$c== :: forall l e.
(Eq l, Eq e) =>
GenLocated l e -> GenLocated l e -> Bool
== :: GenLocated l e -> GenLocated l e -> Bool
$c/= :: forall l e.
(Eq l, Eq e) =>
GenLocated l e -> GenLocated l e -> Bool
/= :: GenLocated l e -> GenLocated l e -> Bool
Eq, Eq (GenLocated l e)
Eq (GenLocated l e) =>
(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)
-> (GenLocated l e -> GenLocated l e -> GenLocated l e)
-> (GenLocated l e -> GenLocated l e -> GenLocated l e)
-> Ord (GenLocated l e)
GenLocated l e -> GenLocated l e -> Bool
GenLocated l e -> GenLocated l e -> Ordering
GenLocated l e -> GenLocated l e -> GenLocated l e
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall l e. (Ord l, Ord e) => Eq (GenLocated l e)
forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Bool
forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Ordering
forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> GenLocated l e
$ccompare :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Ordering
compare :: GenLocated l e -> GenLocated l e -> Ordering
$c< :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Bool
< :: GenLocated l e -> GenLocated l e -> Bool
$c<= :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Bool
<= :: GenLocated l e -> GenLocated l e -> Bool
$c> :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Bool
> :: GenLocated l e -> GenLocated l e -> Bool
$c>= :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> Bool
>= :: GenLocated l e -> GenLocated l e -> Bool
$cmax :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> GenLocated l e
max :: GenLocated l e -> GenLocated l e -> GenLocated l e
$cmin :: forall l e.
(Ord l, Ord e) =>
GenLocated l e -> GenLocated l e -> GenLocated l e
min :: GenLocated l e -> GenLocated l e -> GenLocated l e
Ord, Int -> GenLocated l e -> ShowS
[GenLocated l e] -> ShowS
GenLocated l e -> String
(Int -> GenLocated l e -> ShowS)
-> (GenLocated l e -> String)
-> ([GenLocated l e] -> ShowS)
-> Show (GenLocated l e)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall l e. (Show l, Show e) => Int -> GenLocated l e -> ShowS
forall l e. (Show l, Show e) => [GenLocated l e] -> ShowS
forall l e. (Show l, Show e) => GenLocated l e -> String
$cshowsPrec :: forall l e. (Show l, Show e) => Int -> GenLocated l e -> ShowS
showsPrec :: Int -> GenLocated l e -> ShowS
$cshow :: forall l e. (Show l, Show e) => GenLocated l e -> String
show :: GenLocated l e -> String
$cshowList :: forall l e. (Show l, Show e) => [GenLocated l e] -> ShowS
showList :: [GenLocated l e] -> ShowS
Show, Typeable (GenLocated l e)
Typeable (GenLocated l e) =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GenLocated l e))
-> (GenLocated l e -> Constr)
-> (GenLocated l e -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GenLocated l e)))
-> ((forall b. Data b => b -> b)
-> GenLocated l e -> GenLocated l e)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r)
-> (forall u.
(forall d. Data d => d -> u) -> GenLocated l e -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e))
-> Data (GenLocated l e)
GenLocated l e -> Constr
GenLocated l e -> DataType
(forall b. Data b => b -> b) -> GenLocated l e -> GenLocated l e
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u
forall u. (forall d. Data d => d -> u) -> GenLocated l e -> [u]
forall l e. (Data l, Data e) => Typeable (GenLocated l e)
forall l e. (Data l, Data e) => GenLocated l e -> Constr
forall l e. (Data l, Data e) => GenLocated l e -> DataType
forall l e.
(Data l, Data e) =>
(forall b. Data b => b -> b) -> GenLocated l e -> GenLocated l e
forall l e u.
(Data l, Data e) =>
Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u
forall l e u.
(Data l, Data e) =>
(forall d. Data d => d -> u) -> GenLocated l e -> [u]
forall l e r r'.
(Data l, Data e) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
forall l e r r'.
(Data l, Data e) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
forall l e (m :: * -> *).
(Data l, Data e, Monad m) =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
forall l e (m :: * -> *).
(Data l, Data e, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
forall l e (c :: * -> *).
(Data l, Data e) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GenLocated l e)
forall l e (c :: * -> *).
(Data l, Data e) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e)
forall l e (t :: * -> *) (c :: * -> *).
(Data l, Data e, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e))
forall l e (t :: * -> * -> *) (c :: * -> *).
(Data l, Data e, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GenLocated l e))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GenLocated l e)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GenLocated l e))
$cgfoldl :: forall l e (c :: * -> *).
(Data l, Data e) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GenLocated l e -> c (GenLocated l e)
$cgunfold :: forall l e (c :: * -> *).
(Data l, Data e) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GenLocated l e)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GenLocated l e)
$ctoConstr :: forall l e. (Data l, Data e) => GenLocated l e -> Constr
toConstr :: GenLocated l e -> Constr
$cdataTypeOf :: forall l e. (Data l, Data e) => GenLocated l e -> DataType
dataTypeOf :: GenLocated l e -> DataType
$cdataCast1 :: forall l e (t :: * -> *) (c :: * -> *).
(Data l, Data e, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (GenLocated l e))
$cdataCast2 :: forall l e (t :: * -> * -> *) (c :: * -> *).
(Data l, Data e, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GenLocated l e))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GenLocated l e))
$cgmapT :: forall l e.
(Data l, Data e) =>
(forall b. Data b => b -> b) -> GenLocated l e -> GenLocated l e
gmapT :: (forall b. Data b => b -> b) -> GenLocated l e -> GenLocated l e
$cgmapQl :: forall l e r r'.
(Data l, Data e) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
$cgmapQr :: forall l e r r'.
(Data l, Data e) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GenLocated l e -> r
$cgmapQ :: forall l e u.
(Data l, Data e) =>
(forall d. Data d => d -> u) -> GenLocated l e -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> GenLocated l e -> [u]
$cgmapQi :: forall l e u.
(Data l, Data e) =>
Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> GenLocated l e -> u
$cgmapM :: forall l e (m :: * -> *).
(Data l, Data e, Monad m) =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
$cgmapMp :: forall l e (m :: * -> *).
(Data l, Data e, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
$cgmapMo :: forall l e (m :: * -> *).
(Data l, Data e, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GenLocated l e -> m (GenLocated l e)
Data, (forall a b. (a -> b) -> GenLocated l a -> GenLocated l b)
-> (forall a b. a -> GenLocated l b -> GenLocated l a)
-> Functor (GenLocated l)
forall a b. a -> GenLocated l b -> GenLocated l a
forall a b. (a -> b) -> GenLocated l a -> GenLocated l b
forall l a b. a -> GenLocated l b -> GenLocated l a
forall l a b. (a -> b) -> GenLocated l a -> GenLocated l b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall l a b. (a -> b) -> GenLocated l a -> GenLocated l b
fmap :: forall a b. (a -> b) -> GenLocated l a -> GenLocated l b
$c<$ :: forall l a b. a -> GenLocated l b -> GenLocated l a
<$ :: forall a b. a -> GenLocated l b -> GenLocated l a
Functor, (forall m. Monoid m => GenLocated l m -> m)
-> (forall m a. Monoid m => (a -> m) -> GenLocated l a -> m)
-> (forall m a. Monoid m => (a -> m) -> GenLocated l a -> m)
-> (forall a b. (a -> b -> b) -> b -> GenLocated l a -> b)
-> (forall a b. (a -> b -> b) -> b -> GenLocated l a -> b)
-> (forall b a. (b -> a -> b) -> b -> GenLocated l a -> b)
-> (forall b a. (b -> a -> b) -> b -> GenLocated l a -> b)
-> (forall a. (a -> a -> a) -> GenLocated l a -> a)
-> (forall a. (a -> a -> a) -> GenLocated l a -> a)
-> (forall a. GenLocated l a -> [a])
-> (forall a. GenLocated l a -> Bool)
-> (forall a. GenLocated l a -> Int)
-> (forall a. Eq a => a -> GenLocated l a -> Bool)
-> (forall a. Ord a => GenLocated l a -> a)
-> (forall a. Ord a => GenLocated l a -> a)
-> (forall a. Num a => GenLocated l a -> a)
-> (forall a. Num a => GenLocated l a -> a)
-> Foldable (GenLocated l)
forall a. Eq a => a -> GenLocated l a -> Bool
forall a. Num a => GenLocated l a -> a
forall a. Ord a => GenLocated l a -> a
forall m. Monoid m => GenLocated l m -> m
forall a. GenLocated l a -> Bool
forall a. GenLocated l a -> Int
forall a. GenLocated l a -> [a]
forall a. (a -> a -> a) -> GenLocated l a -> a
forall l a. Eq a => a -> GenLocated l a -> Bool
forall l a. Num a => GenLocated l a -> a
forall l a. Ord a => GenLocated l a -> a
forall m a. Monoid m => (a -> m) -> GenLocated l a -> m
forall l m. Monoid m => GenLocated l m -> m
forall l a. GenLocated l a -> Bool
forall l a. GenLocated l a -> Int
forall l a. GenLocated l a -> [a]
forall b a. (b -> a -> b) -> b -> GenLocated l a -> b
forall a b. (a -> b -> b) -> b -> GenLocated l a -> b
forall l a. (a -> a -> a) -> GenLocated l a -> a
forall l m a. Monoid m => (a -> m) -> GenLocated l a -> m
forall l b a. (b -> a -> b) -> b -> GenLocated l a -> b
forall l a b. (a -> b -> b) -> b -> GenLocated l a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall l m. Monoid m => GenLocated l m -> m
fold :: forall m. Monoid m => GenLocated l m -> m
$cfoldMap :: forall l m a. Monoid m => (a -> m) -> GenLocated l a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> GenLocated l a -> m
$cfoldMap' :: forall l m a. Monoid m => (a -> m) -> GenLocated l a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> GenLocated l a -> m
$cfoldr :: forall l a b. (a -> b -> b) -> b -> GenLocated l a -> b
foldr :: forall a b. (a -> b -> b) -> b -> GenLocated l a -> b
$cfoldr' :: forall l a b. (a -> b -> b) -> b -> GenLocated l a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> GenLocated l a -> b
$cfoldl :: forall l b a. (b -> a -> b) -> b -> GenLocated l a -> b
foldl :: forall b a. (b -> a -> b) -> b -> GenLocated l a -> b
$cfoldl' :: forall l b a. (b -> a -> b) -> b -> GenLocated l a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> GenLocated l a -> b
$cfoldr1 :: forall l a. (a -> a -> a) -> GenLocated l a -> a
foldr1 :: forall a. (a -> a -> a) -> GenLocated l a -> a
$cfoldl1 :: forall l a. (a -> a -> a) -> GenLocated l a -> a
foldl1 :: forall a. (a -> a -> a) -> GenLocated l a -> a
$ctoList :: forall l a. GenLocated l a -> [a]
toList :: forall a. GenLocated l a -> [a]
$cnull :: forall l a. GenLocated l a -> Bool
null :: forall a. GenLocated l a -> Bool
$clength :: forall l a. GenLocated l a -> Int
length :: forall a. GenLocated l a -> Int
$celem :: forall l a. Eq a => a -> GenLocated l a -> Bool
elem :: forall a. Eq a => a -> GenLocated l a -> Bool
$cmaximum :: forall l a. Ord a => GenLocated l a -> a
maximum :: forall a. Ord a => GenLocated l a -> a
$cminimum :: forall l a. Ord a => GenLocated l a -> a
minimum :: forall a. Ord a => GenLocated l a -> a
$csum :: forall l a. Num a => GenLocated l a -> a
sum :: forall a. Num a => GenLocated l a -> a
$cproduct :: forall l a. Num a => GenLocated l a -> a
product :: forall a. Num a => GenLocated l a -> a
Foldable, Functor (GenLocated l)
Foldable (GenLocated l)
(Functor (GenLocated l), Foldable (GenLocated l)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GenLocated l a -> f (GenLocated l b))
-> (forall (f :: * -> *) a.
Applicative f =>
GenLocated l (f a) -> f (GenLocated l a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b))
-> (forall (m :: * -> *) a.
Monad m =>
GenLocated l (m a) -> m (GenLocated l a))
-> Traversable (GenLocated l)
forall l. Functor (GenLocated l)
forall l. Foldable (GenLocated l)
forall l (m :: * -> *) a.
Monad m =>
GenLocated l (m a) -> m (GenLocated l a)
forall l (f :: * -> *) a.
Applicative f =>
GenLocated l (f a) -> f (GenLocated l a)
forall l (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
forall l (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GenLocated l a -> f (GenLocated l b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
GenLocated l (m a) -> m (GenLocated l a)
forall (f :: * -> *) a.
Applicative f =>
GenLocated l (f a) -> f (GenLocated l a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GenLocated l a -> f (GenLocated l b)
$ctraverse :: forall l (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GenLocated l a -> f (GenLocated l b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GenLocated l a -> f (GenLocated l b)
$csequenceA :: forall l (f :: * -> *) a.
Applicative f =>
GenLocated l (f a) -> f (GenLocated l a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
GenLocated l (f a) -> f (GenLocated l a)
$cmapM :: forall l (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
$csequence :: forall l (m :: * -> *) a.
Monad m =>
GenLocated l (m a) -> m (GenLocated l a)
sequence :: forall (m :: * -> *) a.
Monad m =>
GenLocated l (m a) -> m (GenLocated l a)
Traversable)
instance (NFData l, NFData e) => NFData (GenLocated l e) where
rnf :: GenLocated l e -> ()
rnf (L l
l e
e) = l -> ()
forall a. NFData a => a -> ()
rnf l
l () -> () -> ()
forall a b. a -> b -> b
`seq` e -> ()
forall a. NFData a => a -> ()
rnf e
e
type Located = GenLocated SrcSpan
type RealLocated = GenLocated RealSrcSpan
unLoc :: GenLocated l e -> e
unLoc :: forall l e. GenLocated l e -> e
unLoc (L l
_ e
e) = e
e
getLoc :: GenLocated l e -> l
getLoc :: forall l e. GenLocated l e -> l
getLoc (L l
l e
_) = l
l
noLoc :: e -> Located e
noLoc :: forall e. e -> Located e
noLoc e
e = SrcSpan -> e -> GenLocated SrcSpan e
forall l e. l -> e -> GenLocated l e
L SrcSpan
noSrcSpan e
e
mkGeneralLocated :: String -> e -> Located e
mkGeneralLocated :: forall e. String -> e -> Located e
mkGeneralLocated String
s e
e = SrcSpan -> e -> GenLocated SrcSpan e
forall l e. l -> e -> GenLocated l e
L (FastString -> SrcSpan
mkGeneralSrcSpan (String -> FastString
fsLit String
s)) e
e
combineLocs :: Located a -> Located b -> SrcSpan
combineLocs :: forall a b. Located a -> Located b -> SrcSpan
combineLocs Located a
a Located b
b = SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (Located a -> SrcSpan
forall l e. GenLocated l e -> l
getLoc Located a
a) (Located b -> SrcSpan
forall l e. GenLocated l e -> l
getLoc Located b
b)
addCLoc :: Located a -> Located b -> c -> Located c
addCLoc :: forall a b c. Located a -> Located b -> c -> Located c
addCLoc Located a
a Located b
b c
c = SrcSpan -> c -> GenLocated SrcSpan c
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (Located a -> SrcSpan
forall l e. GenLocated l e -> l
getLoc Located a
a) (Located b -> SrcSpan
forall l e. GenLocated l e -> l
getLoc Located b
b)) c
c
eqLocated :: Eq a => GenLocated l a -> GenLocated l a -> Bool
eqLocated :: forall a l. Eq a => GenLocated l a -> GenLocated l a -> Bool
eqLocated GenLocated l a
a GenLocated l a
b = GenLocated l a -> a
forall l e. GenLocated l e -> e
unLoc GenLocated l a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== GenLocated l a -> a
forall l e. GenLocated l e -> e
unLoc GenLocated l a
b
cmpLocated :: Ord a => GenLocated l a -> GenLocated l a -> Ordering
cmpLocated :: forall a l. Ord a => GenLocated l a -> GenLocated l a -> Ordering
cmpLocated GenLocated l a
a GenLocated l a
b = GenLocated l a -> a
forall l e. GenLocated l e -> e
unLoc GenLocated l a
a a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` GenLocated l a -> a
forall l e. GenLocated l e -> e
unLoc GenLocated l a
b
cmpBufSpan :: HasDebugCallStack => Located a -> Located a -> Ordering
cmpBufSpan :: forall a. HasDebugCallStack => Located a -> Located a -> Ordering
cmpBufSpan (L SrcSpan
l1 a
_) (L SrcSpan
l2 a
_)
| Strict.Just BufSpan
a <- SrcSpan -> Maybe BufSpan
getBufSpan SrcSpan
l1
, Strict.Just BufSpan
b <- SrcSpan -> Maybe BufSpan
getBufSpan SrcSpan
l2
= BufSpan -> BufSpan -> Ordering
forall a. Ord a => a -> a -> Ordering
compare BufSpan
a BufSpan
b
| Bool
otherwise = String -> Ordering
forall a. HasCallStack => String -> a
panic String
"cmpBufSpan: no BufSpan"
instance (Outputable e) => Outputable (Located e) where
ppr :: Located e -> SDoc
ppr (L SrcSpan
l e
e) =
SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc
whenPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (Bool -> SrcSpan -> SDoc
pprUserSpan Bool
False SrcSpan
l))
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ e -> SDoc
forall a. Outputable a => a -> SDoc
ppr e
e
instance (Outputable e) => Outputable (GenLocated RealSrcSpan e) where
ppr :: GenLocated RealSrcSpan e -> SDoc
ppr (L RealSrcSpan
l e
e) =
SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc
whenPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (Bool -> SrcSpan -> SDoc
pprUserSpan Bool
False (RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan RealSrcSpan
l Maybe BufSpan
forall a. Maybe a
Strict.Nothing)))
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ e -> SDoc
forall a. Outputable a => a -> SDoc
ppr e
e
pprLocated :: (Outputable l, Outputable e) => GenLocated l e -> SDoc
pprLocated :: forall l e. (Outputable l, Outputable e) => GenLocated l e -> SDoc
pprLocated (L l
l e
e) =
SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc
whenPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (l -> SDoc
forall a. Outputable a => a -> SDoc
ppr l
l))
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ e -> SDoc
forall a. Outputable a => a -> SDoc
ppr e
e
pprLocatedAlways :: (Outputable l, Outputable e) => GenLocated l e -> SDoc
pprLocatedAlways :: forall l e. (Outputable l, Outputable e) => GenLocated l e -> SDoc
pprLocatedAlways (L l
l e
e) =
SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (l -> SDoc
forall a. Outputable a => a -> SDoc
ppr l
l)
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ e -> SDoc
forall a. Outputable a => a -> SDoc
ppr e
e
leftmost_smallest, leftmost_largest, rightmost_smallest :: SrcSpan -> SrcSpan -> Ordering
rightmost_smallest :: SrcSpan -> SrcSpan -> Ordering
rightmost_smallest = (RealSrcSpan -> RealSrcSpan -> Ordering)
-> SrcSpan -> SrcSpan -> Ordering
compareSrcSpanBy ((RealSrcSpan -> RealSrcSpan -> Ordering)
-> RealSrcSpan -> RealSrcSpan -> Ordering
forall a b c. (a -> b -> c) -> b -> a -> c
flip RealSrcSpan -> RealSrcSpan -> Ordering
forall a. Ord a => a -> a -> Ordering
compare)
leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering
leftmost_smallest = (RealSrcSpan -> RealSrcSpan -> Ordering)
-> SrcSpan -> SrcSpan -> Ordering
compareSrcSpanBy RealSrcSpan -> RealSrcSpan -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
leftmost_largest :: SrcSpan -> SrcSpan -> Ordering
leftmost_largest = (RealSrcSpan -> RealSrcSpan -> Ordering)
-> SrcSpan -> SrcSpan -> Ordering
compareSrcSpanBy ((RealSrcSpan -> RealSrcSpan -> Ordering)
-> SrcSpan -> SrcSpan -> Ordering)
-> (RealSrcSpan -> RealSrcSpan -> Ordering)
-> SrcSpan
-> SrcSpan
-> Ordering
forall a b. (a -> b) -> a -> b
$
(RealSrcLoc -> RealSrcLoc -> Ordering)
-> (RealSrcSpan -> RealSrcLoc)
-> RealSrcSpan
-> RealSrcSpan
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on RealSrcLoc -> RealSrcLoc -> Ordering
forall a. Ord a => a -> a -> Ordering
compare RealSrcSpan -> RealSrcLoc
realSrcSpanStart (RealSrcSpan -> RealSrcSpan -> Ordering)
-> (RealSrcSpan -> RealSrcSpan -> Ordering)
-> RealSrcSpan
-> RealSrcSpan
-> Ordering
forall a. Semigroup a => a -> a -> a
S.<> (RealSrcSpan -> RealSrcSpan -> Ordering)
-> RealSrcSpan -> RealSrcSpan -> Ordering
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((RealSrcLoc -> RealSrcLoc -> Ordering)
-> (RealSrcSpan -> RealSrcLoc)
-> RealSrcSpan
-> RealSrcSpan
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on RealSrcLoc -> RealSrcLoc -> Ordering
forall a. Ord a => a -> a -> Ordering
compare RealSrcSpan -> RealSrcLoc
realSrcSpanEnd)
compareSrcSpanBy :: (RealSrcSpan -> RealSrcSpan -> Ordering) -> SrcSpan -> SrcSpan -> Ordering
compareSrcSpanBy :: (RealSrcSpan -> RealSrcSpan -> Ordering)
-> SrcSpan -> SrcSpan -> Ordering
compareSrcSpanBy RealSrcSpan -> RealSrcSpan -> Ordering
cmp (RealSrcSpan RealSrcSpan
a Maybe BufSpan
_) (RealSrcSpan RealSrcSpan
b Maybe BufSpan
_) = RealSrcSpan -> RealSrcSpan -> Ordering
cmp RealSrcSpan
a RealSrcSpan
b
compareSrcSpanBy RealSrcSpan -> RealSrcSpan -> Ordering
_ (RealSrcSpan RealSrcSpan
_ Maybe BufSpan
_) (UnhelpfulSpan UnhelpfulSpanReason
_) = Ordering
LT
compareSrcSpanBy RealSrcSpan -> RealSrcSpan -> Ordering
_ (UnhelpfulSpan UnhelpfulSpanReason
_) (RealSrcSpan RealSrcSpan
_ Maybe BufSpan
_) = Ordering
GT
compareSrcSpanBy RealSrcSpan -> RealSrcSpan -> Ordering
_ (UnhelpfulSpan UnhelpfulSpanReason
_) (UnhelpfulSpan UnhelpfulSpanReason
_) = Ordering
EQ
spans :: SrcSpan -> (Int, Int) -> Bool
spans :: SrcSpan -> (Int, Int) -> Bool
spans (UnhelpfulSpan UnhelpfulSpanReason
_) (Int, Int)
_ = String -> Bool
forall a. HasCallStack => String -> a
panic String
"spans UnhelpfulSpan"
spans (RealSrcSpan RealSrcSpan
span Maybe BufSpan
_) (Int
l,Int
c) = RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
span RealSrcLoc -> RealSrcLoc -> Bool
forall a. Ord a => a -> a -> Bool
<= RealSrcLoc
loc Bool -> Bool -> Bool
&& RealSrcLoc
loc RealSrcLoc -> RealSrcLoc -> Bool
forall a. Ord a => a -> a -> Bool
<= RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
span
where loc :: RealSrcLoc
loc = FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
span) Int
l Int
c
isSubspanOf :: SrcSpan
-> SrcSpan
-> Bool
isSubspanOf :: SrcSpan -> SrcSpan -> Bool
isSubspanOf (RealSrcSpan RealSrcSpan
src Maybe BufSpan
_) (RealSrcSpan RealSrcSpan
parent Maybe BufSpan
_) = RealSrcSpan -> RealSrcSpan -> Bool
isRealSubspanOf RealSrcSpan
src RealSrcSpan
parent
isSubspanOf SrcSpan
_ SrcSpan
_ = Bool
False
isRealSubspanOf :: RealSrcSpan
-> RealSrcSpan
-> Bool
isRealSubspanOf :: RealSrcSpan -> RealSrcSpan -> Bool
isRealSubspanOf RealSrcSpan
src RealSrcSpan
parent
| RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
parent FastString -> FastString -> Bool
forall a. Eq a => a -> a -> Bool
/= RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
src = Bool
False
| Bool
otherwise = RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
parent RealSrcLoc -> RealSrcLoc -> Bool
forall a. Ord a => a -> a -> Bool
<= RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
src Bool -> Bool -> Bool
&&
RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
parent RealSrcLoc -> RealSrcLoc -> Bool
forall a. Ord a => a -> a -> Bool
>= RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
src
getRealSrcSpan :: RealLocated a -> RealSrcSpan
getRealSrcSpan :: forall a. RealLocated a -> RealSrcSpan
getRealSrcSpan (L RealSrcSpan
l a
_) = RealSrcSpan
l
unRealSrcSpan :: RealLocated a -> a
unRealSrcSpan :: forall a. RealLocated a -> a
unRealSrcSpan (L RealSrcSpan
_ a
e) = a
e
data PsLoc
= PsLoc { PsLoc -> RealSrcLoc
psRealLoc :: !RealSrcLoc, PsLoc -> BufPos
psBufPos :: !BufPos }
deriving (PsLoc -> PsLoc -> Bool
(PsLoc -> PsLoc -> Bool) -> (PsLoc -> PsLoc -> Bool) -> Eq PsLoc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PsLoc -> PsLoc -> Bool
== :: PsLoc -> PsLoc -> Bool
$c/= :: PsLoc -> PsLoc -> Bool
/= :: PsLoc -> PsLoc -> Bool
Eq, Eq PsLoc
Eq PsLoc =>
(PsLoc -> PsLoc -> Ordering)
-> (PsLoc -> PsLoc -> Bool)
-> (PsLoc -> PsLoc -> Bool)
-> (PsLoc -> PsLoc -> Bool)
-> (PsLoc -> PsLoc -> Bool)
-> (PsLoc -> PsLoc -> PsLoc)
-> (PsLoc -> PsLoc -> PsLoc)
-> Ord PsLoc
PsLoc -> PsLoc -> Bool
PsLoc -> PsLoc -> Ordering
PsLoc -> PsLoc -> PsLoc
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PsLoc -> PsLoc -> Ordering
compare :: PsLoc -> PsLoc -> Ordering
$c< :: PsLoc -> PsLoc -> Bool
< :: PsLoc -> PsLoc -> Bool
$c<= :: PsLoc -> PsLoc -> Bool
<= :: PsLoc -> PsLoc -> Bool
$c> :: PsLoc -> PsLoc -> Bool
> :: PsLoc -> PsLoc -> Bool
$c>= :: PsLoc -> PsLoc -> Bool
>= :: PsLoc -> PsLoc -> Bool
$cmax :: PsLoc -> PsLoc -> PsLoc
max :: PsLoc -> PsLoc -> PsLoc
$cmin :: PsLoc -> PsLoc -> PsLoc
min :: PsLoc -> PsLoc -> PsLoc
Ord, Int -> PsLoc -> ShowS
[PsLoc] -> ShowS
PsLoc -> String
(Int -> PsLoc -> ShowS)
-> (PsLoc -> String) -> ([PsLoc] -> ShowS) -> Show PsLoc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PsLoc -> ShowS
showsPrec :: Int -> PsLoc -> ShowS
$cshow :: PsLoc -> String
show :: PsLoc -> String
$cshowList :: [PsLoc] -> ShowS
showList :: [PsLoc] -> ShowS
Show)
data PsSpan
= PsSpan { PsSpan -> RealSrcSpan
psRealSpan :: !RealSrcSpan, PsSpan -> BufSpan
psBufSpan :: !BufSpan }
deriving (PsSpan -> PsSpan -> Bool
(PsSpan -> PsSpan -> Bool)
-> (PsSpan -> PsSpan -> Bool) -> Eq PsSpan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PsSpan -> PsSpan -> Bool
== :: PsSpan -> PsSpan -> Bool
$c/= :: PsSpan -> PsSpan -> Bool
/= :: PsSpan -> PsSpan -> Bool
Eq, Eq PsSpan
Eq PsSpan =>
(PsSpan -> PsSpan -> Ordering)
-> (PsSpan -> PsSpan -> Bool)
-> (PsSpan -> PsSpan -> Bool)
-> (PsSpan -> PsSpan -> Bool)
-> (PsSpan -> PsSpan -> Bool)
-> (PsSpan -> PsSpan -> PsSpan)
-> (PsSpan -> PsSpan -> PsSpan)
-> Ord PsSpan
PsSpan -> PsSpan -> Bool
PsSpan -> PsSpan -> Ordering
PsSpan -> PsSpan -> PsSpan
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PsSpan -> PsSpan -> Ordering
compare :: PsSpan -> PsSpan -> Ordering
$c< :: PsSpan -> PsSpan -> Bool
< :: PsSpan -> PsSpan -> Bool
$c<= :: PsSpan -> PsSpan -> Bool
<= :: PsSpan -> PsSpan -> Bool
$c> :: PsSpan -> PsSpan -> Bool
> :: PsSpan -> PsSpan -> Bool
$c>= :: PsSpan -> PsSpan -> Bool
>= :: PsSpan -> PsSpan -> Bool
$cmax :: PsSpan -> PsSpan -> PsSpan
max :: PsSpan -> PsSpan -> PsSpan
$cmin :: PsSpan -> PsSpan -> PsSpan
min :: PsSpan -> PsSpan -> PsSpan
Ord, Int -> PsSpan -> ShowS
[PsSpan] -> ShowS
PsSpan -> String
(Int -> PsSpan -> ShowS)
-> (PsSpan -> String) -> ([PsSpan] -> ShowS) -> Show PsSpan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PsSpan -> ShowS
showsPrec :: Int -> PsSpan -> ShowS
$cshow :: PsSpan -> String
show :: PsSpan -> String
$cshowList :: [PsSpan] -> ShowS
showList :: [PsSpan] -> ShowS
Show, Typeable PsSpan
Typeable PsSpan =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PsSpan -> c PsSpan)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PsSpan)
-> (PsSpan -> Constr)
-> (PsSpan -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PsSpan))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PsSpan))
-> ((forall b. Data b => b -> b) -> PsSpan -> PsSpan)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PsSpan -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PsSpan -> r)
-> (forall u. (forall d. Data d => d -> u) -> PsSpan -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PsSpan -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan)
-> Data PsSpan
PsSpan -> Constr
PsSpan -> DataType
(forall b. Data b => b -> b) -> PsSpan -> PsSpan
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PsSpan -> u
forall u. (forall d. Data d => d -> u) -> PsSpan -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PsSpan -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PsSpan -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PsSpan
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PsSpan -> c PsSpan
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PsSpan)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PsSpan)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PsSpan -> c PsSpan
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PsSpan -> c PsSpan
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PsSpan
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PsSpan
$ctoConstr :: PsSpan -> Constr
toConstr :: PsSpan -> Constr
$cdataTypeOf :: PsSpan -> DataType
dataTypeOf :: PsSpan -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PsSpan)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PsSpan)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PsSpan)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PsSpan)
$cgmapT :: (forall b. Data b => b -> b) -> PsSpan -> PsSpan
gmapT :: (forall b. Data b => b -> b) -> PsSpan -> PsSpan
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PsSpan -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PsSpan -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PsSpan -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PsSpan -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PsSpan -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PsSpan -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PsSpan -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PsSpan -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PsSpan -> m PsSpan
Data)
type PsLocated = GenLocated PsSpan
psLocatedToLocated :: PsLocated a -> Located a
psLocatedToLocated :: forall a. PsLocated a -> Located a
psLocatedToLocated (L PsSpan
sp a
a) = SrcSpan -> a -> GenLocated SrcSpan a
forall l e. l -> e -> GenLocated l e
L (PsSpan -> SrcSpan
mkSrcSpanPs PsSpan
sp) a
a
advancePsLoc :: PsLoc -> Char -> PsLoc
advancePsLoc :: PsLoc -> Char -> PsLoc
advancePsLoc (PsLoc RealSrcLoc
real_loc BufPos
buf_loc) Char
c =
RealSrcLoc -> BufPos -> PsLoc
PsLoc (RealSrcLoc -> Char -> RealSrcLoc
advanceSrcLoc RealSrcLoc
real_loc Char
c) (BufPos -> BufPos
advanceBufPos BufPos
buf_loc)
mkPsSpan :: PsLoc -> PsLoc -> PsSpan
mkPsSpan :: PsLoc -> PsLoc -> PsSpan
mkPsSpan (PsLoc RealSrcLoc
r1 BufPos
b1) (PsLoc RealSrcLoc
r2 BufPos
b2) = RealSrcSpan -> BufSpan -> PsSpan
PsSpan (RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan RealSrcLoc
r1 RealSrcLoc
r2) (BufPos -> BufPos -> BufSpan
BufSpan BufPos
b1 BufPos
b2)
psSpanStart :: PsSpan -> PsLoc
psSpanStart :: PsSpan -> PsLoc
psSpanStart (PsSpan RealSrcSpan
r BufSpan
b) = RealSrcLoc -> BufPos -> PsLoc
PsLoc (RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
r) (BufSpan -> BufPos
bufSpanStart BufSpan
b)
psSpanEnd :: PsSpan -> PsLoc
psSpanEnd :: PsSpan -> PsLoc
psSpanEnd (PsSpan RealSrcSpan
r BufSpan
b) = RealSrcLoc -> BufPos -> PsLoc
PsLoc (RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
r) (BufSpan -> BufPos
bufSpanEnd BufSpan
b)
mkSrcSpanPs :: PsSpan -> SrcSpan
mkSrcSpanPs :: PsSpan -> SrcSpan
mkSrcSpanPs (PsSpan RealSrcSpan
r BufSpan
b) = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan RealSrcSpan
r (BufSpan -> Maybe BufSpan
forall a. a -> Maybe a
Strict.Just BufSpan
b)