{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE CPP #-}
module Rattus.Plugin.Dependency (dependency, HasBV (..),printBinds) where
import GhcPlugins
import Bag
#if __GLASGOW_HASKELL__ >= 810
import GHC.Hs.Extension
import GHC.Hs.Expr
import GHC.Hs.Pat
import GHC.Hs.Binds
import GHC.Hs.Types
#else
import HsExtension
import HsExpr
import HsPat
import HsBinds
import HsTypes
#endif
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Graph
import Data.Maybe
import Data.Either
import Prelude hiding ((<>))
dependency :: Bag (LHsBindLR GhcTc GhcTc) -> [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
dependency :: Bag (LHsBindLR GhcTc GhcTc)
-> [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
dependency Bag (LHsBindLR GhcTc GhcTc)
binds = ((LHsBindLR GhcTc GhcTc, Set Var)
-> SCC (LHsBindLR GhcTc GhcTc, Set Var))
-> [(LHsBindLR GhcTc GhcTc, Set Var)]
-> [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
forall a b. (a -> b) -> [a] -> [b]
map (LHsBindLR GhcTc GhcTc, Set Var)
-> SCC (LHsBindLR GhcTc GhcTc, Set Var)
forall vertex. vertex -> SCC vertex
AcyclicSCC [(LHsBindLR GhcTc GhcTc, Set Var)]
noDeps [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
-> [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
-> [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
forall a. [a] -> [a] -> [a]
++ [Maybe (SCC (LHsBindLR GhcTc GhcTc, Set Var))]
-> [SCC (LHsBindLR GhcTc GhcTc, Set Var)]
forall a. [Maybe a] -> [a]
catMaybes ((SCC (Maybe (LHsBindLR GhcTc GhcTc, Set Var))
-> Maybe (SCC (LHsBindLR GhcTc GhcTc, Set Var)))
-> [SCC (Maybe (LHsBindLR GhcTc GhcTc, Set Var))]
-> [Maybe (SCC (LHsBindLR GhcTc GhcTc, Set Var))]
forall a b. (a -> b) -> [a] -> [b]
map SCC (Maybe (LHsBindLR GhcTc GhcTc, Set Var))
-> Maybe (SCC (LHsBindLR GhcTc GhcTc, Set Var))
forall vertex. SCC (Maybe vertex) -> Maybe (SCC vertex)
filterJust ([(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
-> [SCC (Maybe (LHsBindLR GhcTc GhcTc, Set Var))]
forall key node. Ord key => [(node, key, [key])] -> [SCC node]
stronglyConnComp ([[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]]
-> [(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]]
deps)))
where ([[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]]
deps,[(LHsBindLR GhcTc GhcTc, Set Var)]
noDeps) = [Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)]
-> ([[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]],
[(LHsBindLR GhcTc GhcTc, Set Var)])
forall a b. [Either a b] -> ([a], [b])
partitionEithers ([Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)]
-> ([[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]],
[(LHsBindLR GhcTc GhcTc, Set Var)]))
-> [Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)]
-> ([[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]],
[(LHsBindLR GhcTc GhcTc, Set Var)])
forall a b. (a -> b) -> a -> b
$ (LHsBindLR GhcTc GhcTc
-> Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var))
-> [LHsBindLR GhcTc GhcTc]
-> [Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)]
forall a b. (a -> b) -> [a] -> [b]
map LHsBindLR GhcTc GhcTc
-> Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)
forall l.
GenLocated l (HsBindLR GhcTc GhcTc)
-> Either
[(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
(GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
mkDep ([LHsBindLR GhcTc GhcTc]
-> [Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)])
-> [LHsBindLR GhcTc GhcTc]
-> [Either
[(Maybe (LHsBindLR GhcTc GhcTc, Set Var), Name, [Name])]
(LHsBindLR GhcTc GhcTc, Set Var)]
forall a b. (a -> b) -> a -> b
$ Bag (LHsBindLR GhcTc GhcTc) -> [LHsBindLR GhcTc GhcTc]
forall a. Bag a -> [a]
bagToList Bag (LHsBindLR GhcTc GhcTc)
binds
mkDep :: GenLocated l (HsBindLR GhcTc GhcTc) ->
Either [(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name, [Name])]
(GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
mkDep :: GenLocated l (HsBindLR GhcTc GhcTc)
-> Either
[(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
(GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
mkDep GenLocated l (HsBindLR GhcTc GhcTc)
b =
let dep :: [Name]
dep = (Var -> Name) -> [Var] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Var -> Name
varName ([Var] -> [Name]) -> [Var] -> [Name]
forall a b. (a -> b) -> a -> b
$ Set Var -> [Var]
forall a. Set a -> [a]
Set.toList (GenLocated l (HsBindLR GhcTc GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV GenLocated l (HsBindLR GhcTc GhcTc)
b)
vars :: Set Var
vars = GenLocated l (HsBindLR GhcTc GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV GenLocated l (HsBindLR GhcTc GhcTc)
b in
case Set Var -> [Var]
forall a. Set a -> [a]
Set.toList Set Var
vars of
(Var
v:[Var]
vs) -> [(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
-> Either
[(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
(GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
forall a b. a -> Either a b
Left (((GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
-> Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
forall a. a -> Maybe a
Just (GenLocated l (HsBindLR GhcTc GhcTc)
b,Set Var
vars), Var -> Name
varName Var
v , [Name]
dep) (Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])
-> [(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
-> [(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
forall a. a -> [a] -> [a]
: (Var
-> (Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name]))
-> [Var]
-> [(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
forall a b. (a -> b) -> [a] -> [b]
map (\ Var
v' -> (Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
forall a. Maybe a
Nothing, Var -> Name
varName Var
v' , [Name]
dep)) [Var]
vs)
[] -> (GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
-> Either
[(Maybe (GenLocated l (HsBindLR GhcTc GhcTc), Set Var), Name,
[Name])]
(GenLocated l (HsBindLR GhcTc GhcTc), Set Var)
forall a b. b -> Either a b
Right (GenLocated l (HsBindLR GhcTc GhcTc)
b,Set Var
vars)
filterJust :: SCC (Maybe vertex) -> Maybe (SCC vertex)
filterJust (AcyclicSCC Maybe vertex
Nothing) = Maybe (SCC vertex)
forall a. Maybe a
Nothing
filterJust (AcyclicSCC (Just vertex
b)) = SCC vertex -> Maybe (SCC vertex)
forall a. a -> Maybe a
Just (vertex -> SCC vertex
forall vertex. vertex -> SCC vertex
AcyclicSCC vertex
b)
filterJust (CyclicSCC [Maybe vertex]
bs) = SCC vertex -> Maybe (SCC vertex)
forall a. a -> Maybe a
Just ([vertex] -> SCC vertex
forall vertex. [vertex] -> SCC vertex
CyclicSCC ([Maybe vertex] -> [vertex]
forall a. [Maybe a] -> [a]
catMaybes [Maybe vertex]
bs))
printBinds :: SCC (GenLocated l (HsBindLR p idR), b) -> m ()
printBinds (AcyclicSCC (GenLocated l (HsBindLR p idR), b)
bind) = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (String -> IO ()
putStr String
"acyclic bind: ") m () -> m () -> m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> GenLocated l (HsBindLR p idR) -> m ()
forall (m :: * -> *) p l idR.
(MonadIO m, NamedThing (IdP p)) =>
GenLocated l (HsBindLR p idR) -> m ()
printBind ((GenLocated l (HsBindLR p idR), b) -> GenLocated l (HsBindLR p idR)
forall a b. (a, b) -> a
fst (GenLocated l (HsBindLR p idR), b)
bind) m () -> m () -> m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (String -> IO ()
putStrLn String
"")
printBinds (CyclicSCC [(GenLocated l (HsBindLR p idR), b)]
binds) = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (String -> IO ()
putStr String
"cyclic binds: ") m () -> m () -> m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ((GenLocated l (HsBindLR p idR), b) -> m ())
-> [(GenLocated l (HsBindLR p idR), b)] -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (GenLocated l (HsBindLR p idR) -> m ()
forall (m :: * -> *) p l idR.
(MonadIO m, NamedThing (IdP p)) =>
GenLocated l (HsBindLR p idR) -> m ()
printBind (GenLocated l (HsBindLR p idR) -> m ())
-> ((GenLocated l (HsBindLR p idR), b)
-> GenLocated l (HsBindLR p idR))
-> (GenLocated l (HsBindLR p idR), b)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenLocated l (HsBindLR p idR), b) -> GenLocated l (HsBindLR p idR)
forall a b. (a, b) -> a
fst) [(GenLocated l (HsBindLR p idR), b)]
binds m () -> m () -> m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (String -> IO ()
putStrLn String
"")
printBind :: GenLocated l (HsBindLR p idR) -> m ()
printBind (L l
_ FunBind{fun_id :: forall idL idR. HsBindLR idL idR -> Located (IdP idL)
fun_id = L SrcSpan
_ IdP p
name}) =
IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
putStr (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ (IdP p -> String
forall a. NamedThing a => a -> String
getOccString IdP p
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" ")
printBind (L l
_ (AbsBinds {abs_exports :: forall idL idR. HsBindLR idL idR -> [ABExport idL]
abs_exports = [ABExport p]
exp})) =
(ABExport p -> m ()) -> [ABExport p] -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\ ABExport p
e -> IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
putStr (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ ((IdP p -> String
forall a. NamedThing a => a -> String
getOccString (IdP p -> String) -> IdP p -> String
forall a b. (a -> b) -> a -> b
$ ABExport p -> IdP p
forall p. ABExport p -> IdP p
abe_poly ABExport p
e) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" ")) [ABExport p]
exp
printBind (L l
_ (VarBind {var_id :: forall idL idR. HsBindLR idL idR -> IdP idL
var_id = IdP p
name})) = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
putStr (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ (IdP p -> String
forall a. NamedThing a => a -> String
getOccString IdP p
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" ")
printBind GenLocated l (HsBindLR p idR)
_ = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
class HasBV a where
getBV :: a -> Set Var
instance HasBV (HsBindLR GhcTc GhcTc) where
getBV :: HsBindLR GhcTc GhcTc -> Set Var
getBV (FunBind{fun_id :: forall idL idR. HsBindLR idL idR -> Located (IdP idL)
fun_id = L SrcSpan
_ IdP GhcTc
v}) = Var -> Set Var
forall a. a -> Set a
Set.singleton IdP GhcTc
Var
v
getBV (AbsBinds {abs_exports :: forall idL idR. HsBindLR idL idR -> [ABExport idL]
abs_exports = [ABExport GhcTc]
es}) = [Var] -> Set Var
forall a. Ord a => [a] -> Set a
Set.fromList ((ABExport GhcTc -> Var) -> [ABExport GhcTc] -> [Var]
forall a b. (a -> b) -> [a] -> [b]
map ABExport GhcTc -> Var
forall p. ABExport p -> IdP p
abe_poly [ABExport GhcTc]
es)
getBV (PatBind {pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat GhcTc
pat}) = Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
pat
getBV (VarBind {var_id :: forall idL idR. HsBindLR idL idR -> IdP idL
var_id = IdP GhcTc
v}) = Var -> Set Var
forall a. a -> Set a
Set.singleton IdP GhcTc
Var
v
getBV PatSynBind{} = Set Var
forall a. Set a
Set.empty
getBV XHsBindsLR{} = Set Var
forall a. Set a
Set.empty
instance HasBV a => HasBV (GenLocated b a) where
getBV :: GenLocated b a -> Set Var
getBV (L b
_ a
e) = a -> Set Var
forall a. HasBV a => a -> Set Var
getBV a
e
instance HasBV a => HasBV [a] where
getBV :: [a] -> Set Var
getBV [a]
ps = (Set Var -> a -> Set Var) -> Set Var -> [a] -> Set Var
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (\Set Var
s a
p -> a -> Set Var
forall a. HasBV a => a -> Set Var
getBV a
p Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` Set Var
s) Set Var
forall a. Set a
Set.empty [a]
ps
getConBV :: HsConDetails a (HsRecFields p a) -> Set Var
getConBV (PrefixCon [a]
ps) = [a] -> Set Var
forall a. HasBV a => a -> Set Var
getBV [a]
ps
getConBV (InfixCon a
p a
p') = a -> Set Var
forall a. HasBV a => a -> Set Var
getBV a
p Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` a -> Set Var
forall a. HasBV a => a -> Set Var
getBV a
p'
getConBV (RecCon (HsRecFields {rec_flds :: forall p arg. HsRecFields p arg -> [LHsRecField p arg]
rec_flds = [LHsRecField p a]
fs})) = (Set Var -> LHsRecField p a -> Set Var)
-> Set Var -> [LHsRecField p a] -> Set Var
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl Set Var -> LHsRecField p a -> Set Var
forall a l id.
HasBV a =>
Set Var -> GenLocated l (HsRecField' id a) -> Set Var
run Set Var
forall a. Set a
Set.empty [LHsRecField p a]
fs
where run :: Set Var -> GenLocated l (HsRecField' id a) -> Set Var
run Set Var
s (L l
_ HsRecField' id a
f) = a -> Set Var
forall a. HasBV a => a -> Set Var
getBV (HsRecField' id a -> a
forall id arg. HsRecField' id arg -> arg
hsRecFieldArg HsRecField' id a
f) Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` Set Var
s
instance HasBV (Pat GhcTc) where
getBV :: Pat GhcTc -> Set Var
getBV (VarPat XVarPat GhcTc
_ (L SrcSpan
_ IdP GhcTc
v)) = Var -> Set Var
forall a. a -> Set a
Set.singleton IdP GhcTc
Var
v
getBV (LazyPat XLazyPat GhcTc
_ LPat GhcTc
p) = Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p
getBV (AsPat XAsPat GhcTc
_ (L SrcSpan
_ IdP GhcTc
v) LPat GhcTc
p) = Var -> Set Var -> Set Var
forall a. Ord a => a -> Set a -> Set a
Set.insert IdP GhcTc
Var
v (Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p)
getBV (ParPat XParPat GhcTc
_ LPat GhcTc
p) = Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p
getBV (BangPat XBangPat GhcTc
_ LPat GhcTc
p) = Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p
getBV (ListPat XListPat GhcTc
_ [LPat GhcTc]
ps) = [Located (Pat GhcTc)] -> Set Var
forall a. HasBV a => a -> Set Var
getBV [LPat GhcTc]
[Located (Pat GhcTc)]
ps
getBV (TuplePat XTuplePat GhcTc
_ [LPat GhcTc]
ps Boxity
_) = [Located (Pat GhcTc)] -> Set Var
forall a. HasBV a => a -> Set Var
getBV [LPat GhcTc]
[Located (Pat GhcTc)]
ps
getBV (SumPat XSumPat GhcTc
_ LPat GhcTc
p ConTag
_ ConTag
_) = Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p
getBV (ConPatIn (L SrcSpan
_ IdP GhcTc
v) HsConPatDetails GhcTc
con) = Var -> Set Var -> Set Var
forall a. Ord a => a -> Set a -> Set a
Set.insert IdP GhcTc
Var
v (HsConDetails
(Located (Pat GhcTc)) (HsRecFields GhcTc (Located (Pat GhcTc)))
-> Set Var
forall a a p.
(HasBV a, HasBV a) =>
HsConDetails a (HsRecFields p a) -> Set Var
getConBV HsConPatDetails GhcTc
HsConDetails
(Located (Pat GhcTc)) (HsRecFields GhcTc (Located (Pat GhcTc)))
con)
getBV (ConPatOut {pat_args :: forall p. Pat p -> HsConPatDetails p
pat_args = HsConPatDetails GhcTc
con}) = HsConDetails
(Located (Pat GhcTc)) (HsRecFields GhcTc (Located (Pat GhcTc)))
-> Set Var
forall a a p.
(HasBV a, HasBV a) =>
HsConDetails a (HsRecFields p a) -> Set Var
getConBV HsConPatDetails GhcTc
HsConDetails
(Located (Pat GhcTc)) (HsRecFields GhcTc (Located (Pat GhcTc)))
con
getBV (ViewPat XViewPat GhcTc
_ LHsExpr GhcTc
_ LPat GhcTc
p) = Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p
getBV (SplicePat XSplicePat GhcTc
_ HsSplice GhcTc
sp) =
case HsSplice GhcTc
sp of
HsTypedSplice XTypedSplice GhcTc
_ SpliceDecoration
_ IdP GhcTc
v LHsExpr GhcTc
_ -> Var -> Set Var
forall a. a -> Set a
Set.singleton IdP GhcTc
Var
v
HsUntypedSplice XUntypedSplice GhcTc
_ SpliceDecoration
_ IdP GhcTc
v LHsExpr GhcTc
_ -> Var -> Set Var
forall a. a -> Set a
Set.singleton IdP GhcTc
Var
v
HsQuasiQuote XQuasiQuote GhcTc
_ IdP GhcTc
p IdP GhcTc
p' SrcSpan
_ FastString
_ -> [Var] -> Set Var
forall a. Ord a => [a] -> Set a
Set.fromList [IdP GhcTc
Var
p,IdP GhcTc
Var
p']
HsSpliced XSpliced GhcTc
_ ThModFinalizers
_ (HsSplicedPat Pat GhcTc
p) -> Pat GhcTc -> Set Var
forall a. HasBV a => a -> Set Var
getBV Pat GhcTc
p
HsSplice GhcTc
_ -> Set Var
forall a. Set a
Set.empty
getBV (NPlusKPat XNPlusKPat GhcTc
_ (L SrcSpan
_ IdP GhcTc
v) Located (HsOverLit GhcTc)
_ HsOverLit GhcTc
_ SyntaxExpr GhcTc
_ SyntaxExpr GhcTc
_) = Var -> Set Var
forall a. a -> Set a
Set.singleton IdP GhcTc
Var
v
getBV (CoPat XCoPat GhcTc
_ HsWrapper
_ Pat GhcTc
p Type
_) = Pat GhcTc -> Set Var
forall a. HasBV a => a -> Set Var
getBV Pat GhcTc
p
getBV (NPat {}) = Set Var
forall a. Set a
Set.empty
getBV (XPat XXPat GhcTc
p) = NoExtCon -> Set Var
forall a. HasBV a => a -> Set Var
getBV NoExtCon
XXPat GhcTc
p
getBV (WildPat {}) = Set Var
forall a. Set a
Set.empty
getBV (LitPat {}) = Set Var
forall a. Set a
Set.empty
#if __GLASGOW_HASKELL__ >= 808
getBV (SigPat XSigPat GhcTc
_ LPat GhcTc
p LHsSigWcType (NoGhcTc GhcTc)
_) =
#else
getBV (SigPat _ p) =
#endif
Located (Pat GhcTc) -> Set Var
forall a. HasBV a => a -> Set Var
getBV LPat GhcTc
Located (Pat GhcTc)
p
#if __GLASGOW_HASKELL__ >= 810
instance HasBV NoExtCon where
#else
instance HasBV NoExt where
#endif
getBV :: NoExtCon -> Set Var
getBV NoExtCon
_ = Set Var
forall a. Set a
Set.empty
class HasFV a where
getFV :: a -> Set Var
instance HasFV a => HasFV (GenLocated b a) where
getFV :: GenLocated b a -> Set Var
getFV (L b
_ a
e) = a -> Set Var
forall a. HasFV a => a -> Set Var
getFV a
e
instance HasFV a => HasFV [a] where
getFV :: [a] -> Set Var
getFV [a]
es = (a -> Set Var) -> [a] -> Set Var
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> Set Var
forall a. HasFV a => a -> Set Var
getFV [a]
es
instance HasFV a => HasFV (Bag a) where
getFV :: Bag a -> Set Var
getFV Bag a
es = (a -> Set Var) -> Bag a -> Set Var
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> Set Var
forall a. HasFV a => a -> Set Var
getFV Bag a
es
instance HasFV Var where
getFV :: Var -> Set Var
getFV Var
v = Var -> Set Var
forall a. a -> Set a
Set.singleton Var
v
instance HasFV a => HasFV (MatchGroup GhcTc a) where
getFV :: MatchGroup GhcTc a -> Set Var
getFV MG {mg_alts :: forall p body. MatchGroup p body -> Located [LMatch p body]
mg_alts = Located [LMatch GhcTc a]
alts} = Located [LMatch GhcTc a] -> Set Var
forall a. HasFV a => a -> Set Var
getFV Located [LMatch GhcTc a]
alts
getFV XMatchGroup{} = Set Var
forall a. Set a
Set.empty
instance HasFV a => HasFV (Match GhcTc a) where
getFV :: Match GhcTc a -> Set Var
getFV Match {m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs GhcTc a
rhss} = GRHSs GhcTc a -> Set Var
forall a. HasFV a => a -> Set Var
getFV GRHSs GhcTc a
rhss
getFV XMatch{} = Set Var
forall a. Set a
Set.empty
instance HasFV (HsTupArg GhcTc) where
getFV :: HsTupArg GhcTc -> Set Var
getFV (Present XPresent GhcTc
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV HsTupArg GhcTc
_ = Set Var
forall a. Set a
Set.empty
instance HasFV a => HasFV (GRHS GhcTc a) where
getFV :: GRHS GhcTc a -> Set Var
getFV (GRHS XCGRHS GhcTc a
_ [GuardLStmt GhcTc]
g a
b) = [GuardLStmt GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [GuardLStmt GhcTc]
g Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` a -> Set Var
forall a. HasFV a => a -> Set Var
getFV a
b
getFV XGRHS{} = Set Var
forall a. Set a
Set.empty
instance HasFV a => HasFV (GRHSs GhcTc a) where
getFV :: GRHSs GhcTc a -> Set Var
getFV GRHSs {grhssGRHSs :: forall p body. GRHSs p body -> [LGRHS p body]
grhssGRHSs = [LGRHS GhcTc a]
rhs, grhssLocalBinds :: forall p body. GRHSs p body -> LHsLocalBinds p
grhssLocalBinds = LHsLocalBinds GhcTc
lbs} =
[LGRHS GhcTc a] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LGRHS GhcTc a]
rhs Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsLocalBinds GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsLocalBinds GhcTc
lbs
getFV GRHSs GhcTc a
_ = Set Var
forall a. Set a
Set.empty
instance HasFV (HsLocalBindsLR GhcTc GhcTc) where
getFV :: HsLocalBindsLR GhcTc GhcTc -> Set Var
getFV (HsValBinds XHsValBinds GhcTc GhcTc
_ HsValBindsLR GhcTc GhcTc
bs) = HsValBindsLR GhcTc GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsValBindsLR GhcTc GhcTc
bs
getFV (HsIPBinds XHsIPBinds GhcTc GhcTc
_ HsIPBinds GhcTc
bs) = HsIPBinds GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsIPBinds GhcTc
bs
getFV HsLocalBindsLR GhcTc GhcTc
_ = Set Var
forall a. Set a
Set.empty
instance HasFV (HsValBindsLR GhcTc GhcTc) where
getFV :: HsValBindsLR GhcTc GhcTc -> Set Var
getFV (ValBinds XValBinds GhcTc GhcTc
_ Bag (LHsBindLR GhcTc GhcTc)
b [LSig GhcTc]
_) = Bag (LHsBindLR GhcTc GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV Bag (LHsBindLR GhcTc GhcTc)
b
getFV (XValBindsLR XXValBindsLR GhcTc GhcTc
b) = NHsValBindsLR GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV NHsValBindsLR GhcTc
XXValBindsLR GhcTc GhcTc
b
instance HasFV (NHsValBindsLR GhcTc) where
getFV :: NHsValBindsLR GhcTc -> Set Var
getFV (NValBinds [(RecFlag, Bag (LHsBindLR GhcTc GhcTc))]
bs [LSig GhcRn]
_) = ((RecFlag, Bag (LHsBindLR GhcTc GhcTc)) -> Set Var)
-> [(RecFlag, Bag (LHsBindLR GhcTc GhcTc))] -> Set Var
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Bag (LHsBindLR GhcTc GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV (Bag (LHsBindLR GhcTc GhcTc) -> Set Var)
-> ((RecFlag, Bag (LHsBindLR GhcTc GhcTc))
-> Bag (LHsBindLR GhcTc GhcTc))
-> (RecFlag, Bag (LHsBindLR GhcTc GhcTc))
-> Set Var
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RecFlag, Bag (LHsBindLR GhcTc GhcTc))
-> Bag (LHsBindLR GhcTc GhcTc)
forall a b. (a, b) -> b
snd) [(RecFlag, Bag (LHsBindLR GhcTc GhcTc))]
bs
instance HasFV (HsBindLR GhcTc GhcTc) where
getFV :: HsBindLR GhcTc GhcTc -> Set Var
getFV FunBind {fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches = MatchGroup GhcTc (LHsExpr GhcTc)
ms} = MatchGroup GhcTc (LHsExpr GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV MatchGroup GhcTc (LHsExpr GhcTc)
ms
getFV PatBind {pat_rhs :: forall idL idR. HsBindLR idL idR -> GRHSs idR (LHsExpr idR)
pat_rhs = GRHSs GhcTc (LHsExpr GhcTc)
rhs} = GRHSs GhcTc (LHsExpr GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV GRHSs GhcTc (LHsExpr GhcTc)
rhs
getFV VarBind {var_rhs :: forall idL idR. HsBindLR idL idR -> LHsExpr idR
var_rhs = LHsExpr GhcTc
rhs} = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
rhs
getFV AbsBinds {abs_binds :: forall idL idR. HsBindLR idL idR -> LHsBinds idL
abs_binds = Bag (LHsBindLR GhcTc GhcTc)
bs} = Bag (LHsBindLR GhcTc GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV Bag (LHsBindLR GhcTc GhcTc)
bs
getFV HsBindLR GhcTc GhcTc
_ = Set Var
forall a. Set a
Set.empty
instance HasFV (IPBind GhcTc) where
getFV :: IPBind GhcTc -> Set Var
getFV (IPBind XCIPBind GhcTc
_ Either (Located HsIPName) (IdP GhcTc)
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV IPBind GhcTc
_ = Set Var
forall a. Set a
Set.empty
instance HasFV (HsIPBinds GhcTc) where
getFV :: HsIPBinds GhcTc -> Set Var
getFV (IPBinds XIPBinds GhcTc
_ [LIPBind GhcTc]
bs) = [LIPBind GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LIPBind GhcTc]
bs
getFV HsIPBinds GhcTc
_ = Set Var
forall a. Set a
Set.empty
instance HasFV (ApplicativeArg GhcTc) where
#if __GLASGOW_HASKELL__ >= 810
getFV :: ApplicativeArg GhcTc -> Set Var
getFV (ApplicativeArgOne XApplicativeArgOne GhcTc
_ LPat GhcTc
_ LHsExpr GhcTc
e Bool
_ SyntaxExpr GhcTc
_)
#else
getFV (ApplicativeArgOne _ _ e _)
#endif
= LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (ApplicativeArgMany XApplicativeArgMany GhcTc
_ [GuardLStmt GhcTc]
es HsExpr GhcTc
e LPat GhcTc
_) = [GuardLStmt GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [GuardLStmt GhcTc]
es Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` HsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsExpr GhcTc
e
getFV XApplicativeArg{} = Set Var
forall a. Set a
Set.empty
instance HasFV (ParStmtBlock GhcTc GhcTc) where
getFV :: ParStmtBlock GhcTc GhcTc -> Set Var
getFV (ParStmtBlock XParStmtBlock GhcTc GhcTc
_ [GuardLStmt GhcTc]
es [IdP GhcTc]
_ SyntaxExpr GhcTc
_) = [GuardLStmt GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [GuardLStmt GhcTc]
es
getFV XParStmtBlock{} = Set Var
forall a. Set a
Set.empty
instance HasFV a => HasFV (StmtLR GhcTc GhcTc a) where
getFV :: StmtLR GhcTc GhcTc a -> Set Var
getFV (LastStmt XLastStmt GhcTc GhcTc a
_ a
e Bool
_ SyntaxExpr GhcTc
_) = a -> Set Var
forall a. HasFV a => a -> Set Var
getFV a
e
getFV (BindStmt XBindStmt GhcTc GhcTc a
_ LPat GhcTc
_ a
e SyntaxExpr GhcTc
_ SyntaxExpr GhcTc
_) = a -> Set Var
forall a. HasFV a => a -> Set Var
getFV a
e
getFV (ApplicativeStmt XApplicativeStmt GhcTc GhcTc a
_ [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)]
args Maybe (SyntaxExpr GhcTc)
_) = ((SyntaxExpr GhcTc, ApplicativeArg GhcTc) -> Set Var)
-> [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)] -> Set Var
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (ApplicativeArg GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV (ApplicativeArg GhcTc -> Set Var)
-> ((SyntaxExpr GhcTc, ApplicativeArg GhcTc)
-> ApplicativeArg GhcTc)
-> (SyntaxExpr GhcTc, ApplicativeArg GhcTc)
-> Set Var
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SyntaxExpr GhcTc, ApplicativeArg GhcTc) -> ApplicativeArg GhcTc
forall a b. (a, b) -> b
snd) [(SyntaxExpr GhcTc, ApplicativeArg GhcTc)]
args
getFV (BodyStmt XBodyStmt GhcTc GhcTc a
_ a
e SyntaxExpr GhcTc
_ SyntaxExpr GhcTc
_) = a -> Set Var
forall a. HasFV a => a -> Set Var
getFV a
e
getFV (LetStmt XLetStmt GhcTc GhcTc a
_ LHsLocalBinds GhcTc
bs) = LHsLocalBinds GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsLocalBinds GhcTc
bs
getFV (ParStmt XParStmt GhcTc GhcTc a
_ [ParStmtBlock GhcTc GhcTc]
stms HsExpr GhcTc
e SyntaxExpr GhcTc
_) = [ParStmtBlock GhcTc GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [ParStmtBlock GhcTc GhcTc]
stms Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` HsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsExpr GhcTc
e
getFV TransStmt{} = Set Var
forall a. Set a
Set.empty
getFV RecStmt{} = Set Var
forall a. Set a
Set.empty
getFV XStmtLR{} = Set Var
forall a. Set a
Set.empty
instance HasFV (HsRecordBinds GhcTc) where
getFV :: HsRecordBinds GhcTc -> Set Var
getFV HsRecFields{rec_flds :: forall p arg. HsRecFields p arg -> [LHsRecField p arg]
rec_flds = [LHsRecField GhcTc (LHsExpr GhcTc)]
fs} = [LHsRecField GhcTc (LHsExpr GhcTc)] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LHsRecField GhcTc (LHsExpr GhcTc)]
fs
instance HasFV (HsRecField' o (LHsExpr GhcTc)) where
getFV :: HsRecField' o (LHsExpr GhcTc) -> Set Var
getFV HsRecField {hsRecFieldArg :: forall id arg. HsRecField' id arg -> arg
hsRecFieldArg = LHsExpr GhcTc
arg} = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
arg
instance HasFV (ArithSeqInfo GhcTc) where
getFV :: ArithSeqInfo GhcTc -> Set Var
getFV (From LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (FromThen LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
getFV (FromTo LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
getFV (FromThenTo LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 LHsExpr GhcTc
e3) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e3
instance HasFV (HsBracket GhcTc) where
getFV :: HsBracket GhcTc -> Set Var
getFV (ExpBr XExpBr GhcTc
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (VarBr XVarBr GhcTc
_ Bool
_ IdP GhcTc
e) = Var -> Set Var
forall a. HasFV a => a -> Set Var
getFV IdP GhcTc
Var
e
getFV HsBracket GhcTc
_ = Set Var
forall a. Set a
Set.empty
instance HasFV (HsCmd GhcTc) where
getFV :: HsCmd GhcTc -> Set Var
getFV (HsCmdArrApp XCmdArrApp GhcTc
_ LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 HsArrAppType
_ Bool
_) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
getFV (HsCmdArrForm XCmdArrForm GhcTc
_ LHsExpr GhcTc
e LexicalFixity
_ Maybe Fixity
_ [LHsCmdTop GhcTc]
cmd) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` [LHsCmdTop GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LHsCmdTop GhcTc]
cmd
getFV (HsCmdApp XCmdApp GhcTc
_ LHsCmd GhcTc
e1 LHsExpr GhcTc
e2) = LHsCmd GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsCmd GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
getFV (HsCmdLam XCmdLam GhcTc
_ MatchGroup GhcTc (LHsCmd GhcTc)
l) = MatchGroup GhcTc (LHsCmd GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV MatchGroup GhcTc (LHsCmd GhcTc)
l
getFV (HsCmdPar XCmdPar GhcTc
_ LHsCmd GhcTc
cmd) = LHsCmd GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsCmd GhcTc
cmd
getFV (HsCmdCase XCmdCase GhcTc
_ LHsExpr GhcTc
_ MatchGroup GhcTc (LHsCmd GhcTc)
mg) = MatchGroup GhcTc (LHsCmd GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV MatchGroup GhcTc (LHsCmd GhcTc)
mg
getFV (HsCmdIf XCmdIf GhcTc
_ Maybe (SyntaxExpr GhcTc)
_ LHsExpr GhcTc
e1 LHsCmd GhcTc
e2 LHsCmd GhcTc
e3) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsCmd GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsCmd GhcTc
e2 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsCmd GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsCmd GhcTc
e3
getFV (HsCmdLet XCmdLet GhcTc
_ LHsLocalBinds GhcTc
bs LHsCmd GhcTc
_) = LHsLocalBinds GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsLocalBinds GhcTc
bs
getFV (HsCmdDo XCmdDo GhcTc
_ Located [CmdLStmt GhcTc]
cmd) = Located [CmdLStmt GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV Located [CmdLStmt GhcTc]
cmd
getFV (HsCmdWrap XCmdWrap GhcTc
_ HsWrapper
_ HsCmd GhcTc
cmd) = HsCmd GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsCmd GhcTc
cmd
getFV XCmd{} = Set Var
forall a. Set a
Set.empty
instance HasFV (HsCmdTop GhcTc) where
getFV :: HsCmdTop GhcTc -> Set Var
getFV (HsCmdTop XCmdTop GhcTc
_ LHsCmd GhcTc
cmd) = LHsCmd GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsCmd GhcTc
cmd
getFV XCmdTop{} = Set Var
forall a. Set a
Set.empty
instance HasFV (HsExpr GhcTc) where
getFV :: HsExpr GhcTc -> Set Var
getFV (HsVar XVar GhcTc
_ GenLocated SrcSpan (IdP GhcTc)
v) = Located Var -> Set Var
forall a. HasFV a => a -> Set Var
getFV GenLocated SrcSpan (IdP GhcTc)
Located Var
v
getFV HsUnboundVar {} = Set Var
forall a. Set a
Set.empty
getFV HsConLikeOut {} = Set Var
forall a. Set a
Set.empty
getFV HsRecFld {} = Set Var
forall a. Set a
Set.empty
getFV HsOverLabel {} = Set Var
forall a. Set a
Set.empty
getFV HsIPVar {} = Set Var
forall a. Set a
Set.empty
getFV HsOverLit {} = Set Var
forall a. Set a
Set.empty
getFV HsLit {} = Set Var
forall a. Set a
Set.empty
getFV (HsLam XLam GhcTc
_ MatchGroup GhcTc (LHsExpr GhcTc)
mg) = MatchGroup GhcTc (LHsExpr GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV MatchGroup GhcTc (LHsExpr GhcTc)
mg
getFV (HsLamCase XLamCase GhcTc
_ MatchGroup GhcTc (LHsExpr GhcTc)
mg) = MatchGroup GhcTc (LHsExpr GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV MatchGroup GhcTc (LHsExpr GhcTc)
mg
getFV (HsApp XApp GhcTc
_ LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
#if __GLASGOW_HASKELL__ >= 808
getFV (HsAppType XAppTypeE GhcTc
_ LHsExpr GhcTc
e LHsWcType (NoGhcTc GhcTc)
_)
#else
getFV (HsAppType _ e)
#endif
= LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (OpApp XOpApp GhcTc
_ LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 LHsExpr GhcTc
e3) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e3
getFV (NegApp XNegApp GhcTc
_ LHsExpr GhcTc
e SyntaxExpr GhcTc
_) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsPar XPar GhcTc
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (SectionL XSectionL GhcTc
_ LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
getFV (SectionR XSectionR GhcTc
_ LHsExpr GhcTc
e1 LHsExpr GhcTc
e2) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2
getFV (ExplicitTuple XExplicitTuple GhcTc
_ [LHsTupArg GhcTc]
es Boxity
_) = [LHsTupArg GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LHsTupArg GhcTc]
es
getFV (ExplicitSum XExplicitSum GhcTc
_ ConTag
_ ConTag
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsCase XCase GhcTc
_ LHsExpr GhcTc
e MatchGroup GhcTc (LHsExpr GhcTc)
mg) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` MatchGroup GhcTc (LHsExpr GhcTc) -> Set Var
forall a. HasFV a => a -> Set Var
getFV MatchGroup GhcTc (LHsExpr GhcTc)
mg
getFV (HsIf XIf GhcTc
_ Maybe (SyntaxExpr GhcTc)
_ LHsExpr GhcTc
e1 LHsExpr GhcTc
e2 LHsExpr GhcTc
e3) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e1 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e2 Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e3
getFV (HsMultiIf XMultiIf GhcTc
_ [LGRHS GhcTc (LHsExpr GhcTc)]
es) = [LGRHS GhcTc (LHsExpr GhcTc)] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LGRHS GhcTc (LHsExpr GhcTc)]
es
getFV (HsLet XLet GhcTc
_ LHsLocalBinds GhcTc
bs LHsExpr GhcTc
e) = LHsLocalBinds GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsLocalBinds GhcTc
bs Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsDo XDo GhcTc
_ HsStmtContext Name
_ Located [GuardLStmt GhcTc]
e) = Located [GuardLStmt GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV Located [GuardLStmt GhcTc]
e
getFV (ExplicitList XExplicitList GhcTc
_ Maybe (SyntaxExpr GhcTc)
_ [LHsExpr GhcTc]
es) = [LHsExpr GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LHsExpr GhcTc]
es
getFV (RecordCon {rcon_flds :: forall p. HsExpr p -> HsRecordBinds p
rcon_flds = HsRecordBinds GhcTc
fs}) = HsRecordBinds GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsRecordBinds GhcTc
fs
getFV (RecordUpd {rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr GhcTc
e, rupd_flds :: forall p. HsExpr p -> [LHsRecUpdField p]
rupd_flds = [LHsRecUpdField GhcTc]
fs}) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e Set Var -> Set Var -> Set Var
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` [LHsRecUpdField GhcTc] -> Set Var
forall a. HasFV a => a -> Set Var
getFV [LHsRecUpdField GhcTc]
fs
#if __GLASGOW_HASKELL__ >= 808
getFV (ExprWithTySig XExprWithTySig GhcTc
_ LHsExpr GhcTc
e LHsSigWcType (NoGhcTc GhcTc)
_)
#else
getFV (ExprWithTySig _ e)
#endif
= LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (ArithSeq XArithSeq GhcTc
_ Maybe (SyntaxExpr GhcTc)
_ ArithSeqInfo GhcTc
e) = ArithSeqInfo GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV ArithSeqInfo GhcTc
e
getFV (HsSCC XSCC GhcTc
_ SourceText
_ StringLiteral
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsCoreAnn XCoreAnn GhcTc
_ SourceText
_ StringLiteral
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsBracket XBracket GhcTc
_ HsBracket GhcTc
e) = HsBracket GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsBracket GhcTc
e
getFV HsRnBracketOut {} = Set Var
forall a. Set a
Set.empty
getFV HsTcBracketOut {} = Set Var
forall a. Set a
Set.empty
getFV HsSpliceE{} = Set Var
forall a. Set a
Set.empty
getFV (HsProc XProc GhcTc
_ LPat GhcTc
_ LHsCmdTop GhcTc
e) = LHsCmdTop GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsCmdTop GhcTc
e
getFV (HsStatic XStatic GhcTc
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
#if __GLASGOW_HASKELL__ < 810
getFV (HsArrApp _ e1 e2 _ _) = getFV e1 `Set.union` getFV e2
getFV (HsArrForm _ e _ cmd) = getFV e `Set.union` getFV cmd
getFV EWildPat {} = Set.empty
getFV (EAsPat _ e1 e2) = getFV e1 `Set.union` getFV e2
getFV (EViewPat _ e1 e2) = getFV e1 `Set.union` getFV e2
getFV (ELazyPat _ e) = getFV e
#endif
getFV (HsTick XTick GhcTc
_ Tickish (IdP GhcTc)
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsBinTick XBinTick GhcTc
_ ConTag
_ ConTag
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsTickPragma XTickPragma GhcTc
_ SourceText
_ (StringLiteral, (ConTag, ConTag), (ConTag, ConTag))
_ ((SourceText, SourceText), (SourceText, SourceText))
_ LHsExpr GhcTc
e) = LHsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV LHsExpr GhcTc
e
getFV (HsWrap XWrap GhcTc
_ HsWrapper
_ HsExpr GhcTc
e) = HsExpr GhcTc -> Set Var
forall a. HasFV a => a -> Set Var
getFV HsExpr GhcTc
e
getFV XExpr{} = Set Var
forall a. Set a
Set.empty