{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE NondecreasingIndentation #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.HsToCore.Coverage
( CoverageConfig (..)
, addTicksToBinds
, hpcInitCode
) where
import GHC.Prelude as Prelude
import GHC.Driver.Session
import GHC.Driver.Backend
import qualified GHC.Runtime.Interpreter as GHCi
import GHCi.RemoteTypes
import GHC.ByteCode.Types
import GHC.Stack.CCS
import GHC.Hs
import GHC.Unit
import GHC.Cmm.CLabel
import GHC.Core.Type
import GHC.Core.TyCon
import GHC.Data.Maybe
import GHC.Data.FastString
import GHC.Data.Bag
import GHC.Platform
import GHC.Runtime.Interpreter.Types
import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
import GHC.Utils.Monad
import GHC.Utils.Logger
import GHC.Types.SrcLoc
import GHC.Types.Basic
import GHC.Types.Id
import GHC.Types.Var.Set
import GHC.Types.Name.Set hiding (FreeVars)
import GHC.Types.Name
import GHC.Types.HpcInfo
import GHC.Types.CostCentre
import GHC.Types.CostCentre.State
import GHC.Types.ForeignStubs
import GHC.Types.Tickish
import Control.Monad
import Data.List (isSuffixOf, intersperse)
import Data.Array
import Data.Time
import System.Directory
import Trace.Hpc.Mix
import Trace.Hpc.Util
import qualified Data.ByteString as BS
import Data.Set (Set)
import qualified Data.Set as Set
data CoverageConfig = CoverageConfig
{ CoverageConfig -> Logger
coverageConfig_logger :: Logger
, CoverageConfig -> DynFlags
coverageConfig_dynFlags :: DynFlags
, CoverageConfig -> Maybe Interp
coverageConfig_mInterp :: Maybe Interp
}
addTicksToBinds
:: CoverageConfig
-> Module
-> ModLocation
-> NameSet
-> [TyCon]
-> LHsBinds GhcTc
-> IO (LHsBinds GhcTc, HpcInfo, Maybe ModBreaks)
addTicksToBinds :: CoverageConfig
-> Module
-> ModLocation
-> NameSet
-> [TyCon]
-> LHsBinds GhcTc
-> IO (LHsBinds GhcTc, HpcInfo, Maybe ModBreaks)
addTicksToBinds (CoverageConfig
{ coverageConfig_logger :: CoverageConfig -> Logger
coverageConfig_logger = Logger
logger
, coverageConfig_dynFlags :: CoverageConfig -> DynFlags
coverageConfig_dynFlags = DynFlags
dflags
, coverageConfig_mInterp :: CoverageConfig -> Maybe Interp
coverageConfig_mInterp = Maybe Interp
m_interp
})
Module
mod ModLocation
mod_loc NameSet
exports [TyCon]
tyCons LHsBinds GhcTc
binds
| let passes :: [TickishType]
passes = DynFlags -> [TickishType]
coveragePasses DynFlags
dflags
, Bool -> Bool
not ([TickishType] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [TickishType]
passes)
, Just FilePath
orig_file <- ModLocation -> Maybe FilePath
ml_hs_file ModLocation
mod_loc = do
let orig_file2 :: FilePath
orig_file2 = LHsBinds GhcTc -> FilePath -> FilePath
guessSourceFile LHsBinds GhcTc
binds FilePath
orig_file
tickPass :: TickishType
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
tickPass TickishType
tickish (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds,TickTransState
st) =
let env :: TickTransEnv
env = TTE
{ fileName :: FastString
fileName = FilePath -> FastString
mkFastString FilePath
orig_file2
, declPath :: [FilePath]
declPath = []
, tte_countEntries :: Bool
tte_countEntries = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_ProfCountEntries DynFlags
dflags
, exports :: NameSet
exports = NameSet
exports
, inlines :: VarSet
inlines = VarSet
emptyVarSet
, inScope :: VarSet
inScope = VarSet
emptyVarSet
, blackList :: Set RealSrcSpan
blackList = [RealSrcSpan] -> Set RealSrcSpan
forall a. Ord a => [a] -> Set a
Set.fromList ([RealSrcSpan] -> Set RealSrcSpan)
-> [RealSrcSpan] -> Set RealSrcSpan
forall a b. (a -> b) -> a -> b
$
(TyCon -> Maybe RealSrcSpan) -> [TyCon] -> [RealSrcSpan]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (\TyCon
tyCon -> case Name -> SrcSpan
forall a. NamedThing a => a -> SrcSpan
getSrcSpan (TyCon -> Name
tyConName TyCon
tyCon) of
RealSrcSpan RealSrcSpan
l Maybe BufSpan
_ -> RealSrcSpan -> Maybe RealSrcSpan
forall a. a -> Maybe a
Just RealSrcSpan
l
UnhelpfulSpan UnhelpfulSpanReason
_ -> Maybe RealSrcSpan
forall a. Maybe a
Nothing)
[TyCon]
tyCons
, density :: TickDensity
density = TickishType -> DynFlags -> TickDensity
mkDensity TickishType
tickish DynFlags
dflags
, this_mod :: Module
this_mod = Module
mod
, tickishType :: TickishType
tickishType = TickishType
tickish
}
(Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds',FreeVars
_,TickTransState
st') = TM (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> TickTransEnv
-> TickTransState
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)), FreeVars,
TickTransState)
forall a.
TM a
-> TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
unTM (LHsBinds GhcTc -> TM (LHsBinds GhcTc)
addTickLHsBinds LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds) TickTransEnv
env TickTransState
st
in (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds', TickTransState
st')
initState :: TickTransState
initState = TT { tickBoxCount :: Int
tickBoxCount = Int
0
, mixEntries :: [MixEntry_]
mixEntries = []
, ccIndices :: CostCentreState
ccIndices = CostCentreState
newCostCentreState
}
(Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds1,TickTransState
st) = (TickishType
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState))
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
-> [TickishType]
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr TickishType
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
-> (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)),
TickTransState)
tickPass (LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds, TickTransState
initState) [TickishType]
passes
let tickCount :: Int
tickCount = TickTransState -> Int
tickBoxCount TickTransState
st
entries :: [MixEntry_]
entries = [MixEntry_] -> [MixEntry_]
forall a. [a] -> [a]
reverse ([MixEntry_] -> [MixEntry_]) -> [MixEntry_] -> [MixEntry_]
forall a b. (a -> b) -> a -> b
$ TickTransState -> [MixEntry_]
mixEntries TickTransState
st
Int
hashNo <- DynFlags -> Module -> Int -> [MixEntry_] -> FilePath -> IO Int
writeMixEntries DynFlags
dflags Module
mod Int
tickCount [MixEntry_]
entries FilePath
orig_file2
Maybe ModBreaks
modBreaks <- Maybe Interp
-> DynFlags -> Module -> Int -> [MixEntry_] -> IO (Maybe ModBreaks)
mkModBreaks Maybe Interp
m_interp DynFlags
dflags Module
mod Int
tickCount [MixEntry_]
entries
Logger -> DumpFlag -> FilePath -> DumpFormat -> SDoc -> IO ()
putDumpFileMaybe Logger
logger DumpFlag
Opt_D_dump_ticked FilePath
"HPC" DumpFormat
FormatHaskell
(LHsBinds GhcTc -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
LHsBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprLHsBinds LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds1)
(Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)), HpcInfo,
Maybe ModBreaks)
-> IO
(Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)), HpcInfo,
Maybe ModBreaks)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds1, Int -> Int -> HpcInfo
HpcInfo Int
tickCount Int
hashNo, Maybe ModBreaks
modBreaks)
| Bool
otherwise = (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)), HpcInfo,
Maybe ModBreaks)
-> IO
(Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)), HpcInfo,
Maybe ModBreaks)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds, Bool -> HpcInfo
emptyHpcInfo Bool
False, Maybe ModBreaks
forall a. Maybe a
Nothing)
guessSourceFile :: LHsBinds GhcTc -> FilePath -> FilePath
guessSourceFile :: LHsBinds GhcTc -> FilePath -> FilePath
guessSourceFile LHsBinds GhcTc
binds FilePath
orig_file =
let top_pos :: [FastString]
top_pos = [Maybe FastString] -> [FastString]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe FastString] -> [FastString])
-> [Maybe FastString] -> [FastString]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> [Maybe FastString] -> [Maybe FastString])
-> [Maybe FastString]
-> Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> [Maybe FastString]
forall a b. (a -> b -> b) -> b -> Bag a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\ (L SrcSpanAnnA
pos HsBindLR GhcTc GhcTc
_) [Maybe FastString]
rest ->
SrcSpan -> Maybe FastString
srcSpanFileName_maybe (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos) Maybe FastString -> [Maybe FastString] -> [Maybe FastString]
forall a. a -> [a] -> [a]
: [Maybe FastString]
rest) [] LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds
in
case [FastString]
top_pos of
(FastString
file_name:[FastString]
_) | FilePath
".hsc" FilePath -> FilePath -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` FastString -> FilePath
unpackFS FastString
file_name
-> FastString -> FilePath
unpackFS FastString
file_name
[FastString]
_ -> FilePath
orig_file
mkModBreaks :: Maybe Interp -> DynFlags -> Module -> Int -> [MixEntry_] -> IO (Maybe ModBreaks)
mkModBreaks :: Maybe Interp
-> DynFlags -> Module -> Int -> [MixEntry_] -> IO (Maybe ModBreaks)
mkModBreaks Maybe Interp
m_interp DynFlags
dflags Module
mod Int
count [MixEntry_]
entries
| Just Interp
interp <- Maybe Interp
m_interp
, DynFlags -> Bool
breakpointsEnabled DynFlags
dflags = do
ForeignRef BreakArray
breakArray <- Interp -> Int -> IO (ForeignRef BreakArray)
GHCi.newBreakArray Interp
interp ([MixEntry_] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [MixEntry_]
entries)
Array Int (RemotePtr CostCentre)
ccs <- Interp
-> Module
-> Int
-> [MixEntry_]
-> IO (Array Int (RemotePtr CostCentre))
mkCCSArray Interp
interp Module
mod Int
count [MixEntry_]
entries
let
locsTicks :: Array Int SrcSpan
locsTicks = (Int, Int) -> [SrcSpan] -> Array Int SrcSpan
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (Int
0,Int
countInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [ SrcSpan
span | (SrcSpan
span,[FilePath]
_,[OccName]
_,BoxLabel
_) <- [MixEntry_]
entries ]
varsTicks :: Array Int [OccName]
varsTicks = (Int, Int) -> [[OccName]] -> Array Int [OccName]
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (Int
0,Int
countInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [ [OccName]
vars | (SrcSpan
_,[FilePath]
_,[OccName]
vars,BoxLabel
_) <- [MixEntry_]
entries ]
declsTicks :: Array Int [FilePath]
declsTicks = (Int, Int) -> [[FilePath]] -> Array Int [FilePath]
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (Int
0,Int
countInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [ [FilePath]
decls | (SrcSpan
_,[FilePath]
decls,[OccName]
_,BoxLabel
_) <- [MixEntry_]
entries ]
Maybe ModBreaks -> IO (Maybe ModBreaks)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe ModBreaks -> IO (Maybe ModBreaks))
-> Maybe ModBreaks -> IO (Maybe ModBreaks)
forall a b. (a -> b) -> a -> b
$ ModBreaks -> Maybe ModBreaks
forall a. a -> Maybe a
Just (ModBreaks -> Maybe ModBreaks) -> ModBreaks -> Maybe ModBreaks
forall a b. (a -> b) -> a -> b
$ ModBreaks
emptyModBreaks
{ modBreaks_flags :: ForeignRef BreakArray
modBreaks_flags = ForeignRef BreakArray
breakArray
, modBreaks_locs :: Array Int SrcSpan
modBreaks_locs = Array Int SrcSpan
locsTicks
, modBreaks_vars :: Array Int [OccName]
modBreaks_vars = Array Int [OccName]
varsTicks
, modBreaks_decls :: Array Int [FilePath]
modBreaks_decls = Array Int [FilePath]
declsTicks
, modBreaks_ccs :: Array Int (RemotePtr CostCentre)
modBreaks_ccs = Array Int (RemotePtr CostCentre)
ccs
}
| Bool
otherwise = Maybe ModBreaks -> IO (Maybe ModBreaks)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ModBreaks
forall a. Maybe a
Nothing
mkCCSArray
:: Interp -> Module -> Int -> [MixEntry_]
-> IO (Array BreakIndex (RemotePtr GHC.Stack.CCS.CostCentre))
mkCCSArray :: Interp
-> Module
-> Int
-> [MixEntry_]
-> IO (Array Int (RemotePtr CostCentre))
mkCCSArray Interp
interp Module
modul Int
count [MixEntry_]
entries
| Interp -> Bool
GHCi.interpreterProfiled Interp
interp = do
let module_str :: FilePath
module_str = ModuleName -> FilePath
moduleNameString (Module -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName Module
modul)
[RemotePtr CostCentre]
costcentres <- Interp
-> FilePath -> [(FilePath, FilePath)] -> IO [RemotePtr CostCentre]
GHCi.mkCostCentres Interp
interp FilePath
module_str ((MixEntry_ -> (FilePath, FilePath))
-> [MixEntry_] -> [(FilePath, FilePath)]
forall a b. (a -> b) -> [a] -> [b]
map MixEntry_ -> (FilePath, FilePath)
forall {a} {c} {d}.
Outputable a =>
(a, [FilePath], c, d) -> (FilePath, FilePath)
mk_one [MixEntry_]
entries)
Array Int (RemotePtr CostCentre)
-> IO (Array Int (RemotePtr CostCentre))
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Int, Int)
-> [RemotePtr CostCentre] -> Array Int (RemotePtr CostCentre)
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (Int
0,Int
countInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [RemotePtr CostCentre]
costcentres)
| Bool
otherwise = Array Int (RemotePtr CostCentre)
-> IO (Array Int (RemotePtr CostCentre))
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Int, Int)
-> [RemotePtr CostCentre] -> Array Int (RemotePtr CostCentre)
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (Int
0,-Int
1) [])
where
mk_one :: (a, [FilePath], c, d) -> (FilePath, FilePath)
mk_one (a
srcspan, [FilePath]
decl_path, c
_, d
_) = (FilePath
name, FilePath
src)
where name :: FilePath
name = [FilePath] -> FilePath
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (FilePath -> [FilePath] -> [FilePath]
forall a. a -> [a] -> [a]
intersperse FilePath
"." [FilePath]
decl_path)
src :: FilePath
src = SDocContext -> SDoc -> FilePath
renderWithContext SDocContext
defaultSDocContext (a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
srcspan)
writeMixEntries
:: DynFlags -> Module -> Int -> [MixEntry_] -> FilePath -> IO Int
writeMixEntries :: DynFlags -> Module -> Int -> [MixEntry_] -> FilePath -> IO Int
writeMixEntries DynFlags
dflags Module
mod Int
count [MixEntry_]
entries FilePath
filename
| Bool -> Bool
not (GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_Hpc DynFlags
dflags) = Int -> IO Int
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
0
| Bool
otherwise = do
let
hpc_dir :: FilePath
hpc_dir = DynFlags -> FilePath
hpcDir DynFlags
dflags
mod_name :: FilePath
mod_name = ModuleName -> FilePath
moduleNameString (Module -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName Module
mod)
hpc_mod_dir :: FilePath
hpc_mod_dir
| Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
mod Unit -> Unit -> Bool
forall a. Eq a => a -> a -> Bool
== Unit
mainUnit = FilePath
hpc_dir
| Bool
otherwise = FilePath
hpc_dir FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
"/" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Unit -> FilePath
forall u. IsUnitId u => u -> FilePath
unitString (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
mod)
tabStop :: Int
tabStop = Int
8
Bool -> FilePath -> IO ()
createDirectoryIfMissing Bool
True FilePath
hpc_mod_dir
UTCTime
modTime <- FilePath -> IO UTCTime
getModificationUTCTime FilePath
filename
let entries' :: [(HpcPos, BoxLabel)]
entries' = [ (HpcPos
hpcPos, BoxLabel
box)
| (SrcSpan
span,[FilePath]
_,[OccName]
_,BoxLabel
box) <- [MixEntry_]
entries, HpcPos
hpcPos <- [SrcSpan -> HpcPos
mkHpcPos SrcSpan
span] ]
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([(HpcPos, BoxLabel)]
entries' [(HpcPos, BoxLabel)] -> Int -> Bool
forall a. [a] -> Int -> Bool
`lengthIsNot` Int
count) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
FilePath -> IO ()
forall a. FilePath -> a
panic FilePath
"the number of .mix entries are inconsistent"
let hashNo :: Int
hashNo = FilePath -> UTCTime -> Int -> [(HpcPos, BoxLabel)] -> Int
mixHash FilePath
filename UTCTime
modTime Int
tabStop [(HpcPos, BoxLabel)]
entries'
FilePath -> FilePath -> Mix -> IO ()
mixCreate FilePath
hpc_mod_dir FilePath
mod_name
(Mix -> IO ()) -> Mix -> IO ()
forall a b. (a -> b) -> a -> b
$ FilePath -> UTCTime -> Hash -> Int -> [(HpcPos, BoxLabel)] -> Mix
Mix FilePath
filename UTCTime
modTime (Int -> Hash
forall a. HpcHash a => a -> Hash
toHash Int
hashNo) Int
tabStop [(HpcPos, BoxLabel)]
entries'
Int -> IO Int
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
hashNo
data TickDensity
= TickForCoverage
| TickForBreakPoints
| TickAllFunctions
| TickTopFunctions
| TickExportedFunctions
| TickCallSites
deriving TickDensity -> TickDensity -> Bool
(TickDensity -> TickDensity -> Bool)
-> (TickDensity -> TickDensity -> Bool) -> Eq TickDensity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TickDensity -> TickDensity -> Bool
== :: TickDensity -> TickDensity -> Bool
$c/= :: TickDensity -> TickDensity -> Bool
/= :: TickDensity -> TickDensity -> Bool
Eq
mkDensity :: TickishType -> DynFlags -> TickDensity
mkDensity :: TickishType -> DynFlags -> TickDensity
mkDensity TickishType
tickish DynFlags
dflags = case TickishType
tickish of
TickishType
HpcTicks -> TickDensity
TickForCoverage
TickishType
SourceNotes -> TickDensity
TickForCoverage
TickishType
Breakpoints -> TickDensity
TickForBreakPoints
TickishType
ProfNotes ->
case DynFlags -> ProfAuto
profAuto DynFlags
dflags of
ProfAuto
ProfAutoAll -> TickDensity
TickAllFunctions
ProfAuto
ProfAutoTop -> TickDensity
TickTopFunctions
ProfAuto
ProfAutoExports -> TickDensity
TickExportedFunctions
ProfAuto
ProfAutoCalls -> TickDensity
TickCallSites
ProfAuto
_other -> FilePath -> TickDensity
forall a. FilePath -> a
panic FilePath
"mkDensity"
shouldTickBind :: TickDensity
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
shouldTickBind :: TickDensity -> Bool -> Bool -> Bool -> Bool -> Bool
shouldTickBind TickDensity
density Bool
top_lev Bool
exported Bool
_simple_pat Bool
inline
= case TickDensity
density of
TickDensity
TickForBreakPoints -> Bool
False
TickDensity
TickAllFunctions -> Bool -> Bool
not Bool
inline
TickDensity
TickTopFunctions -> Bool
top_lev Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
inline
TickDensity
TickExportedFunctions -> Bool
exported Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
inline
TickDensity
TickForCoverage -> Bool
True
TickDensity
TickCallSites -> Bool
False
shouldTickPatBind :: TickDensity -> Bool -> Bool
shouldTickPatBind :: TickDensity -> Bool -> Bool
shouldTickPatBind TickDensity
density Bool
top_lev
= case TickDensity
density of
TickDensity
TickForBreakPoints -> Bool
False
TickDensity
TickAllFunctions -> Bool
True
TickDensity
TickTopFunctions -> Bool
top_lev
TickDensity
TickExportedFunctions -> Bool
False
TickDensity
TickForCoverage -> Bool
False
TickDensity
TickCallSites -> Bool
False
addTickLHsBinds :: LHsBinds GhcTc -> TM (LHsBinds GhcTc)
addTickLHsBinds :: LHsBinds GhcTc -> TM (LHsBinds GhcTc)
addTickLHsBinds = (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> TM (Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Bag a -> m (Bag b)
mapBagM LHsBind GhcTc -> TM (LHsBind GhcTc)
GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
addTickLHsBind
addTickLHsBind :: LHsBind GhcTc -> TM (LHsBind GhcTc)
addTickLHsBind :: LHsBind GhcTc -> TM (LHsBind GhcTc)
addTickLHsBind (L SrcSpanAnnA
pos (XHsBindsLR bind :: XXHsBindsLR GhcTc GhcTc
bind@(AbsBinds { abs_binds :: AbsBinds -> LHsBinds GhcTc
abs_binds = LHsBinds GhcTc
binds
, abs_exports :: AbsBinds -> [ABExport]
abs_exports = [ABExport]
abs_exports
}))) =
(TickTransEnv -> TickTransEnv)
-> TM (LHsBind GhcTc) -> TM (LHsBind GhcTc)
forall a. (TickTransEnv -> TickTransEnv) -> TM a -> TM a
withEnv TickTransEnv -> TickTransEnv
add_exports (TM (LHsBind GhcTc) -> TM (LHsBind GhcTc))
-> TM (LHsBind GhcTc) -> TM (LHsBind GhcTc)
forall a b. (a -> b) -> a -> b
$
(TickTransEnv -> TickTransEnv)
-> TM (LHsBind GhcTc) -> TM (LHsBind GhcTc)
forall a. (TickTransEnv -> TickTransEnv) -> TM a -> TM a
withEnv TickTransEnv -> TickTransEnv
add_inlines (TM (LHsBind GhcTc) -> TM (LHsBind GhcTc))
-> TM (LHsBind GhcTc) -> TM (LHsBind GhcTc)
forall a b. (a -> b) -> a -> b
$ do
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds' <- LHsBinds GhcTc -> TM (LHsBinds GhcTc)
addTickLHsBinds LHsBinds GhcTc
binds
GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos (HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall a b. (a -> b) -> a -> b
$ XXHsBindsLR GhcTc GhcTc -> HsBindLR GhcTc GhcTc
forall idL idR. XXHsBindsLR idL idR -> HsBindLR idL idR
XHsBindsLR (XXHsBindsLR GhcTc GhcTc -> HsBindLR GhcTc GhcTc)
-> XXHsBindsLR GhcTc GhcTc -> HsBindLR GhcTc GhcTc
forall a b. (a -> b) -> a -> b
$ XXHsBindsLR GhcTc GhcTc
AbsBinds
bind { abs_binds :: LHsBinds GhcTc
abs_binds = LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds' }
where
add_exports :: TickTransEnv -> TickTransEnv
add_exports TickTransEnv
env =
TickTransEnv
env{ exports :: NameSet
exports = TickTransEnv -> NameSet
exports TickTransEnv
env NameSet -> [Name] -> NameSet
`extendNameSetList`
[ Id -> Name
idName Id
mid
| ABE{ abe_poly :: ABExport -> Id
abe_poly = Id
pid, abe_mono :: ABExport -> Id
abe_mono = Id
mid } <- [ABExport]
abs_exports
, Id -> Name
idName Id
pid Name -> NameSet -> Bool
`elemNameSet` (TickTransEnv -> NameSet
exports TickTransEnv
env) ] }
add_inlines :: TickTransEnv -> TickTransEnv
add_inlines TickTransEnv
env =
TickTransEnv
env{ inlines :: VarSet
inlines = TickTransEnv -> VarSet
inlines TickTransEnv
env VarSet -> [Id] -> VarSet
`extendVarSetList`
[ Id
mid
| ABE{ abe_poly :: ABExport -> Id
abe_poly = Id
pid, abe_mono :: ABExport -> Id
abe_mono = Id
mid } <- [ABExport]
abs_exports
, InlinePragma -> Bool
isInlinePragma (Id -> InlinePragma
idInlinePragma Id
pid) ] }
addTickLHsBind (L SrcSpanAnnA
pos (funBind :: HsBindLR GhcTc GhcTc
funBind@(FunBind { fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_id = L SrcSpanAnnN
_ Id
id }))) = do
let name :: FilePath
name = Id -> FilePath
forall a. NamedThing a => a -> FilePath
getOccString Id
id
[FilePath]
decl_path <- TM [FilePath]
getPathEntry
TickDensity
density <- TM TickDensity
getDensity
VarSet
inline_ids <- (TickTransEnv -> VarSet) -> TM TickTransEnv -> TM VarSet
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM TickTransEnv -> VarSet
inlines TM TickTransEnv
getEnv
let inline :: Bool
inline = InlinePragma -> Bool
isInlinePragma (Id -> InlinePragma
idInlinePragma Id
id)
Bool -> Bool -> Bool
|| Id
id Id -> VarSet -> Bool
`elemVarSet` VarSet
inline_ids
TickishType
tickish <- TickTransEnv -> TickishType
tickishType (TickTransEnv -> TickishType) -> TM TickTransEnv -> TM TickishType
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` TM TickTransEnv
getEnv
if Bool
inline Bool -> Bool -> Bool
&& TickishType
tickish TickishType -> TickishType -> Bool
forall a. Eq a => a -> a -> Bool
== TickishType
ProfNotes then GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnA
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos HsBindLR GhcTc GhcTc
funBind) else do
(FreeVars
fvs, MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
mg) <-
TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(FreeVars,
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. TM a -> TM (FreeVars, a)
getFreeVars (TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(FreeVars,
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(FreeVars,
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$
FilePath
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
forall a. FilePath -> TM a -> TM a
addPathEntry FilePath
name (TM (MatchGroup GhcTc (LHsExpr GhcTc))
-> TM (MatchGroup GhcTc (LHsExpr GhcTc)))
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$
Bool
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup Bool
False (HsBindLR GhcTc GhcTc -> MatchGroup GhcTc (LHsExpr GhcTc)
forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches HsBindLR GhcTc GhcTc
funBind)
Bool
blackListed <- SrcSpan -> TM Bool
isBlackListed (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos)
NameSet
exported_names <- (TickTransEnv -> NameSet) -> TM TickTransEnv -> TM NameSet
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM TickTransEnv -> NameSet
exports TM TickTransEnv
getEnv
let simple :: Bool
simple = HsBindLR GhcTc GhcTc -> Bool
isSimplePatBind HsBindLR GhcTc GhcTc
funBind
toplev :: Bool
toplev = [FilePath] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FilePath]
decl_path
exported :: Bool
exported = Id -> Name
idName Id
id Name -> NameSet -> Bool
`elemNameSet` NameSet
exported_names
Maybe CoreTickish
tick <- if Bool -> Bool
not Bool
blackListed Bool -> Bool -> Bool
&&
TickDensity -> Bool -> Bool -> Bool -> Bool -> Bool
shouldTickBind TickDensity
density Bool
toplev Bool
exported Bool
simple Bool
inline
then
TickDensity
-> FilePath -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
bindTick TickDensity
density FilePath
name (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos) FreeVars
fvs
else
Maybe CoreTickish -> TM (Maybe CoreTickish)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe CoreTickish
forall a. Maybe a
Nothing
let mbCons :: Maybe a -> [a] -> [a]
mbCons = ([a] -> [a]) -> (a -> [a] -> [a]) -> Maybe a -> [a] -> [a]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [a] -> [a]
forall a. a -> a
Prelude.id (:)
GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos (HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall a b. (a -> b) -> a -> b
$ HsBindLR GhcTc GhcTc
funBind { fun_matches :: MatchGroup GhcTc (LHsExpr GhcTc)
fun_matches = MatchGroup GhcTc (LHsExpr GhcTc)
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
mg
, fun_tick :: [CoreTickish]
fun_tick = Maybe CoreTickish
tick Maybe CoreTickish -> [CoreTickish] -> [CoreTickish]
forall {a}. Maybe a -> [a] -> [a]
`mbCons` HsBindLR GhcTc GhcTc -> [CoreTickish]
forall idL idR. HsBindLR idL idR -> [CoreTickish]
fun_tick HsBindLR GhcTc GhcTc
funBind }
where
isSimplePatBind :: HsBind GhcTc -> Bool
isSimplePatBind :: HsBindLR GhcTc GhcTc -> Bool
isSimplePatBind HsBindLR GhcTc GhcTc
funBind = MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> Int
forall (id :: Pass) body. MatchGroup (GhcPass id) body -> Int
matchGroupArity (HsBindLR GhcTc GhcTc -> MatchGroup GhcTc (LHsExpr GhcTc)
forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches HsBindLR GhcTc GhcTc
funBind) Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
addTickLHsBind (L SrcSpanAnnA
pos (pat :: HsBindLR GhcTc GhcTc
pat@(PatBind { pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat GhcTc
lhs
, pat_rhs :: forall idL idR. HsBindLR idL idR -> GRHSs idR (LHsExpr idR)
pat_rhs = GRHSs GhcTc (LHsExpr GhcTc)
rhs }))) = do
let simplePatId :: Maybe (IdP GhcTc)
simplePatId = LPat GhcTc -> Maybe (IdP GhcTc)
forall (x :: Pass). LPat (GhcPass x) -> Maybe (IdP (GhcPass x))
isSimplePat LPat GhcTc
lhs
let name :: FilePath
name = FilePath -> (Id -> FilePath) -> Maybe Id -> FilePath
forall b a. b -> (a -> b) -> Maybe a -> b
maybe FilePath
"(...)" Id -> FilePath
forall a. NamedThing a => a -> FilePath
getOccString Maybe (IdP GhcTc)
Maybe Id
simplePatId
(FreeVars
fvs, GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
rhs') <- TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(FreeVars, GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. TM a -> TM (FreeVars, a)
getFreeVars (TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(FreeVars, GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(FreeVars, GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ FilePath
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
forall a. FilePath -> TM a -> TM a
addPathEntry FilePath
name (TM (GRHSs GhcTc (LHsExpr GhcTc))
-> TM (GRHSs GhcTc (LHsExpr GhcTc)))
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> GRHSs GhcTc (LHsExpr GhcTc)
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
addTickGRHSs Bool
False Bool
False GRHSs GhcTc (LHsExpr GhcTc)
rhs
let pat' :: HsBindLR GhcTc GhcTc
pat' = HsBindLR GhcTc GhcTc
pat { pat_rhs :: GRHSs GhcTc (LHsExpr GhcTc)
pat_rhs = GRHSs GhcTc (LHsExpr GhcTc)
GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
rhs'}
TickDensity
density <- TM TickDensity
getDensity
[FilePath]
decl_path <- TM [FilePath]
getPathEntry
let top_lev :: Bool
top_lev = [FilePath] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FilePath]
decl_path
if Bool -> Bool
not (TickDensity -> Bool -> Bool
shouldTickPatBind TickDensity
density Bool
top_lev)
then GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnA
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos HsBindLR GhcTc GhcTc
pat')
else do
let mbCons :: Maybe a -> [a] -> [a]
mbCons = ([a] -> [a]) -> (a -> [a] -> [a]) -> Maybe a -> [a] -> [a]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [a] -> [a]
forall a. a -> a
id (:)
let ([CoreTickish]
initial_rhs_ticks, [[CoreTickish]]
initial_patvar_tickss) = HsBindLR GhcTc GhcTc -> ([CoreTickish], [[CoreTickish]])
forall idL idR.
HsBindLR idL idR -> ([CoreTickish], [[CoreTickish]])
pat_ticks HsBindLR GhcTc GhcTc
pat'
Maybe CoreTickish
rhs_tick <- TickDensity
-> FilePath -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
bindTick TickDensity
density FilePath
name (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos) FreeVars
fvs
let rhs_ticks :: [CoreTickish]
rhs_ticks = Maybe CoreTickish
rhs_tick Maybe CoreTickish -> [CoreTickish] -> [CoreTickish]
forall {a}. Maybe a -> [a] -> [a]
`mbCons` [CoreTickish]
initial_rhs_ticks
[[CoreTickish]]
patvar_tickss <- case Maybe (IdP GhcTc)
simplePatId of
Just{} -> [[CoreTickish]] -> TM [[CoreTickish]]
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return [[CoreTickish]]
initial_patvar_tickss
Maybe (IdP GhcTc)
Nothing -> do
let patvars :: [FilePath]
patvars = (IdP GhcTc -> FilePath) -> [IdP GhcTc] -> [FilePath]
forall a b. (a -> b) -> [a] -> [b]
map IdP GhcTc -> FilePath
forall a. NamedThing a => a -> FilePath
getOccString (CollectFlag GhcTc -> LPat GhcTc -> [IdP GhcTc]
forall p. CollectPass p => CollectFlag p -> LPat p -> [IdP p]
collectPatBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders LPat GhcTc
lhs)
[Maybe CoreTickish]
patvar_ticks <- (FilePath -> TM (Maybe CoreTickish))
-> [FilePath] -> TM [Maybe CoreTickish]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\FilePath
v -> TickDensity
-> FilePath -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
bindTick TickDensity
density FilePath
v (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos) FreeVars
fvs) [FilePath]
patvars
[[CoreTickish]] -> TM [[CoreTickish]]
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return
((Maybe CoreTickish -> [CoreTickish] -> [CoreTickish])
-> [Maybe CoreTickish] -> [[CoreTickish]] -> [[CoreTickish]]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Maybe CoreTickish -> [CoreTickish] -> [CoreTickish]
forall {a}. Maybe a -> [a] -> [a]
mbCons [Maybe CoreTickish]
patvar_ticks
([[CoreTickish]]
initial_patvar_tickss [[CoreTickish]] -> [[CoreTickish]] -> [[CoreTickish]]
forall a. [a] -> [a] -> [a]
++ [CoreTickish] -> [[CoreTickish]]
forall a. a -> [a]
repeat []))
GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos (HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> HsBindLR GhcTc GhcTc
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
forall a b. (a -> b) -> a -> b
$ HsBindLR GhcTc GhcTc
pat' { pat_ticks :: ([CoreTickish], [[CoreTickish]])
pat_ticks = ([CoreTickish]
rhs_ticks, [[CoreTickish]]
patvar_tickss) }
addTickLHsBind var_bind :: LHsBind GhcTc
var_bind@(L SrcSpanAnnA
_ (VarBind {})) = GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return LHsBind GhcTc
GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
var_bind
addTickLHsBind patsyn_bind :: LHsBind GhcTc
patsyn_bind@(L SrcSpanAnnA
_ (PatSynBind {})) = GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return LHsBind GhcTc
GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
patsyn_bind
bindTick
:: TickDensity -> String -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
bindTick :: TickDensity
-> FilePath -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
bindTick TickDensity
density FilePath
name SrcSpan
pos FreeVars
fvs = do
[FilePath]
decl_path <- TM [FilePath]
getPathEntry
let
toplev :: Bool
toplev = [FilePath] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FilePath]
decl_path
count_entries :: Bool
count_entries = Bool
toplev Bool -> Bool -> Bool
|| TickDensity
density TickDensity -> TickDensity -> Bool
forall a. Eq a => a -> a -> Bool
== TickDensity
TickAllFunctions
top_only :: Bool
top_only = TickDensity
density TickDensity -> TickDensity -> Bool
forall a. Eq a => a -> a -> Bool
/= TickDensity
TickAllFunctions
box_label :: BoxLabel
box_label = if Bool
toplev then [FilePath] -> BoxLabel
TopLevelBox [FilePath
name]
else [FilePath] -> BoxLabel
LocalBox ([FilePath]
decl_path [FilePath] -> [FilePath] -> [FilePath]
forall a. [a] -> [a] -> [a]
++ [FilePath
name])
BoxLabel
-> Bool -> Bool -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
allocATickBox BoxLabel
box_label Bool
count_entries Bool
top_only SrcSpan
pos FreeVars
fvs
addTickLHsExpr :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr e :: LHsExpr GhcTc
e@(L SrcSpanAnnA
pos HsExpr GhcTc
e0) = do
TickDensity
d <- TM TickDensity
getDensity
case TickDensity
d of
TickDensity
TickForBreakPoints | HsExpr GhcTc -> Bool
isGoodBreakExpr HsExpr GhcTc
e0 -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
TickForCoverage -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
TickCallSites | HsExpr GhcTc -> Bool
isCallSite HsExpr GhcTc
e0 -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
_other -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
dont_tick_it
where
tick_it :: TM (LHsExpr GhcTc)
tick_it = BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox (Bool -> BoxLabel
ExpBox Bool
False) Bool
False Bool
False (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos)
(TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0
dont_tick_it :: TM (LHsExpr GhcTc)
dont_tick_it = LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e
addTickLHsExprRHS :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS e :: LHsExpr GhcTc
e@(L SrcSpanAnnA
pos HsExpr GhcTc
e0) = do
TickDensity
d <- TM TickDensity
getDensity
case TickDensity
d of
TickDensity
TickForBreakPoints | HsLet{} <- HsExpr GhcTc
e0 -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
dont_tick_it
| Bool
otherwise -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
TickForCoverage -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
TickCallSites | HsExpr GhcTc -> Bool
isCallSite HsExpr GhcTc
e0 -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
_other -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
dont_tick_it
where
tick_it :: TM (LHsExpr GhcTc)
tick_it = BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox (Bool -> BoxLabel
ExpBox Bool
False) Bool
False Bool
False (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos)
(TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0
dont_tick_it :: TM (LHsExpr GhcTc)
dont_tick_it = LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e
addTickLHsExprEvalInner :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprEvalInner :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprEvalInner LHsExpr GhcTc
e = do
TickDensity
d <- TM TickDensity
getDensity
case TickDensity
d of
TickDensity
TickForCoverage -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e
TickDensity
_otherwise -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e
addTickLHsExprLetBody :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprLetBody :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprLetBody e :: LHsExpr GhcTc
e@(L SrcSpanAnnA
pos HsExpr GhcTc
e0) = do
TickDensity
d <- TM TickDensity
getDensity
case TickDensity
d of
TickDensity
TickForBreakPoints | HsLet{} <- HsExpr GhcTc
e0 -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
dont_tick_it
| Bool
otherwise -> TM (LHsExpr GhcTc)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
tick_it
TickDensity
_other -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprEvalInner LHsExpr GhcTc
e
where
tick_it :: TM (LHsExpr GhcTc)
tick_it = BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox (Bool -> BoxLabel
ExpBox Bool
False) Bool
False Bool
False (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos)
(TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0
dont_tick_it :: TM (LHsExpr GhcTc)
dont_tick_it = LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e
addTickLHsExprNever :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever (L SrcSpanAnnA
pos HsExpr GhcTc
e0) = do
HsExpr GhcTc
e1 <- HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos HsExpr GhcTc
e1
isGoodBreakExpr :: HsExpr GhcTc -> Bool
isGoodBreakExpr :: HsExpr GhcTc -> Bool
isGoodBreakExpr HsExpr GhcTc
e = HsExpr GhcTc -> Bool
isCallSite HsExpr GhcTc
e
isCallSite :: HsExpr GhcTc -> Bool
isCallSite :: HsExpr GhcTc -> Bool
isCallSite HsApp{} = Bool
True
isCallSite HsAppType{} = Bool
True
isCallSite (XExpr (ExpansionExpr (HsExpanded HsExpr GhcRn
_ HsExpr GhcTc
e)))
= HsExpr GhcTc -> Bool
isCallSite HsExpr GhcTc
e
isCallSite HsExpr GhcTc
_ = Bool
False
addTickLHsExprOptAlt :: Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprOptAlt :: Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprOptAlt Bool
oneOfMany (L SrcSpanAnnA
pos HsExpr GhcTc
e0)
= TickDensity
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. TickDensity -> TM a -> TM a -> TM a
ifDensity TickDensity
TickForCoverage
(BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox (Bool -> BoxLabel
ExpBox Bool
oneOfMany) Bool
False Bool
False (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos)
(TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos HsExpr GhcTc
e0))
addBinTickLHsExpr :: (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addBinTickLHsExpr :: (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addBinTickLHsExpr Bool -> BoxLabel
boxLabel (L SrcSpanAnnA
pos HsExpr GhcTc
e0)
= TickDensity
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. TickDensity -> TM a -> TM a -> TM a
ifDensity TickDensity
TickForCoverage
((Bool -> BoxLabel)
-> SrcSpan -> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
allocBinTickBox Bool -> BoxLabel
boxLabel (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos) (TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos HsExpr GhcTc
e0))
addTickHsExpr :: HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr :: HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr e :: HsExpr GhcTc
e@(HsVar XVar GhcTc
_ (L SrcSpanAnnN
_ Id
id)) = do Id -> TM ()
freeVar Id
id; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsUnboundVar {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsRecSel XRecSel GhcTc
_ (FieldOcc XCFieldOcc GhcTc
id XRec GhcTc RdrName
_)) = do Id -> TM ()
freeVar XCFieldOcc GhcTc
Id
id; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsIPVar {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsOverLit {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsOverLabel{}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsLit {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr (HsLam XLam GhcTc
x MatchGroup GhcTc (LHsExpr GhcTc)
mg) = (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> HsExpr GhcTc)
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XLam GhcTc -> MatchGroup GhcTc (LHsExpr GhcTc) -> HsExpr GhcTc
forall p. XLam p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLam XLam GhcTc
x)
(Bool
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup Bool
True MatchGroup GhcTc (LHsExpr GhcTc)
mg)
addTickHsExpr (HsLamCase XLamCase GhcTc
x LamCaseVariant
lc_variant MatchGroup GhcTc (LHsExpr GhcTc)
mgs) = (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> HsExpr GhcTc)
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XLamCase GhcTc
-> LamCaseVariant
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> HsExpr GhcTc
forall p.
XLamCase p
-> LamCaseVariant -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLamCase XLamCase GhcTc
x LamCaseVariant
lc_variant)
(Bool
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup Bool
True MatchGroup GhcTc (LHsExpr GhcTc)
mgs)
addTickHsExpr (HsApp XApp GhcTc
x LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) = (GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XApp GhcTc -> LHsExpr GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp XApp GhcTc
x) (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e2)
addTickHsExpr (HsAppType XAppTypeE GhcTc
x LHsExpr GhcTc
e LHsWcType (NoGhcTc GhcTc)
ty) = (Type
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> HsExpr GhcTc)
-> TM Type
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 XAppTypeE GhcTc
-> LHsExpr GhcTc -> LHsWcType (NoGhcTc GhcTc) -> HsExpr GhcTc
Type
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> HsExpr GhcTc
forall p.
XAppTypeE p -> LHsExpr p -> LHsWcType (NoGhcTc p) -> HsExpr p
HsAppType (Type -> TM Type
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XAppTypeE GhcTc
Type
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e)
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> TM
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return LHsWcType (NoGhcTc GhcTc)
HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
ty)
addTickHsExpr (OpApp XOpApp GhcTc
fix LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 LHsExpr GhcTc
e3) =
(DataConCantHappen
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsExpr GhcTc)
-> TM DataConCantHappen
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 XOpApp GhcTc
-> LHsExpr GhcTc -> LHsExpr GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
DataConCantHappen
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsExpr GhcTc
forall p.
XOpApp p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
OpApp
(DataConCantHappen -> TM DataConCantHappen
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XOpApp GhcTc
DataConCantHappen
fix)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e2)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e3)
addTickHsExpr (NegApp XNegApp GhcTc
x LHsExpr GhcTc
e SyntaxExpr GhcTc
neg) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> SyntaxExprTc -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM SyntaxExprTc
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XNegApp GhcTc -> LHsExpr GhcTc -> SyntaxExpr GhcTc -> HsExpr GhcTc
forall p. XNegApp p -> LHsExpr p -> SyntaxExpr p -> HsExpr p
NegApp XNegApp GhcTc
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
neg)
addTickHsExpr (HsPar XPar GhcTc
x LHsToken "(" GhcTc
lpar LHsExpr GhcTc
e LHsToken ")" GhcTc
rpar) = do
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprEvalInner LHsExpr GhcTc
e
HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPar GhcTc
-> LHsToken "(" GhcTc
-> LHsExpr GhcTc
-> LHsToken ")" GhcTc
-> HsExpr GhcTc
forall p.
XPar p -> LHsToken "(" p -> LHsExpr p -> LHsToken ")" p -> HsExpr p
HsPar XPar GhcTc
x LHsToken "(" GhcTc
lpar LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' LHsToken ")" GhcTc
rpar)
addTickHsExpr (SectionL XSectionL GhcTc
x LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XSectionL GhcTc -> LHsExpr GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XSectionL p -> LHsExpr p -> LHsExpr p -> HsExpr p
SectionL XSectionL GhcTc
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e2)
addTickHsExpr (SectionR XSectionR GhcTc
x LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XSectionR GhcTc -> LHsExpr GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XSectionR p -> LHsExpr p -> LHsExpr p -> HsExpr p
SectionR XSectionR GhcTc
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e2)
addTickHsExpr (ExplicitTuple XExplicitTuple GhcTc
x [HsTupArg GhcTc]
es Boxity
boxity) =
([HsTupArg GhcTc] -> Boxity -> HsExpr GhcTc)
-> TM [HsTupArg GhcTc] -> TM Boxity -> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XExplicitTuple GhcTc -> [HsTupArg GhcTc] -> Boxity -> HsExpr GhcTc
forall p. XExplicitTuple p -> [HsTupArg p] -> Boxity -> HsExpr p
ExplicitTuple XExplicitTuple GhcTc
x)
((HsTupArg GhcTc -> TM (HsTupArg GhcTc))
-> [HsTupArg GhcTc] -> TM [HsTupArg GhcTc]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM HsTupArg GhcTc -> TM (HsTupArg GhcTc)
addTickTupArg [HsTupArg GhcTc]
es)
(Boxity -> TM Boxity
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Boxity
boxity)
addTickHsExpr (ExplicitSum XExplicitSum GhcTc
ty Int
tag Int
arity LHsExpr GhcTc
e) = do
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e
HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExplicitSum GhcTc -> Int -> Int -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XExplicitSum p -> Int -> Int -> LHsExpr p -> HsExpr p
ExplicitSum XExplicitSum GhcTc
ty Int
tag Int
arity LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e')
addTickHsExpr (HsCase XCase GhcTc
x LHsExpr GhcTc
e MatchGroup GhcTc (LHsExpr GhcTc)
mgs) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XCase GhcTc
-> LHsExpr GhcTc
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> HsExpr GhcTc
forall p.
XCase p -> LHsExpr p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsCase XCase GhcTc
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
(Bool
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup Bool
False MatchGroup GhcTc (LHsExpr GhcTc)
mgs)
addTickHsExpr (HsIf XIf GhcTc
x LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 LHsExpr GhcTc
e3) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XIf GhcTc
-> LHsExpr GhcTc -> LHsExpr GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XIf p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsIf XIf GhcTc
x)
((Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addBinTickLHsExpr (CondBox -> Bool -> BoxLabel
BinBox CondBox
CondBinBox) LHsExpr GhcTc
e1)
(Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprOptAlt Bool
True LHsExpr GhcTc
e2)
(Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprOptAlt Bool
True LHsExpr GhcTc
e3)
addTickHsExpr (HsMultiIf XMultiIf GhcTc
ty [LGRHS GhcTc (LHsExpr GhcTc)]
alts)
= do { let isOneOfMany :: Bool
isOneOfMany = case [LGRHS GhcTc (LHsExpr GhcTc)]
alts of [LGRHS GhcTc (LHsExpr GhcTc)
_] -> Bool
False; [LGRHS GhcTc (LHsExpr GhcTc)]
_ -> Bool
True
; [GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
alts' <- (GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((GRHS GhcTc (LHsExpr GhcTc) -> TM (GRHS GhcTc (LHsExpr GhcTc)))
-> GenLocated (SrcAnn NoEpAnns) (GRHS GhcTc (LHsExpr GhcTc))
-> TM (GenLocated (SrcAnn NoEpAnns) (GRHS GhcTc (LHsExpr GhcTc)))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL ((GRHS GhcTc (LHsExpr GhcTc) -> TM (GRHS GhcTc (LHsExpr GhcTc)))
-> GenLocated (SrcAnn NoEpAnns) (GRHS GhcTc (LHsExpr GhcTc))
-> TM (GenLocated (SrcAnn NoEpAnns) (GRHS GhcTc (LHsExpr GhcTc))))
-> (GRHS GhcTc (LHsExpr GhcTc) -> TM (GRHS GhcTc (LHsExpr GhcTc)))
-> GenLocated (SrcAnn NoEpAnns) (GRHS GhcTc (LHsExpr GhcTc))
-> TM (GenLocated (SrcAnn NoEpAnns) (GRHS GhcTc (LHsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> GRHS GhcTc (LHsExpr GhcTc)
-> TM (GRHS GhcTc (LHsExpr GhcTc))
addTickGRHS Bool
isOneOfMany Bool
False) [LGRHS GhcTc (LHsExpr GhcTc)]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
alts
; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsExpr GhcTc -> TM (HsExpr GhcTc))
-> HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ XMultiIf GhcTc -> [LGRHS GhcTc (LHsExpr GhcTc)] -> HsExpr GhcTc
forall p. XMultiIf p -> [LGRHS p (LHsExpr p)] -> HsExpr p
HsMultiIf XMultiIf GhcTc
ty [LGRHS GhcTc (LHsExpr GhcTc)]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
alts' }
addTickHsExpr (HsLet XLet GhcTc
x LHsToken "let" GhcTc
tkLet HsLocalBinds GhcTc
binds LHsToken "in" GhcTc
tkIn LHsExpr GhcTc
e) =
[Id] -> TM (HsExpr GhcTc) -> TM (HsExpr GhcTc)
forall a. [Id] -> TM a -> TM a
bindLocals (CollectFlag GhcTc -> HsLocalBinds GhcTc -> [IdP GhcTc]
forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders HsLocalBinds GhcTc
binds) (TM (HsExpr GhcTc) -> TM (HsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (HsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ do
HsLocalBinds GhcTc
binds' <- HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds HsLocalBinds GhcTc
binds
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprLetBody LHsExpr GhcTc
e
HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLet GhcTc
-> LHsToken "let" GhcTc
-> HsLocalBinds GhcTc
-> LHsToken "in" GhcTc
-> LHsExpr GhcTc
-> HsExpr GhcTc
forall p.
XLet p
-> LHsToken "let" p
-> HsLocalBinds p
-> LHsToken "in" p
-> LHsExpr p
-> HsExpr p
HsLet XLet GhcTc
x LHsToken "let" GhcTc
tkLet HsLocalBinds GhcTc
binds' LHsToken "in" GhcTc
tkIn LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e')
addTickHsExpr (HsDo XDo GhcTc
srcloc HsDoFlavour
cxt (L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts))
= do { ([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts', ()
_) <- Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM () -> TM ([ExprLStmt GhcTc], ())
forall a.
Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM a -> TM ([ExprLStmt GhcTc], a)
addTickLStmts' Maybe (Bool -> BoxLabel)
forQual [ExprLStmt GhcTc]
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts (() -> TM ()
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XDo GhcTc
-> HsDoFlavour -> XRec GhcTc [ExprLStmt GhcTc] -> HsExpr GhcTc
forall p. XDo p -> HsDoFlavour -> XRec p [ExprLStmt p] -> HsExpr p
HsDo XDo GhcTc
srcloc HsDoFlavour
cxt (SrcSpanAnnL
-> [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> GenLocated
SrcSpanAnnL
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts')) }
where
forQual :: Maybe (Bool -> BoxLabel)
forQual = case HsDoFlavour
cxt of
HsDoFlavour
ListComp -> (Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel)
forall a. a -> Maybe a
Just ((Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel))
-> (Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel)
forall a b. (a -> b) -> a -> b
$ CondBox -> Bool -> BoxLabel
BinBox CondBox
QualBinBox
HsDoFlavour
_ -> Maybe (Bool -> BoxLabel)
forall a. Maybe a
Nothing
addTickHsExpr (ExplicitList XExplicitList GhcTc
ty [LHsExpr GhcTc]
es)
= (Type -> [GenLocated SrcSpanAnnA (HsExpr GhcTc)] -> HsExpr GhcTc)
-> TM Type
-> TM [GenLocated SrcSpanAnnA (HsExpr GhcTc)]
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 XExplicitList GhcTc -> [LHsExpr GhcTc] -> HsExpr GhcTc
Type -> [GenLocated SrcSpanAnnA (HsExpr GhcTc)] -> HsExpr GhcTc
forall p. XExplicitList p -> [LHsExpr p] -> HsExpr p
ExplicitList (Type -> TM Type
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XExplicitList GhcTc
Type
ty) ((GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> [GenLocated SrcSpanAnnA (HsExpr GhcTc)]
-> TM [GenLocated SrcSpanAnnA (HsExpr GhcTc)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
addTickLHsExpr) [LHsExpr GhcTc]
[GenLocated SrcSpanAnnA (HsExpr GhcTc)]
es)
addTickHsExpr (HsStatic XStatic GhcTc
fvs LHsExpr GhcTc
e) = XStatic GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XStatic p -> LHsExpr p -> HsExpr p
HsStatic XStatic GhcTc
fvs (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e
addTickHsExpr expr :: HsExpr GhcTc
expr@(RecordCon { rcon_flds :: forall p. HsExpr p -> HsRecordBinds p
rcon_flds = HsRecordBinds GhcTc
rec_binds })
= do { HsRecFields GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
rec_binds' <- HsRecordBinds GhcTc -> TM (HsRecordBinds GhcTc)
addTickHsRecordBinds HsRecordBinds GhcTc
rec_binds
; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsExpr GhcTc
expr { rcon_flds :: HsRecordBinds GhcTc
rcon_flds = HsRecordBinds GhcTc
HsRecFields GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
rec_binds' }) }
addTickHsExpr expr :: HsExpr GhcTc
expr@(RecordUpd { rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr GhcTc
e, rupd_flds :: forall p. HsExpr p -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
rupd_flds = Left [LHsRecUpdField GhcTc]
flds })
= do { GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e
; [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
flds' <- (GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM LHsFieldBind
GhcTc
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(LHsExpr GhcTc)
-> TM
(LHsFieldBind
GhcTc
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(LHsExpr GhcTc))
GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall id.
LHsFieldBind GhcTc id (LHsExpr GhcTc)
-> TM (LHsFieldBind GhcTc id (LHsExpr GhcTc))
addTickHsRecField [LHsRecUpdField GhcTc]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
flds
; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsExpr GhcTc
expr { rupd_expr :: LHsExpr GhcTc
rupd_expr = LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e', rupd_flds :: Either [LHsRecUpdField GhcTc] [LHsRecUpdProj GhcTc]
rupd_flds = [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> Either
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall a b. a -> Either a b
Left [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
flds' }) }
addTickHsExpr expr :: HsExpr GhcTc
expr@(RecordUpd { rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr GhcTc
e, rupd_flds :: forall p. HsExpr p -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
rupd_flds = Right [LHsRecUpdProj GhcTc]
flds })
= do { GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e
; [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
flds' <- (GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM LHsFieldBind
GhcTc
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(LHsExpr GhcTc)
-> TM
(LHsFieldBind
GhcTc
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(LHsExpr GhcTc))
GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall id.
LHsFieldBind GhcTc id (LHsExpr GhcTc)
-> TM (LHsFieldBind GhcTc id (LHsExpr GhcTc))
addTickHsRecField [LHsRecUpdProj GhcTc]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
flds
; HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsExpr GhcTc
expr { rupd_expr :: LHsExpr GhcTc
rupd_expr = LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e', rupd_flds :: Either [LHsRecUpdField GhcTc] [LHsRecUpdProj GhcTc]
rupd_flds = [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> Either
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall a b. b -> Either a b
Right [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
flds' }) }
addTickHsExpr (ExprWithTySig XExprWithTySig GhcTc
x LHsExpr GhcTc
e LHsSigWcType (NoGhcTc GhcTc)
ty) =
(NoExtField
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HsExpr GhcTc)
-> TM NoExtField
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 XExprWithTySig GhcTc
-> LHsExpr GhcTc -> LHsSigWcType (NoGhcTc GhcTc) -> HsExpr GhcTc
NoExtField
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HsExpr GhcTc
forall p.
XExprWithTySig p
-> LHsExpr p -> LHsSigWcType (NoGhcTc p) -> HsExpr p
ExprWithTySig
(NoExtField -> TM NoExtField
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XExprWithTySig GhcTc
NoExtField
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e)
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> TM
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return LHsSigWcType (NoGhcTc GhcTc)
HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
ty)
addTickHsExpr (ArithSeq XArithSeq GhcTc
ty Maybe (SyntaxExpr GhcTc)
wit ArithSeqInfo GhcTc
arith_seq) =
(HsExpr GhcTc
-> Maybe SyntaxExprTc -> ArithSeqInfo GhcTc -> HsExpr GhcTc)
-> TM (HsExpr GhcTc)
-> TM (Maybe SyntaxExprTc)
-> TM (ArithSeqInfo GhcTc)
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 XArithSeq GhcTc
-> Maybe (SyntaxExpr GhcTc) -> ArithSeqInfo GhcTc -> HsExpr GhcTc
HsExpr GhcTc
-> Maybe SyntaxExprTc -> ArithSeqInfo GhcTc -> HsExpr GhcTc
forall p.
XArithSeq p -> Maybe (SyntaxExpr p) -> ArithSeqInfo p -> HsExpr p
ArithSeq
(HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XArithSeq GhcTc
HsExpr GhcTc
ty)
(Maybe SyntaxExprTc -> TM (Maybe SyntaxExprTc)
addTickWit Maybe (SyntaxExpr GhcTc)
Maybe SyntaxExprTc
wit)
(ArithSeqInfo GhcTc -> TM (ArithSeqInfo GhcTc)
addTickArithSeqInfo ArithSeqInfo GhcTc
arith_seq)
where addTickWit :: Maybe SyntaxExprTc -> TM (Maybe SyntaxExprTc)
addTickWit Maybe SyntaxExprTc
Nothing = Maybe SyntaxExprTc -> TM (Maybe SyntaxExprTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe SyntaxExprTc
forall a. Maybe a
Nothing
addTickWit (Just SyntaxExprTc
fl) = do SyntaxExprTc
fl' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
SyntaxExprTc
fl
Maybe SyntaxExprTc -> TM (Maybe SyntaxExprTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SyntaxExprTc -> Maybe SyntaxExprTc
forall a. a -> Maybe a
Just SyntaxExprTc
fl')
addTickHsExpr (HsPragE XPragE GhcTc
x HsPragE GhcTc
p LHsExpr GhcTc
e) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XPragE GhcTc -> HsPragE GhcTc -> LHsExpr GhcTc -> HsExpr GhcTc
forall p. XPragE p -> HsPragE p -> LHsExpr p -> HsExpr p
HsPragE XPragE GhcTc
x HsPragE GhcTc
p) (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
addTickHsExpr e :: HsExpr GhcTc
e@(HsTypedBracket {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsUntypedBracket{}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsSpliceE {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsGetField {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr e :: HsExpr GhcTc
e@(HsProjection {}) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr (HsProc XProc GhcTc
x LPat GhcTc
pat LHsCmdTop GhcTc
cmdtop) =
(GenLocated SrcSpanAnnA (Pat GhcTc)
-> GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (Pat GhcTc))
-> TM (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc))
-> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XProc GhcTc -> LPat GhcTc -> LHsCmdTop GhcTc -> HsExpr GhcTc
forall p. XProc p -> LPat p -> LHsCmdTop p -> HsExpr p
HsProc XProc GhcTc
x)
(LPat GhcTc -> TM (LPat GhcTc)
addTickLPat LPat GhcTc
pat)
((HsCmdTop GhcTc -> TM (HsCmdTop GhcTc))
-> GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)
-> TM (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL (HsCmdTop GhcTc -> TM (HsCmdTop GhcTc)
addTickHsCmdTop) LHsCmdTop GhcTc
GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)
cmdtop)
addTickHsExpr (XExpr (WrapExpr (HsWrap HsWrapper
w HsExpr GhcTc
e))) =
(HsExpr GhcTc -> HsExpr GhcTc)
-> TM (HsExpr GhcTc) -> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XXExpr GhcTc -> HsExpr GhcTc
XXExprGhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (XXExprGhcTc -> HsExpr GhcTc)
-> (HsExpr GhcTc -> XXExprGhcTc) -> HsExpr GhcTc -> HsExpr GhcTc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsWrap HsExpr -> XXExprGhcTc
WrapExpr (HsWrap HsExpr -> XXExprGhcTc)
-> (HsExpr GhcTc -> HsWrap HsExpr) -> HsExpr GhcTc -> XXExprGhcTc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsWrapper -> HsExpr GhcTc -> HsWrap HsExpr
forall (hs_syn :: * -> *).
HsWrapper -> hs_syn GhcTc -> HsWrap hs_syn
HsWrap HsWrapper
w) (TM (HsExpr GhcTc) -> TM (HsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (HsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$
(HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e)
addTickHsExpr (XExpr (ExpansionExpr (HsExpanded HsExpr GhcRn
a HsExpr GhcTc
b))) =
(HsExpr GhcTc -> HsExpr GhcTc)
-> TM (HsExpr GhcTc) -> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XXExpr GhcTc -> HsExpr GhcTc
XXExprGhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (XXExprGhcTc -> HsExpr GhcTc)
-> (HsExpr GhcTc -> XXExprGhcTc) -> HsExpr GhcTc -> HsExpr GhcTc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsExpansion (HsExpr GhcRn) (HsExpr GhcTc) -> XXExprGhcTc
ExpansionExpr (HsExpansion (HsExpr GhcRn) (HsExpr GhcTc) -> XXExprGhcTc)
-> (HsExpr GhcTc -> HsExpansion (HsExpr GhcRn) (HsExpr GhcTc))
-> HsExpr GhcTc
-> XXExprGhcTc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsExpr GhcRn
-> HsExpr GhcTc -> HsExpansion (HsExpr GhcRn) (HsExpr GhcTc)
forall orig expanded. orig -> expanded -> HsExpansion orig expanded
HsExpanded HsExpr GhcRn
a) (TM (HsExpr GhcTc) -> TM (HsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (HsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$
(HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
b)
addTickHsExpr e :: HsExpr GhcTc
e@(XExpr (ConLikeTc {})) = HsExpr GhcTc -> TM (HsExpr GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcTc
e
addTickHsExpr (XExpr (HsTick CoreTickish
t LHsExpr GhcTc
e)) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XXExpr GhcTc -> HsExpr GhcTc
XXExprGhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (XXExprGhcTc -> HsExpr GhcTc)
-> (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsExpr GhcTc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoreTickish -> LHsExpr GhcTc -> XXExprGhcTc
HsTick CoreTickish
t) (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e)
addTickHsExpr (XExpr (HsBinTick Int
t0 Int
t1 LHsExpr GhcTc
e)) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XXExpr GhcTc -> HsExpr GhcTc
XXExprGhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (XXExprGhcTc -> HsExpr GhcTc)
-> (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsExpr GhcTc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> LHsExpr GhcTc -> XXExprGhcTc
HsBinTick Int
t0 Int
t1) (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever LHsExpr GhcTc
e)
addTickTupArg :: HsTupArg GhcTc -> TM (HsTupArg GhcTc)
addTickTupArg :: HsTupArg GhcTc -> TM (HsTupArg GhcTc)
addTickTupArg (Present XPresent GhcTc
x LHsExpr GhcTc
e) = do { GenLocated SrcSpanAnnA (HsExpr GhcTc)
e' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e
; HsTupArg GhcTc -> TM (HsTupArg GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPresent GhcTc -> LHsExpr GhcTc -> HsTupArg GhcTc
forall id. XPresent id -> LHsExpr id -> HsTupArg id
Present XPresent GhcTc
x LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e') }
addTickTupArg (Missing XMissing GhcTc
ty) = HsTupArg GhcTc -> TM (HsTupArg GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XMissing GhcTc -> HsTupArg GhcTc
forall id. XMissing id -> HsTupArg id
Missing XMissing GhcTc
ty)
addTickMatchGroup :: Bool -> MatchGroup GhcTc (LHsExpr GhcTc)
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup :: Bool
-> MatchGroup GhcTc (LHsExpr GhcTc)
-> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup Bool
is_lam mg :: MatchGroup GhcTc (LHsExpr GhcTc)
mg@(MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
matches }) = do
let isOneOfMany :: Bool
isOneOfMany = [LMatch GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))] -> Bool
forall body. [LMatch GhcTc body] -> Bool
matchesOneOfMany [LMatch GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
matches
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
matches' <- (GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL (Bool
-> Bool
-> Match GhcTc (LHsExpr GhcTc)
-> TM (Match GhcTc (LHsExpr GhcTc))
addTickMatch Bool
isOneOfMany Bool
is_lam)) [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
matches
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ MatchGroup GhcTc (LHsExpr GhcTc)
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
mg { mg_alts :: XRec GhcTc [LMatch GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
mg_alts = SrcSpanAnnL
-> [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> GenLocated
SrcSpanAnnL
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
matches' }
addTickMatch :: Bool -> Bool -> Match GhcTc (LHsExpr GhcTc)
-> TM (Match GhcTc (LHsExpr GhcTc))
addTickMatch :: Bool
-> Bool
-> Match GhcTc (LHsExpr GhcTc)
-> TM (Match GhcTc (LHsExpr GhcTc))
addTickMatch Bool
isOneOfMany Bool
isLambda match :: Match GhcTc (LHsExpr GhcTc)
match@(Match { m_pats :: forall p body. Match p body -> [LPat p]
m_pats = [LPat GhcTc]
pats
, m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs GhcTc (LHsExpr GhcTc)
gRHSs }) =
[Id]
-> TM (Match GhcTc (LHsExpr GhcTc))
-> TM (Match GhcTc (LHsExpr GhcTc))
forall a. [Id] -> TM a -> TM a
bindLocals (CollectFlag GhcTc -> [LPat GhcTc] -> [IdP GhcTc]
forall p. CollectPass p => CollectFlag p -> [LPat p] -> [IdP p]
collectPatsBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders [LPat GhcTc]
pats) (TM (Match GhcTc (LHsExpr GhcTc))
-> TM (Match GhcTc (LHsExpr GhcTc)))
-> TM (Match GhcTc (LHsExpr GhcTc))
-> TM (Match GhcTc (LHsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$ do
GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
gRHSs' <- Bool
-> Bool
-> GRHSs GhcTc (LHsExpr GhcTc)
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
addTickGRHSs Bool
isOneOfMany Bool
isLambda GRHSs GhcTc (LHsExpr GhcTc)
gRHSs
Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ Match GhcTc (LHsExpr GhcTc)
Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
match { m_grhss :: GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
m_grhss = GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
gRHSs' }
addTickGRHSs :: Bool -> Bool -> GRHSs GhcTc (LHsExpr GhcTc)
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
addTickGRHSs :: Bool
-> Bool
-> GRHSs GhcTc (LHsExpr GhcTc)
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
addTickGRHSs Bool
isOneOfMany Bool
isLambda (GRHSs XCGRHSs GhcTc (LHsExpr GhcTc)
x [LGRHS GhcTc (LHsExpr GhcTc)]
guarded HsLocalBinds GhcTc
local_binds) =
[Id]
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
forall a. [Id] -> TM a -> TM a
bindLocals [IdP GhcTc]
[Id]
binders (TM (GRHSs GhcTc (LHsExpr GhcTc))
-> TM (GRHSs GhcTc (LHsExpr GhcTc)))
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
-> TM (GRHSs GhcTc (LHsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$ do
HsLocalBinds GhcTc
local_binds' <- HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds HsLocalBinds GhcTc
local_binds
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
guarded' <- (GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL (Bool
-> Bool
-> GRHS GhcTc (LHsExpr GhcTc)
-> TM (GRHS GhcTc (LHsExpr GhcTc))
addTickGRHS Bool
isOneOfMany Bool
isLambda)) [LGRHS GhcTc (LHsExpr GhcTc)]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
guarded
GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ XCGRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> [LGRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
-> HsLocalBinds GhcTc
-> GRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall p body.
XCGRHSs p body -> [LGRHS p body] -> HsLocalBinds p -> GRHSs p body
GRHSs XCGRHSs GhcTc (LHsExpr GhcTc)
XCGRHSs GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
x [LGRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
guarded' HsLocalBinds GhcTc
local_binds'
where
binders :: [IdP GhcTc]
binders = CollectFlag GhcTc -> HsLocalBinds GhcTc -> [IdP GhcTc]
forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders HsLocalBinds GhcTc
local_binds
addTickGRHS :: Bool -> Bool -> GRHS GhcTc (LHsExpr GhcTc)
-> TM (GRHS GhcTc (LHsExpr GhcTc))
addTickGRHS :: Bool
-> Bool
-> GRHS GhcTc (LHsExpr GhcTc)
-> TM (GRHS GhcTc (LHsExpr GhcTc))
addTickGRHS Bool
isOneOfMany Bool
isLambda (GRHS XCGRHS GhcTc (LHsExpr GhcTc)
x [ExprLStmt GhcTc]
stmts LHsExpr GhcTc
expr) = do
([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts',GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr') <- Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc]
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM ([ExprLStmt GhcTc], GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a.
Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM a -> TM ([ExprLStmt GhcTc], a)
addTickLStmts' ((Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel)
forall a. a -> Maybe a
Just ((Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel))
-> (Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel)
forall a b. (a -> b) -> a -> b
$ CondBox -> Bool -> BoxLabel
BinBox (CondBox -> Bool -> BoxLabel) -> CondBox -> Bool -> BoxLabel
forall a b. (a -> b) -> a -> b
$ CondBox
GuardBinBox) [ExprLStmt GhcTc]
stmts
(Bool -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickGRHSBody Bool
isOneOfMany Bool
isLambda LHsExpr GhcTc
expr)
GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ XCGRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> [ExprLStmt GhcTc]
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS XCGRHS GhcTc (LHsExpr GhcTc)
XCGRHS GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
x [ExprLStmt GhcTc]
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts' GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr'
addTickGRHSBody :: Bool -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickGRHSBody :: Bool -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickGRHSBody Bool
isOneOfMany Bool
isLambda expr :: LHsExpr GhcTc
expr@(L SrcSpanAnnA
pos HsExpr GhcTc
e0) = do
TickDensity
d <- TM TickDensity
getDensity
case TickDensity
d of
TickDensity
TickForCoverage -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprOptAlt Bool
isOneOfMany LHsExpr GhcTc
expr
TickDensity
TickAllFunctions | Bool
isLambda ->
FilePath
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. FilePath -> TM a -> TM a
addPathEntry FilePath
"\\" (TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$
BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox (Bool -> BoxLabel
ExpBox Bool
False) Bool
True Bool
False (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
pos) (TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$
HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr HsExpr GhcTc
e0
TickDensity
_otherwise ->
LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS LHsExpr GhcTc
expr
addTickLStmts :: (Maybe (Bool -> BoxLabel)) -> [ExprLStmt GhcTc]
-> TM [ExprLStmt GhcTc]
addTickLStmts :: Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM [ExprLStmt GhcTc]
addTickLStmts Maybe (Bool -> BoxLabel)
isGuard [ExprLStmt GhcTc]
stmts = do
([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts, ()
_) <- Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM () -> TM ([ExprLStmt GhcTc], ())
forall a.
Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM a -> TM ([ExprLStmt GhcTc], a)
addTickLStmts' Maybe (Bool -> BoxLabel)
isGuard [ExprLStmt GhcTc]
stmts (() -> TM ()
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts
addTickLStmts' :: (Maybe (Bool -> BoxLabel)) -> [ExprLStmt GhcTc] -> TM a
-> TM ([ExprLStmt GhcTc], a)
addTickLStmts' :: forall a.
Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM a -> TM ([ExprLStmt GhcTc], a)
addTickLStmts' Maybe (Bool -> BoxLabel)
isGuard [ExprLStmt GhcTc]
lstmts TM a
res
= [Id] -> TM ([ExprLStmt GhcTc], a) -> TM ([ExprLStmt GhcTc], a)
forall a. [Id] -> TM a -> TM a
bindLocals (CollectFlag GhcTc
-> [LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
-> [IdP GhcTc]
forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders [ExprLStmt GhcTc]
[LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
lstmts) (TM ([ExprLStmt GhcTc], a) -> TM ([ExprLStmt GhcTc], a))
-> TM ([ExprLStmt GhcTc], a) -> TM ([ExprLStmt GhcTc], a)
forall a b. (a -> b) -> a -> b
$
do { [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
lstmts' <- (GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL (Maybe (Bool -> BoxLabel)
-> Stmt GhcTc (LHsExpr GhcTc) -> TM (Stmt GhcTc (LHsExpr GhcTc))
addTickStmt Maybe (Bool -> BoxLabel)
isGuard)) [ExprLStmt GhcTc]
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
lstmts
; a
a <- TM a
res
; ([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))],
a)
-> TM
([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))],
a)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
lstmts', a
a) }
addTickStmt :: (Maybe (Bool -> BoxLabel)) -> Stmt GhcTc (LHsExpr GhcTc)
-> TM (Stmt GhcTc (LHsExpr GhcTc))
addTickStmt :: Maybe (Bool -> BoxLabel)
-> Stmt GhcTc (LHsExpr GhcTc) -> TM (Stmt GhcTc (LHsExpr GhcTc))
addTickStmt Maybe (Bool -> BoxLabel)
_isGuard (LastStmt XLastStmt GhcTc GhcTc (LHsExpr GhcTc)
x LHsExpr GhcTc
e Maybe Bool
noret SyntaxExpr GhcTc
ret) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> Maybe Bool
-> SyntaxExprTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (Maybe Bool)
-> TM SyntaxExprTc
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XLastStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> Maybe Bool
-> SyntaxExpr GhcTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall idL idR body.
XLastStmt idL idR body
-> body -> Maybe Bool -> SyntaxExpr idR -> StmtLR idL idR body
LastStmt XLastStmt GhcTc GhcTc (LHsExpr GhcTc)
XLastStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
(Maybe Bool -> TM (Maybe Bool)
forall a. a -> TM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Bool
noret)
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
ret)
addTickStmt Maybe (Bool -> BoxLabel)
_isGuard (BindStmt XBindStmt GhcTc GhcTc (LHsExpr GhcTc)
xbs LPat GhcTc
pat LHsExpr GhcTc
e) =
(SyntaxExprTc
-> Maybe SyntaxExprTc
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM SyntaxExprTc
-> TM (Maybe SyntaxExprTc)
-> TM (GenLocated SrcSpanAnnA (Pat GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 (\SyntaxExprTc
b Maybe SyntaxExprTc
f -> XBindStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> LPat GhcTc
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt (XBindStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> LPat GhcTc
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> XBindStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> LPat GhcTc
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$ XBindStmtTc
{ xbstc_bindOp :: SyntaxExpr GhcTc
xbstc_bindOp = SyntaxExpr GhcTc
SyntaxExprTc
b
, xbstc_boundResultType :: Type
xbstc_boundResultType = XBindStmtTc -> Type
xbstc_boundResultType XBindStmt GhcTc GhcTc (LHsExpr GhcTc)
XBindStmtTc
xbs
, xbstc_boundResultMult :: Type
xbstc_boundResultMult = XBindStmtTc -> Type
xbstc_boundResultMult XBindStmt GhcTc GhcTc (LHsExpr GhcTc)
XBindStmtTc
xbs
, xbstc_failOp :: Maybe (SyntaxExpr GhcTc)
xbstc_failOp = Maybe (SyntaxExpr GhcTc)
Maybe SyntaxExprTc
f
})
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (XBindStmtTc -> SyntaxExpr GhcTc
xbstc_bindOp XBindStmt GhcTc GhcTc (LHsExpr GhcTc)
XBindStmtTc
xbs))
((SyntaxExprTc -> TM SyntaxExprTc)
-> Maybe SyntaxExprTc -> TM (Maybe SyntaxExprTc)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM (SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan) (XBindStmtTc -> Maybe (SyntaxExpr GhcTc)
xbstc_failOp XBindStmt GhcTc GhcTc (LHsExpr GhcTc)
XBindStmtTc
xbs))
(LPat GhcTc -> TM (LPat GhcTc)
addTickLPat LPat GhcTc
pat)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS LHsExpr GhcTc
e)
addTickStmt Maybe (Bool -> BoxLabel)
isGuard (BodyStmt XBodyStmt GhcTc GhcTc (LHsExpr GhcTc)
x LHsExpr GhcTc
e SyntaxExpr GhcTc
bind' SyntaxExpr GhcTc
guard') =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> SyntaxExprTc
-> SyntaxExprTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM SyntaxExprTc
-> TM SyntaxExprTc
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XBodyStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> SyntaxExpr GhcTc
-> SyntaxExpr GhcTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall idL idR body.
XBodyStmt idL idR body
-> body -> SyntaxExpr idR -> SyntaxExpr idR -> StmtLR idL idR body
BodyStmt XBodyStmt GhcTc GhcTc (LHsExpr GhcTc)
XBodyStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
x)
(Maybe (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTick Maybe (Bool -> BoxLabel)
isGuard LHsExpr GhcTc
e)
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
bind')
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
guard')
addTickStmt Maybe (Bool -> BoxLabel)
_isGuard (LetStmt XLetStmt GhcTc GhcTc (LHsExpr GhcTc)
x HsLocalBinds GhcTc
binds) =
(HsLocalBinds GhcTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM (HsLocalBinds GhcTc)
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XLetStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> HsLocalBinds GhcTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall idL idR body.
XLetStmt idL idR body
-> HsLocalBindsLR idL idR -> StmtLR idL idR body
LetStmt XLetStmt GhcTc GhcTc (LHsExpr GhcTc)
XLetStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
x)
(HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds HsLocalBinds GhcTc
binds)
addTickStmt Maybe (Bool -> BoxLabel)
isGuard (ParStmt XParStmt GhcTc GhcTc (LHsExpr GhcTc)
x [ParStmtBlock GhcTc GhcTc]
pairs HsExpr GhcTc
mzipExpr SyntaxExpr GhcTc
bindExpr) =
([ParStmtBlock GhcTc GhcTc]
-> HsExpr GhcTc
-> SyntaxExprTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM [ParStmtBlock GhcTc GhcTc]
-> TM (HsExpr GhcTc)
-> TM SyntaxExprTc
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XParStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> [ParStmtBlock GhcTc GhcTc]
-> HsExpr GhcTc
-> SyntaxExpr GhcTc
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall idL idR body.
XParStmt idL idR body
-> [ParStmtBlock idL idR]
-> HsExpr idR
-> SyntaxExpr idR
-> StmtLR idL idR body
ParStmt XParStmt GhcTc GhcTc (LHsExpr GhcTc)
XParStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
x)
((ParStmtBlock GhcTc GhcTc -> TM (ParStmtBlock GhcTc GhcTc))
-> [ParStmtBlock GhcTc GhcTc] -> TM [ParStmtBlock GhcTc GhcTc]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Maybe (Bool -> BoxLabel)
-> ParStmtBlock GhcTc GhcTc -> TM (ParStmtBlock GhcTc GhcTc)
addTickStmtAndBinders Maybe (Bool -> BoxLabel)
isGuard) [ParStmtBlock GhcTc GhcTc]
pairs)
(GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
hpcSrcSpan) HsExpr GhcTc
mzipExpr))
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
bindExpr)
addTickStmt Maybe (Bool -> BoxLabel)
isGuard (ApplicativeStmt XApplicativeStmt GhcTc GhcTc (LHsExpr GhcTc)
body_ty [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)]
args Maybe (SyntaxExpr GhcTc)
mb_join) = do
[(SyntaxExprTc, ApplicativeArg GhcTc)]
args' <- ((SyntaxExprTc, ApplicativeArg GhcTc)
-> TM (SyntaxExprTc, ApplicativeArg GhcTc))
-> [(SyntaxExprTc, ApplicativeArg GhcTc)]
-> TM [(SyntaxExprTc, ApplicativeArg GhcTc)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Maybe (Bool -> BoxLabel)
-> (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
-> TM (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
addTickApplicativeArg Maybe (Bool -> BoxLabel)
isGuard) [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)]
[(SyntaxExprTc, ApplicativeArg GhcTc)]
args
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XApplicativeStmt
GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)]
-> Maybe (SyntaxExpr GhcTc)
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall idL idR body.
XApplicativeStmt idL idR body
-> [(SyntaxExpr idR, ApplicativeArg idL)]
-> Maybe (SyntaxExpr idR)
-> StmtLR idL idR body
ApplicativeStmt XApplicativeStmt GhcTc GhcTc (LHsExpr GhcTc)
XApplicativeStmt
GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
body_ty [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)]
[(SyntaxExprTc, ApplicativeArg GhcTc)]
args' Maybe (SyntaxExpr GhcTc)
mb_join)
addTickStmt Maybe (Bool -> BoxLabel)
isGuard stmt :: Stmt GhcTc (LHsExpr GhcTc)
stmt@(TransStmt { trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_stmts = [ExprLStmt GhcTc]
stmts
, trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_by = Maybe (LHsExpr GhcTc)
by, trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_using = LHsExpr GhcTc
using
, trS_ret :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_ret = SyntaxExpr GhcTc
returnExpr, trS_bind :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_bind = SyntaxExpr GhcTc
bindExpr
, trS_fmap :: forall idL idR body. StmtLR idL idR body -> HsExpr idR
trS_fmap = HsExpr GhcTc
liftMExpr }) = do
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
t_s <- Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM [ExprLStmt GhcTc]
addTickLStmts Maybe (Bool -> BoxLabel)
isGuard [ExprLStmt GhcTc]
stmts
Maybe (GenLocated SrcSpanAnnA (HsExpr GhcTc))
t_y <- (GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> Maybe (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (Maybe (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
fmapMaybeM LHsExpr GhcTc -> TM (LHsExpr GhcTc)
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
addTickLHsExprRHS Maybe (LHsExpr GhcTc)
Maybe (GenLocated SrcSpanAnnA (HsExpr GhcTc))
by
GenLocated SrcSpanAnnA (HsExpr GhcTc)
t_u <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS LHsExpr GhcTc
using
SyntaxExprTc
t_f <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
returnExpr
SyntaxExprTc
t_b <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
bindExpr
HsExpr GhcTc
t_m <- (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall a b. (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc
forall l e. GenLocated l e -> e
unLoc (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
hpcSrcSpan) HsExpr GhcTc
liftMExpr))
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
-> StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a b. (a -> b) -> a -> b
$ Stmt GhcTc (LHsExpr GhcTc)
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
stmt { trS_stmts :: [ExprLStmt GhcTc]
trS_stmts = [ExprLStmt GhcTc]
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
t_s, trS_by :: Maybe (LHsExpr GhcTc)
trS_by = Maybe (LHsExpr GhcTc)
Maybe (GenLocated SrcSpanAnnA (HsExpr GhcTc))
t_y, trS_using :: LHsExpr GhcTc
trS_using = LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
t_u
, trS_ret :: SyntaxExpr GhcTc
trS_ret = SyntaxExpr GhcTc
SyntaxExprTc
t_f, trS_bind :: SyntaxExpr GhcTc
trS_bind = SyntaxExpr GhcTc
SyntaxExprTc
t_b, trS_fmap :: HsExpr GhcTc
trS_fmap = HsExpr GhcTc
t_m }
addTickStmt Maybe (Bool -> BoxLabel)
isGuard stmt :: Stmt GhcTc (LHsExpr GhcTc)
stmt@(RecStmt {})
= do { [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts' <- Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM [ExprLStmt GhcTc]
addTickLStmts Maybe (Bool -> BoxLabel)
isGuard (GenLocated SrcSpanAnnL [ExprLStmt GhcTc] -> [ExprLStmt GhcTc]
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnL [ExprLStmt GhcTc] -> [ExprLStmt GhcTc])
-> GenLocated SrcSpanAnnL [ExprLStmt GhcTc] -> [ExprLStmt GhcTc]
forall a b. (a -> b) -> a -> b
$ StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> XRec
GhcTc [LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_stmts Stmt GhcTc (LHsExpr GhcTc)
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
stmt)
; SyntaxExprTc
ret' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> SyntaxExpr GhcTc
forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_ret_fn Stmt GhcTc (LHsExpr GhcTc)
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
stmt)
; SyntaxExprTc
mfix' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> SyntaxExpr GhcTc
forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_mfix_fn Stmt GhcTc (LHsExpr GhcTc)
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
stmt)
; SyntaxExprTc
bind' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> SyntaxExpr GhcTc
forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_bind_fn Stmt GhcTc (LHsExpr GhcTc)
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
stmt)
; StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (Stmt GhcTc (LHsExpr GhcTc)
StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
stmt { recS_stmts :: XRec
GhcTc [LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
recS_stmts = [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> GenLocated
SrcSpanAnnL
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall a an. a -> LocatedAn an a
noLocA [GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts', recS_ret_fn :: SyntaxExpr GhcTc
recS_ret_fn = SyntaxExpr GhcTc
SyntaxExprTc
ret'
, recS_mfix_fn :: SyntaxExpr GhcTc
recS_mfix_fn = SyntaxExpr GhcTc
SyntaxExprTc
mfix', recS_bind_fn :: SyntaxExpr GhcTc
recS_bind_fn = SyntaxExpr GhcTc
SyntaxExprTc
bind' }) }
addTick :: Maybe (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTick :: Maybe (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTick Maybe (Bool -> BoxLabel)
isGuard LHsExpr GhcTc
e | Just Bool -> BoxLabel
fn <- Maybe (Bool -> BoxLabel)
isGuard = (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addBinTickLHsExpr Bool -> BoxLabel
fn LHsExpr GhcTc
e
| Bool
otherwise = LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS LHsExpr GhcTc
e
addTickApplicativeArg
:: Maybe (Bool -> BoxLabel) -> (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
-> TM (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
addTickApplicativeArg :: Maybe (Bool -> BoxLabel)
-> (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
-> TM (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
addTickApplicativeArg Maybe (Bool -> BoxLabel)
isGuard (SyntaxExpr GhcTc
op, ApplicativeArg GhcTc
arg) =
(SyntaxExprTc
-> ApplicativeArg GhcTc -> (SyntaxExprTc, ApplicativeArg GhcTc))
-> TM SyntaxExprTc
-> TM (ApplicativeArg GhcTc)
-> TM (SyntaxExprTc, ApplicativeArg GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (,) (SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
op) (ApplicativeArg GhcTc -> TM (ApplicativeArg GhcTc)
addTickArg ApplicativeArg GhcTc
arg)
where
addTickArg :: ApplicativeArg GhcTc -> TM (ApplicativeArg GhcTc)
addTickArg (ApplicativeArgOne XApplicativeArgOne GhcTc
m_fail LPat GhcTc
pat LHsExpr GhcTc
expr Bool
isBody) =
Maybe SyntaxExprTc
-> LPat GhcTc -> LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc
XApplicativeArgOne GhcTc
-> LPat GhcTc -> LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc
forall idL.
XApplicativeArgOne idL
-> LPat idL -> LHsExpr idL -> Bool -> ApplicativeArg idL
ApplicativeArgOne
(Maybe SyntaxExprTc
-> LPat GhcTc -> LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc)
-> TM (Maybe SyntaxExprTc)
-> TM (LPat GhcTc -> LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (SyntaxExprTc -> TM SyntaxExprTc)
-> Maybe SyntaxExprTc -> TM (Maybe SyntaxExprTc)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM (SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan) Maybe SyntaxExprTc
XApplicativeArgOne GhcTc
m_fail
TM (LPat GhcTc -> LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc)
-> TM (LPat GhcTc)
-> TM (LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LPat GhcTc -> TM (LPat GhcTc)
addTickLPat LPat GhcTc
pat
TM (LHsExpr GhcTc -> Bool -> ApplicativeArg GhcTc)
-> TM (LHsExpr GhcTc) -> TM (Bool -> ApplicativeArg GhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
expr
TM (Bool -> ApplicativeArg GhcTc)
-> TM Bool -> TM (ApplicativeArg GhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> TM Bool
forall a. a -> TM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
isBody
addTickArg (ApplicativeArgMany XApplicativeArgMany GhcTc
x [ExprLStmt GhcTc]
stmts HsExpr GhcTc
ret LPat GhcTc
pat HsDoFlavour
ctxt) =
(XApplicativeArgMany GhcTc
-> [ExprLStmt GhcTc]
-> HsExpr GhcTc
-> LPat GhcTc
-> HsDoFlavour
-> ApplicativeArg GhcTc
forall idL.
XApplicativeArgMany idL
-> [ExprLStmt idL]
-> HsExpr idL
-> LPat idL
-> HsDoFlavour
-> ApplicativeArg idL
ApplicativeArgMany XApplicativeArgMany GhcTc
x)
([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> HsExpr GhcTc
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> HsDoFlavour
-> ApplicativeArg GhcTc)
-> TM
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
(HsExpr GhcTc
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> HsDoFlavour
-> ApplicativeArg GhcTc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM [ExprLStmt GhcTc]
addTickLStmts Maybe (Bool -> BoxLabel)
isGuard [ExprLStmt GhcTc]
stmts
TM
(HsExpr GhcTc
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> HsDoFlavour
-> ApplicativeArg GhcTc)
-> TM (HsExpr GhcTc)
-> TM
(GenLocated SrcSpanAnnA (Pat GhcTc)
-> HsDoFlavour -> ApplicativeArg GhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
hpcSrcSpan) HsExpr GhcTc
ret))
TM
(GenLocated SrcSpanAnnA (Pat GhcTc)
-> HsDoFlavour -> ApplicativeArg GhcTc)
-> TM (GenLocated SrcSpanAnnA (Pat GhcTc))
-> TM (HsDoFlavour -> ApplicativeArg GhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LPat GhcTc -> TM (LPat GhcTc)
addTickLPat LPat GhcTc
pat
TM (HsDoFlavour -> ApplicativeArg GhcTc)
-> TM HsDoFlavour -> TM (ApplicativeArg GhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> HsDoFlavour -> TM HsDoFlavour
forall a. a -> TM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HsDoFlavour
ctxt
addTickStmtAndBinders :: Maybe (Bool -> BoxLabel) -> ParStmtBlock GhcTc GhcTc
-> TM (ParStmtBlock GhcTc GhcTc)
addTickStmtAndBinders :: Maybe (Bool -> BoxLabel)
-> ParStmtBlock GhcTc GhcTc -> TM (ParStmtBlock GhcTc GhcTc)
addTickStmtAndBinders Maybe (Bool -> BoxLabel)
isGuard (ParStmtBlock XParStmtBlock GhcTc GhcTc
x [ExprLStmt GhcTc]
stmts [IdP GhcTc]
ids SyntaxExpr GhcTc
returnExpr) =
([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> [Id] -> SyntaxExprTc -> ParStmtBlock GhcTc GhcTc)
-> TM
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM [Id]
-> TM SyntaxExprTc
-> TM (ParStmtBlock GhcTc GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XParStmtBlock GhcTc GhcTc
-> [ExprLStmt GhcTc]
-> [IdP GhcTc]
-> SyntaxExpr GhcTc
-> ParStmtBlock GhcTc GhcTc
forall idL idR.
XParStmtBlock idL idR
-> [ExprLStmt idL]
-> [IdP idR]
-> SyntaxExpr idR
-> ParStmtBlock idL idR
ParStmtBlock XParStmtBlock GhcTc GhcTc
x)
(Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM [ExprLStmt GhcTc]
addTickLStmts Maybe (Bool -> BoxLabel)
isGuard [ExprLStmt GhcTc]
stmts)
([Id] -> TM [Id]
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return [IdP GhcTc]
[Id]
ids)
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
returnExpr)
addTickHsLocalBinds :: HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds :: HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds (HsValBinds XHsValBinds GhcTc GhcTc
x HsValBindsLR GhcTc GhcTc
binds) =
(HsValBindsLR GhcTc GhcTc -> HsLocalBinds GhcTc)
-> TM (HsValBindsLR GhcTc GhcTc) -> TM (HsLocalBinds GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XHsValBinds GhcTc GhcTc
-> HsValBindsLR GhcTc GhcTc -> HsLocalBinds GhcTc
forall idL idR.
XHsValBinds idL idR
-> HsValBindsLR idL idR -> HsLocalBindsLR idL idR
HsValBinds XHsValBinds GhcTc GhcTc
x)
(HsValBindsLR GhcTc GhcTc -> TM (HsValBindsLR GhcTc GhcTc)
forall (a :: Pass) (b :: Pass).
HsValBindsLR GhcTc (GhcPass a)
-> TM (HsValBindsLR GhcTc (GhcPass b))
addTickHsValBinds HsValBindsLR GhcTc GhcTc
binds)
addTickHsLocalBinds (HsIPBinds XHsIPBinds GhcTc GhcTc
x HsIPBinds GhcTc
binds) =
(HsIPBinds GhcTc -> HsLocalBinds GhcTc)
-> TM (HsIPBinds GhcTc) -> TM (HsLocalBinds GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XHsIPBinds GhcTc GhcTc -> HsIPBinds GhcTc -> HsLocalBinds GhcTc
forall idL idR.
XHsIPBinds idL idR -> HsIPBinds idR -> HsLocalBindsLR idL idR
HsIPBinds XHsIPBinds GhcTc GhcTc
x)
(HsIPBinds GhcTc -> TM (HsIPBinds GhcTc)
addTickHsIPBinds HsIPBinds GhcTc
binds)
addTickHsLocalBinds (EmptyLocalBinds XEmptyLocalBinds GhcTc GhcTc
x) = HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XEmptyLocalBinds GhcTc GhcTc -> HsLocalBinds GhcTc
forall idL idR. XEmptyLocalBinds idL idR -> HsLocalBindsLR idL idR
EmptyLocalBinds XEmptyLocalBinds GhcTc GhcTc
x)
addTickHsValBinds :: HsValBindsLR GhcTc (GhcPass a)
-> TM (HsValBindsLR GhcTc (GhcPass b))
addTickHsValBinds :: forall (a :: Pass) (b :: Pass).
HsValBindsLR GhcTc (GhcPass a)
-> TM (HsValBindsLR GhcTc (GhcPass b))
addTickHsValBinds (XValBindsLR (NValBinds [(RecFlag, LHsBinds GhcTc)]
binds [LSig GhcRn]
sigs)) = do
NHsValBindsLR GhcTc
b <- ([(RecFlag, LHsBinds GhcTc)]
-> [GenLocated SrcSpanAnnA (Sig GhcRn)] -> NHsValBindsLR GhcTc)
-> TM [(RecFlag, LHsBinds GhcTc)]
-> TM [GenLocated SrcSpanAnnA (Sig GhcRn)]
-> TM (NHsValBindsLR GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 [(RecFlag, LHsBinds GhcTc)] -> [LSig GhcRn] -> NHsValBindsLR GhcTc
[(RecFlag, LHsBinds GhcTc)]
-> [GenLocated SrcSpanAnnA (Sig GhcRn)] -> NHsValBindsLR GhcTc
forall idL.
[(RecFlag, LHsBinds idL)] -> [LSig GhcRn] -> NHsValBindsLR idL
NValBinds
(((RecFlag, Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> TM (RecFlag, LHsBinds GhcTc))
-> [(RecFlag, Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))]
-> TM [(RecFlag, LHsBinds GhcTc)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\ (RecFlag
rec,Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds') ->
(RecFlag -> LHsBinds GhcTc -> (RecFlag, LHsBinds GhcTc))
-> TM RecFlag
-> TM (LHsBinds GhcTc)
-> TM (RecFlag, LHsBinds GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (,)
(RecFlag -> TM RecFlag
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return RecFlag
rec)
(LHsBinds GhcTc -> TM (LHsBinds GhcTc)
addTickLHsBinds LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds'))
[(RecFlag, LHsBinds GhcTc)]
[(RecFlag, Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))]
binds)
([GenLocated SrcSpanAnnA (Sig GhcRn)]
-> TM [GenLocated SrcSpanAnnA (Sig GhcRn)]
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return [LSig GhcRn]
[GenLocated SrcSpanAnnA (Sig GhcRn)]
sigs)
HsValBindsLR GhcTc (GhcPass b)
-> TM (HsValBindsLR GhcTc (GhcPass b))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsValBindsLR GhcTc (GhcPass b)
-> TM (HsValBindsLR GhcTc (GhcPass b)))
-> HsValBindsLR GhcTc (GhcPass b)
-> TM (HsValBindsLR GhcTc (GhcPass b))
forall a b. (a -> b) -> a -> b
$ XXValBindsLR GhcTc (GhcPass b) -> HsValBindsLR GhcTc (GhcPass b)
forall idL idR. XXValBindsLR idL idR -> HsValBindsLR idL idR
XValBindsLR XXValBindsLR GhcTc (GhcPass b)
NHsValBindsLR GhcTc
b
addTickHsValBinds HsValBindsLR GhcTc (GhcPass a)
_ = FilePath -> TM (HsValBindsLR GhcTc (GhcPass b))
forall a. FilePath -> a
panic FilePath
"addTickHsValBinds"
addTickHsIPBinds :: HsIPBinds GhcTc -> TM (HsIPBinds GhcTc)
addTickHsIPBinds :: HsIPBinds GhcTc -> TM (HsIPBinds GhcTc)
addTickHsIPBinds (IPBinds XIPBinds GhcTc
dictbinds [LIPBind GhcTc]
ipbinds) =
(TcEvBinds
-> [GenLocated SrcSpanAnnA (IPBind GhcTc)] -> HsIPBinds GhcTc)
-> TM TcEvBinds
-> TM [GenLocated SrcSpanAnnA (IPBind GhcTc)]
-> TM (HsIPBinds GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 XIPBinds GhcTc -> [LIPBind GhcTc] -> HsIPBinds GhcTc
TcEvBinds
-> [GenLocated SrcSpanAnnA (IPBind GhcTc)] -> HsIPBinds GhcTc
forall id. XIPBinds id -> [LIPBind id] -> HsIPBinds id
IPBinds
(TcEvBinds -> TM TcEvBinds
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XIPBinds GhcTc
TcEvBinds
dictbinds)
((GenLocated SrcSpanAnnA (IPBind GhcTc)
-> TM (GenLocated SrcSpanAnnA (IPBind GhcTc)))
-> [GenLocated SrcSpanAnnA (IPBind GhcTc)]
-> TM [GenLocated SrcSpanAnnA (IPBind GhcTc)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((IPBind GhcTc -> TM (IPBind GhcTc))
-> GenLocated SrcSpanAnnA (IPBind GhcTc)
-> TM (GenLocated SrcSpanAnnA (IPBind GhcTc))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL (IPBind GhcTc -> TM (IPBind GhcTc)
addTickIPBind)) [LIPBind GhcTc]
[GenLocated SrcSpanAnnA (IPBind GhcTc)]
ipbinds)
addTickIPBind :: IPBind GhcTc -> TM (IPBind GhcTc)
addTickIPBind :: IPBind GhcTc -> TM (IPBind GhcTc)
addTickIPBind (IPBind XCIPBind GhcTc
x XRec GhcTc HsIPName
nm LHsExpr GhcTc
e) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc) -> IPBind GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (IPBind GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XCIPBind GhcTc
-> XRec GhcTc HsIPName -> LHsExpr GhcTc -> IPBind GhcTc
forall id.
XCIPBind id -> XRec id HsIPName -> LHsExpr id -> IPBind id
IPBind XCIPBind GhcTc
x XRec GhcTc HsIPName
nm)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
addTickSyntaxExpr :: SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr :: SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
pos syn :: SyntaxExpr GhcTc
syn@(SyntaxExprTc { syn_expr :: SyntaxExprTc -> HsExpr GhcTc
syn_expr = HsExpr GhcTc
x }) = do
HsExpr GhcTc
x' <- (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM (HsExpr GhcTc)
forall a b. (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsExpr GhcTc
forall l e. GenLocated l e -> e
unLoc (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
pos) HsExpr GhcTc
x))
SyntaxExprTc -> TM SyntaxExprTc
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SyntaxExprTc -> TM SyntaxExprTc)
-> SyntaxExprTc -> TM SyntaxExprTc
forall a b. (a -> b) -> a -> b
$ SyntaxExpr GhcTc
SyntaxExprTc
syn { syn_expr :: HsExpr GhcTc
syn_expr = HsExpr GhcTc
x' }
addTickSyntaxExpr SrcSpan
_ SyntaxExpr GhcTc
SyntaxExprTc
NoSyntaxExprTc = SyntaxExprTc -> TM SyntaxExprTc
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return SyntaxExprTc
NoSyntaxExprTc
addTickLPat :: LPat GhcTc -> TM (LPat GhcTc)
addTickLPat :: LPat GhcTc -> TM (LPat GhcTc)
addTickLPat LPat GhcTc
pat = GenLocated SrcSpanAnnA (Pat GhcTc)
-> TM (GenLocated SrcSpanAnnA (Pat GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return LPat GhcTc
GenLocated SrcSpanAnnA (Pat GhcTc)
pat
addTickHsCmdTop :: HsCmdTop GhcTc -> TM (HsCmdTop GhcTc)
addTickHsCmdTop :: HsCmdTop GhcTc -> TM (HsCmdTop GhcTc)
addTickHsCmdTop (HsCmdTop XCmdTop GhcTc
x LHsCmd GhcTc
cmd) =
(CmdTopTc
-> GenLocated SrcSpanAnnA (HsCmd GhcTc) -> HsCmdTop GhcTc)
-> TM CmdTopTc
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (HsCmdTop GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 XCmdTop GhcTc -> LHsCmd GhcTc -> HsCmdTop GhcTc
CmdTopTc -> GenLocated SrcSpanAnnA (HsCmd GhcTc) -> HsCmdTop GhcTc
forall p. XCmdTop p -> LHsCmd p -> HsCmdTop p
HsCmdTop
(CmdTopTc -> TM CmdTopTc
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XCmdTop GhcTc
CmdTopTc
x)
(LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
cmd)
addTickLHsCmd :: LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd :: LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd (L SrcSpanAnnA
pos HsCmd GhcTc
c0) = do
HsCmd GhcTc
c1 <- HsCmd GhcTc -> TM (HsCmd GhcTc)
addTickHsCmd HsCmd GhcTc
c0
GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> HsCmd GhcTc -> GenLocated SrcSpanAnnA (HsCmd GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos HsCmd GhcTc
c1
addTickHsCmd :: HsCmd GhcTc -> TM (HsCmd GhcTc)
addTickHsCmd :: HsCmd GhcTc -> TM (HsCmd GhcTc)
addTickHsCmd (HsCmdLam XCmdLam GhcTc
x MatchGroup GhcTc (LHsCmd GhcTc)
matchgroup) =
(MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> HsCmd GhcTc)
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XCmdLam GhcTc -> MatchGroup GhcTc (LHsCmd GhcTc) -> HsCmd GhcTc
forall id. XCmdLam id -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdLam XCmdLam GhcTc
x) (MatchGroup GhcTc (LHsCmd GhcTc)
-> TM (MatchGroup GhcTc (LHsCmd GhcTc))
addTickCmdMatchGroup MatchGroup GhcTc (LHsCmd GhcTc)
matchgroup)
addTickHsCmd (HsCmdApp XCmdApp GhcTc
x LHsCmd GhcTc
c LHsExpr GhcTc
e) =
(GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XCmdApp GhcTc -> LHsCmd GhcTc -> LHsExpr GhcTc -> HsCmd GhcTc
forall id. XCmdApp id -> LHsCmd id -> LHsExpr id -> HsCmd id
HsCmdApp XCmdApp GhcTc
x) (LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c) (LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
addTickHsCmd (HsCmdPar XCmdPar GhcTc
x LHsToken "(" GhcTc
lpar LHsCmd GhcTc
e LHsToken ")" GhcTc
rpar) = do
GenLocated SrcSpanAnnA (HsCmd GhcTc)
e' <- LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
e
HsCmd GhcTc -> TM (HsCmd GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdPar GhcTc
-> LHsToken "(" GhcTc
-> LHsCmd GhcTc
-> LHsToken ")" GhcTc
-> HsCmd GhcTc
forall id.
XCmdPar id
-> LHsToken "(" id -> LHsCmd id -> LHsToken ")" id -> HsCmd id
HsCmdPar XCmdPar GhcTc
x LHsToken "(" GhcTc
lpar LHsCmd GhcTc
GenLocated SrcSpanAnnA (HsCmd GhcTc)
e' LHsToken ")" GhcTc
rpar)
addTickHsCmd (HsCmdCase XCmdCase GhcTc
x LHsExpr GhcTc
e MatchGroup GhcTc (LHsCmd GhcTc)
mgs) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XCmdCase GhcTc
-> LHsExpr GhcTc -> MatchGroup GhcTc (LHsCmd GhcTc) -> HsCmd GhcTc
forall id.
XCmdCase id -> LHsExpr id -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdCase XCmdCase GhcTc
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
(MatchGroup GhcTc (LHsCmd GhcTc)
-> TM (MatchGroup GhcTc (LHsCmd GhcTc))
addTickCmdMatchGroup MatchGroup GhcTc (LHsCmd GhcTc)
mgs)
addTickHsCmd (HsCmdLamCase XCmdLamCase GhcTc
x LamCaseVariant
lc_variant MatchGroup GhcTc (LHsCmd GhcTc)
mgs) =
(MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> HsCmd GhcTc)
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XCmdLamCase GhcTc
-> LamCaseVariant -> MatchGroup GhcTc (LHsCmd GhcTc) -> HsCmd GhcTc
forall id.
XCmdLamCase id
-> LamCaseVariant -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdLamCase XCmdLamCase GhcTc
x LamCaseVariant
lc_variant) (MatchGroup GhcTc (LHsCmd GhcTc)
-> TM (MatchGroup GhcTc (LHsCmd GhcTc))
addTickCmdMatchGroup MatchGroup GhcTc (LHsCmd GhcTc)
mgs)
addTickHsCmd (HsCmdIf XCmdIf GhcTc
x SyntaxExpr GhcTc
cnd LHsExpr GhcTc
e1 LHsCmd GhcTc
c2 LHsCmd GhcTc
c3) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XCmdIf GhcTc
-> SyntaxExpr GhcTc
-> LHsExpr GhcTc
-> LHsCmd GhcTc
-> LHsCmd GhcTc
-> HsCmd GhcTc
forall id.
XCmdIf id
-> SyntaxExpr id
-> LHsExpr id
-> LHsCmd id
-> LHsCmd id
-> HsCmd id
HsCmdIf XCmdIf GhcTc
x SyntaxExpr GhcTc
cnd)
((Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addBinTickLHsExpr (CondBox -> Bool -> BoxLabel
BinBox CondBox
CondBinBox) LHsExpr GhcTc
e1)
(LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c2)
(LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c3)
addTickHsCmd (HsCmdLet XCmdLet GhcTc
x LHsToken "let" GhcTc
tkLet HsLocalBinds GhcTc
binds LHsToken "in" GhcTc
tkIn LHsCmd GhcTc
c) =
[Id] -> TM (HsCmd GhcTc) -> TM (HsCmd GhcTc)
forall a. [Id] -> TM a -> TM a
bindLocals (CollectFlag GhcTc -> HsLocalBinds GhcTc -> [IdP GhcTc]
forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders HsLocalBinds GhcTc
binds) (TM (HsCmd GhcTc) -> TM (HsCmd GhcTc))
-> TM (HsCmd GhcTc) -> TM (HsCmd GhcTc)
forall a b. (a -> b) -> a -> b
$ do
HsLocalBinds GhcTc
binds' <- HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds HsLocalBinds GhcTc
binds
GenLocated SrcSpanAnnA (HsCmd GhcTc)
c' <- LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c
HsCmd GhcTc -> TM (HsCmd GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdLet GhcTc
-> LHsToken "let" GhcTc
-> HsLocalBinds GhcTc
-> LHsToken "in" GhcTc
-> LHsCmd GhcTc
-> HsCmd GhcTc
forall id.
XCmdLet id
-> LHsToken "let" id
-> HsLocalBinds id
-> LHsToken "in" id
-> LHsCmd id
-> HsCmd id
HsCmdLet XCmdLet GhcTc
x LHsToken "let" GhcTc
tkLet HsLocalBinds GhcTc
binds' LHsToken "in" GhcTc
tkIn LHsCmd GhcTc
GenLocated SrcSpanAnnA (HsCmd GhcTc)
c')
addTickHsCmd (HsCmdDo XCmdDo GhcTc
srcloc (L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts))
= do { ([GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts', ()
_) <- [CmdLStmt GhcTc] -> TM () -> TM ([CmdLStmt GhcTc], ())
forall a. [CmdLStmt GhcTc] -> TM a -> TM ([CmdLStmt GhcTc], a)
addTickLCmdStmts' [CmdLStmt GhcTc]
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts (() -> TM ()
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
; HsCmd GhcTc -> TM (HsCmd GhcTc)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdDo GhcTc -> XRec GhcTc [CmdLStmt GhcTc] -> HsCmd GhcTc
forall id. XCmdDo id -> XRec id [CmdLStmt id] -> HsCmd id
HsCmdDo XCmdDo GhcTc
srcloc (SrcSpanAnnL
-> [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> GenLocated
SrcSpanAnnL
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts')) }
addTickHsCmd (HsCmdArrApp XCmdArrApp GhcTc
arr_ty LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 HsArrAppType
ty1 Bool
lr) =
(Type
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsArrAppType
-> Bool
-> HsCmd GhcTc)
-> TM Type
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM HsArrAppType
-> TM Bool
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 a2 a3 a4 a5 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> a5 -> r)
-> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
liftM5 XCmdArrApp GhcTc
-> LHsExpr GhcTc
-> LHsExpr GhcTc
-> HsArrAppType
-> Bool
-> HsCmd GhcTc
Type
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> HsArrAppType
-> Bool
-> HsCmd GhcTc
forall id.
XCmdArrApp id
-> LHsExpr id -> LHsExpr id -> HsArrAppType -> Bool -> HsCmd id
HsCmdArrApp
(Type -> TM Type
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return XCmdArrApp GhcTc
Type
arr_ty)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e2)
(HsArrAppType -> TM HsArrAppType
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return HsArrAppType
ty1)
(Bool -> TM Bool
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
lr)
addTickHsCmd (HsCmdArrForm XCmdArrForm GhcTc
x LHsExpr GhcTc
e LexicalFixity
f Maybe Fixity
fix [LHsCmdTop GhcTc]
cmdtop) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> LexicalFixity
-> Maybe Fixity
-> [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)]
-> HsCmd GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM LexicalFixity
-> TM (Maybe Fixity)
-> TM [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)]
-> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 (XCmdArrForm GhcTc
-> LHsExpr GhcTc
-> LexicalFixity
-> Maybe Fixity
-> [LHsCmdTop GhcTc]
-> HsCmd GhcTc
forall id.
XCmdArrForm id
-> LHsExpr id
-> LexicalFixity
-> Maybe Fixity
-> [LHsCmdTop id]
-> HsCmd id
HsCmdArrForm XCmdArrForm GhcTc
x)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e)
(LexicalFixity -> TM LexicalFixity
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return LexicalFixity
f)
(Maybe Fixity -> TM (Maybe Fixity)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Fixity
fix)
((GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)
-> TM (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)))
-> [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)]
-> TM [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((HsCmdTop GhcTc -> TM (HsCmdTop GhcTc))
-> GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)
-> TM (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL (HsCmdTop GhcTc -> TM (HsCmdTop GhcTc)
addTickHsCmdTop)) [LHsCmdTop GhcTc]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcTc)]
cmdtop)
addTickHsCmd (XCmd (HsWrap HsWrapper
w HsCmd GhcTc
cmd)) =
(HsWrap HsCmd -> HsCmd GhcTc)
-> TM (HsWrap HsCmd) -> TM (HsCmd GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM XXCmd GhcTc -> HsCmd GhcTc
HsWrap HsCmd -> HsCmd GhcTc
forall id. XXCmd id -> HsCmd id
XCmd (TM (HsWrap HsCmd) -> TM (HsCmd GhcTc))
-> TM (HsWrap HsCmd) -> TM (HsCmd GhcTc)
forall a b. (a -> b) -> a -> b
$
(HsCmd GhcTc -> HsWrap HsCmd)
-> TM (HsCmd GhcTc) -> TM (HsWrap HsCmd)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (HsWrapper -> HsCmd GhcTc -> HsWrap HsCmd
forall (hs_syn :: * -> *).
HsWrapper -> hs_syn GhcTc -> HsWrap hs_syn
HsWrap HsWrapper
w) (HsCmd GhcTc -> TM (HsCmd GhcTc)
addTickHsCmd HsCmd GhcTc
cmd)
addTickCmdMatchGroup :: MatchGroup GhcTc (LHsCmd GhcTc)
-> TM (MatchGroup GhcTc (LHsCmd GhcTc))
addTickCmdMatchGroup :: MatchGroup GhcTc (LHsCmd GhcTc)
-> TM (MatchGroup GhcTc (LHsCmd GhcTc))
addTickCmdMatchGroup mg :: MatchGroup GhcTc (LHsCmd GhcTc)
mg@(MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = (L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
matches) }) = do
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
matches' <- (GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))))
-> [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL Match GhcTc (LHsCmd GhcTc) -> TM (Match GhcTc (LHsCmd GhcTc))
Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
addTickCmdMatch) [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
matches
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a b. (a -> b) -> a -> b
$ MatchGroup GhcTc (LHsCmd GhcTc)
MatchGroup GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
mg { mg_alts :: XRec GhcTc [LMatch GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
mg_alts = SrcSpanAnnL
-> [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> GenLocated
SrcSpanAnnL
[GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnL
l [GenLocated
SrcSpanAnnA (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
matches' }
addTickCmdMatch :: Match GhcTc (LHsCmd GhcTc) -> TM (Match GhcTc (LHsCmd GhcTc))
addTickCmdMatch :: Match GhcTc (LHsCmd GhcTc) -> TM (Match GhcTc (LHsCmd GhcTc))
addTickCmdMatch match :: Match GhcTc (LHsCmd GhcTc)
match@(Match { m_pats :: forall p body. Match p body -> [LPat p]
m_pats = [LPat GhcTc]
pats, m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs GhcTc (LHsCmd GhcTc)
gRHSs }) =
[Id]
-> TM (Match GhcTc (LHsCmd GhcTc))
-> TM (Match GhcTc (LHsCmd GhcTc))
forall a. [Id] -> TM a -> TM a
bindLocals (CollectFlag GhcTc -> [LPat GhcTc] -> [IdP GhcTc]
forall p. CollectPass p => CollectFlag p -> [LPat p] -> [IdP p]
collectPatsBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders [LPat GhcTc]
pats) (TM (Match GhcTc (LHsCmd GhcTc))
-> TM (Match GhcTc (LHsCmd GhcTc)))
-> TM (Match GhcTc (LHsCmd GhcTc))
-> TM (Match GhcTc (LHsCmd GhcTc))
forall a b. (a -> b) -> a -> b
$ do
GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
gRHSs' <- GRHSs GhcTc (LHsCmd GhcTc) -> TM (GRHSs GhcTc (LHsCmd GhcTc))
addTickCmdGRHSs GRHSs GhcTc (LHsCmd GhcTc)
gRHSs
Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a b. (a -> b) -> a -> b
$ Match GhcTc (LHsCmd GhcTc)
Match GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
match { m_grhss :: GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
m_grhss = GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
gRHSs' }
addTickCmdGRHSs :: GRHSs GhcTc (LHsCmd GhcTc) -> TM (GRHSs GhcTc (LHsCmd GhcTc))
addTickCmdGRHSs :: GRHSs GhcTc (LHsCmd GhcTc) -> TM (GRHSs GhcTc (LHsCmd GhcTc))
addTickCmdGRHSs (GRHSs XCGRHSs GhcTc (LHsCmd GhcTc)
x [LGRHS GhcTc (LHsCmd GhcTc)]
guarded HsLocalBinds GhcTc
local_binds) =
[Id]
-> TM (GRHSs GhcTc (LHsCmd GhcTc))
-> TM (GRHSs GhcTc (LHsCmd GhcTc))
forall a. [Id] -> TM a -> TM a
bindLocals [IdP GhcTc]
[Id]
binders (TM (GRHSs GhcTc (LHsCmd GhcTc))
-> TM (GRHSs GhcTc (LHsCmd GhcTc)))
-> TM (GRHSs GhcTc (LHsCmd GhcTc))
-> TM (GRHSs GhcTc (LHsCmd GhcTc))
forall a b. (a -> b) -> a -> b
$ do
HsLocalBinds GhcTc
local_binds' <- HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds HsLocalBinds GhcTc
local_binds
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
guarded' <- (GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM
(GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))))
-> [GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> TM
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM
(GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL GRHS GhcTc (LHsCmd GhcTc) -> TM (GRHS GhcTc (LHsCmd GhcTc))
GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
addTickCmdGRHS) [LGRHS GhcTc (LHsCmd GhcTc)]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
guarded
GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a b. (a -> b) -> a -> b
$ XCGRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> [LGRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
-> HsLocalBinds GhcTc
-> GRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall p body.
XCGRHSs p body -> [LGRHS p body] -> HsLocalBinds p -> GRHSs p body
GRHSs XCGRHSs GhcTc (LHsCmd GhcTc)
XCGRHSs GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
x [LGRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
guarded' HsLocalBinds GhcTc
local_binds'
where
binders :: [IdP GhcTc]
binders = CollectFlag GhcTc -> HsLocalBinds GhcTc -> [IdP GhcTc]
forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders HsLocalBinds GhcTc
local_binds
addTickCmdGRHS :: GRHS GhcTc (LHsCmd GhcTc) -> TM (GRHS GhcTc (LHsCmd GhcTc))
addTickCmdGRHS :: GRHS GhcTc (LHsCmd GhcTc) -> TM (GRHS GhcTc (LHsCmd GhcTc))
addTickCmdGRHS (GRHS XCGRHS GhcTc (LHsCmd GhcTc)
x [ExprLStmt GhcTc]
stmts LHsCmd GhcTc
cmd)
= do { ([GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts',GenLocated SrcSpanAnnA (HsCmd GhcTc)
expr') <- Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc]
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM ([ExprLStmt GhcTc], GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall a.
Maybe (Bool -> BoxLabel)
-> [ExprLStmt GhcTc] -> TM a -> TM ([ExprLStmt GhcTc], a)
addTickLStmts' ((Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel)
forall a. a -> Maybe a
Just ((Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel))
-> (Bool -> BoxLabel) -> Maybe (Bool -> BoxLabel)
forall a b. (a -> b) -> a -> b
$ CondBox -> Bool -> BoxLabel
BinBox (CondBox -> Bool -> BoxLabel) -> CondBox -> Bool -> BoxLabel
forall a b. (a -> b) -> a -> b
$ CondBox
GuardBinBox)
[ExprLStmt GhcTc]
stmts (LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
cmd)
; GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a b. (a -> b) -> a -> b
$ XCGRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> [ExprLStmt GhcTc]
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> GRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS XCGRHS GhcTc (LHsCmd GhcTc)
XCGRHS GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
x [ExprLStmt GhcTc]
[GenLocated
SrcSpanAnnA
(StmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
stmts' GenLocated SrcSpanAnnA (HsCmd GhcTc)
expr' }
addTickLCmdStmts :: [LStmt GhcTc (LHsCmd GhcTc)]
-> TM [LStmt GhcTc (LHsCmd GhcTc)]
addTickLCmdStmts :: [CmdLStmt GhcTc] -> TM [CmdLStmt GhcTc]
addTickLCmdStmts [CmdLStmt GhcTc]
stmts = do
([GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts, ()
_) <- [CmdLStmt GhcTc] -> TM () -> TM ([CmdLStmt GhcTc], ())
forall a. [CmdLStmt GhcTc] -> TM a -> TM ([CmdLStmt GhcTc], a)
addTickLCmdStmts' [CmdLStmt GhcTc]
stmts (() -> TM ()
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts
addTickLCmdStmts' :: [LStmt GhcTc (LHsCmd GhcTc)] -> TM a
-> TM ([LStmt GhcTc (LHsCmd GhcTc)], a)
addTickLCmdStmts' :: forall a. [CmdLStmt GhcTc] -> TM a -> TM ([CmdLStmt GhcTc], a)
addTickLCmdStmts' [CmdLStmt GhcTc]
lstmts TM a
res
= [Id] -> TM ([CmdLStmt GhcTc], a) -> TM ([CmdLStmt GhcTc], a)
forall a. [Id] -> TM a -> TM a
bindLocals [IdP GhcTc]
[Id]
binders (TM ([CmdLStmt GhcTc], a) -> TM ([CmdLStmt GhcTc], a))
-> TM ([CmdLStmt GhcTc], a) -> TM ([CmdLStmt GhcTc], a)
forall a b. (a -> b) -> a -> b
$ do
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
lstmts' <- (GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))))
-> [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
-> GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))))
forall (m :: * -> *) a b l.
Monad m =>
(a -> m b) -> GenLocated l a -> m (GenLocated l b)
liftL Stmt GhcTc (LHsCmd GhcTc) -> TM (Stmt GhcTc (LHsCmd GhcTc))
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
addTickCmdStmt) [CmdLStmt GhcTc]
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
lstmts
a
a <- TM a
res
([GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))],
a)
-> TM
([GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))],
a)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ([GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
lstmts', a
a)
where
binders :: [IdP GhcTc]
binders = CollectFlag GhcTc
-> [LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
-> [IdP GhcTc]
forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders CollectFlag GhcTc
forall p. CollectFlag p
CollNoDictBinders [CmdLStmt GhcTc]
[LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
lstmts
addTickCmdStmt :: Stmt GhcTc (LHsCmd GhcTc) -> TM (Stmt GhcTc (LHsCmd GhcTc))
addTickCmdStmt :: Stmt GhcTc (LHsCmd GhcTc) -> TM (Stmt GhcTc (LHsCmd GhcTc))
addTickCmdStmt (BindStmt XBindStmt GhcTc GhcTc (LHsCmd GhcTc)
x LPat GhcTc
pat LHsCmd GhcTc
c) =
(GenLocated SrcSpanAnnA (Pat GhcTc)
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (GenLocated SrcSpanAnnA (Pat GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (XBindStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> LPat GhcTc
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt XBindStmt GhcTc GhcTc (LHsCmd GhcTc)
XBindStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
x)
(LPat GhcTc -> TM (LPat GhcTc)
addTickLPat LPat GhcTc
pat)
(LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c)
addTickCmdStmt (LastStmt XLastStmt GhcTc GhcTc (LHsCmd GhcTc)
x LHsCmd GhcTc
c Maybe Bool
noret SyntaxExpr GhcTc
ret) =
(GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> Maybe Bool
-> SyntaxExprTc
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Maybe Bool)
-> TM SyntaxExprTc
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XLastStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> Maybe Bool
-> SyntaxExpr GhcTc
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall idL idR body.
XLastStmt idL idR body
-> body -> Maybe Bool -> SyntaxExpr idR -> StmtLR idL idR body
LastStmt XLastStmt GhcTc GhcTc (LHsCmd GhcTc)
XLastStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
x)
(LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c)
(Maybe Bool -> TM (Maybe Bool)
forall a. a -> TM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Bool
noret)
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
ret)
addTickCmdStmt (BodyStmt XBodyStmt GhcTc GhcTc (LHsCmd GhcTc)
x LHsCmd GhcTc
c SyntaxExpr GhcTc
bind' SyntaxExpr GhcTc
guard') =
(GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> SyntaxExprTc
-> SyntaxExprTc
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM SyntaxExprTc
-> TM SyntaxExprTc
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (XBodyStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> GenLocated SrcSpanAnnA (HsCmd GhcTc)
-> SyntaxExpr GhcTc
-> SyntaxExpr GhcTc
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall idL idR body.
XBodyStmt idL idR body
-> body -> SyntaxExpr idR -> SyntaxExpr idR -> StmtLR idL idR body
BodyStmt XBodyStmt GhcTc GhcTc (LHsCmd GhcTc)
XBodyStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
x)
(LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd LHsCmd GhcTc
c)
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
bind')
(SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan SyntaxExpr GhcTc
guard')
addTickCmdStmt (LetStmt XLetStmt GhcTc GhcTc (LHsCmd GhcTc)
x HsLocalBinds GhcTc
binds) =
(HsLocalBinds GhcTc
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
-> TM (HsLocalBinds GhcTc)
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XLetStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> HsLocalBinds GhcTc
-> Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
forall idL idR body.
XLetStmt idL idR body
-> HsLocalBindsLR idL idR -> StmtLR idL idR body
LetStmt XLetStmt GhcTc GhcTc (LHsCmd GhcTc)
XLetStmt GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
x)
(HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds HsLocalBinds GhcTc
binds)
addTickCmdStmt stmt :: Stmt GhcTc (LHsCmd GhcTc)
stmt@(RecStmt {})
= do { [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts' <- [CmdLStmt GhcTc] -> TM [CmdLStmt GhcTc]
addTickLCmdStmts (GenLocated SrcSpanAnnL [CmdLStmt GhcTc] -> [CmdLStmt GhcTc]
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnL [CmdLStmt GhcTc] -> [CmdLStmt GhcTc])
-> GenLocated SrcSpanAnnL [CmdLStmt GhcTc] -> [CmdLStmt GhcTc]
forall a b. (a -> b) -> a -> b
$ Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> XRec
GhcTc [LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_stmts Stmt GhcTc (LHsCmd GhcTc)
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
stmt)
; SyntaxExprTc
ret' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> SyntaxExpr GhcTc
forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_ret_fn Stmt GhcTc (LHsCmd GhcTc)
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
stmt)
; SyntaxExprTc
mfix' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> SyntaxExpr GhcTc
forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_mfix_fn Stmt GhcTc (LHsCmd GhcTc)
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
stmt)
; SyntaxExprTc
bind' <- SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr SrcSpan
hpcSrcSpan (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> SyntaxExpr GhcTc
forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_bind_fn Stmt GhcTc (LHsCmd GhcTc)
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
stmt)
; Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
-> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (Stmt GhcTc (LHsCmd GhcTc)
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
stmt { recS_stmts :: XRec
GhcTc [LStmtLR GhcTc GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))]
recS_stmts = [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
-> GenLocated
SrcSpanAnnL
[GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
forall a an. a -> LocatedAn an a
noLocA [GenLocated
SrcSpanAnnA (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))]
stmts', recS_ret_fn :: SyntaxExpr GhcTc
recS_ret_fn = SyntaxExpr GhcTc
SyntaxExprTc
ret'
, recS_mfix_fn :: SyntaxExpr GhcTc
recS_mfix_fn = SyntaxExpr GhcTc
SyntaxExprTc
mfix', recS_bind_fn :: SyntaxExpr GhcTc
recS_bind_fn = SyntaxExpr GhcTc
SyntaxExprTc
bind' }) }
addTickCmdStmt ApplicativeStmt{} =
FilePath -> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. FilePath -> a
panic FilePath
"ToDo: addTickCmdStmt ApplicativeLastStmt"
addTickCmdStmt Stmt GhcTc (LHsCmd GhcTc)
stmt = FilePath
-> SDoc -> TM (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)))
forall a. HasCallStack => FilePath -> SDoc -> a
pprPanic FilePath
"addTickHsCmd" (Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr Stmt GhcTc (LHsCmd GhcTc)
Stmt GhcTc (GenLocated SrcSpanAnnA (HsCmd GhcTc))
stmt)
addTickHsRecordBinds :: HsRecordBinds GhcTc -> TM (HsRecordBinds GhcTc)
addTickHsRecordBinds :: HsRecordBinds GhcTc -> TM (HsRecordBinds GhcTc)
addTickHsRecordBinds (HsRecFields [LHsRecField GhcTc (LHsExpr GhcTc)]
fields Maybe (Located Int)
dd)
= do { [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
fields' <- (GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))))
-> [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
-> TM
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM LHsFieldBind
GhcTc
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(LHsExpr GhcTc)
-> TM
(LHsFieldBind
GhcTc
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(LHsExpr GhcTc))
GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall id.
LHsFieldBind GhcTc id (LHsExpr GhcTc)
-> TM (LHsFieldBind GhcTc id (LHsExpr GhcTc))
addTickHsRecField [LHsRecField GhcTc (LHsExpr GhcTc)]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
fields
; HsRecFields GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsRecFields GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return ([LHsRecField GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
-> Maybe (Located Int)
-> HsRecFields GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall p arg.
[LHsRecField p arg] -> Maybe (Located Int) -> HsRecFields p arg
HsRecFields [LHsRecField GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcTc))
(GenLocated SrcSpanAnnA (HsExpr GhcTc)))]
fields' Maybe (Located Int)
dd) }
addTickHsRecField :: LHsFieldBind GhcTc id (LHsExpr GhcTc)
-> TM (LHsFieldBind GhcTc id (LHsExpr GhcTc))
addTickHsRecField :: forall id.
LHsFieldBind GhcTc id (LHsExpr GhcTc)
-> TM (LHsFieldBind GhcTc id (LHsExpr GhcTc))
addTickHsRecField (L SrcSpanAnnA
l (HsFieldBind XHsFieldBind id
x id
id GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr Bool
pun))
= do { GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr' <- LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr
; GenLocated
SrcSpanAnnA
(HsFieldBind id (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> TM
(GenLocated
SrcSpanAnnA
(HsFieldBind id (GenLocated SrcSpanAnnA (HsExpr GhcTc))))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnA
-> HsFieldBind id (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> GenLocated
SrcSpanAnnA
(HsFieldBind id (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
l (XHsFieldBind id
-> id
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> Bool
-> HsFieldBind id (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind XHsFieldBind id
x id
id GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr' Bool
pun)) }
addTickArithSeqInfo :: ArithSeqInfo GhcTc -> TM (ArithSeqInfo GhcTc)
addTickArithSeqInfo :: ArithSeqInfo GhcTc -> TM (ArithSeqInfo GhcTc)
addTickArithSeqInfo (From LHsExpr GhcTc
e1) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc) -> ArithSeqInfo GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (ArithSeqInfo GhcTc)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM LHsExpr GhcTc -> ArithSeqInfo GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc) -> ArithSeqInfo GhcTc
forall id. LHsExpr id -> ArithSeqInfo id
From
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
addTickArithSeqInfo (FromThen LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> ArithSeqInfo GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (ArithSeqInfo GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 LHsExpr GhcTc -> LHsExpr GhcTc -> ArithSeqInfo GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> ArithSeqInfo GhcTc
forall id. LHsExpr id -> LHsExpr id -> ArithSeqInfo id
FromThen
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e2)
addTickArithSeqInfo (FromTo LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> ArithSeqInfo GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (ArithSeqInfo GhcTc)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 LHsExpr GhcTc -> LHsExpr GhcTc -> ArithSeqInfo GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> ArithSeqInfo GhcTc
forall id. LHsExpr id -> LHsExpr id -> ArithSeqInfo id
FromTo
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e2)
addTickArithSeqInfo (FromThenTo LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 LHsExpr GhcTc
e3) =
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> ArithSeqInfo GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (ArithSeqInfo GhcTc)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 LHsExpr GhcTc
-> LHsExpr GhcTc -> LHsExpr GhcTc -> ArithSeqInfo GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> ArithSeqInfo GhcTc
forall id.
LHsExpr id -> LHsExpr id -> LHsExpr id -> ArithSeqInfo id
FromThenTo
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e1)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e2)
(LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr LHsExpr GhcTc
e3)
data TickTransState = TT { TickTransState -> Int
tickBoxCount:: !Int
, TickTransState -> [MixEntry_]
mixEntries :: [MixEntry_]
, TickTransState -> CostCentreState
ccIndices :: !CostCentreState
}
addMixEntry :: MixEntry_ -> TM Int
addMixEntry :: MixEntry_ -> TM Int
addMixEntry MixEntry_
ent = do
Int
c <- TickTransState -> Int
tickBoxCount (TickTransState -> Int) -> TM TickTransState -> TM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TM TickTransState
getState
(TickTransState -> TickTransState) -> TM ()
setState ((TickTransState -> TickTransState) -> TM ())
-> (TickTransState -> TickTransState) -> TM ()
forall a b. (a -> b) -> a -> b
$ \TickTransState
st ->
TickTransState
st { tickBoxCount :: Int
tickBoxCount = Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
, mixEntries :: [MixEntry_]
mixEntries = MixEntry_
ent MixEntry_ -> [MixEntry_] -> [MixEntry_]
forall a. a -> [a] -> [a]
: TickTransState -> [MixEntry_]
mixEntries TickTransState
st
}
Int -> TM Int
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
c
data TickTransEnv = TTE { TickTransEnv -> FastString
fileName :: FastString
, TickTransEnv -> TickDensity
density :: TickDensity
, TickTransEnv -> Bool
tte_countEntries :: !Bool
, TickTransEnv -> NameSet
exports :: NameSet
, TickTransEnv -> VarSet
inlines :: VarSet
, TickTransEnv -> [FilePath]
declPath :: [String]
, TickTransEnv -> VarSet
inScope :: VarSet
, TickTransEnv -> Set RealSrcSpan
blackList :: Set RealSrcSpan
, TickTransEnv -> Module
this_mod :: Module
, TickTransEnv -> TickishType
tickishType :: TickishType
}
data TickishType = ProfNotes | HpcTicks | Breakpoints | SourceNotes
deriving (TickishType -> TickishType -> Bool
(TickishType -> TickishType -> Bool)
-> (TickishType -> TickishType -> Bool) -> Eq TickishType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TickishType -> TickishType -> Bool
== :: TickishType -> TickishType -> Bool
$c/= :: TickishType -> TickishType -> Bool
/= :: TickishType -> TickishType -> Bool
Eq)
coveragePasses :: DynFlags -> [TickishType]
coveragePasses :: DynFlags -> [TickishType]
coveragePasses DynFlags
dflags =
Bool -> TickishType -> [TickishType] -> [TickishType]
forall {a}. Bool -> a -> [a] -> [a]
ifa (DynFlags -> Bool
breakpointsEnabled DynFlags
dflags) TickishType
Breakpoints ([TickishType] -> [TickishType]) -> [TickishType] -> [TickishType]
forall a b. (a -> b) -> a -> b
$
Bool -> TickishType -> [TickishType] -> [TickishType]
forall {a}. Bool -> a -> [a] -> [a]
ifa (GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_Hpc DynFlags
dflags) TickishType
HpcTicks ([TickishType] -> [TickishType]) -> [TickishType] -> [TickishType]
forall a b. (a -> b) -> a -> b
$
Bool -> TickishType -> [TickishType] -> [TickishType]
forall {a}. Bool -> a -> [a] -> [a]
ifa (DynFlags -> Bool
sccProfilingEnabled DynFlags
dflags Bool -> Bool -> Bool
&&
DynFlags -> ProfAuto
profAuto DynFlags
dflags ProfAuto -> ProfAuto -> Bool
forall a. Eq a => a -> a -> Bool
/= ProfAuto
NoProfAuto) TickishType
ProfNotes ([TickishType] -> [TickishType]) -> [TickishType] -> [TickishType]
forall a b. (a -> b) -> a -> b
$
Bool -> TickishType -> [TickishType] -> [TickishType]
forall {a}. Bool -> a -> [a] -> [a]
ifa (DynFlags -> Bool
needSourceNotes DynFlags
dflags) TickishType
SourceNotes []
where ifa :: Bool -> a -> [a] -> [a]
ifa Bool
f a
x [a]
xs | Bool
f = a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
xs
| Bool
otherwise = [a]
xs
breakpointsEnabled :: DynFlags -> Bool
breakpointsEnabled :: DynFlags -> Bool
breakpointsEnabled DynFlags
dflags = DynFlags -> Backend
backend DynFlags
dflags Backend -> Backend -> Bool
forall a. Eq a => a -> a -> Bool
== Backend
Interpreter
tickSameFileOnly :: TickishType -> Bool
tickSameFileOnly :: TickishType -> Bool
tickSameFileOnly TickishType
HpcTicks = Bool
True
tickSameFileOnly TickishType
_other = Bool
False
type FreeVars = OccEnv Id
noFVs :: FreeVars
noFVs :: FreeVars
noFVs = FreeVars
forall a. OccEnv a
emptyOccEnv
newtype TM a = TM { forall a.
TM a
-> TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
unTM :: TickTransEnv -> TickTransState -> (a,FreeVars,TickTransState) }
deriving ((forall a b. (a -> b) -> TM a -> TM b)
-> (forall a b. a -> TM b -> TM a) -> Functor TM
forall a b. a -> TM b -> TM a
forall a b. (a -> b) -> TM a -> TM b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> TM a -> TM b
fmap :: forall a b. (a -> b) -> TM a -> TM b
$c<$ :: forall a b. a -> TM b -> TM a
<$ :: forall a b. a -> TM b -> TM a
Functor)
instance Applicative TM where
pure :: forall a. a -> TM a
pure a
a = (TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a)
-> (TickTransEnv
-> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
_env TickTransState
st -> (a
a,FreeVars
noFVs,TickTransState
st)
<*> :: forall a b. TM (a -> b) -> TM a -> TM b
(<*>) = TM (a -> b) -> TM a -> TM b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
instance Monad TM where
(TM TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m) >>= :: forall a b. TM a -> (a -> TM b) -> TM b
>>= a -> TM b
k = (TickTransEnv -> TickTransState -> (b, FreeVars, TickTransState))
-> TM b
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv -> TickTransState -> (b, FreeVars, TickTransState))
-> TM b)
-> (TickTransEnv
-> TickTransState -> (b, FreeVars, TickTransState))
-> TM b
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st ->
case TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m TickTransEnv
env TickTransState
st of
(a
r1,FreeVars
fv1,TickTransState
st1) ->
case TM b
-> TickTransEnv -> TickTransState -> (b, FreeVars, TickTransState)
forall a.
TM a
-> TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
unTM (a -> TM b
k a
r1) TickTransEnv
env TickTransState
st1 of
(b
r2,FreeVars
fv2,TickTransState
st2) ->
(b
r2, FreeVars
fv1 FreeVars -> FreeVars -> FreeVars
forall a. OccEnv a -> OccEnv a -> OccEnv a
`plusOccEnv` FreeVars
fv2, TickTransState
st2)
getCCIndexM :: FastString -> TM CostCentreIndex
getCCIndexM :: FastString -> TM CostCentreIndex
getCCIndexM FastString
n = (TickTransEnv
-> TickTransState -> (CostCentreIndex, FreeVars, TickTransState))
-> TM CostCentreIndex
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv
-> TickTransState -> (CostCentreIndex, FreeVars, TickTransState))
-> TM CostCentreIndex)
-> (TickTransEnv
-> TickTransState -> (CostCentreIndex, FreeVars, TickTransState))
-> TM CostCentreIndex
forall a b. (a -> b) -> a -> b
$ \TickTransEnv
_ TickTransState
st -> let (CostCentreIndex
idx, CostCentreState
is') = FastString -> CostCentreState -> (CostCentreIndex, CostCentreState)
getCCIndex FastString
n (CostCentreState -> (CostCentreIndex, CostCentreState))
-> CostCentreState -> (CostCentreIndex, CostCentreState)
forall a b. (a -> b) -> a -> b
$
TickTransState -> CostCentreState
ccIndices TickTransState
st
in (CostCentreIndex
idx, FreeVars
noFVs, TickTransState
st { ccIndices :: CostCentreState
ccIndices = CostCentreState
is' })
getState :: TM TickTransState
getState :: TM TickTransState
getState = (TickTransEnv
-> TickTransState -> (TickTransState, FreeVars, TickTransState))
-> TM TickTransState
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv
-> TickTransState -> (TickTransState, FreeVars, TickTransState))
-> TM TickTransState)
-> (TickTransEnv
-> TickTransState -> (TickTransState, FreeVars, TickTransState))
-> TM TickTransState
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
_ TickTransState
st -> (TickTransState
st, FreeVars
noFVs, TickTransState
st)
setState :: (TickTransState -> TickTransState) -> TM ()
setState :: (TickTransState -> TickTransState) -> TM ()
setState TickTransState -> TickTransState
f = (TickTransEnv -> TickTransState -> ((), FreeVars, TickTransState))
-> TM ()
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv -> TickTransState -> ((), FreeVars, TickTransState))
-> TM ())
-> (TickTransEnv
-> TickTransState -> ((), FreeVars, TickTransState))
-> TM ()
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
_ TickTransState
st -> ((), FreeVars
noFVs, TickTransState -> TickTransState
f TickTransState
st)
getEnv :: TM TickTransEnv
getEnv :: TM TickTransEnv
getEnv = (TickTransEnv
-> TickTransState -> (TickTransEnv, FreeVars, TickTransState))
-> TM TickTransEnv
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv
-> TickTransState -> (TickTransEnv, FreeVars, TickTransState))
-> TM TickTransEnv)
-> (TickTransEnv
-> TickTransState -> (TickTransEnv, FreeVars, TickTransState))
-> TM TickTransEnv
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st -> (TickTransEnv
env, FreeVars
noFVs, TickTransState
st)
withEnv :: (TickTransEnv -> TickTransEnv) -> TM a -> TM a
withEnv :: forall a. (TickTransEnv -> TickTransEnv) -> TM a -> TM a
withEnv TickTransEnv -> TickTransEnv
f (TM TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m) = (TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a)
-> (TickTransEnv
-> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st ->
case TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m (TickTransEnv -> TickTransEnv
f TickTransEnv
env) TickTransState
st of
(a
a, FreeVars
fvs, TickTransState
st') -> (a
a, FreeVars
fvs, TickTransState
st')
getDensity :: TM TickDensity
getDensity :: TM TickDensity
getDensity = (TickTransEnv
-> TickTransState -> (TickDensity, FreeVars, TickTransState))
-> TM TickDensity
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv
-> TickTransState -> (TickDensity, FreeVars, TickTransState))
-> TM TickDensity)
-> (TickTransEnv
-> TickTransState -> (TickDensity, FreeVars, TickTransState))
-> TM TickDensity
forall a b. (a -> b) -> a -> b
$ \TickTransEnv
env TickTransState
st -> (TickTransEnv -> TickDensity
density TickTransEnv
env, FreeVars
noFVs, TickTransState
st)
ifDensity :: TickDensity -> TM a -> TM a -> TM a
ifDensity :: forall a. TickDensity -> TM a -> TM a -> TM a
ifDensity TickDensity
d TM a
th TM a
el = do TickDensity
d0 <- TM TickDensity
getDensity; if TickDensity
d TickDensity -> TickDensity -> Bool
forall a. Eq a => a -> a -> Bool
== TickDensity
d0 then TM a
th else TM a
el
getFreeVars :: TM a -> TM (FreeVars, a)
getFreeVars :: forall a. TM a -> TM (FreeVars, a)
getFreeVars (TM TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m)
= (TickTransEnv
-> TickTransState -> ((FreeVars, a), FreeVars, TickTransState))
-> TM (FreeVars, a)
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv
-> TickTransState -> ((FreeVars, a), FreeVars, TickTransState))
-> TM (FreeVars, a))
-> (TickTransEnv
-> TickTransState -> ((FreeVars, a), FreeVars, TickTransState))
-> TM (FreeVars, a)
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st -> case TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m TickTransEnv
env TickTransState
st of (a
a, FreeVars
fv, TickTransState
st') -> ((FreeVars
fv,a
a), FreeVars
fv, TickTransState
st')
freeVar :: Id -> TM ()
freeVar :: Id -> TM ()
freeVar Id
id = (TickTransEnv -> TickTransState -> ((), FreeVars, TickTransState))
-> TM ()
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv -> TickTransState -> ((), FreeVars, TickTransState))
-> TM ())
-> (TickTransEnv
-> TickTransState -> ((), FreeVars, TickTransState))
-> TM ()
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st ->
if Id
id Id -> VarSet -> Bool
`elemVarSet` TickTransEnv -> VarSet
inScope TickTransEnv
env
then ((), OccName -> Id -> FreeVars
forall a. OccName -> a -> OccEnv a
unitOccEnv (Name -> OccName
nameOccName (Id -> Name
idName Id
id)) Id
id, TickTransState
st)
else ((), FreeVars
noFVs, TickTransState
st)
addPathEntry :: String -> TM a -> TM a
addPathEntry :: forall a. FilePath -> TM a -> TM a
addPathEntry FilePath
nm = (TickTransEnv -> TickTransEnv) -> TM a -> TM a
forall a. (TickTransEnv -> TickTransEnv) -> TM a -> TM a
withEnv (\ TickTransEnv
env -> TickTransEnv
env { declPath :: [FilePath]
declPath = TickTransEnv -> [FilePath]
declPath TickTransEnv
env [FilePath] -> [FilePath] -> [FilePath]
forall a. [a] -> [a] -> [a]
++ [FilePath
nm] })
getPathEntry :: TM [String]
getPathEntry :: TM [FilePath]
getPathEntry = TickTransEnv -> [FilePath]
declPath (TickTransEnv -> [FilePath]) -> TM TickTransEnv -> TM [FilePath]
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` TM TickTransEnv
getEnv
getFileName :: TM FastString
getFileName :: TM FastString
getFileName = TickTransEnv -> FastString
fileName (TickTransEnv -> FastString) -> TM TickTransEnv -> TM FastString
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` TM TickTransEnv
getEnv
isGoodSrcSpan' :: SrcSpan -> Bool
isGoodSrcSpan' :: SrcSpan -> Bool
isGoodSrcSpan' pos :: SrcSpan
pos@(RealSrcSpan RealSrcSpan
_ Maybe BufSpan
_) = SrcSpan -> SrcLoc
srcSpanStart SrcSpan
pos SrcLoc -> SrcLoc -> Bool
forall a. Eq a => a -> a -> Bool
/= SrcSpan -> SrcLoc
srcSpanEnd SrcSpan
pos
isGoodSrcSpan' (UnhelpfulSpan UnhelpfulSpanReason
_) = Bool
False
isGoodTickSrcSpan :: SrcSpan -> TM Bool
isGoodTickSrcSpan :: SrcSpan -> TM Bool
isGoodTickSrcSpan SrcSpan
pos = do
FastString
file_name <- TM FastString
getFileName
TickishType
tickish <- TickTransEnv -> TickishType
tickishType (TickTransEnv -> TickishType) -> TM TickTransEnv -> TM TickishType
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` TM TickTransEnv
getEnv
let need_same_file :: Bool
need_same_file = TickishType -> Bool
tickSameFileOnly TickishType
tickish
same_file :: Bool
same_file = FastString -> Maybe FastString
forall a. a -> Maybe a
Just FastString
file_name Maybe FastString -> Maybe FastString -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan -> Maybe FastString
srcSpanFileName_maybe SrcSpan
pos
Bool -> TM Bool
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> Bool
isGoodSrcSpan' SrcSpan
pos Bool -> Bool -> Bool
&& (Bool -> Bool
not Bool
need_same_file Bool -> Bool -> Bool
|| Bool
same_file))
ifGoodTickSrcSpan :: SrcSpan -> TM a -> TM a -> TM a
ifGoodTickSrcSpan :: forall a. SrcSpan -> TM a -> TM a -> TM a
ifGoodTickSrcSpan SrcSpan
pos TM a
then_code TM a
else_code = do
Bool
good <- SrcSpan -> TM Bool
isGoodTickSrcSpan SrcSpan
pos
if Bool
good then TM a
then_code else TM a
else_code
bindLocals :: [Id] -> TM a -> TM a
bindLocals :: forall a. [Id] -> TM a -> TM a
bindLocals [Id]
new_ids (TM TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m)
= (TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a)
-> (TickTransEnv
-> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st ->
case TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState)
m TickTransEnv
env{ inScope :: VarSet
inScope = TickTransEnv -> VarSet
inScope TickTransEnv
env VarSet -> [Id] -> VarSet
`extendVarSetList` [Id]
new_ids } TickTransState
st of
(a
r, FreeVars
fv, TickTransState
st') -> (a
r, FreeVars
fv FreeVars -> [OccName] -> FreeVars
forall a. OccEnv a -> [OccName] -> OccEnv a
`delListFromOccEnv` [OccName]
occs, TickTransState
st')
where occs :: [OccName]
occs = [ Name -> OccName
nameOccName (Id -> Name
idName Id
id) | Id
id <- [Id]
new_ids ]
isBlackListed :: SrcSpan -> TM Bool
isBlackListed :: SrcSpan -> TM Bool
isBlackListed (RealSrcSpan RealSrcSpan
pos Maybe BufSpan
_) = (TickTransEnv
-> TickTransState -> (Bool, FreeVars, TickTransState))
-> TM Bool
forall a.
(TickTransEnv -> TickTransState -> (a, FreeVars, TickTransState))
-> TM a
TM ((TickTransEnv
-> TickTransState -> (Bool, FreeVars, TickTransState))
-> TM Bool)
-> (TickTransEnv
-> TickTransState -> (Bool, FreeVars, TickTransState))
-> TM Bool
forall a b. (a -> b) -> a -> b
$ \ TickTransEnv
env TickTransState
st -> (RealSrcSpan -> Set RealSrcSpan -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member RealSrcSpan
pos (TickTransEnv -> Set RealSrcSpan
blackList TickTransEnv
env), FreeVars
noFVs, TickTransState
st)
isBlackListed (UnhelpfulSpan UnhelpfulSpanReason
_) = Bool -> TM Bool
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
allocTickBox :: BoxLabel -> Bool -> Bool -> SrcSpan -> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox :: BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox BoxLabel
boxLabel Bool
countEntries Bool
topOnly SrcSpan
pos TM (HsExpr GhcTc)
m =
SrcSpan
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. SrcSpan -> TM a -> TM a -> TM a
ifGoodTickSrcSpan SrcSpan
pos (do
(FreeVars
fvs, HsExpr GhcTc
e) <- TM (HsExpr GhcTc) -> TM (FreeVars, HsExpr GhcTc)
forall a. TM a -> TM (FreeVars, a)
getFreeVars TM (HsExpr GhcTc)
m
TickTransEnv
env <- TM TickTransEnv
getEnv
CoreTickish
tickish <- BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> FreeVars
-> [FilePath]
-> TM CoreTickish
mkTickish BoxLabel
boxLabel Bool
countEntries Bool
topOnly SrcSpan
pos FreeVars
fvs (TickTransEnv -> [FilePath]
declPath TickTransEnv
env)
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
pos) (XXExpr GhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (XXExpr GhcTc -> HsExpr GhcTc) -> XXExpr GhcTc -> HsExpr GhcTc
forall a b. (a -> b) -> a -> b
$ CoreTickish -> LHsExpr GhcTc -> XXExprGhcTc
HsTick CoreTickish
tickish (LHsExpr GhcTc -> XXExprGhcTc) -> LHsExpr GhcTc -> XXExprGhcTc
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
pos) HsExpr GhcTc
e))
) (do
HsExpr GhcTc
e <- TM (HsExpr GhcTc)
m
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
pos) HsExpr GhcTc
e)
)
allocATickBox :: BoxLabel -> Bool -> Bool -> SrcSpan -> FreeVars
-> TM (Maybe CoreTickish)
allocATickBox :: BoxLabel
-> Bool -> Bool -> SrcSpan -> FreeVars -> TM (Maybe CoreTickish)
allocATickBox BoxLabel
boxLabel Bool
countEntries Bool
topOnly SrcSpan
pos FreeVars
fvs =
SrcSpan
-> TM (Maybe CoreTickish)
-> TM (Maybe CoreTickish)
-> TM (Maybe CoreTickish)
forall a. SrcSpan -> TM a -> TM a -> TM a
ifGoodTickSrcSpan SrcSpan
pos (do
let
mydecl_path :: [FilePath]
mydecl_path = case BoxLabel
boxLabel of
TopLevelBox [FilePath]
x -> [FilePath]
x
LocalBox [FilePath]
xs -> [FilePath]
xs
BoxLabel
_ -> FilePath -> [FilePath]
forall a. FilePath -> a
panic FilePath
"allocATickBox"
CoreTickish
tickish <- BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> FreeVars
-> [FilePath]
-> TM CoreTickish
mkTickish BoxLabel
boxLabel Bool
countEntries Bool
topOnly SrcSpan
pos FreeVars
fvs [FilePath]
mydecl_path
Maybe CoreTickish -> TM (Maybe CoreTickish)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (CoreTickish -> Maybe CoreTickish
forall a. a -> Maybe a
Just CoreTickish
tickish)
) (Maybe CoreTickish -> TM (Maybe CoreTickish)
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe CoreTickish
forall a. Maybe a
Nothing)
mkTickish :: BoxLabel -> Bool -> Bool -> SrcSpan -> OccEnv Id -> [String]
-> TM CoreTickish
mkTickish :: BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> FreeVars
-> [FilePath]
-> TM CoreTickish
mkTickish BoxLabel
boxLabel Bool
countEntries Bool
topOnly SrcSpan
pos FreeVars
fvs [FilePath]
decl_path = do
let ids :: [Id]
ids = (Id -> Bool) -> [Id] -> [Id]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (Id -> Bool) -> Id -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> Bool
mightBeUnliftedType (Type -> Bool) -> (Id -> Type) -> Id -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Id -> Type
idType) ([Id] -> [Id]) -> [Id] -> [Id]
forall a b. (a -> b) -> a -> b
$ FreeVars -> [Id]
forall a. OccEnv a -> [a]
nonDetOccEnvElts FreeVars
fvs
me :: MixEntry_
me = (SrcSpan
pos, [FilePath]
decl_path, (Id -> OccName) -> [Id] -> [OccName]
forall a b. (a -> b) -> [a] -> [b]
map (Name -> OccName
nameOccName(Name -> OccName) -> (Id -> Name) -> Id -> OccName
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Id -> Name
idName) [Id]
ids, BoxLabel
boxLabel)
cc_name :: FilePath
cc_name | Bool
topOnly = [FilePath] -> FilePath
forall a. HasCallStack => [a] -> a
head [FilePath]
decl_path
| Bool
otherwise = [FilePath] -> FilePath
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (FilePath -> [FilePath] -> [FilePath]
forall a. a -> [a] -> [a]
intersperse FilePath
"." [FilePath]
decl_path)
TickTransEnv
env <- TM TickTransEnv
getEnv
case TickTransEnv -> TickishType
tickishType TickTransEnv
env of
TickishType
HpcTicks -> Module -> Int -> CoreTickish
forall (pass :: TickishPass). Module -> Int -> GenTickish pass
HpcTick (TickTransEnv -> Module
this_mod TickTransEnv
env) (Int -> CoreTickish) -> TM Int -> TM CoreTickish
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MixEntry_ -> TM Int
addMixEntry MixEntry_
me
TickishType
ProfNotes -> do
let nm :: FastString
nm = FilePath -> FastString
mkFastString FilePath
cc_name
CCFlavour
flavour <- CostCentreIndex -> CCFlavour
HpcCC (CostCentreIndex -> CCFlavour)
-> TM CostCentreIndex -> TM CCFlavour
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FastString -> TM CostCentreIndex
getCCIndexM FastString
nm
let cc :: CostCentre
cc = FastString -> Module -> SrcSpan -> CCFlavour -> CostCentre
mkUserCC FastString
nm (TickTransEnv -> Module
this_mod TickTransEnv
env) SrcSpan
pos CCFlavour
flavour
count :: Bool
count = Bool
countEntries Bool -> Bool -> Bool
&& TickTransEnv -> Bool
tte_countEntries TickTransEnv
env
CoreTickish -> TM CoreTickish
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (CoreTickish -> TM CoreTickish) -> CoreTickish -> TM CoreTickish
forall a b. (a -> b) -> a -> b
$ CostCentre -> Bool -> Bool -> CoreTickish
forall (pass :: TickishPass).
CostCentre -> Bool -> Bool -> GenTickish pass
ProfNote CostCentre
cc Bool
count Bool
True
TickishType
Breakpoints -> XBreakpoint 'TickishPassCore
-> Int -> [XTickishId 'TickishPassCore] -> CoreTickish
forall (pass :: TickishPass).
XBreakpoint pass -> Int -> [XTickishId pass] -> GenTickish pass
Breakpoint NoExtField
XBreakpoint 'TickishPassCore
noExtField (Int -> [Id] -> CoreTickish) -> TM Int -> TM ([Id] -> CoreTickish)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MixEntry_ -> TM Int
addMixEntry MixEntry_
me TM ([Id] -> CoreTickish) -> TM [Id] -> TM CoreTickish
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Id] -> TM [Id]
forall a. a -> TM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Id]
ids
TickishType
SourceNotes | RealSrcSpan RealSrcSpan
pos' Maybe BufSpan
_ <- SrcSpan
pos ->
CoreTickish -> TM CoreTickish
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (CoreTickish -> TM CoreTickish) -> CoreTickish -> TM CoreTickish
forall a b. (a -> b) -> a -> b
$ RealSrcSpan -> FilePath -> CoreTickish
forall (pass :: TickishPass).
RealSrcSpan -> FilePath -> GenTickish pass
SourceNote RealSrcSpan
pos' FilePath
cc_name
TickishType
_otherwise -> FilePath -> TM CoreTickish
forall a. FilePath -> a
panic FilePath
"mkTickish: bad source span!"
allocBinTickBox :: (Bool -> BoxLabel) -> SrcSpan -> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocBinTickBox :: (Bool -> BoxLabel)
-> SrcSpan -> TM (HsExpr GhcTc) -> TM (LHsExpr GhcTc)
allocBinTickBox Bool -> BoxLabel
boxLabel SrcSpan
pos TM (HsExpr GhcTc)
m = do
TickTransEnv
env <- TM TickTransEnv
getEnv
case TickTransEnv -> TickishType
tickishType TickTransEnv
env of
TickishType
HpcTicks -> do GenLocated SrcSpanAnnA (HsExpr GhcTc)
e <- (HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (HsExpr GhcTc) -> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
pos)) TM (HsExpr GhcTc)
m
SrcSpan
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. SrcSpan -> TM a -> TM a -> TM a
ifGoodTickSrcSpan SrcSpan
pos
((Bool -> BoxLabel)
-> SrcSpan -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
mkBinTickBoxHpc Bool -> BoxLabel
boxLabel SrcSpan
pos LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e)
(GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return GenLocated SrcSpanAnnA (HsExpr GhcTc)
e)
TickishType
_other -> BoxLabel
-> Bool
-> Bool
-> SrcSpan
-> TM (HsExpr GhcTc)
-> TM (LHsExpr GhcTc)
allocTickBox (Bool -> BoxLabel
ExpBox Bool
False) Bool
False Bool
False SrcSpan
pos TM (HsExpr GhcTc)
m
mkBinTickBoxHpc :: (Bool -> BoxLabel) -> SrcSpan -> LHsExpr GhcTc
-> TM (LHsExpr GhcTc)
mkBinTickBoxHpc :: (Bool -> BoxLabel)
-> SrcSpan -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
mkBinTickBoxHpc Bool -> BoxLabel
boxLabel SrcSpan
pos LHsExpr GhcTc
e = do
TickTransEnv
env <- TM TickTransEnv
getEnv
XXExprGhcTc
binTick <- Int -> Int -> LHsExpr GhcTc -> XXExprGhcTc
Int -> Int -> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc
HsBinTick
(Int
-> Int -> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
-> TM Int
-> TM (Int -> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MixEntry_ -> TM Int
addMixEntry (SrcSpan
pos,TickTransEnv -> [FilePath]
declPath TickTransEnv
env, [],Bool -> BoxLabel
boxLabel Bool
True)
TM (Int -> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
-> TM Int
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MixEntry_ -> TM Int
addMixEntry (SrcSpan
pos,TickTransEnv -> [FilePath]
declPath TickTransEnv
env, [],Bool -> BoxLabel
boxLabel Bool
False)
TM (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> XXExprGhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)) -> TM XXExprGhcTc
forall a b. TM (a -> b) -> TM a -> TM b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. a -> TM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e
CoreTickish
tick <- Module -> Int -> CoreTickish
forall (pass :: TickishPass). Module -> Int -> GenTickish pass
HpcTick (TickTransEnv -> Module
this_mod TickTransEnv
env)
(Int -> CoreTickish) -> TM Int -> TM CoreTickish
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MixEntry_ -> TM Int
addMixEntry (SrcSpan
pos,TickTransEnv -> [FilePath]
declPath TickTransEnv
env, [],Bool -> BoxLabel
ExpBox Bool
False)
let pos' :: SrcSpanAnnA
pos' = SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
pos
GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a. a -> TM a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
-> GenLocated SrcSpanAnnA (HsExpr GhcTc)
-> TM (GenLocated SrcSpanAnnA (HsExpr GhcTc))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos' (HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc))
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall a b. (a -> b) -> a -> b
$ XXExpr GhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (XXExpr GhcTc -> HsExpr GhcTc) -> XXExpr GhcTc -> HsExpr GhcTc
forall a b. (a -> b) -> a -> b
$ CoreTickish -> LHsExpr GhcTc -> XXExprGhcTc
HsTick CoreTickish
tick (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
pos' (XXExpr GhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr XXExpr GhcTc
XXExprGhcTc
binTick))
mkHpcPos :: SrcSpan -> HpcPos
mkHpcPos :: SrcSpan -> HpcPos
mkHpcPos pos :: SrcSpan
pos@(RealSrcSpan RealSrcSpan
s Maybe BufSpan
_)
| SrcSpan -> Bool
isGoodSrcSpan' SrcSpan
pos = (Int, Int, Int, Int) -> HpcPos
toHpcPos (RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
s,
RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
s,
RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
s,
RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
s Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
mkHpcPos SrcSpan
_ = FilePath -> HpcPos
forall a. FilePath -> a
panic FilePath
"bad source span; expected such spans to be filtered out"
hpcSrcSpan :: SrcSpan
hpcSrcSpan :: SrcSpan
hpcSrcSpan = FastString -> SrcSpan
mkGeneralSrcSpan (FilePath -> FastString
fsLit FilePath
"Haskell Program Coverage internals")
matchesOneOfMany :: [LMatch GhcTc body] -> Bool
matchesOneOfMany :: forall body. [LMatch GhcTc body] -> Bool
matchesOneOfMany [LMatch GhcTc body]
lmatches = [Int] -> Int
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ((GenLocated (Anno (Match GhcTc body)) (Match GhcTc body) -> Int)
-> [GenLocated (Anno (Match GhcTc body)) (Match GhcTc body)]
-> [Int]
forall a b. (a -> b) -> [a] -> [b]
map LMatch GhcTc body -> Int
GenLocated (Anno (Match GhcTc body)) (Match GhcTc body) -> Int
forall body. LMatch GhcTc body -> Int
matchCount [LMatch GhcTc body]
[GenLocated (Anno (Match GhcTc body)) (Match GhcTc body)]
lmatches) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1
where
matchCount :: LMatch GhcTc body -> Int
matchCount :: forall body. LMatch GhcTc body -> Int
matchCount (L Anno (Match GhcTc body)
_ (Match { m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs XCGRHSs GhcTc body
_ [LGRHS GhcTc body]
grhss HsLocalBinds GhcTc
_ }))
= [GenLocated (Anno (GRHS GhcTc body)) (GRHS GhcTc body)] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [LGRHS GhcTc body]
[GenLocated (Anno (GRHS GhcTc body)) (GRHS GhcTc body)]
grhss
type MixEntry_ = (SrcSpan, [String], [OccName], BoxLabel)
mixHash :: FilePath -> UTCTime -> Int -> [MixEntry] -> Int
mixHash :: FilePath -> UTCTime -> Int -> [(HpcPos, BoxLabel)] -> Int
mixHash FilePath
file UTCTime
tm Int
tabstop [(HpcPos, BoxLabel)]
entries = Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int32 -> Int) -> Int32 -> Int
forall a b. (a -> b) -> a -> b
$ FilePath -> Int32
hashString
(Mix -> FilePath
forall a. Show a => a -> FilePath
show (Mix -> FilePath) -> Mix -> FilePath
forall a b. (a -> b) -> a -> b
$ FilePath -> UTCTime -> Hash -> Int -> [(HpcPos, BoxLabel)] -> Mix
Mix FilePath
file UTCTime
tm Hash
0 Int
tabstop [(HpcPos, BoxLabel)]
entries)
hpcInitCode :: Platform -> Module -> HpcInfo -> CStub
hpcInitCode :: Platform -> Module -> HpcInfo -> CStub
hpcInitCode Platform
_ Module
_ (NoHpcInfo {}) = CStub
forall a. Monoid a => a
mempty
hpcInitCode Platform
platform Module
this_mod (HpcInfo Int
tickCount Int
hashNo)
= Platform -> CLabel -> SDoc -> SDoc -> CStub
initializerCStub Platform
platform CLabel
fn_name SDoc
decls SDoc
body
where
fn_name :: CLabel
fn_name = Module -> FilePath -> CLabel
mkInitializerStubLabel Module
this_mod FilePath
"hpc"
decls :: SDoc
decls = FilePath -> SDoc
text FilePath
"extern StgWord64 " SDoc -> SDoc -> SDoc
<> SDoc
tickboxes SDoc -> SDoc -> SDoc
<> FilePath -> SDoc
text FilePath
"[]" SDoc -> SDoc -> SDoc
<> SDoc
semi
body :: SDoc
body = FilePath -> SDoc
text FilePath
"hs_hpc_module" SDoc -> SDoc -> SDoc
<>
SDoc -> SDoc
parens ([SDoc] -> SDoc
hcat (SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma [
SDoc -> SDoc
doubleQuotes SDoc
full_name_str,
Int -> SDoc
int Int
tickCount,
Int -> SDoc
int Int
hashNo,
SDoc
tickboxes
])) SDoc -> SDoc -> SDoc
<> SDoc
semi
tickboxes :: SDoc
tickboxes = Platform -> LabelStyle -> CLabel -> SDoc
pprCLabel Platform
platform LabelStyle
CStyle (Module -> CLabel
mkHpcTicksLabel (Module -> CLabel) -> Module -> CLabel
forall a b. (a -> b) -> a -> b
$ Module
this_mod)
module_name :: SDoc
module_name = [SDoc] -> SDoc
hcat ((Word8 -> SDoc) -> [Word8] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (FilePath -> SDoc
text(FilePath -> SDoc) -> (Word8 -> FilePath) -> Word8 -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Word8 -> FilePath
charToC) ([Word8] -> [SDoc]) -> [Word8] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
BS.unpack (ByteString -> [Word8]) -> ByteString -> [Word8]
forall a b. (a -> b) -> a -> b
$
FastString -> ByteString
bytesFS (ModuleName -> FastString
moduleNameFS (Module -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName Module
this_mod)))
package_name :: SDoc
package_name = [SDoc] -> SDoc
hcat ((Word8 -> SDoc) -> [Word8] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (FilePath -> SDoc
text(FilePath -> SDoc) -> (Word8 -> FilePath) -> Word8 -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Word8 -> FilePath
charToC) ([Word8] -> [SDoc]) -> [Word8] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
BS.unpack (ByteString -> [Word8]) -> ByteString -> [Word8]
forall a b. (a -> b) -> a -> b
$
FastString -> ByteString
bytesFS (Unit -> FastString
forall u. IsUnitId u => u -> FastString
unitFS (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
this_mod)))
full_name_str :: SDoc
full_name_str
| Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
this_mod Unit -> Unit -> Bool
forall a. Eq a => a -> a -> Bool
== Unit
mainUnit
= SDoc
module_name
| Bool
otherwise
= SDoc
package_name SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'/' SDoc -> SDoc -> SDoc
<> SDoc
module_name