{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module GHC.Iface.Ext.Ast ( mkHieFile, mkHieFileWithSource, getCompressedAsts, enrichHie) where
import GHC.Utils.Outputable(ppr)
import GHC.Prelude hiding ( head, init, last, tail )
import GHC.Types.Avail ( Avails )
import GHC.Data.Bag ( Bag, bagToList )
import GHC.Types.Basic
import GHC.Data.BooleanFormula
import GHC.Core.Class ( className, classSCSelIds )
import GHC.Core.ConLike ( conLikeName )
import GHC.Core.TyCon ( TyCon, tyConClass_maybe )
import GHC.Core.FVs
import GHC.Core.DataCon ( dataConNonlinearType )
import GHC.Types.FieldLabel
import GHC.Hs
import GHC.Hs.Syn.Type
import GHC.Utils.Monad ( concatMapM, MonadIO(liftIO) )
import GHC.Types.Id ( isDataConId_maybe )
import GHC.Types.Name ( Name, nameSrcSpan, nameUnique )
import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnv, lookupNameEnv )
import GHC.Types.Name.Reader ( RecFieldInfo(..) )
import GHC.Types.SrcLoc
import GHC.Core.Type ( Type )
import GHC.Core.Predicate
import GHC.Core.InstEnv
import GHC.Tc.Types
import GHC.Tc.Types.Evidence
import GHC.Types.Var ( Id, Var, EvId, varName, varType, varUnique )
import GHC.Types.Var.Env
import GHC.Builtin.Uniques
import GHC.Iface.Make ( mkIfaceExports )
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
import GHC.Utils.Misc
import GHC.Data.Maybe
import GHC.Data.FastString
import qualified GHC.Data.Strict as Strict
import GHC.Iface.Ext.Types
import GHC.Iface.Ext.Utils
import GHC.Unit.Module ( ml_hs_file )
import GHC.Unit.Module.ModSummary
import qualified Data.Array as A
import qualified Data.ByteString as BS
import qualified Data.Map as M
import qualified Data.Set as S
import Data.Data ( Data, Typeable )
import Data.Foldable ( toList )
import Data.Functor.Identity ( Identity(..) )
import Data.List.NonEmpty ( NonEmpty(..), nonEmpty )
import qualified Data.List.NonEmpty as NE
import Data.Void ( Void, absurd )
import Control.Monad ( forM_ )
import Control.Monad.Trans.State.Strict
import Control.Monad.Trans.Reader
import Control.Monad.Trans.Class ( lift )
import Control.Applicative ( (<|>) )
type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn]
, Maybe [(LIE GhcRn, Avails)]
, Maybe (LHsDoc GhcRn) )
type TypecheckedSource = LHsBinds GhcTc
type VarMap a = DVarEnv (Var,a)
data HieState = HieState
{ HieState -> NameEnv Id
name_remapping :: NameEnv Id
, HieState -> VarMap (Set ContextInfo)
unlocated_ev_binds :: VarMap (S.Set ContextInfo)
}
addUnlocatedEvBind :: Var -> ContextInfo -> HieM ()
addUnlocatedEvBind :: Id -> ContextInfo -> HieM ()
addUnlocatedEvBind Id
var ContextInfo
ci = do
let go :: (a, Set a) -> (a, Set a) -> (a, Set a)
go (a
a,Set a
b) (a
_,Set a
c) = (a
a,Set a -> Set a -> Set a
forall a. Ord a => Set a -> Set a -> Set a
S.union Set a
b Set a
c)
State HieState () -> HieM ()
forall (m :: * -> *) a. Monad m => m a -> ReaderT NodeOrigin m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (State HieState () -> HieM ()) -> State HieState () -> HieM ()
forall a b. (a -> b) -> a -> b
$ (HieState -> HieState) -> State HieState ()
forall (m :: * -> *) s. Monad m => (s -> s) -> StateT s m ()
modify' ((HieState -> HieState) -> State HieState ())
-> (HieState -> HieState) -> State HieState ()
forall a b. (a -> b) -> a -> b
$ \HieState
s ->
HieState
s { unlocated_ev_binds =
extendDVarEnv_C go (unlocated_ev_binds s)
var (var,S.singleton ci)
}
getUnlocatedEvBinds :: FastString -> HieM (NodeIdentifiers Type,[HieAST Type])
getUnlocatedEvBinds :: FastString -> HieM (NodeIdentifiers Type, [HieAST Type])
getUnlocatedEvBinds FastString
file = do
VarMap (Set ContextInfo)
binds <- State HieState (VarMap (Set ContextInfo))
-> ReaderT NodeOrigin (State HieState) (VarMap (Set ContextInfo))
forall (m :: * -> *) a. Monad m => m a -> ReaderT NodeOrigin m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (State HieState (VarMap (Set ContextInfo))
-> ReaderT NodeOrigin (State HieState) (VarMap (Set ContextInfo)))
-> State HieState (VarMap (Set ContextInfo))
-> ReaderT NodeOrigin (State HieState) (VarMap (Set ContextInfo))
forall a b. (a -> b) -> a -> b
$ (HieState -> VarMap (Set ContextInfo))
-> State HieState (VarMap (Set ContextInfo))
forall (m :: * -> *) s a. Monad m => (s -> a) -> StateT s m a
gets HieState -> VarMap (Set ContextInfo)
unlocated_ev_binds
NodeOrigin
org <- ReaderT NodeOrigin (State HieState) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
let elts :: [(Id, Set ContextInfo)]
elts = VarMap (Set ContextInfo) -> [(Id, Set ContextInfo)]
forall a. DVarEnv a -> [a]
dVarEnvElts VarMap (Set ContextInfo)
binds
mkNodeInfo :: (Id, Set ContextInfo) -> (Either a Name, IdentifierDetails Type)
mkNodeInfo (Id
n,Set ContextInfo
ci) = (Name -> Either a Name
forall a b. b -> Either a b
Right (Id -> Name
varName Id
n), Maybe Type -> Set ContextInfo -> IdentifierDetails Type
forall a. Maybe a -> Set ContextInfo -> IdentifierDetails a
IdentifierDetails (Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Maybe Type) -> Type -> Maybe Type
forall a b. (a -> b) -> a -> b
$ Id -> Type
varType Id
n) Set ContextInfo
ci)
go :: (Id, Set ContextInfo)
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
go e :: (Id, Set ContextInfo)
e@(Id
v,Set ContextInfo
_) ([(Identifier, IdentifierDetails Type)]
xs,[HieAST Type]
ys) = case Name -> SrcSpan
nameSrcSpan (Name -> SrcSpan) -> Name -> SrcSpan
forall a b. (a -> b) -> a -> b
$ Id -> Name
varName Id
v of
RealSrcSpan Span
spn Maybe BufSpan
_
| Span -> FastString
srcSpanFile Span
spn FastString -> FastString -> Bool
forall a. Eq a => a -> a -> Bool
== FastString
file ->
let node :: HieAST Type
node = SourcedNodeInfo Type -> Span -> [HieAST Type] -> HieAST Type
forall a. SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
Node (NodeOrigin -> NodeInfo Type -> SourcedNodeInfo Type
forall a. NodeOrigin -> NodeInfo a -> SourcedNodeInfo a
mkSourcedNodeInfo NodeOrigin
org NodeInfo Type
ni) Span
spn []
ni :: NodeInfo Type
ni = Set NodeAnnotation
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set NodeAnnotation
forall a. Monoid a => a
mempty [] (NodeIdentifiers Type -> NodeInfo Type)
-> NodeIdentifiers Type -> NodeInfo Type
forall a b. (a -> b) -> a -> b
$ [(Identifier, IdentifierDetails Type)] -> NodeIdentifiers Type
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(Id, Set ContextInfo) -> (Identifier, IdentifierDetails Type)
forall {a}.
(Id, Set ContextInfo) -> (Either a Name, IdentifierDetails Type)
mkNodeInfo (Id, Set ContextInfo)
e]
in ([(Identifier, IdentifierDetails Type)]
xs,HieAST Type
nodeHieAST Type -> [HieAST Type] -> [HieAST Type]
forall a. a -> [a] -> [a]
:[HieAST Type]
ys)
SrcSpan
_ -> ((Id, Set ContextInfo) -> (Identifier, IdentifierDetails Type)
forall {a}.
(Id, Set ContextInfo) -> (Either a Name, IdentifierDetails Type)
mkNodeInfo (Id, Set ContextInfo)
e (Identifier, IdentifierDetails Type)
-> [(Identifier, IdentifierDetails Type)]
-> [(Identifier, IdentifierDetails Type)]
forall a. a -> [a] -> [a]
: [(Identifier, IdentifierDetails Type)]
xs,[HieAST Type]
ys)
([(Identifier, IdentifierDetails Type)]
nis,[HieAST Type]
asts) = ((Id, Set ContextInfo)
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type]))
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
-> [(Id, Set ContextInfo)]
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Id, Set ContextInfo)
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
-> ([(Identifier, IdentifierDetails Type)], [HieAST Type])
go ([],[]) [(Id, Set ContextInfo)]
elts
(NodeIdentifiers Type, [HieAST Type])
-> HieM (NodeIdentifiers Type, [HieAST Type])
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((NodeIdentifiers Type, [HieAST Type])
-> HieM (NodeIdentifiers Type, [HieAST Type]))
-> (NodeIdentifiers Type, [HieAST Type])
-> HieM (NodeIdentifiers Type, [HieAST Type])
forall a b. (a -> b) -> a -> b
$ ([(Identifier, IdentifierDetails Type)] -> NodeIdentifiers Type
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(Identifier, IdentifierDetails Type)]
nis, [HieAST Type]
asts)
initState :: HieState
initState :: HieState
initState = NameEnv Id -> VarMap (Set ContextInfo) -> HieState
HieState NameEnv Id
forall a. NameEnv a
emptyNameEnv VarMap (Set ContextInfo)
forall a. DVarEnv a
emptyDVarEnv
class ModifyState a where
addSubstitution :: a -> a -> HieState -> HieState
instance ModifyState Name where
addSubstitution :: Name -> Name -> HieState -> HieState
addSubstitution Name
_ Name
_ HieState
hs = HieState
hs
instance ModifyState Id where
addSubstitution :: Id -> Id -> HieState -> HieState
addSubstitution Id
mono Id
poly HieState
hs =
HieState
hs{name_remapping = extendNameEnv (name_remapping hs) (varName mono) poly}
modifyState :: [ABExport] -> HieState -> HieState
modifyState :: [ABExport] -> HieState -> HieState
modifyState = (ABExport -> (HieState -> HieState) -> HieState -> HieState)
-> (HieState -> HieState) -> [ABExport] -> HieState -> HieState
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ABExport -> (HieState -> HieState) -> HieState -> HieState
forall {a}. ABExport -> (a -> HieState) -> a -> HieState
go HieState -> HieState
forall a. a -> a
id
where
go :: ABExport -> (a -> HieState) -> a -> HieState
go ABE{abe_poly :: ABExport -> Id
abe_poly=Id
poly,abe_mono :: ABExport -> Id
abe_mono=Id
mono} a -> HieState
f
= Id -> Id -> HieState -> HieState
forall a. ModifyState a => a -> a -> HieState -> HieState
addSubstitution Id
mono Id
poly (HieState -> HieState) -> (a -> HieState) -> a -> HieState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> HieState
f
type HieM = ReaderT NodeOrigin (State HieState)
mkHieFile :: MonadIO m
=> ModSummary
-> TcGblEnv
-> RenamedSource -> m HieFile
mkHieFile :: forall (m :: * -> *).
MonadIO m =>
ModSummary -> TcGblEnv -> RenamedSource -> m HieFile
mkHieFile ModSummary
ms TcGblEnv
ts RenamedSource
rs = do
let src_file :: FilePath
src_file = FilePath -> Maybe FilePath -> FilePath
forall a. HasDebugCallStack => FilePath -> Maybe a -> a
expectJust FilePath
"mkHieFile" (ModLocation -> Maybe FilePath
ml_hs_file (ModLocation -> Maybe FilePath) -> ModLocation -> Maybe FilePath
forall a b. (a -> b) -> a -> b
$ ModSummary -> ModLocation
ms_location ModSummary
ms)
ByteString
src <- IO ByteString -> m ByteString
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString) -> IO ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ FilePath -> IO ByteString
BS.readFile FilePath
src_file
HieFile -> m HieFile
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (HieFile -> m HieFile) -> HieFile -> m HieFile
forall a b. (a -> b) -> a -> b
$ FilePath
-> ByteString -> ModSummary -> TcGblEnv -> RenamedSource -> HieFile
mkHieFileWithSource FilePath
src_file ByteString
src ModSummary
ms TcGblEnv
ts RenamedSource
rs
mkHieFileWithSource :: FilePath
-> BS.ByteString
-> ModSummary
-> TcGblEnv
-> RenamedSource -> HieFile
mkHieFileWithSource :: FilePath
-> ByteString -> ModSummary -> TcGblEnv -> RenamedSource -> HieFile
mkHieFileWithSource FilePath
src_file ByteString
src ModSummary
ms TcGblEnv
ts RenamedSource
rs =
let tc_binds :: LHsBinds GhcTc
tc_binds = TcGblEnv -> LHsBinds GhcTc
tcg_binds TcGblEnv
ts
top_ev_binds :: Bag EvBind
top_ev_binds = TcGblEnv -> Bag EvBind
tcg_ev_binds TcGblEnv
ts
insts :: [ClsInst]
insts = TcGblEnv -> [ClsInst]
tcg_insts TcGblEnv
ts
tcs :: [TyCon]
tcs = TcGblEnv -> [TyCon]
tcg_tcs TcGblEnv
ts
(HieASTs TypeIndex
asts',Array TypeIndex HieTypeFlat
arr) = LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
getCompressedAsts LHsBinds GhcTc
tc_binds RenamedSource
rs Bag EvBind
top_ev_binds [ClsInst]
insts [TyCon]
tcs in
HieFile
{ hie_hs_file :: FilePath
hie_hs_file = FilePath
src_file
, hie_module :: Module
hie_module = ModSummary -> Module
ms_mod ModSummary
ms
, hie_types :: Array TypeIndex HieTypeFlat
hie_types = Array TypeIndex HieTypeFlat
arr
, hie_asts :: HieASTs TypeIndex
hie_asts = HieASTs TypeIndex
asts'
, hie_exports :: [AvailInfo]
hie_exports = [AvailInfo] -> [AvailInfo]
mkIfaceExports (TcGblEnv -> [AvailInfo]
tcg_exports TcGblEnv
ts)
, hie_hs_src :: ByteString
hie_hs_src = ByteString
src
}
getCompressedAsts :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon]
-> (HieASTs TypeIndex, A.Array TypeIndex HieTypeFlat)
getCompressedAsts :: LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
getCompressedAsts LHsBinds GhcTc
ts RenamedSource
rs Bag EvBind
top_ev_binds [ClsInst]
insts [TyCon]
tcs =
let asts :: HieASTs Type
asts = LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> HieASTs Type
enrichHie LHsBinds GhcTc
ts RenamedSource
rs Bag EvBind
top_ev_binds [ClsInst]
insts [TyCon]
tcs in
HieASTs Type -> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
compressTypes HieASTs Type
asts
enrichHie :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon]
-> HieASTs Type
enrichHie :: LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> HieASTs Type
enrichHie LHsBinds GhcTc
ts (HsGroup GhcRn
hsGrp, [LImportDecl GhcRn]
imports, Maybe [(LIE GhcRn, [AvailInfo])]
exports, Maybe (LHsDoc GhcRn)
docs) Bag EvBind
ev_bs [ClsInst]
insts [TyCon]
tcs =
Identity (HieASTs Type) -> HieASTs Type
forall a. Identity a -> a
runIdentity (Identity (HieASTs Type) -> HieASTs Type)
-> Identity (HieASTs Type) -> HieASTs Type
forall a b. (a -> b) -> a -> b
$ (StateT HieState Identity (HieASTs Type)
-> HieState -> Identity (HieASTs Type))
-> HieState
-> StateT HieState Identity (HieASTs Type)
-> Identity (HieASTs Type)
forall a b c. (a -> b -> c) -> b -> a -> c
flip StateT HieState Identity (HieASTs Type)
-> HieState -> Identity (HieASTs Type)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT HieState
initState (StateT HieState Identity (HieASTs Type)
-> Identity (HieASTs Type))
-> StateT HieState Identity (HieASTs Type)
-> Identity (HieASTs Type)
forall a b. (a -> b) -> a -> b
$ (ReaderT NodeOrigin (State HieState) (HieASTs Type)
-> NodeOrigin -> StateT HieState Identity (HieASTs Type))
-> NodeOrigin
-> ReaderT NodeOrigin (State HieState) (HieASTs Type)
-> StateT HieState Identity (HieASTs Type)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT NodeOrigin (State HieState) (HieASTs Type)
-> NodeOrigin -> StateT HieState Identity (HieASTs Type)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT NodeOrigin
SourceInfo (ReaderT NodeOrigin (State HieState) (HieASTs Type)
-> StateT HieState Identity (HieASTs Type))
-> ReaderT NodeOrigin (State HieState) (HieASTs Type)
-> StateT HieState Identity (HieASTs Type)
forall a b. (a -> b) -> a -> b
$ do
[HieAST Type]
tasts <- Bag (BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> HieM [HieAST Type])
-> Bag
(BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> Bag
(BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
forall a b. (a -> b) -> Bag a -> Bag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
ModuleScope) LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
ts
[HieAST Type]
rasts <- HsGroup GhcRn -> HieM [HieAST Type]
processGrp HsGroup GhcRn
hsGrp
[HieAST Type]
imps <- [GenLocated SrcSpanAnnA (ImportDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (ImportDecl GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (ImportDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> Bool)
-> [GenLocated SrcSpanAnnA (ImportDecl GhcRn)]
-> [GenLocated SrcSpanAnnA (ImportDecl GhcRn)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> Bool)
-> GenLocated SrcSpanAnnA (ImportDecl GhcRn)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XImportDeclPass -> Bool
ideclImplicit (XImportDeclPass -> Bool)
-> (GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> XImportDeclPass)
-> GenLocated SrcSpanAnnA (ImportDecl GhcRn)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ImportDecl GhcRn -> XCImportDecl GhcRn
ImportDecl GhcRn -> XImportDeclPass
forall pass. ImportDecl pass -> XCImportDecl pass
ideclExt (ImportDecl GhcRn -> XImportDeclPass)
-> (GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> ImportDecl GhcRn)
-> GenLocated SrcSpanAnnA (ImportDecl GhcRn)
-> XImportDeclPass
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> ImportDecl GhcRn
forall l e. GenLocated l e -> e
unLoc) [LImportDecl GhcRn]
[GenLocated SrcSpanAnnA (ImportDecl GhcRn)]
imports
[HieAST Type]
exps <- Maybe [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))]
-> HieM [HieAST Type])
-> Maybe [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ([(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
-> [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))])
-> Maybe [(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
-> Maybe [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))]
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])
-> IEContext (GenLocated SrcSpanAnnA (IE GhcRn)))
-> [(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
-> [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (((GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])
-> IEContext (GenLocated SrcSpanAnnA (IE GhcRn)))
-> [(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
-> [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))])
-> ((GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])
-> IEContext (GenLocated SrcSpanAnnA (IE GhcRn)))
-> [(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
-> [IEContext (GenLocated SrcSpanAnnA (IE GhcRn))]
forall a b. (a -> b) -> a -> b
$ IEType
-> GenLocated SrcSpanAnnA (IE GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IE GhcRn))
forall a. IEType -> a -> IEContext a
IEC IEType
Export (GenLocated SrcSpanAnnA (IE GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IE GhcRn)))
-> ((GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])
-> GenLocated SrcSpanAnnA (IE GhcRn))
-> (GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])
-> IEContext (GenLocated SrcSpanAnnA (IE GhcRn))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])
-> GenLocated SrcSpanAnnA (IE GhcRn)
forall a b. (a, b) -> a
fst) Maybe [(LIE GhcRn, [AvailInfo])]
Maybe [(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
exports
[HieAST Type]
docs <- Maybe (LHsDoc GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsDoc GhcRn)
docs
[ClsInst] -> (ClsInst -> HieM ()) -> HieM ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [ClsInst]
insts ((ClsInst -> HieM ()) -> HieM ())
-> (ClsInst -> HieM ()) -> HieM ()
forall a b. (a -> b) -> a -> b
$ \ClsInst
i ->
Id -> ContextInfo -> HieM ()
addUnlocatedEvBind (ClsInst -> Id
is_dfun ClsInst
i) (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind (Bool -> Name -> EvVarSource
EvInstBind Bool
False (ClsInst -> Name
is_cls_nm ClsInst
i)) Scope
ModuleScope Maybe Span
forall a. Maybe a
Nothing)
[TyCon] -> (TyCon -> HieM ()) -> HieM ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [TyCon]
tcs ((TyCon -> HieM ()) -> HieM ()) -> (TyCon -> HieM ()) -> HieM ()
forall a b. (a -> b) -> a -> b
$ \TyCon
tc ->
case TyCon -> Maybe Class
tyConClass_maybe TyCon
tc of
Maybe Class
Nothing -> () -> HieM ()
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
Just Class
c -> [Id] -> (Id -> HieM ()) -> HieM ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ (Class -> [Id]
classSCSelIds Class
c) ((Id -> HieM ()) -> HieM ()) -> (Id -> HieM ()) -> HieM ()
forall a b. (a -> b) -> a -> b
$ \Id
v ->
Id -> ContextInfo -> HieM ()
addUnlocatedEvBind Id
v (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind (Bool -> Name -> EvVarSource
EvInstBind Bool
True (Class -> Name
className Class
c)) Scope
ModuleScope Maybe Span
forall a. Maybe a
Nothing)
let spanFile :: FastString -> [HieAST a] -> Span
spanFile FastString
file [HieAST a]
children = case [HieAST a] -> Maybe (NonEmpty (HieAST a))
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty [HieAST a]
children of
Maybe (NonEmpty (HieAST a))
Nothing -> RealSrcLoc -> Span
realSrcLocSpan (FastString -> TypeIndex -> TypeIndex -> RealSrcLoc
mkRealSrcLoc FastString
file TypeIndex
1 TypeIndex
1)
Just NonEmpty (HieAST a)
children -> RealSrcLoc -> RealSrcLoc -> Span
mkRealSrcSpan
(Span -> RealSrcLoc
realSrcSpanStart (Span -> RealSrcLoc) -> Span -> RealSrcLoc
forall a b. (a -> b) -> a -> b
$ HieAST a -> Span
forall a. HieAST a -> Span
nodeSpan (NonEmpty (HieAST a) -> HieAST a
forall a. NonEmpty a -> a
NE.head NonEmpty (HieAST a)
children))
(Span -> RealSrcLoc
realSrcSpanEnd (Span -> RealSrcLoc) -> Span -> RealSrcLoc
forall a b. (a -> b) -> a -> b
$ HieAST a -> Span
forall a. HieAST a -> Span
nodeSpan (NonEmpty (HieAST a) -> HieAST a
forall a. NonEmpty a -> a
NE.last NonEmpty (HieAST a)
children))
flat_asts :: [HieAST Type]
flat_asts = [[HieAST Type]] -> [HieAST Type]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [HieAST Type]
tasts
, [HieAST Type]
rasts
, [HieAST Type]
imps
, [HieAST Type]
exps
, [HieAST Type]
docs
]
modulify :: HiePath
-> [HieAST Type]
-> ReaderT NodeOrigin (State HieState) (HieAST Type)
modulify (HiePath FastString
file) [HieAST Type]
xs' = do
[HieAST Type]
top_ev_asts :: [HieAST Type] <- do
let
l :: SrcSpanAnnA
l :: SrcSpanAnnA
l = SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (Span -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcLoc -> Span
realSrcLocSpan (RealSrcLoc -> Span) -> RealSrcLoc -> Span
forall a b. (a -> b) -> a -> b
$ FastString -> TypeIndex -> TypeIndex -> RealSrcLoc
mkRealSrcLoc FastString
file TypeIndex
1 TypeIndex
1) Maybe BufSpan
forall a. Maybe a
Strict.Nothing)
EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type])
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> Maybe Span
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a. Scope -> Maybe Span -> a -> EvBindContext a
EvBindContext Scope
ModuleScope Maybe Span
forall a. Maybe a
Nothing
(GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds))
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> TcEvBinds -> GenLocated SrcSpanAnnA TcEvBinds
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
l (Bag EvBind -> TcEvBinds
EvBinds Bag EvBind
ev_bs)
(NodeIdentifiers Type
uloc_evs,[HieAST Type]
more_ev_asts) <- FastString -> HieM (NodeIdentifiers Type, [HieAST Type])
getUnlocatedEvBinds FastString
file
let xs :: [HieAST Type]
xs = [HieAST Type] -> [HieAST Type]
mergeSortAsts ([HieAST Type] -> [HieAST Type]) -> [HieAST Type] -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$ [HieAST Type]
xs' [HieAST Type] -> [HieAST Type] -> [HieAST Type]
forall a. [a] -> [a] -> [a]
++ [HieAST Type]
top_ev_asts [HieAST Type] -> [HieAST Type] -> [HieAST Type]
forall a. [a] -> [a] -> [a]
++ [HieAST Type]
more_ev_asts
span :: Span
span = FastString -> [HieAST Type] -> Span
forall {a}. FastString -> [HieAST a] -> Span
spanFile FastString
file [HieAST Type]
xs
moduleInfo :: SourcedNodeInfo Type
moduleInfo = Map NodeOrigin (NodeInfo Type) -> SourcedNodeInfo Type
forall a. Map NodeOrigin (NodeInfo a) -> SourcedNodeInfo a
SourcedNodeInfo
(Map NodeOrigin (NodeInfo Type) -> SourcedNodeInfo Type)
-> Map NodeOrigin (NodeInfo Type) -> SourcedNodeInfo Type
forall a b. (a -> b) -> a -> b
$ NodeOrigin -> NodeInfo Type -> Map NodeOrigin (NodeInfo Type)
forall k a. k -> a -> Map k a
M.singleton NodeOrigin
SourceInfo
(NodeInfo Type -> Map NodeOrigin (NodeInfo Type))
-> NodeInfo Type -> Map NodeOrigin (NodeInfo Type)
forall a b. (a -> b) -> a -> b
$ (FastString -> FastString -> NodeInfo Type
forall a. FastString -> FastString -> NodeInfo a
simpleNodeInfo FastString
"Module" FastString
"Module")
{nodeIdentifiers = uloc_evs}
moduleNode :: HieAST Type
moduleNode = SourcedNodeInfo Type -> Span -> [HieAST Type] -> HieAST Type
forall a. SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
Node SourcedNodeInfo Type
moduleInfo Span
span []
case [HieAST Type] -> [HieAST Type]
mergeSortAsts ([HieAST Type] -> [HieAST Type]) -> [HieAST Type] -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HieAST Type
moduleNode HieAST Type -> [HieAST Type] -> [HieAST Type]
forall a. a -> [a] -> [a]
: [HieAST Type]
xs of
[HieAST Type
x] -> HieAST Type -> ReaderT NodeOrigin (State HieState) (HieAST Type)
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (m :: * -> *) a. Monad m => a -> m a
return HieAST Type
x
[HieAST Type]
xs -> FilePath
-> SDoc -> ReaderT NodeOrigin (State HieState) (HieAST Type)
forall a. FilePath -> SDoc -> a
panicDoc FilePath
"enrichHie: mergeSortAsts retur:ed more than one result" ([Span] -> SDoc
forall a. Outputable a => a -> SDoc
ppr ([Span] -> SDoc) -> [Span] -> SDoc
forall a b. (a -> b) -> a -> b
$ (HieAST Type -> Span) -> [HieAST Type] -> [Span]
forall a b. (a -> b) -> [a] -> [b]
map HieAST Type -> Span
forall a. HieAST a -> Span
nodeSpan [HieAST Type]
xs)
Map HiePath (HieAST Type)
asts' <- Map HiePath (ReaderT NodeOrigin (State HieState) (HieAST Type))
-> ReaderT NodeOrigin (State HieState) (Map HiePath (HieAST Type))
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a.
Monad m =>
Map HiePath (m a) -> m (Map HiePath a)
sequence
(Map HiePath (ReaderT NodeOrigin (State HieState) (HieAST Type))
-> ReaderT NodeOrigin (State HieState) (Map HiePath (HieAST Type)))
-> Map HiePath (ReaderT NodeOrigin (State HieState) (HieAST Type))
-> ReaderT NodeOrigin (State HieState) (Map HiePath (HieAST Type))
forall a b. (a -> b) -> a -> b
$ (HiePath
-> [HieAST Type]
-> ReaderT NodeOrigin (State HieState) (HieAST Type))
-> Map HiePath [HieAST Type]
-> Map HiePath (ReaderT NodeOrigin (State HieState) (HieAST Type))
forall k a b. (k -> a -> b) -> Map k a -> Map k b
M.mapWithKey HiePath
-> [HieAST Type]
-> ReaderT NodeOrigin (State HieState) (HieAST Type)
modulify
(Map HiePath [HieAST Type]
-> Map HiePath (ReaderT NodeOrigin (State HieState) (HieAST Type)))
-> Map HiePath [HieAST Type]
-> Map HiePath (ReaderT NodeOrigin (State HieState) (HieAST Type))
forall a b. (a -> b) -> a -> b
$ ([HieAST Type] -> [HieAST Type] -> [HieAST Type])
-> [(HiePath, [HieAST Type])] -> Map HiePath [HieAST Type]
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
M.fromListWith [HieAST Type] -> [HieAST Type] -> [HieAST Type]
forall a. [a] -> [a] -> [a]
(++)
([(HiePath, [HieAST Type])] -> Map HiePath [HieAST Type])
-> [(HiePath, [HieAST Type])] -> Map HiePath [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (HieAST Type -> (HiePath, [HieAST Type]))
-> [HieAST Type] -> [(HiePath, [HieAST Type])]
forall a b. (a -> b) -> [a] -> [b]
map (\HieAST Type
x -> (FastString -> HiePath
HiePath (Span -> FastString
srcSpanFile (HieAST Type -> Span
forall a. HieAST a -> Span
nodeSpan HieAST Type
x)),[HieAST Type
x])) [HieAST Type]
flat_asts
let asts :: HieASTs Type
asts = Map HiePath (HieAST Type) -> HieASTs Type
forall a. Map HiePath (HieAST a) -> HieASTs a
HieASTs (Map HiePath (HieAST Type) -> HieASTs Type)
-> Map HiePath (HieAST Type) -> HieASTs Type
forall a b. (a -> b) -> a -> b
$ Map HiePath (HieAST Type) -> Map HiePath (HieAST Type)
forall a. Map HiePath (HieAST a) -> Map HiePath (HieAST a)
resolveTyVarScopes Map HiePath (HieAST Type)
asts'
HieASTs Type -> ReaderT NodeOrigin (State HieState) (HieASTs Type)
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (m :: * -> *) a. Monad m => a -> m a
return HieASTs Type
asts
processGrp :: HsGroup GhcRn -> HieM [HieAST Type]
processGrp :: HsGroup GhcRn -> HieM [HieAST Type]
processGrp HsGroup GhcRn
grp = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ RScoped (HsValBinds GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsValBinds GhcRn) -> HieM [HieAST Type])
-> RScoped (HsValBinds GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (HsValBinds GhcRn -> RScoped (HsValBinds GhcRn))
-> (HsGroup GhcRn -> HsValBinds GhcRn)
-> HsGroup GhcRn
-> RScoped (HsValBinds GhcRn)
forall a b. (a -> b) -> (HsGroup GhcRn -> a) -> HsGroup GhcRn -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Scope -> HsValBinds GhcRn -> RScoped (HsValBinds GhcRn)
forall a. Scope -> a -> RScoped a
RS Scope
ModuleScope ) HsGroup GhcRn -> HsValBinds GhcRn
forall p. HsGroup p -> HsValBinds p
hs_valds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (SpliceDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (SpliceDecl GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (SpliceDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LSpliceDecl GhcRn]
forall p. HsGroup p -> [LSpliceDecl p]
hs_splcds HsGroup GhcRn
grp
, [TyClGroup GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TyClGroup GhcRn] -> HieM [HieAST Type])
-> [TyClGroup GhcRn] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [TyClGroup GhcRn]
forall p. HsGroup p -> [TyClGroup p]
hs_tyclds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (DerivDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (DerivDecl GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (DerivDecl GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LDerivDecl GhcRn]
forall p. HsGroup p -> [LDerivDecl p]
hs_derivds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (FixitySig GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (FixitySig GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (FixitySig GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LFixitySig GhcRn]
forall p. HsGroup p -> [LFixitySig p]
hs_fixds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (DefaultDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (DefaultDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (DefaultDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LDefaultDecl GhcRn]
forall p. HsGroup p -> [LDefaultDecl p]
hs_defds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (ForeignDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (ForeignDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (ForeignDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LForeignDecl GhcRn]
forall p. HsGroup p -> [LForeignDecl p]
hs_fords HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (WarnDecls GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (WarnDecls GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (WarnDecls GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LWarnDecls GhcRn]
forall p. HsGroup p -> [LWarnDecls p]
hs_warnds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (AnnDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (AnnDecl GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (AnnDecl GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LAnnDecl GhcRn]
forall p. HsGroup p -> [LAnnDecl p]
hs_annds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (RuleDecls GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (RuleDecls GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (RuleDecls GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LRuleDecls GhcRn]
forall p. HsGroup p -> [LRuleDecls p]
hs_ruleds HsGroup GhcRn
grp
, [GenLocated SrcSpanAnnA (DocDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (DocDecl GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (DocDecl GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup GhcRn -> [LDocDecl GhcRn]
forall p. HsGroup p -> [LDocDecl p]
hs_docs HsGroup GhcRn
grp
]
getRealSpanA :: SrcSpanAnn' ann -> Maybe Span
getRealSpanA :: forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnn' ann
la = SrcSpan -> Maybe Span
getRealSpan (SrcSpanAnn' ann -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' ann
la)
getRealSpan :: SrcSpan -> Maybe Span
getRealSpan :: SrcSpan -> Maybe Span
getRealSpan (RealSrcSpan Span
sp Maybe BufSpan
_) = Span -> Maybe Span
forall a. a -> Maybe a
Just Span
sp
getRealSpan SrcSpan
_ = Maybe Span
forall a. Maybe a
Nothing
grhss_span :: (Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcAnn NoEpAnns)
=> GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
grhss_span :: forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcAnn NoEpAnns) =>
GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
grhss_span (GRHSs XCGRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
_ [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
xs HsLocalBinds (GhcPass p)
bs) = (SrcSpan -> SrcSpan -> SrcSpan) -> SrcSpan -> [SrcSpan] -> SrcSpan
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (HsLocalBinds (GhcPass p) -> SrcSpan
forall (p :: Pass). HsLocalBinds (GhcPass p) -> SrcSpan
spanHsLocaLBinds HsLocalBinds (GhcPass p)
bs) ((GenLocated
(SrcAnn NoEpAnns) (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
-> SrcSpan)
-> [GenLocated
(SrcAnn NoEpAnns) (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
-> [SrcSpan]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
(SrcAnn NoEpAnns) (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
-> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
[GenLocated
(SrcAnn NoEpAnns) (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
xs)
bindingsOnly :: [Context Name] -> HieM [HieAST a]
bindingsOnly :: forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly [] = [HieAST a] -> ReaderT NodeOrigin (State HieState) [HieAST a]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
bindingsOnly (C ContextInfo
c Name
n : [Context Name]
xs) = do
NodeOrigin
org <- ReaderT NodeOrigin (State HieState) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
[HieAST a]
rest <- [Context Name] -> ReaderT NodeOrigin (State HieState) [HieAST a]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly [Context Name]
xs
[HieAST a] -> ReaderT NodeOrigin (State HieState) [HieAST a]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([HieAST a] -> ReaderT NodeOrigin (State HieState) [HieAST a])
-> [HieAST a] -> ReaderT NodeOrigin (State HieState) [HieAST a]
forall a b. (a -> b) -> a -> b
$ case Name -> SrcSpan
nameSrcSpan Name
n of
RealSrcSpan Span
span Maybe BufSpan
_ -> SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
forall a. SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
Node (NodeOrigin -> NodeInfo a -> SourcedNodeInfo a
forall a. NodeOrigin -> NodeInfo a -> SourcedNodeInfo a
mkSourcedNodeInfo NodeOrigin
org NodeInfo a
nodeinfo) Span
span [] HieAST a -> [HieAST a] -> [HieAST a]
forall a. a -> [a] -> [a]
: [HieAST a]
rest
where nodeinfo :: NodeInfo a
nodeinfo = Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
forall a.
Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set NodeAnnotation
forall a. Set a
S.empty [] (Identifier -> IdentifierDetails a -> NodeIdentifiers a
forall k a. k -> a -> Map k a
M.singleton (Name -> Identifier
forall a b. b -> Either a b
Right Name
n) IdentifierDetails a
info)
info :: IdentifierDetails a
info = IdentifierDetails a
forall a. Monoid a => a
mempty{identInfo = S.singleton c}
SrcSpan
_ -> [HieAST a]
rest
concatM :: Monad m => [m [a]] -> m [a]
concatM :: forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM [m [a]]
xs = [[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[a]] -> [a]) -> m [[a]] -> m [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [m [a]] -> m [[a]]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence [m [a]]
xs
data Context a = C ContextInfo a
data RContext a = RC RecFieldContext a
data RFContext a = RFC RecFieldContext (Maybe Span) a
data IEContext a = IEC IEType a
data BindContext a = BC BindType Scope a
data PatSynFieldContext a = PSC (Maybe Span) a
data SigContext a = SC SigInfo a
data SigInfo = SI SigType (Maybe Span)
data SigType = BindSig | ClassSig | InstSig
data EvBindContext a = EvBindContext Scope (Maybe Span) a
data RScoped a = RS Scope a
data PScoped a = PS (Maybe Span)
Scope
Scope
a
deriving (Typeable, Typeable (PScoped a)
Typeable (PScoped a) =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> c (PScoped a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PScoped a))
-> (PScoped a -> Constr)
-> (PScoped a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PScoped a)))
-> ((forall b. Data b => b -> b) -> PScoped a -> PScoped a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r)
-> (forall u. (forall d. Data d => d -> u) -> PScoped a -> [u])
-> (forall u.
TypeIndex -> (forall d. Data d => d -> u) -> PScoped a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a))
-> Data (PScoped a)
PScoped a -> Constr
PScoped a -> DataType
(forall b. Data b => b -> b) -> PScoped a -> PScoped a
forall a. Data a => Typeable (PScoped a)
forall a. Data a => PScoped a -> Constr
forall a. Data a => PScoped a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> PScoped a -> PScoped a
forall a u.
Data a =>
TypeIndex -> (forall d. Data d => d -> u) -> PScoped a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> PScoped a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PScoped a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> c (PScoped a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PScoped a))
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. TypeIndex -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
TypeIndex -> (forall d. Data d => d -> u) -> PScoped a -> u
forall u. (forall d. Data d => d -> u) -> PScoped a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PScoped a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> c (PScoped a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PScoped a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> c (PScoped a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> c (PScoped a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PScoped a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PScoped a)
$ctoConstr :: forall a. Data a => PScoped a -> Constr
toConstr :: PScoped a -> Constr
$cdataTypeOf :: forall a. Data a => PScoped a -> DataType
dataTypeOf :: PScoped a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PScoped a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PScoped a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> PScoped a -> PScoped a
gmapT :: (forall b. Data b => b -> b) -> PScoped a -> PScoped a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> PScoped a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PScoped a -> [u]
$cgmapQi :: forall a u.
Data a =>
TypeIndex -> (forall d. Data d => d -> u) -> PScoped a -> u
gmapQi :: forall u.
TypeIndex -> (forall d. Data d => d -> u) -> PScoped a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
Data)
data TScoped a = TS TyVarScope a
data TVScoped a = TVS TyVarScope Scope a
listScopes :: Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes :: forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
_ [] = []
listScopes Scope
rhsScope [LocatedA a
pat] = [Scope -> LocatedA a -> RScoped (LocatedA a)
forall a. Scope -> a -> RScoped a
RS Scope
rhsScope LocatedA a
pat]
listScopes Scope
rhsScope (LocatedA a
pat : [LocatedA a]
pats) = Scope -> LocatedA a -> RScoped (LocatedA a)
forall a. Scope -> a -> RScoped a
RS Scope
sc LocatedA a
pat RScoped (LocatedA a)
-> [RScoped (LocatedA a)] -> [RScoped (LocatedA a)]
forall a. a -> [a] -> [a]
: [RScoped (LocatedA a)]
pats'
where
pats' :: [RScoped (LocatedA a)]
pats'@((RS Scope
scope LocatedA a
p):[RScoped (LocatedA a)]
_) = Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
rhsScope [LocatedA a]
pats
sc :: Scope
sc = Scope -> Scope -> Scope
combineScopes Scope
scope (Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ LocatedA a -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LocatedA a
p
patScopes
:: Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes :: forall (p :: Pass).
Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe Span
rsp Scope
useScope Scope
patScope [LPat (GhcPass p)]
xs =
(RScoped (LocatedA (Pat (GhcPass p)))
-> PScoped (LPat (GhcPass p)))
-> [RScoped (LocatedA (Pat (GhcPass p)))]
-> [PScoped (LPat (GhcPass p))]
forall a b. (a -> b) -> [a] -> [b]
map (\(RS Scope
sc LocatedA (Pat (GhcPass p))
a) -> Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
useScope Scope
sc LocatedA (Pat (GhcPass p))
a) ([RScoped (LocatedA (Pat (GhcPass p)))]
-> [PScoped (LPat (GhcPass p))])
-> [RScoped (LocatedA (Pat (GhcPass p)))]
-> [PScoped (LPat (GhcPass p))]
forall a b. (a -> b) -> a -> b
$
Scope
-> [LocatedA (Pat (GhcPass p))]
-> [RScoped (LocatedA (Pat (GhcPass p)))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
patScope [LPat (GhcPass p)]
[LocatedA (Pat (GhcPass p))]
xs
taScopes
:: Scope
-> Scope
-> [HsConPatTyArg (GhcPass a)]
-> [TScoped (HsPatSigType (GhcPass a))]
taScopes :: forall (a :: Pass).
Scope
-> Scope
-> [HsConPatTyArg (GhcPass a)]
-> [TScoped (HsPatSigType (GhcPass a))]
taScopes Scope
scope Scope
rhsScope [HsConPatTyArg (GhcPass a)]
xs =
(RScoped (GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))
-> TScoped (HsPatSigType (GhcPass a)))
-> [RScoped (GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))]
-> [TScoped (HsPatSigType (GhcPass a))]
forall a b. (a -> b) -> [a] -> [b]
map (\(RS Scope
sc GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))
a) -> TyVarScope
-> HsPatSigType (GhcPass a) -> TScoped (HsPatSigType (GhcPass a))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
scope, Scope
sc]) (GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))
-> HsPatSigType (GhcPass a)
forall l e. GenLocated l e -> e
unLoc GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))
a)) ([RScoped (GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))]
-> [TScoped (HsPatSigType (GhcPass a))])
-> [RScoped (GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))]
-> [TScoped (HsPatSigType (GhcPass a))]
forall a b. (a -> b) -> a -> b
$
Scope
-> [GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))]
-> [RScoped (GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
rhsScope ((HsConPatTyArg (GhcPass a)
-> GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))
-> [HsConPatTyArg (GhcPass a)]
-> [GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))]
forall a b. (a -> b) -> [a] -> [b]
map (\(HsConPatTyArg LHsToken "@" (GhcPass a)
_ HsPatSigType (GhcPass a)
hsps) -> SrcSpanAnnA
-> HsPatSigType (GhcPass a)
-> GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))
forall l e. l -> e -> GenLocated l e
L (GenLocated SrcSpanAnnA (HsType (GhcPass a)) -> SrcSpanAnnA
forall l e. GenLocated l e -> l
getLoc (GenLocated SrcSpanAnnA (HsType (GhcPass a)) -> SrcSpanAnnA)
-> GenLocated SrcSpanAnnA (HsType (GhcPass a)) -> SrcSpanAnnA
forall a b. (a -> b) -> a -> b
$ HsPatSigType (GhcPass a) -> LHsType (GhcPass a)
forall pass. HsPatSigType pass -> LHsType pass
hsps_body HsPatSigType (GhcPass a)
hsps) HsPatSigType (GhcPass a)
hsps) [HsConPatTyArg (GhcPass a)]
xs)
tvScopes
:: TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes :: forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes TyVarScope
tvScope Scope
rhsScope [LHsTyVarBndr flag (GhcPass a)]
xs =
(RScoped (LocatedA (HsTyVarBndr flag (GhcPass a)))
-> TVScoped (LHsTyVarBndr flag (GhcPass a)))
-> [RScoped (LocatedA (HsTyVarBndr flag (GhcPass a)))]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
forall a b. (a -> b) -> [a] -> [b]
map (\(RS Scope
sc LocatedA (HsTyVarBndr flag (GhcPass a))
a)-> TyVarScope
-> Scope
-> LocatedA (HsTyVarBndr flag (GhcPass a))
-> TVScoped (LocatedA (HsTyVarBndr flag (GhcPass a)))
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS TyVarScope
tvScope Scope
sc LocatedA (HsTyVarBndr flag (GhcPass a))
a) ([RScoped (LocatedA (HsTyVarBndr flag (GhcPass a)))]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))])
-> [RScoped (LocatedA (HsTyVarBndr flag (GhcPass a)))]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA (HsTyVarBndr flag (GhcPass a))]
-> [RScoped (LocatedA (HsTyVarBndr flag (GhcPass a)))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
rhsScope [LHsTyVarBndr flag (GhcPass a)]
[LocatedA (HsTyVarBndr flag (GhcPass a))]
xs
class HasLoc a where
loc :: a -> SrcSpan
instance HasLoc thing => HasLoc (PScoped thing) where
loc :: PScoped thing -> SrcSpan
loc (PS Maybe Span
_ Scope
_ Scope
_ thing
a) = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
instance HasLoc (Located a) where
loc :: Located a -> SrcSpan
loc (L SrcSpan
l a
_) = SrcSpan
l
instance HasLoc (LocatedA a) where
loc :: LocatedA a -> SrcSpan
loc (L SrcSpanAnnA
la a
_) = SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
la
instance HasLoc (LocatedN a) where
loc :: LocatedN a -> SrcSpan
loc (L SrcSpanAnnN
la a
_) = SrcSpanAnnN -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnN
la
instance HasLoc a => HasLoc [a] where
loc :: [a] -> SrcSpan
loc [] = SrcSpan
noSrcSpan
loc [a]
xs = (SrcSpan -> SrcSpan -> SrcSpan) -> [SrcSpan] -> SrcSpan
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans ([SrcSpan] -> SrcSpan) -> [SrcSpan] -> SrcSpan
forall a b. (a -> b) -> a -> b
$ (a -> SrcSpan) -> [a] -> [SrcSpan]
forall a b. (a -> b) -> [a] -> [b]
map a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [a]
xs
instance HasLoc a => HasLoc (DataDefnCons a) where
loc :: DataDefnCons a -> SrcSpan
loc = [a] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc ([a] -> SrcSpan)
-> (DataDefnCons a -> [a]) -> DataDefnCons a -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataDefnCons a -> [a]
forall a. DataDefnCons a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance (HasLoc a, HiePass p) => HasLoc (FamEqn (GhcPass p) a) where
loc :: FamEqn (GhcPass p) a -> SrcSpan
loc (FamEqn XCFamEqn (GhcPass p) a
_ LIdP (GhcPass p)
a HsOuterFamEqnTyVarBndrs (GhcPass p)
outer_bndrs HsTyPats (GhcPass p)
b LexicalFixity
_ a
c) = case HsOuterFamEqnTyVarBndrs (GhcPass p)
outer_bndrs of
HsOuterImplicit{} ->
(SrcSpan -> SrcSpan -> SrcSpan) -> [SrcSpan] -> SrcSpan
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans [GenLocated SrcSpanAnnN (IdGhcP p) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
a, [HsArg
(GhcPass p)
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc HsTyPats (GhcPass p)
[HsArg
(GhcPass p)
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
b, a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc a
c]
HsOuterExplicit{hso_bndrs :: forall flag pass.
HsOuterTyVarBndrs flag pass -> [LHsTyVarBndr flag (NoGhcTc pass)]
hso_bndrs = [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
tvs} ->
(SrcSpan -> SrcSpan -> SrcSpan) -> [SrcSpan] -> SrcSpan
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans [GenLocated SrcSpanAnnN (IdGhcP p) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
a, [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)]
tvs, [HsArg
(GhcPass p)
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc HsTyPats (GhcPass p)
[HsArg
(GhcPass p)
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
b, a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc a
c]
instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg p tm ty) where
loc :: HsArg p tm ty -> SrcSpan
loc (HsValArg tm
tm) = tm -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc tm
tm
loc (HsTypeArg LHsToken "@" p
_ ty
ty) = ty -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc ty
ty
loc (HsArgPar SrcSpan
sp) = SrcSpan
sp
instance HasLoc (HsDataDefn GhcRn) where
loc :: HsDataDefn GhcRn -> SrcSpan
loc def :: HsDataDefn GhcRn
def@(HsDataDefn{}) = DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcRn)) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc (DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcRn)) -> SrcSpan)
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcRn)) -> SrcSpan
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> DataDefnCons (LConDecl GhcRn)
forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons HsDataDefn GhcRn
def
class ToHie a where
toHie :: a -> HieM [HieAST Type]
class HasType a where
getTypeNode :: a -> HieM [HieAST Type]
instance ToHie Void where
toHie :: Void -> HieM [HieAST Type]
toHie Void
v = Void -> HieM [HieAST Type]
forall a. Void -> a
absurd Void
v
instance (ToHie a) => ToHie [a] where
toHie :: [a] -> HieM [HieAST Type]
toHie = (a -> HieM [HieAST Type]) -> [a] -> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie
instance (ToHie a) => ToHie (NonEmpty a) where
toHie :: NonEmpty a -> HieM [HieAST Type]
toHie = (a -> HieM [HieAST Type]) -> NonEmpty a -> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie
instance (ToHie a) => ToHie (DataDefnCons a) where
toHie :: DataDefnCons a -> HieM [HieAST Type]
toHie = (a -> HieM [HieAST Type]) -> DataDefnCons a -> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie
instance (ToHie a) => ToHie (Bag a) where
toHie :: Bag a -> HieM [HieAST Type]
toHie = [a] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([a] -> HieM [HieAST Type])
-> (Bag a -> [a]) -> Bag a -> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bag a -> [a]
forall a. Bag a -> [a]
bagToList
instance (ToHie a) => ToHie (Maybe a) where
toHie :: Maybe a -> HieM [HieAST Type]
toHie = HieM [HieAST Type]
-> (a -> HieM [HieAST Type]) -> Maybe a -> HieM [HieAST Type]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []) a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie
instance ToHie (IEContext (LocatedA ModuleName)) where
toHie :: IEContext (LocatedA ModuleName) -> HieM [HieAST Type]
toHie (IEC IEType
c (L (SrcSpanAnn EpAnn AnnListItem
_ (RealSrcSpan Span
span Maybe BufSpan
_)) ModuleName
mname)) = do
NodeOrigin
org <- ReaderT NodeOrigin (State HieState) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
[HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([HieAST Type] -> HieM [HieAST Type])
-> [HieAST Type] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ [SourcedNodeInfo Type -> Span -> [HieAST Type] -> HieAST Type
forall a. SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
Node (NodeOrigin -> NodeInfo Type -> SourcedNodeInfo Type
forall a. NodeOrigin -> NodeInfo a -> SourcedNodeInfo a
mkSourcedNodeInfo NodeOrigin
org (NodeInfo Type -> SourcedNodeInfo Type)
-> NodeInfo Type -> SourcedNodeInfo Type
forall a b. (a -> b) -> a -> b
$ Set NodeAnnotation
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set NodeAnnotation
forall a. Set a
S.empty [] NodeIdentifiers Type
idents) Span
span []]
where details :: IdentifierDetails Type
details = IdentifierDetails Type
forall a. Monoid a => a
mempty{identInfo = S.singleton (IEThing c)}
idents :: NodeIdentifiers Type
idents = Identifier -> IdentifierDetails Type -> NodeIdentifiers Type
forall k a. k -> a -> Map k a
M.singleton (ModuleName -> Identifier
forall a b. a -> Either a b
Left ModuleName
mname) IdentifierDetails Type
details
toHie IEContext (LocatedA ModuleName)
_ = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (Context (Located a)) => ToHie (Context (LocatedN a)) where
toHie :: Context (LocatedN a) -> HieM [HieAST Type]
toHie (C ContextInfo
c (L SrcSpanAnnN
l a
a)) = Context (Located a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (ContextInfo -> Located a -> Context (Located a)
forall a. ContextInfo -> a -> Context a
C ContextInfo
c (SrcSpan -> a -> Located a
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnN -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnN
l) a
a))
instance ToHie (Context (Located a)) => ToHie (Context (LocatedA a)) where
toHie :: Context (LocatedA a) -> HieM [HieAST Type]
toHie (C ContextInfo
c (L SrcSpanAnnA
l a
a)) = Context (Located a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (ContextInfo -> Located a -> Context (Located a)
forall a. ContextInfo -> a -> Context a
C ContextInfo
c (SrcSpan -> a -> Located a
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
l) a
a))
instance ToHie (Context (Located Var)) where
toHie :: Context (Located Id) -> HieM [HieAST Type]
toHie Context (Located Id)
c = case Context (Located Id)
c of
C ContextInfo
context (L (RealSrcSpan Span
span Maybe BufSpan
_) Id
name')
| Id -> Unique
varUnique Id
name' Unique -> Unique -> Bool
forall a. Eq a => a -> a -> Bool
== TypeIndex -> Unique
mkBuiltinUnique TypeIndex
1 -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
| Bool
otherwise -> do
NameEnv Id
m <- State HieState (NameEnv Id)
-> ReaderT NodeOrigin (State HieState) (NameEnv Id)
forall (m :: * -> *) a. Monad m => m a -> ReaderT NodeOrigin m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (State HieState (NameEnv Id)
-> ReaderT NodeOrigin (State HieState) (NameEnv Id))
-> State HieState (NameEnv Id)
-> ReaderT NodeOrigin (State HieState) (NameEnv Id)
forall a b. (a -> b) -> a -> b
$ (HieState -> NameEnv Id) -> State HieState (NameEnv Id)
forall (m :: * -> *) s a. Monad m => (s -> a) -> StateT s m a
gets HieState -> NameEnv Id
name_remapping
NodeOrigin
org <- ReaderT NodeOrigin (State HieState) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
let name :: Id
name = case NameEnv Id -> Name -> Maybe Id
forall a. NameEnv a -> Name -> Maybe a
lookupNameEnv NameEnv Id
m (Id -> Name
varName Id
name') of
Just Id
var -> Id
var
Maybe Id
Nothing-> Id
name'
ty :: Type
ty = case Id -> Maybe DataCon
isDataConId_maybe Id
name' of
Maybe DataCon
Nothing -> Id -> Type
varType Id
name'
Just DataCon
dc -> DataCon -> Type
dataConNonlinearType DataCon
dc
[HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
[SourcedNodeInfo Type -> Span -> [HieAST Type] -> HieAST Type
forall a. SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
Node
(NodeOrigin -> NodeInfo Type -> SourcedNodeInfo Type
forall a. NodeOrigin -> NodeInfo a -> SourcedNodeInfo a
mkSourcedNodeInfo NodeOrigin
org (NodeInfo Type -> SourcedNodeInfo Type)
-> NodeInfo Type -> SourcedNodeInfo Type
forall a b. (a -> b) -> a -> b
$ Set NodeAnnotation
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set NodeAnnotation
forall a. Set a
S.empty [] (NodeIdentifiers Type -> NodeInfo Type)
-> NodeIdentifiers Type -> NodeInfo Type
forall a b. (a -> b) -> a -> b
$
Identifier -> IdentifierDetails Type -> NodeIdentifiers Type
forall k a. k -> a -> Map k a
M.singleton (Name -> Identifier
forall a b. b -> Either a b
Right (Name -> Identifier) -> Name -> Identifier
forall a b. (a -> b) -> a -> b
$ Id -> Name
varName Id
name)
(Maybe Type -> Set ContextInfo -> IdentifierDetails Type
forall a. Maybe a -> Set ContextInfo -> IdentifierDetails a
IdentifierDetails (Type -> Maybe Type
forall a. a -> Maybe a
Just Type
ty)
(ContextInfo -> Set ContextInfo
forall a. a -> Set a
S.singleton ContextInfo
context)))
Span
span
[]]
C (EvidenceVarBind EvVarSource
i Scope
_ Maybe Span
sp) (L SrcSpan
_ Id
name) -> do
Id -> ContextInfo -> HieM ()
addUnlocatedEvBind Id
name (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind EvVarSource
i Scope
ModuleScope Maybe Span
sp)
[HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
Context (Located Id)
_ -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (Context (Located Name)) where
toHie :: Context (Located Name) -> HieM [HieAST Type]
toHie Context (Located Name)
c = case Context (Located Name)
c of
C ContextInfo
context (L (RealSrcSpan Span
span Maybe BufSpan
_) Name
name')
| Name -> Unique
nameUnique Name
name' Unique -> Unique -> Bool
forall a. Eq a => a -> a -> Bool
== TypeIndex -> Unique
mkBuiltinUnique TypeIndex
1 -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
| Bool
otherwise -> do
NameEnv Id
m <- State HieState (NameEnv Id)
-> ReaderT NodeOrigin (State HieState) (NameEnv Id)
forall (m :: * -> *) a. Monad m => m a -> ReaderT NodeOrigin m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (State HieState (NameEnv Id)
-> ReaderT NodeOrigin (State HieState) (NameEnv Id))
-> State HieState (NameEnv Id)
-> ReaderT NodeOrigin (State HieState) (NameEnv Id)
forall a b. (a -> b) -> a -> b
$ (HieState -> NameEnv Id) -> State HieState (NameEnv Id)
forall (m :: * -> *) s a. Monad m => (s -> a) -> StateT s m a
gets HieState -> NameEnv Id
name_remapping
NodeOrigin
org <- ReaderT NodeOrigin (State HieState) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
let name :: Name
name = case NameEnv Id -> Name -> Maybe Id
forall a. NameEnv a -> Name -> Maybe a
lookupNameEnv NameEnv Id
m Name
name' of
Just Id
var -> Id -> Name
varName Id
var
Maybe Id
Nothing -> Name
name'
[HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
[SourcedNodeInfo Type -> Span -> [HieAST Type] -> HieAST Type
forall a. SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
Node
(NodeOrigin -> NodeInfo Type -> SourcedNodeInfo Type
forall a. NodeOrigin -> NodeInfo a -> SourcedNodeInfo a
mkSourcedNodeInfo NodeOrigin
org (NodeInfo Type -> SourcedNodeInfo Type)
-> NodeInfo Type -> SourcedNodeInfo Type
forall a b. (a -> b) -> a -> b
$ Set NodeAnnotation
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set NodeAnnotation
forall a. Set a
S.empty [] (NodeIdentifiers Type -> NodeInfo Type)
-> NodeIdentifiers Type -> NodeInfo Type
forall a b. (a -> b) -> a -> b
$
Identifier -> IdentifierDetails Type -> NodeIdentifiers Type
forall k a. k -> a -> Map k a
M.singleton (Name -> Identifier
forall a b. b -> Either a b
Right Name
name)
(Maybe Type -> Set ContextInfo -> IdentifierDetails Type
forall a. Maybe a -> Set ContextInfo -> IdentifierDetails a
IdentifierDetails Maybe Type
forall a. Maybe a
Nothing
(ContextInfo -> Set ContextInfo
forall a. a -> Set a
S.singleton ContextInfo
context)))
Span
span
[]]
Context (Located Name)
_ -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
evVarsOfTermList :: EvTerm -> [EvId]
evVarsOfTermList :: EvTerm -> [Id]
evVarsOfTermList (EvExpr EvExpr
e) = InterestingVarFun -> EvExpr -> [Id]
exprSomeFreeVarsList InterestingVarFun
isEvVar EvExpr
e
evVarsOfTermList (EvTypeable Type
_ EvTypeable
ev) =
case EvTypeable
ev of
EvTypeableTyCon TyCon
_ [EvTerm]
e -> (EvTerm -> [Id]) -> [EvTerm] -> [Id]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap EvTerm -> [Id]
evVarsOfTermList [EvTerm]
e
EvTypeableTyApp EvTerm
e1 EvTerm
e2 -> (EvTerm -> [Id]) -> [EvTerm] -> [Id]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap EvTerm -> [Id]
evVarsOfTermList [EvTerm
e1,EvTerm
e2]
EvTypeableTrFun EvTerm
e1 EvTerm
e2 EvTerm
e3 -> (EvTerm -> [Id]) -> [EvTerm] -> [Id]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap EvTerm -> [Id]
evVarsOfTermList [EvTerm
e1,EvTerm
e2,EvTerm
e3]
EvTypeableTyLit EvTerm
e -> EvTerm -> [Id]
evVarsOfTermList EvTerm
e
evVarsOfTermList (EvFun{}) = []
instance ToHie (EvBindContext (LocatedA TcEvBinds)) where
toHie :: EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
toHie (EvBindContext Scope
sc Maybe Span
sp (L SrcSpanAnnA
span (EvBinds Bag EvBind
bs)))
= (EvBind -> HieM [HieAST Type]) -> [EvBind] -> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM EvBind -> HieM [HieAST Type]
go ([EvBind] -> HieM [HieAST Type]) -> [EvBind] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Bag EvBind -> [EvBind]
forall a. Bag a -> [a]
bagToList Bag EvBind
bs
where
go :: EvBind -> HieM [HieAST Type]
go EvBind
evbind = do
let evDeps :: [Id]
evDeps = EvTerm -> [Id]
evVarsOfTermList (EvTerm -> [Id]) -> EvTerm -> [Id]
forall a b. (a -> b) -> a -> b
$ EvBind -> EvTerm
eb_rhs EvBind
evbind
depNames :: EvBindDeps
depNames = [Name] -> EvBindDeps
EvBindDeps ([Name] -> EvBindDeps) -> [Name] -> EvBindDeps
forall a b. (a -> b) -> a -> b
$ (Id -> Name) -> [Id] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Id -> Name
varName [Id]
evDeps
[HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind (EvBindDeps -> EvVarSource
EvLetBind EvBindDeps
depNames) (Scope -> Scope -> Scope
combineScopes Scope
sc (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span)) Maybe Span
sp)
(SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span (Id -> GenLocated SrcSpanAnnA Id)
-> Id -> GenLocated SrcSpanAnnA Id
forall a b. (a -> b) -> a -> b
$ EvBind -> Id
eb_lhs EvBind
evbind))
, [Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Id -> Context (GenLocated SrcSpanAnnA Id))
-> [Id] -> [Context (GenLocated SrcSpanAnnA Id)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C ContextInfo
EvidenceVarUse (GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id))
-> (Id -> GenLocated SrcSpanAnnA Id)
-> Id
-> Context (GenLocated SrcSpanAnnA Id)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span) ([Id] -> [Context (GenLocated SrcSpanAnnA Id)])
-> [Id] -> [Context (GenLocated SrcSpanAnnA Id)]
forall a b. (a -> b) -> a -> b
$ [Id]
evDeps
]
toHie EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
_ = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LocatedA HsWrapper) where
toHie :: LocatedA HsWrapper -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
osp HsWrapper
wrap)
= case HsWrapper
wrap of
(WpLet TcEvBinds
bs) -> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type])
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> Maybe Span
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a. Scope -> Maybe Span -> a -> EvBindContext a
EvBindContext (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
osp) (SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
osp) (SrcSpanAnnA -> TcEvBinds -> GenLocated SrcSpanAnnA TcEvBinds
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp TcEvBinds
bs)
(WpCompose HsWrapper
a HsWrapper
b) -> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp HsWrapper
a), LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp HsWrapper
b)]
(WpFun HsWrapper
a HsWrapper
b Scaled Type
_) -> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp HsWrapper
a), LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp HsWrapper
b)]
(WpEvLam Id
a) ->
Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind EvVarSource
EvWrapperBind (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
osp) (SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
osp))
(GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id))
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp Id
a
(WpEvApp EvTerm
a) ->
(Id -> HieM [HieAST Type]) -> [Id] -> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type])
-> (Id -> Context (GenLocated SrcSpanAnnA Id))
-> Id
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C ContextInfo
EvidenceVarUse (GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id))
-> (Id -> GenLocated SrcSpanAnnA Id)
-> Id
-> Context (GenLocated SrcSpanAnnA Id)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
osp) ([Id] -> HieM [HieAST Type]) -> [Id] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ EvTerm -> [Id]
evVarsOfTermList EvTerm
a
HsWrapper
_ -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance HiePass p => HasType (LocatedA (HsBind (GhcPass p))) where
getTypeNode :: LocatedA (HsBind (GhcPass p)) -> HieM [HieAST Type]
getTypeNode (L SrcSpanAnnA
spn HsBind (GhcPass p)
bind) =
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> HsBind (GhcPass p) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsBind (GhcPass p)
bind (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
spn)
HiePassEv p
HieTc -> case HsBind (GhcPass p)
bind of
FunBind{fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_id = LIdP (GhcPass p)
name} -> HsBind (GhcPass p) -> SrcSpan -> Type -> HieM [HieAST Type]
forall (m :: * -> *) a.
(Monad m, Data a) =>
a -> SrcSpan -> Type -> ReaderT NodeOrigin m [HieAST Type]
makeTypeNode HsBind (GhcPass p)
bind (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
spn) (Id -> Type
varType (Id -> Type) -> Id -> Type
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnN Id -> Id
forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
GenLocated SrcSpanAnnN Id
name)
HsBind (GhcPass p)
_ -> HsBind (GhcPass p) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsBind (GhcPass p)
bind (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
spn)
instance HiePass p => HasType (LocatedA (Pat (GhcPass p))) where
getTypeNode :: LocatedA (Pat (GhcPass p)) -> HieM [HieAST Type]
getTypeNode (L SrcSpanAnnA
spn Pat (GhcPass p)
pat) =
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> Pat (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA Pat (GhcPass p)
pat SrcSpanAnnA
spn
HiePassEv p
HieTc -> Pat (GhcPass p) -> SrcSpanAnnA -> Type -> HieM [HieAST Type]
forall (m :: * -> *) a.
(Monad m, Data a) =>
a -> SrcSpanAnnA -> Type -> ReaderT NodeOrigin m [HieAST Type]
makeTypeNodeA Pat (GhcPass p)
pat SrcSpanAnnA
spn (Pat GhcTc -> Type
hsPatType Pat (GhcPass p)
Pat GhcTc
pat)
instance HiePass p => HasType (LocatedA (HsExpr (GhcPass p))) where
getTypeNode :: LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
getTypeNode (L SrcSpanAnnA
spn HsExpr (GhcPass p)
e) =
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> HieM [HieAST Type]
fallback
HiePassEv p
HieTc -> case HsExpr GhcTc -> Maybe Type
computeType HsExpr (GhcPass p)
HsExpr GhcTc
e of
Just Type
ty -> HsExpr (GhcPass p) -> SrcSpanAnnA -> Type -> HieM [HieAST Type]
forall (m :: * -> *) a.
(Monad m, Data a) =>
a -> SrcSpanAnnA -> Type -> ReaderT NodeOrigin m [HieAST Type]
makeTypeNodeA HsExpr (GhcPass p)
e SrcSpanAnnA
spn Type
ty
Maybe Type
Nothing -> HieM [HieAST Type]
fallback
where
fallback :: HieM [HieAST Type]
fallback :: HieM [HieAST Type]
fallback = HsExpr (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsExpr (GhcPass p)
e SrcSpanAnnA
spn
computeType :: HsExpr GhcTc -> Maybe Type
computeType :: HsExpr GhcTc -> Maybe Type
computeType HsExpr GhcTc
e = case HsExpr GhcTc
e of
HsApp{} -> Maybe Type
forall a. Maybe a
Nothing
HsAppType{} -> Maybe Type
forall a. Maybe a
Nothing
NegApp{} -> Maybe Type
forall a. Maybe a
Nothing
HsPar XPar GhcTc
_ LHsToken "(" GhcTc
_ LHsExpr GhcTc
e LHsToken ")" GhcTc
_ -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
e
ExplicitTuple{} -> Maybe Type
forall a. Maybe a
Nothing
HsIf XIf GhcTc
_ LHsExpr GhcTc
_ LHsExpr GhcTc
t LHsExpr GhcTc
f -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
t Maybe Type -> Maybe Type -> Maybe Type
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
f
HsLet XLet GhcTc
_ LHsToken "let" GhcTc
_ HsLocalBinds GhcTc
_ LHsToken "in" GhcTc
_ LHsExpr GhcTc
body -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
body
RecordCon XRecordCon GhcTc
con_expr XRec GhcTc (ConLikeP GhcTc)
_ HsRecordBinds GhcTc
_ -> HsExpr GhcTc -> Maybe Type
computeType XRecordCon GhcTc
HsExpr GhcTc
con_expr
ExprWithTySig XExprWithTySig GhcTc
_ LHsExpr GhcTc
e LHsSigWcType (NoGhcTc GhcTc)
_ -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
e
HsPragE XPragE GhcTc
_ HsPragE GhcTc
_ LHsExpr GhcTc
e -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
e
XExpr (ExpansionExpr (HsExpanded (HsGetField XGetField GhcRn
_ LHsExpr GhcRn
_ XRec GhcRn (DotFieldOcc GhcRn)
_) HsExpr GhcTc
e)) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (HsExpr GhcTc -> Type
hsExprType HsExpr GhcTc
e)
XExpr (ExpansionExpr (HsExpanded HsExpr GhcRn
_ HsExpr GhcTc
e)) -> HsExpr GhcTc -> Maybe Type
computeType HsExpr GhcTc
e
XExpr (HsTick CoreTickish
_ LHsExpr GhcTc
e) -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
e
XExpr (HsBinTick TypeIndex
_ TypeIndex
_ LHsExpr GhcTc
e) -> LHsExpr GhcTc -> Maybe Type
computeLType LHsExpr GhcTc
e
HsExpr GhcTc
e -> Type -> Maybe Type
forall a. a -> Maybe a
Just (HsExpr GhcTc -> Type
hsExprType HsExpr GhcTc
e)
computeLType :: LHsExpr GhcTc -> Maybe Type
computeLType :: LHsExpr GhcTc -> Maybe Type
computeLType (L SrcSpanAnnA
_ HsExpr GhcTc
e) = HsExpr GhcTc -> Maybe Type
computeType HsExpr GhcTc
e
data HiePassEv p where
HieRn :: HiePassEv 'Renamed
HieTc :: HiePassEv 'Typechecked
class ( HiePass (NoGhcTcPass p)
, NoGhcTcPass p ~ 'Renamed
, ModifyState (IdGhcP p)
, Data (GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p))))
, Data (Match (GhcPass p) (LocatedA (HsExpr (GhcPass p))))
, Data (Match (GhcPass p) (LocatedA (HsCmd (GhcPass p))))
, Data (Stmt (GhcPass p) (LocatedA (HsExpr (GhcPass p))))
, Data (Stmt (GhcPass p) (LocatedA (HsCmd (GhcPass p))))
, Data (HsExpr (GhcPass p))
, Data (HsCmd (GhcPass p))
, Data (AmbiguousFieldOcc (GhcPass p))
, Data (HsCmdTop (GhcPass p))
, Data (GRHS (GhcPass p) (LocatedA (HsCmd (GhcPass p))))
, Data (HsUntypedSplice (GhcPass p))
, Data (HsLocalBinds (GhcPass p))
, Data (FieldOcc (GhcPass p))
, Data (HsTupArg (GhcPass p))
, Data (IPBind (GhcPass p))
, ToHie (Context (Located (IdGhcP p)))
, Anno (IdGhcP p) ~ SrcSpanAnnN
)
=> HiePass p where
hiePass :: HiePassEv p
instance HiePass 'Renamed where
hiePass :: HiePassEv 'Renamed
hiePass = HiePassEv 'Renamed
HieRn
instance HiePass 'Typechecked where
hiePass :: HiePassEv 'Typechecked
hiePass = HiePassEv 'Typechecked
HieTc
instance ToHie (Context (Located NoExtField)) where
toHie :: Context (Located NoExtField) -> HieM [HieAST Type]
toHie Context (Located NoExtField)
_ = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
type AnnoBody p body
= ( Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA
, Anno [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
~ SrcSpanAnnL
, Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcAnn NoEpAnns
, Anno (StmtLR (GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpanAnnA
, Data (body (GhcPass p))
, Data (Match (GhcPass p) (LocatedA (body (GhcPass p))))
, Data (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
, Data (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))
)
instance HiePass p => ToHie (BindContext (LocatedA (HsBind (GhcPass p)))) where
toHie :: BindContext (LocatedA (HsBind (GhcPass p))) -> HieM [HieAST Type]
toHie (BC BindType
context Scope
scope b :: LocatedA (HsBind (GhcPass p))
b@(L SrcSpanAnnA
span HsBind (GhcPass p)
bind)) =
[HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ LocatedA (HsBind (GhcPass p)) -> HieM [HieAST Type]
forall a. HasType a => a -> HieM [HieAST Type]
getTypeNode LocatedA (HsBind (GhcPass p))
b HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsBind (GhcPass p)
bind of
FunBind{fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_id = LIdP (GhcPass p)
name, fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches = MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
matches, fun_ext :: forall idL idR. HsBindLR idL idR -> XFunBind idL idR
fun_ext = XFunBind (GhcPass p) (GhcPass p)
ext} ->
[ Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C (BindType -> Scope -> Maybe Span -> ContextInfo
ValBind BindType
context Scope
scope (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
name
, MatchGroup
(GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
MatchGroup
(GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
matches
, case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc | (HsWrapper
wrap, [CoreTickish]
_) <- XFunBind (GhcPass p) (GhcPass p)
ext -> LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (LocatedA HsWrapper -> HieM [HieAST Type])
-> LocatedA HsWrapper -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span HsWrapper
wrap
HiePassEv p
_ -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
]
PatBind{pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat (GhcPass p)
lhs, pat_rhs :: forall idL idR. HsBindLR idL idR -> GRHSs idR (LHsExpr idR)
pat_rhs = GRHSs (GhcPass p) (LHsExpr (GhcPass p))
rhs} ->
[ PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat (GhcPass p))
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS (SrcSpan -> Maybe Span
getRealSpan (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span)) Scope
scope Scope
NoScope LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
lhs
, GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GRHSs (GhcPass p) (LHsExpr (GhcPass p))
GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
rhs
]
VarBind{var_rhs :: forall idL idR. HsBindLR idL idR -> LHsExpr idR
var_rhs = LHsExpr (GhcPass p)
expr} ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr
]
XHsBindsLR XXHsBindsLR (GhcPass p) (GhcPass p)
ext -> case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
#if __GLASGOW_HASKELL__ < 811
HieRn -> dataConCantHappen ext
#endif
HiePassEv p
HieTc
| AbsBinds{ abs_exports :: AbsBinds -> [ABExport]
abs_exports = [ABExport]
xs, abs_binds :: AbsBinds -> LHsBinds GhcTc
abs_binds = LHsBinds GhcTc
binds
, abs_ev_binds :: AbsBinds -> [TcEvBinds]
abs_ev_binds = [TcEvBinds]
ev_binds
, abs_ev_vars :: AbsBinds -> [Id]
abs_ev_vars = [Id]
ev_vars } <- XXHsBindsLR (GhcPass p) (GhcPass p)
ext
->
[ State HieState () -> HieM ()
forall (m :: * -> *) a. Monad m => m a -> ReaderT NodeOrigin m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((HieState -> HieState) -> State HieState ()
forall (m :: * -> *) s. Monad m => (s -> s) -> StateT s m ()
modify ([ABExport] -> HieState -> HieState
modifyState [ABExport]
xs)) HieM () -> HieM [HieAST Type] -> HieM [HieAST Type]
forall a b.
ReaderT NodeOrigin (State HieState) a
-> ReaderT NodeOrigin (State HieState) b
-> ReaderT NodeOrigin (State HieState) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
(Bag (BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> HieM [HieAST Type])
-> Bag
(BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
-> Bag
(BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)))
forall a b. (a -> b) -> Bag a -> Bag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc)
-> BindContext (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
context Scope
scope) LHsBinds GhcTc
Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
binds)
, [LocatedA HsWrapper] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([LocatedA HsWrapper] -> HieM [HieAST Type])
-> [LocatedA HsWrapper] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ABExport -> LocatedA HsWrapper)
-> [ABExport] -> [LocatedA HsWrapper]
forall a b. (a -> b) -> [a] -> [b]
map (SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span (HsWrapper -> LocatedA HsWrapper)
-> (ABExport -> HsWrapper) -> ABExport -> LocatedA HsWrapper
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ABExport -> HsWrapper
abe_wrap) [ABExport]
xs
, [EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)]
-> HieM [HieAST Type])
-> [EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
(TcEvBinds -> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds))
-> [TcEvBinds]
-> [EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)]
forall a b. (a -> b) -> [a] -> [b]
map (Scope
-> Maybe Span
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a. Scope -> Maybe Span -> a -> EvBindContext a
EvBindContext (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span) (SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span)
(GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds))
-> (TcEvBinds -> GenLocated SrcSpanAnnA TcEvBinds)
-> TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpanAnnA -> TcEvBinds -> GenLocated SrcSpanAnnA TcEvBinds
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span) [TcEvBinds]
ev_binds
, [Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
(Id -> Context (GenLocated SrcSpanAnnA Id))
-> [Id] -> [Context (GenLocated SrcSpanAnnA Id)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind EvVarSource
EvSigBind
(SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span)
(SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span))
(GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id))
-> (Id -> GenLocated SrcSpanAnnA Id)
-> Id
-> Context (GenLocated SrcSpanAnnA Id)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span) [Id]
ev_vars
]
PatSynBind XPatSynBind (GhcPass p) (GhcPass p)
_ PatSynBind (GhcPass p) (GhcPass p)
psb ->
[ GenLocated SrcSpan (PatSynBind (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (PatSynBind (GhcPass p) (GhcPass p))
-> HieM [HieAST Type])
-> GenLocated SrcSpan (PatSynBind (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> PatSynBind (GhcPass p) (GhcPass p)
-> GenLocated SrcSpan (PatSynBind (GhcPass p) (GhcPass p))
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) PatSynBind (GhcPass p) (GhcPass p)
psb
]
instance ( HiePass p
, AnnoBody p body
, ToHie (LocatedA (body (GhcPass p)))
) => ToHie (MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))) where
toHie :: MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
-> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mg = case MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mg of
MG{ mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = (L SrcSpanAnnL
span [GenLocated
SrcSpanAnnA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
alts) } ->
(NodeOrigin -> NodeOrigin)
-> HieM [HieAST Type] -> HieM [HieAST Type]
forall r (m :: * -> *) a.
(r -> r) -> ReaderT r m a -> ReaderT r m a
local (Origin -> NodeOrigin -> NodeOrigin
setOrigin Origin
origin) (HieM [HieAST Type] -> HieM [HieAST Type])
-> HieM [HieAST Type] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnnL -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
span)
, [GenLocated
SrcSpanAnnA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated
SrcSpanAnnA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
alts
]
where origin :: Origin
origin = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
-> XMG (GhcPass p) (LocatedA (body (GhcPass p)))
forall p body. MatchGroup p body -> XMG p body
mg_ext MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mg
HiePassEv p
HieTc -> MatchGroupTc -> Origin
mg_origin (MatchGroupTc -> Origin) -> MatchGroupTc -> Origin
forall a b. (a -> b) -> a -> b
$ MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
-> XMG (GhcPass p) (LocatedA (body (GhcPass p)))
forall p body. MatchGroup p body -> XMG p body
mg_ext MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mg
setOrigin :: Origin -> NodeOrigin -> NodeOrigin
setOrigin :: Origin -> NodeOrigin -> NodeOrigin
setOrigin Origin
FromSource NodeOrigin
_ = NodeOrigin
SourceInfo
setOrigin (Generated {}) NodeOrigin
_ = NodeOrigin
GeneratedInfo
instance HiePass p => ToHie (Located (PatSynBind (GhcPass p) (GhcPass p))) where
toHie :: Located (PatSynBind (GhcPass p) (GhcPass p)) -> HieM [HieAST Type]
toHie (L SrcSpan
sp PatSynBind (GhcPass p) (GhcPass p)
psb) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case PatSynBind (GhcPass p) (GhcPass p)
psb of
PSB{psb_id :: forall idL idR. PatSynBind idL idR -> LIdP idL
psb_id=XRec (GhcPass p) (IdP (GhcPass p))
var, psb_args :: forall idL idR. PatSynBind idL idR -> HsPatSynDetails idR
psb_args=HsPatSynDetails (GhcPass p)
dets, psb_def :: forall idL idR. PatSynBind idL idR -> LPat idR
psb_def=LPat (GhcPass p)
pat, psb_dir :: forall idL idR. PatSynBind idL idR -> HsPatSynDir idR
psb_dir=HsPatSynDir (GhcPass p)
dir} ->
[ Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
PatSynDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe Span
getRealSpan SrcSpan
sp) XRec (GhcPass p) (IdP (GhcPass p))
GenLocated SrcSpanAnnN (IdGhcP p)
var
, HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HieM [HieAST Type])
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
Void
(GenLocated SrcSpanAnnN (IdGhcP p))
[RecordPatSynField (GhcPass p)]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
toBind HsPatSynDetails (GhcPass p)
HsConDetails
Void
(GenLocated SrcSpanAnnN (IdGhcP p))
[RecordPatSynField (GhcPass p)]
dets
, PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat (GhcPass p))
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
forall a. Maybe a
Nothing Scope
lhsScope Scope
patScope LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat
, HsPatSynDir (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsPatSynDir (GhcPass p)
dir
]
where
lhsScope :: Scope
lhsScope = Scope -> Scope -> Scope
combineScopes Scope
varScope Scope
detScope
varScope :: Scope
varScope = GenLocated SrcSpanAnnN (IdGhcP p) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN XRec (GhcPass p) (IdP (GhcPass p))
GenLocated SrcSpanAnnN (IdGhcP p)
var
patScope :: Scope
patScope = SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA (SrcSpanAnnA -> Scope) -> SrcSpanAnnA -> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnA (Pat (GhcPass p)) -> SrcSpanAnnA
forall l e. GenLocated l e -> l
getLoc LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat
detScope :: Scope
detScope = case HsPatSynDetails (GhcPass p)
dets of
(PrefixCon [Void]
_ [XRec (GhcPass p) (IdP (GhcPass p))]
args) -> (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN (IdGhcP p) -> Scope)
-> [GenLocated SrcSpanAnnN (IdGhcP p)] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnN (IdGhcP p) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN [XRec (GhcPass p) (IdP (GhcPass p))]
[GenLocated SrcSpanAnnN (IdGhcP p)]
args
(InfixCon XRec (GhcPass p) (IdP (GhcPass p))
a XRec (GhcPass p) (IdP (GhcPass p))
b) -> Scope -> Scope -> Scope
combineScopes (GenLocated SrcSpanAnnN (IdGhcP p) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN XRec (GhcPass p) (IdP (GhcPass p))
GenLocated SrcSpanAnnN (IdGhcP p)
a) (GenLocated SrcSpanAnnN (IdGhcP p) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN XRec (GhcPass p) (IdP (GhcPass p))
GenLocated SrcSpanAnnN (IdGhcP p)
b)
(RecCon [RecordPatSynField (GhcPass p)]
r) -> (RecordPatSynField (GhcPass p) -> Scope -> Scope)
-> Scope -> [RecordPatSynField (GhcPass p)] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr RecordPatSynField (GhcPass p) -> Scope -> Scope
forall {pass}.
(XRec pass (IdP pass) ~ LocatedN (IdP pass),
XRec pass RdrName ~ LocatedN RdrName) =>
RecordPatSynField pass -> Scope -> Scope
go Scope
NoScope [RecordPatSynField (GhcPass p)]
r
go :: RecordPatSynField pass -> Scope -> Scope
go (RecordPatSynField FieldOcc pass
a XRec pass (IdP pass)
b) Scope
c = Scope -> Scope -> Scope
combineScopes Scope
c
(Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ Scope -> Scope -> Scope
combineScopes (LocatedN RdrName -> Scope
forall a. LocatedN a -> Scope
mkLScopeN (FieldOcc pass -> XRec pass RdrName
forall pass. FieldOcc pass -> XRec pass RdrName
foLabel FieldOcc pass
a)) (LocatedN (IdP pass) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN XRec pass (IdP pass)
LocatedN (IdP pass)
b)
detSpan :: Maybe Span
detSpan = case Scope
detScope of
LocalScope Span
a -> Span -> Maybe Span
forall a. a -> Maybe a
Just Span
a
Scope
_ -> Maybe Span
forall a. Maybe a
Nothing
toBind :: HsConDetails
Void
(GenLocated SrcSpanAnnN (IdGhcP p))
[RecordPatSynField (GhcPass p)]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
toBind (PrefixCon [Void]
ts [GenLocated SrcSpanAnnN (IdGhcP p)]
args) = Bool
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall a. HasCallStack => Bool -> a -> a
assert ([Void] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Void]
ts) (HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))])
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall a b. (a -> b) -> a -> b
$ [Void]
-> [Context (GenLocated SrcSpanAnnN (IdGhcP p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [Void]
ts ([Context (GenLocated SrcSpanAnnN (IdGhcP p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))])
-> [Context (GenLocated SrcSpanAnnN (IdGhcP p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p)))
-> [GenLocated SrcSpanAnnN (IdGhcP p)]
-> [Context (GenLocated SrcSpanAnnN (IdGhcP p))]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN (IdGhcP p)]
args
toBind (InfixCon GenLocated SrcSpanAnnN (IdGhcP p)
a GenLocated SrcSpanAnnN (IdGhcP p)
b) = Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon (ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN (IdGhcP p)
a) (ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN (IdGhcP p)
b)
toBind (RecCon [RecordPatSynField (GhcPass p)]
r) = [PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon ([PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))])
-> [PatSynFieldContext (RecordPatSynField (GhcPass p))]
-> HsConDetails
Void
(Context (GenLocated SrcSpanAnnN (IdGhcP p)))
[PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall a b. (a -> b) -> a -> b
$ (RecordPatSynField (GhcPass p)
-> PatSynFieldContext (RecordPatSynField (GhcPass p)))
-> [RecordPatSynField (GhcPass p)]
-> [PatSynFieldContext (RecordPatSynField (GhcPass p))]
forall a b. (a -> b) -> [a] -> [b]
map (Maybe Span
-> RecordPatSynField (GhcPass p)
-> PatSynFieldContext (RecordPatSynField (GhcPass p))
forall a. Maybe Span -> a -> PatSynFieldContext a
PSC Maybe Span
detSpan) [RecordPatSynField (GhcPass p)]
r
instance HiePass p => ToHie (HsPatSynDir (GhcPass p)) where
toHie :: HsPatSynDir (GhcPass p) -> HieM [HieAST Type]
toHie HsPatSynDir (GhcPass p)
dir = case HsPatSynDir (GhcPass p)
dir of
ExplicitBidirectional MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg -> MatchGroup
(GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
MatchGroup
(GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
mg
HsPatSynDir (GhcPass p)
_ -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ( HiePass p
, Data (body (GhcPass p))
, AnnoBody p body
, ToHie (LocatedA (body (GhcPass p)))
) => ToHie (LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))) where
toHie :: LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))
-> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span Match (GhcPass p) (LocatedA (body (GhcPass p)))
m ) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Match (GhcPass p) (LocatedA (body (GhcPass p)))
-> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA Match (GhcPass p) (LocatedA (body (GhcPass p)))
m SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case Match (GhcPass p) (LocatedA (body (GhcPass p)))
m of
Match{m_ctxt :: forall p body. Match p body -> HsMatchContext p
m_ctxt=HsMatchContext (GhcPass p)
mctx, m_pats :: forall p body. Match p body -> [LPat p]
m_pats = [LPat (GhcPass p)]
pats, m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
grhss } ->
[ HsMatchContext (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsMatchContext (GhcPass p)
mctx
, let rhsScope :: Scope
rhsScope = SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcAnn NoEpAnns) =>
GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
grhss_span GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
grhss
in [PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))]
-> HieM [HieAST Type])
-> [PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe Span
forall a. Maybe a
Nothing Scope
rhsScope Scope
NoScope [LPat (GhcPass p)]
pats
, GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
grhss
]
instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where
toHie :: HsMatchContext (GhcPass p) -> HieM [HieAST Type]
toHie (FunRhs{mc_fun :: forall p. HsMatchContext p -> LIdP (NoGhcTc p)
mc_fun=LIdP (NoGhcTc (GhcPass p))
name}) = Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
MatchBind LocatedN Name
name'
where
name' :: LocatedN Name
name' :: LocatedN Name
name' = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> LIdP (NoGhcTc (GhcPass p))
LocatedN Name
name
HiePassEv p
HieTc -> LIdP (NoGhcTc (GhcPass p))
LocatedN Name
name
toHie (StmtCtxt HsStmtContext (GhcPass p)
a) = HsStmtContext (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsStmtContext (GhcPass p)
a
toHie HsMatchContext (GhcPass p)
_ = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance HiePass p => ToHie (HsStmtContext (GhcPass p)) where
toHie :: HsStmtContext (GhcPass p) -> HieM [HieAST Type]
toHie (PatGuard HsMatchContext (GhcPass p)
a) = HsMatchContext (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsMatchContext (GhcPass p)
a
toHie (ParStmtCtxt HsStmtContext (GhcPass p)
a) = HsStmtContext (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsStmtContext (GhcPass p)
a
toHie (TransStmtCtxt HsStmtContext (GhcPass p)
a) = HsStmtContext (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsStmtContext (GhcPass p)
a
toHie HsStmtContext (GhcPass p)
_ = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance HiePass p => ToHie (PScoped (LocatedA (Pat (GhcPass p)))) where
toHie :: PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
toHie (PS Maybe Span
rsp Scope
scope Scope
pscope lpat :: LocatedA (Pat (GhcPass p))
lpat@(L SrcSpanAnnA
ospan Pat (GhcPass p)
opat)) =
[HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ LocatedA (Pat (GhcPass p)) -> HieM [HieAST Type]
forall a. HasType a => a -> HieM [HieAST Type]
getTypeNode LocatedA (Pat (GhcPass p))
lpat HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case Pat (GhcPass p)
opat of
WildPat XWildPat (GhcPass p)
_ ->
[]
VarPat XVarPat (GhcPass p)
_ LIdP (GhcPass p)
lname ->
[ Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C (Scope -> Scope -> Maybe Span -> ContextInfo
PatternBind Scope
scope Scope
pscope Maybe Span
rsp) LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
lname
]
LazyPat XLazyPat (GhcPass p)
_ LPat (GhcPass p)
p ->
[ PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
p
]
AsPat XAsPat (GhcPass p)
_ LIdP (GhcPass p)
lname LHsToken "@" (GhcPass p)
_ LPat (GhcPass p)
pat ->
[ Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C (Scope -> Scope -> Maybe Span -> ContextInfo
PatternBind Scope
scope
(Scope -> Scope -> Scope
combineScopes (LocatedA (Pat (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat) Scope
pscope)
Maybe Span
rsp)
LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
lname
, PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat
]
ParPat XParPat (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ LPat (GhcPass p)
pat LHsToken ")" (GhcPass p)
_ ->
[ PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat
]
BangPat XBangPat (GhcPass p)
_ LPat (GhcPass p)
pat ->
[ PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat
]
ListPat XListPat (GhcPass p)
_ [LPat (GhcPass p)]
pats ->
[ [PScoped (LocatedA (Pat (GhcPass p)))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([PScoped (LocatedA (Pat (GhcPass p)))] -> HieM [HieAST Type])
-> [PScoped (LocatedA (Pat (GhcPass p)))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe Span
rsp Scope
scope Scope
pscope [LPat (GhcPass p)]
pats
]
TuplePat XTuplePat (GhcPass p)
_ [LPat (GhcPass p)]
pats Boxity
_ ->
[ [PScoped (LocatedA (Pat (GhcPass p)))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([PScoped (LocatedA (Pat (GhcPass p)))] -> HieM [HieAST Type])
-> [PScoped (LocatedA (Pat (GhcPass p)))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe Span
rsp Scope
scope Scope
pscope [LPat (GhcPass p)]
pats
]
SumPat XSumPat (GhcPass p)
_ LPat (GhcPass p)
pat TypeIndex
_ TypeIndex
_ ->
[ PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat
]
ConPat {pat_con :: forall p. Pat p -> XRec p (ConLikeP p)
pat_con = XRec (GhcPass p) (ConLikeP (GhcPass p))
con, pat_args :: forall p. Pat p -> HsConPatDetails p
pat_args = HsConPatDetails (GhcPass p)
dets, pat_con_ext :: forall p. Pat p -> XConPat p
pat_con_ext = XConPat (GhcPass p)
ext} ->
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (LocatedN Name -> Context (LocatedN Name))
-> LocatedN Name -> Context (LocatedN Name)
forall a b. (a -> b) -> a -> b
$ (ConLike -> Name)
-> GenLocated SrcSpanAnnN ConLike -> LocatedN Name
forall a b.
(a -> b) -> GenLocated SrcSpanAnnN a -> GenLocated SrcSpanAnnN b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConLike -> Name
conLikeName XRec (GhcPass p) (ConLikeP (GhcPass p))
GenLocated SrcSpanAnnN ConLike
con
, HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
-> HieM [HieAST Type])
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
(HsConPatTyArg GhcRn)
(GenLocated SrcSpanAnnA (Pat GhcTc))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcTc)))
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
forall a.
(a ~ LPat (GhcPass p)) =>
HsConDetails (HsConPatTyArg GhcRn) a (HsRecFields (GhcPass p) a)
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify HsConPatDetails (GhcPass p)
HsConDetails
(HsConPatTyArg GhcRn)
(GenLocated SrcSpanAnnA (Pat GhcTc))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcTc)))
dets
, let ev_binds :: TcEvBinds
ev_binds = ConPatTc -> TcEvBinds
cpt_binds XConPat (GhcPass p)
ConPatTc
ext
ev_vars :: [Id]
ev_vars = ConPatTc -> [Id]
cpt_dicts XConPat (GhcPass p)
ConPatTc
ext
wrap :: HsWrapper
wrap = ConPatTc -> HsWrapper
cpt_wrap XConPat (GhcPass p)
ConPatTc
ext
evscope :: Scope
evscope = SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
ospan Scope -> Scope -> Scope
`combineScopes` Scope
scope Scope -> Scope -> Scope
`combineScopes` Scope
pscope
in [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM [ EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type])
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> Maybe Span
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a. Scope -> Maybe Span -> a -> EvBindContext a
EvBindContext Scope
scope Maybe Span
rsp (GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds))
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> TcEvBinds -> GenLocated SrcSpanAnnA TcEvBinds
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan TcEvBinds
ev_binds
, LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (LocatedA HsWrapper -> HieM [HieAST Type])
-> LocatedA HsWrapper -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan HsWrapper
wrap
, [Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnA Id)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Id -> Context (GenLocated SrcSpanAnnA Id))
-> [Id] -> [Context (GenLocated SrcSpanAnnA Id)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind EvVarSource
EvPatternBind Scope
evscope Maybe Span
rsp)
(GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id))
-> (Id -> GenLocated SrcSpanAnnA Id)
-> Id
-> Context (GenLocated SrcSpanAnnA Id)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan) [Id]
ev_vars
]
]
HiePassEv p
HieRn ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use XRec (GhcPass p) (ConLikeP (GhcPass p))
LocatedN Name
con
, HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
-> HieM [HieAST Type])
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
(HsConPatTyArg GhcRn)
(GenLocated SrcSpanAnnA (Pat GhcRn))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcRn)))
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
forall a.
(a ~ LPat (GhcPass p)) =>
HsConDetails (HsConPatTyArg GhcRn) a (HsRecFields (GhcPass p) a)
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify HsConPatDetails (GhcPass p)
HsConDetails
(HsConPatTyArg GhcRn)
(GenLocated SrcSpanAnnA (Pat GhcRn))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcRn)))
dets
]
ViewPat XViewPat (GhcPass p)
_ LHsExpr (GhcPass p)
expr LPat (GhcPass p)
pat ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr
, PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat
]
SplicePat XSplicePat (GhcPass p)
_ HsUntypedSplice (GhcPass p)
sp ->
[ GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsUntypedSplice (GhcPass p)
-> GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan HsUntypedSplice (GhcPass p)
sp
]
LitPat XLitPat (GhcPass p)
_ HsLit (GhcPass p)
_ ->
[]
NPat XNPat (GhcPass p)
_ XRec (GhcPass p) (HsOverLit (GhcPass p))
_ Maybe (SyntaxExpr (GhcPass p))
_ SyntaxExpr (GhcPass p)
_ ->
[]
NPlusKPat XNPlusKPat (GhcPass p)
_ LIdP (GhcPass p)
n XRec (GhcPass p) (HsOverLit (GhcPass p))
_ HsOverLit (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ ->
[ Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C (Scope -> Scope -> Maybe Span -> ContextInfo
PatternBind Scope
scope Scope
pscope Maybe Span
rsp) LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
n
]
SigPat XSigPat (GhcPass p)
_ LPat (GhcPass p)
pat HsPatSigType (NoGhcTc (GhcPass p))
sig ->
[ PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type])
-> PScoped (LocatedA (Pat (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> LocatedA (Pat (GhcPass p))
-> PScoped (LocatedA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope LPat (GhcPass p)
LocatedA (Pat (GhcPass p))
pat
, case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc ->
let cscope :: Scope
cscope = GenLocated SrcSpanAnnA (Pat GhcTc) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat GhcTc)
pat in
TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> HsPatSigType GhcRn -> TScoped (HsPatSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
cscope, Scope
scope, Scope
pscope])
HsPatSigType (NoGhcTc (GhcPass p))
HsPatSigType GhcRn
sig
HiePassEv p
HieRn -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
]
XPat XXPat (GhcPass p)
e ->
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> case XXPat (GhcPass p)
e of
HsPatExpanded Pat GhcRn
_ Pat GhcRn
p -> [ PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat GhcRn)
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcRn))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope (SrcSpanAnnA -> Pat GhcRn -> GenLocated SrcSpanAnnA (Pat GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan Pat GhcRn
p) ]
HiePassEv p
HieTc -> case XXPat (GhcPass p)
e of
CoPat HsWrapper
wrap Pat GhcTc
pat Type
_ ->
[ LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (LocatedA HsWrapper -> HieM [HieAST Type])
-> LocatedA HsWrapper -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan HsWrapper
wrap
, PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope (GenLocated SrcSpanAnnA (Pat GhcTc)
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
forall a b. (a -> b) -> a -> b
$ (SrcSpanAnnA -> Pat GhcTc -> GenLocated SrcSpanAnnA (Pat GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan Pat GhcTc
pat)
]
ExpansionPat Pat GhcRn
_ Pat GhcTc
p -> [ PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat GhcTc)
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcTc))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
pscope (SrcSpanAnnA -> Pat GhcTc -> GenLocated SrcSpanAnnA (Pat GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan Pat GhcTc
p) ]
where
contextify :: a ~ LPat (GhcPass p) => HsConDetails (HsConPatTyArg GhcRn) a (HsRecFields (GhcPass p) a)
-> HsConDetails (TScoped (HsPatSigType GhcRn)) (PScoped a) (RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify :: forall a.
(a ~ LPat (GhcPass p)) =>
HsConDetails (HsConPatTyArg GhcRn) a (HsRecFields (GhcPass p) a)
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify (PrefixCon [HsConPatTyArg GhcRn]
tyargs [a]
args) =
[TScoped (HsPatSigType GhcRn)]
-> [PScoped a]
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon (Scope
-> Scope -> [HsConPatTyArg GhcRn] -> [TScoped (HsPatSigType GhcRn)]
forall (a :: Pass).
Scope
-> Scope
-> [HsConPatTyArg (GhcPass a)]
-> [TScoped (HsPatSigType (GhcPass a))]
taScopes Scope
scope Scope
argscope [HsConPatTyArg GhcRn]
tyargs)
(Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe Span
rsp Scope
scope Scope
pscope [a]
[LPat (GhcPass p)]
args)
where argscope :: Scope
argscope = (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ (LocatedA (Pat (GhcPass p)) -> Scope)
-> [LocatedA (Pat (GhcPass p))] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map LocatedA (Pat (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA [a]
[LocatedA (Pat (GhcPass p))]
args
contextify (InfixCon a
a a
b) = PScoped a
-> PScoped a
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon PScoped a
PScoped (LPat (GhcPass p))
a' PScoped a
PScoped (LPat (GhcPass p))
b'
where [PScoped (LPat (GhcPass p))
a', PScoped (LPat (GhcPass p))
b'] = Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe Span
rsp Scope
scope Scope
pscope [a
LPat (GhcPass p)
a,a
LPat (GhcPass p)
b]
contextify (RecCon HsRecFields (GhcPass p) a
r) = RContext (HsRecFields (GhcPass p) (PScoped a))
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon (RContext (HsRecFields (GhcPass p) (PScoped a))
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a))))
-> RContext (HsRecFields (GhcPass p) (PScoped a))
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
forall a b. (a -> b) -> a -> b
$ RecFieldContext
-> HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
-> RContext
(HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p)))))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
RecFieldMatch (HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
-> RContext
(HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))))
-> HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
-> RContext
(HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p)))))
forall a b. (a -> b) -> a -> b
$ HsRecFields (GhcPass p) (LocatedA (Pat (GhcPass p)))
-> HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
contextify_rec HsRecFields (GhcPass p) a
HsRecFields (GhcPass p) (LocatedA (Pat (GhcPass p)))
r
contextify_rec :: HsRecFields (GhcPass p) (LocatedA (Pat (GhcPass p)))
-> HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
contextify_rec (HsRecFields [LHsRecField (GhcPass p) (LocatedA (Pat (GhcPass p)))]
fds Maybe (XRec (GhcPass p) RecFieldsDotDot)
a) = [LHsRecField (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))]
-> Maybe (XRec (GhcPass p) RecFieldsDotDot)
-> HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
forall p arg.
[LHsRecField p arg]
-> Maybe (XRec p RecFieldsDotDot) -> HsRecFields p arg
HsRecFields ((RScoped
(LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p)))))
-> LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(PScoped (LocatedA (Pat (GhcPass p))))))
-> [RScoped
(LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p)))))]
-> [LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(PScoped (LocatedA (Pat (GhcPass p)))))]
forall a b. (a -> b) -> [a] -> [b]
map RScoped
(LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p)))))
-> LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(PScoped (LocatedA (Pat (GhcPass p)))))
forall id a1.
RScoped (LocatedA (HsFieldBind id a1))
-> LocatedA (HsFieldBind id (PScoped a1))
go [RScoped
(LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p)))))]
scoped_fds) Maybe (XRec (GhcPass p) RecFieldsDotDot)
a
where
go :: RScoped (LocatedA (HsFieldBind id a1))
-> LocatedA (HsFieldBind id (PScoped a1))
go :: forall id a1.
RScoped (LocatedA (HsFieldBind id a1))
-> LocatedA (HsFieldBind id (PScoped a1))
go (RS Scope
fscope (L SrcSpanAnnA
spn (HsFieldBind XHsFieldBind id
x id
lbl a1
pat Bool
pun))) =
SrcSpanAnnA
-> HsFieldBind id (PScoped a1)
-> GenLocated SrcSpanAnnA (HsFieldBind id (PScoped a1))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
spn (HsFieldBind id (PScoped a1)
-> GenLocated SrcSpanAnnA (HsFieldBind id (PScoped a1)))
-> HsFieldBind id (PScoped a1)
-> GenLocated SrcSpanAnnA (HsFieldBind id (PScoped a1))
forall a b. (a -> b) -> a -> b
$ XHsFieldBind id
-> id -> PScoped a1 -> Bool -> HsFieldBind id (PScoped a1)
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind XHsFieldBind id
x id
lbl (Maybe Span -> Scope -> Scope -> a1 -> PScoped a1
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
rsp Scope
scope Scope
fscope a1
pat) Bool
pun
scoped_fds :: [RScoped
(LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p)))))]
scoped_fds = Scope
-> [LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p))))]
-> [RScoped
(LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
pscope [LHsRecField (GhcPass p) (LocatedA (Pat (GhcPass p)))]
[LocatedA
(HsFieldBind
(XRec (GhcPass p) (FieldOcc (GhcPass p)))
(LocatedA (Pat (GhcPass p))))]
fds
instance ToHie (TScoped (HsPatSigType GhcRn)) where
toHie :: TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type]
toHie (TS TyVarScope
sc (HsPS (HsPSRn [Name]
wcs [Name]
tvs) body :: LHsType GhcRn
body@(L SrcSpanAnnA
span HsType GhcRn
_))) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ [Context Name] -> HieM [HieAST Type]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly ([Context Name] -> HieM [HieAST Type])
-> [Context Name] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Name -> Context Name) -> [Name] -> [Context Name]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Name -> Context Name
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Name -> Context Name)
-> ContextInfo -> Name -> Context Name
forall a b. (a -> b) -> a -> b
$ Scope -> TyVarScope -> ContextInfo
TyVarBind (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span) TyVarScope
sc) ([Name]
wcs[Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++[Name]
tvs)
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
body
]
instance ( ToHie (LocatedA (body (GhcPass p)))
, HiePass p
, AnnoBody p body
) => ToHie (GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))) where
toHie :: GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
-> HieM [HieAST Type]
toHie GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
grhs = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
grhs of
GRHSs XCGRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
_ [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
grhss HsLocalBinds (GhcPass p)
binds ->
[ [GenLocated
(SrcAnn NoEpAnns) (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
[GenLocated
(SrcAnn NoEpAnns) (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
grhss
, RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type])
-> RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> HsLocalBinds (GhcPass p) -> RScoped (HsLocalBinds (GhcPass p))
forall a. Scope -> a -> RScoped a
RS (SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcAnn NoEpAnns) =>
GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
grhss_span GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
grhs) HsLocalBinds (GhcPass p)
binds
]
instance ( ToHie (LocatedA (body (GhcPass p)))
, HiePass p
, AnnoBody p body
) => ToHie (LocatedAn NoEpAnns (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))) where
toHie :: LocatedAn NoEpAnns (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
-> HieM [HieAST Type]
toHie (L SrcAnn NoEpAnns
span GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
g) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
-> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
g SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
g of
GRHS XCGRHS (GhcPass p) (LocatedA (body (GhcPass p)))
_ [GuardLStmt (GhcPass p)]
guards LocatedA (body (GhcPass p))
body ->
[ [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes (LocatedA (body (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LocatedA (body (GhcPass p))
body) [GuardLStmt (GhcPass p)]
[LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
guards
, LocatedA (body (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (body (GhcPass p))
body
]
instance HiePass p => ToHie (LocatedA (HsExpr (GhcPass p))) where
toHie :: LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
toHie e :: LocatedA (HsExpr (GhcPass p))
e@(L SrcSpanAnnA
mspan HsExpr (GhcPass p)
oexpr) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. HasType a => a -> HieM [HieAST Type]
getTypeNode LocatedA (HsExpr (GhcPass p))
e HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsExpr (GhcPass p)
oexpr of
HsVar XVar (GhcPass p)
_ (L SrcSpanAnnN
_ IdGhcP p
var) ->
[ Context (GenLocated SrcSpanAnnA (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnA (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnA (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnA (IdGhcP p)
-> Context (GenLocated SrcSpanAnnA (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (SrcSpanAnnA -> IdGhcP p -> GenLocated SrcSpanAnnA (IdGhcP p)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan IdGhcP p
var)
]
HsUnboundVar XUnboundVar (GhcPass p)
_ RdrName
_ -> []
HsRecSel XRecSel (GhcPass p)
_ FieldOcc (GhcPass p)
fld ->
[ RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p)))
-> HieM [HieAST Type])
-> RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RecFieldContext
-> Maybe Span
-> GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))
-> RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p)))
forall a. RecFieldContext -> Maybe Span -> a -> RFContext a
RFC RecFieldContext
RecFieldOcc Maybe Span
forall a. Maybe a
Nothing (SrcAnn NoEpAnns
-> FieldOcc (GhcPass p)
-> GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnA -> SrcAnn NoEpAnns
forall a ann. SrcSpanAnn' a -> SrcAnn ann
l2l SrcSpanAnnA
mspan:: SrcAnn NoEpAnns) FieldOcc (GhcPass p)
fld)
]
HsOverLabel {} -> []
HsIPVar XIPVar (GhcPass p)
_ HsIPName
_ -> []
HsOverLit XOverLitE (GhcPass p)
_ HsOverLit (GhcPass p)
_ -> []
HsLit XLitE (GhcPass p)
_ HsLit (GhcPass p)
_ -> []
HsLam XLam (GhcPass p)
_ MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg ->
[ MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
mg
]
HsLamCase XLamCase (GhcPass p)
_ LamCaseVariant
_ MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg ->
[ MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
mg
]
HsApp XApp (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsExpr (GhcPass p)
b ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
b
]
HsAppType XAppTypeE (GhcPass p)
_ LHsExpr (GhcPass p)
expr LHsToken "@" (GhcPass p)
_ LHsWcType (NoGhcTc (GhcPass p))
sig ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
, TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type])
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
sig
]
OpApp XOpApp (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsExpr (GhcPass p)
b LHsExpr (GhcPass p)
c ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
b
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
c
]
NegApp XNegApp (GhcPass p)
_ LHsExpr (GhcPass p)
a SyntaxExpr (GhcPass p)
_ ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
]
HsPar XPar (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsToken ")" (GhcPass p)
_ ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
]
SectionL XSectionL (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsExpr (GhcPass p)
b ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
b
]
SectionR XSectionR (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsExpr (GhcPass p)
b ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
b
]
ExplicitTuple XExplicitTuple (GhcPass p)
_ [HsTupArg (GhcPass p)]
args Boxity
_ ->
[ [HsTupArg (GhcPass p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [HsTupArg (GhcPass p)]
args
]
ExplicitSum XExplicitSum (GhcPass p)
_ TypeIndex
_ TypeIndex
_ LHsExpr (GhcPass p)
expr ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
]
HsCase XCase (GhcPass p)
_ LHsExpr (GhcPass p)
expr MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
matches ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
, MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
matches
]
HsIf XIf (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsExpr (GhcPass p)
b LHsExpr (GhcPass p)
c ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
b
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
c
]
HsMultiIf XMultiIf (GhcPass p)
_ [LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
grhss ->
[ [GenLocated
(SrcAnn NoEpAnns)
(GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
[GenLocated
(SrcAnn NoEpAnns)
(GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
grhss
]
HsLet XLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type])
-> RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> HsLocalBinds (GhcPass p) -> RScoped (HsLocalBinds (GhcPass p))
forall a. Scope -> a -> RScoped a
RS (LocatedA (HsExpr (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr) HsLocalBinds (GhcPass p)
binds
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
]
HsDo XDo (GhcPass p)
_ HsDoFlavour
_ (L SrcSpanAnnL
ispan [LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
stmts) ->
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnnL -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
ispan)
, [RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
-> [RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
NoScope [LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
stmts
]
ExplicitList XExplicitList (GhcPass p)
_ [LHsExpr (GhcPass p)]
exprs ->
[ [LocatedA (HsExpr (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsExpr (GhcPass p)]
[LocatedA (HsExpr (GhcPass p))]
exprs
]
RecordCon { rcon_con :: forall p. HsExpr p -> XRec p (ConLikeP p)
rcon_con = XRec (GhcPass p) (ConLikeP (GhcPass p))
con, rcon_flds :: forall p. HsExpr p -> HsRecordBinds p
rcon_flds = HsRecordBinds (GhcPass p)
binds} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (LocatedN Name -> Context (LocatedN Name))
-> LocatedN Name -> Context (LocatedN Name)
forall a b. (a -> b) -> a -> b
$ LocatedN Name
con_name
, RContext (HsRecFields (GhcPass p) (LocatedA (HsExpr (GhcPass p))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RContext (HsRecFields (GhcPass p) (LocatedA (HsExpr (GhcPass p))))
-> HieM [HieAST Type])
-> RContext
(HsRecFields (GhcPass p) (LocatedA (HsExpr (GhcPass p))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RecFieldContext
-> HsRecordBinds (GhcPass p)
-> RContext (HsRecordBinds (GhcPass p))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
RecFieldAssign (HsRecordBinds (GhcPass p) -> RContext (HsRecordBinds (GhcPass p)))
-> HsRecordBinds (GhcPass p)
-> RContext (HsRecordBinds (GhcPass p))
forall a b. (a -> b) -> a -> b
$ HsRecordBinds (GhcPass p)
binds
]
where
con_name :: LocatedN Name
con_name :: LocatedN Name
con_name = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> XRec (GhcPass p) (ConLikeP (GhcPass p))
LocatedN Name
con
HiePassEv p
HieTc -> (ConLike -> Name)
-> GenLocated SrcSpanAnnN ConLike -> LocatedN Name
forall a b.
(a -> b) -> GenLocated SrcSpanAnnN a -> GenLocated SrcSpanAnnN b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConLike -> Name
conLikeName XRec (GhcPass p) (ConLikeP (GhcPass p))
GenLocated SrcSpanAnnN ConLike
con
RecordUpd { rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr (GhcPass p)
expr
, rupd_flds :: forall p. HsExpr p -> LHsRecUpdFields p
rupd_flds = RegularRecUpdFields { recUpdFields :: forall p. LHsRecUpdFields p -> [LHsRecUpdField p p]
recUpdFields = [LHsRecUpdField (GhcPass p) (GhcPass p)]
upds } }->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
, [RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p))))
-> RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p))))))
-> [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p))))]
-> [RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p)))))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p))))
-> RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p)))))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
RecFieldAssign) [LHsRecUpdField (GhcPass p) (GhcPass p)]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
(LocatedA (HsExpr (GhcPass p))))]
upds
]
RecordUpd { rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr (GhcPass p)
expr
, rupd_flds :: forall p. HsExpr p -> LHsRecUpdFields p
rupd_flds = OverloadedRecUpdFields {} }->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
]
ExprWithTySig XExprWithTySig (GhcPass p)
_ LHsExpr (GhcPass p)
expr LHsSigWcType (NoGhcTc (GhcPass p))
sig ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
, TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type])
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [LocatedA (HsExpr (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr]) LHsSigWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
sig
]
ArithSeq XArithSeq (GhcPass p)
_ Maybe (SyntaxExpr (GhcPass p))
_ ArithSeqInfo (GhcPass p)
info ->
[ ArithSeqInfo (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ArithSeqInfo (GhcPass p)
info
]
HsPragE XPragE (GhcPass p)
_ HsPragE (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
]
HsProc XProc (GhcPass p)
_ LPat (GhcPass p)
pat LHsCmdTop (GhcPass p)
cmdtop ->
[ PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat (GhcPass p))
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
forall a. Maybe a
Nothing (GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsCmdTop (GhcPass p)
GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
cmdtop) Scope
NoScope LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat
, GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmdTop (GhcPass p)
GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
cmdtop
]
HsStatic XStatic (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
expr
]
HsTypedBracket XTypedBracket (GhcPass p)
xbracket LHsExpr (GhcPass p)
b -> case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn ->
[ LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr GhcRn)
b
]
HiePassEv p
HieTc | HsBracketTc HsQuote GhcRn
_ Type
_ Maybe QuoteWrapper
_ [PendingTcSplice]
p <- XTypedBracket (GhcPass p)
xbracket ->
[ GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr GhcTc)
b
, [PendingTcSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingTcSplice]
p
]
HsUntypedBracket XUntypedBracket (GhcPass p)
xbracket HsQuote (GhcPass p)
b -> case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn ->
[ HsQuote (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsQuote (GhcPass p)
b
, [PendingRnSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingRnSplice]
XUntypedBracket (GhcPass p)
xbracket
]
HiePassEv p
HieTc | HsBracketTc HsQuote GhcRn
q Type
_ Maybe QuoteWrapper
_ [PendingTcSplice]
p <- XUntypedBracket (GhcPass p)
xbracket ->
[ HsQuote GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsQuote GhcRn
q
, [PendingTcSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingTcSplice]
p
]
HsTypedSplice XTypedSplice (GhcPass p)
_ LHsExpr (GhcPass p)
x ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr (GhcPass p))
x
]
HsUntypedSplice XUntypedSplice (GhcPass p)
_ HsUntypedSplice (GhcPass p)
x ->
[ GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsUntypedSplice (GhcPass p)
-> GenLocated SrcSpanAnnA (HsUntypedSplice (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan HsUntypedSplice (GhcPass p)
x
]
HsGetField {} -> []
HsProjection {} -> []
XExpr XXExpr (GhcPass p)
x
| HiePassEv p
HieTc <- forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p
-> case XXExpr (GhcPass p)
x of
WrapExpr (HsWrap HsWrapper
w HsExpr GhcTc
a)
-> [ GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan HsExpr GhcTc
a
, LocatedA HsWrapper -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA -> HsWrapper -> LocatedA HsWrapper
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan HsWrapper
w) ]
ExpansionExpr (HsExpanded HsExpr GhcRn
_ HsExpr GhcTc
b)
-> [ GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA
-> HsExpr GhcTc -> GenLocated SrcSpanAnnA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan HsExpr GhcTc
b) ]
ConLikeTc ConLike
con [Id]
_ [Scaled Type]
_
-> [ Context (GenLocated SrcSpanAnnA Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnA Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnA Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnA Name
-> Context (GenLocated SrcSpanAnnA Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (GenLocated SrcSpanAnnA Name
-> Context (GenLocated SrcSpanAnnA Name))
-> GenLocated SrcSpanAnnA Name
-> Context (GenLocated SrcSpanAnnA Name)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Name -> GenLocated SrcSpanAnnA Name
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan (Name -> GenLocated SrcSpanAnnA Name)
-> Name -> GenLocated SrcSpanAnnA Name
forall a b. (a -> b) -> a -> b
$ ConLike -> Name
conLikeName ConLike
con ]
HsTick CoreTickish
_ LHsExpr GhcTc
expr
-> [ GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr
]
HsBinTick TypeIndex
_ TypeIndex
_ LHsExpr GhcTc
expr
-> [ GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr
]
| Bool
otherwise -> []
instance HiePass p => ToHie (HsTupArg (GhcPass p)) where
toHie :: HsTupArg (GhcPass p) -> HieM [HieAST Type]
toHie HsTupArg (GhcPass p)
arg = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case HsTupArg (GhcPass p)
arg of
Present XPresent (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr
]
Missing XMissing (GhcPass p)
_ -> []
instance ( ToHie (LocatedA (body (GhcPass p)))
, AnnoBody p body
, HiePass p
) => ToHie (RScoped (LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))) where
toHie :: RScoped (LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))
-> HieM [HieAST Type]
toHie (RS Scope
scope (L SrcSpanAnnA
span Stmt (GhcPass p) (LocatedA (body (GhcPass p)))
stmt)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HieM [HieAST Type]
node HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case Stmt (GhcPass p) (LocatedA (body (GhcPass p)))
stmt of
LastStmt XLastStmt (GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))
_ LocatedA (body (GhcPass p))
body Maybe Bool
_ SyntaxExpr (GhcPass p)
_ ->
[ LocatedA (body (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (body (GhcPass p))
body
]
BindStmt XBindStmt (GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))
_ LPat (GhcPass p)
pat LocatedA (body (GhcPass p))
body ->
[ PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat (GhcPass p))
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS (SrcSpan -> Maybe Span
getRealSpan (SrcSpan -> Maybe Span) -> SrcSpan -> Maybe Span
forall a b. (a -> b) -> a -> b
$ LocatedA (body (GhcPass p)) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LocatedA (body (GhcPass p))
body) Scope
scope Scope
NoScope LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat
, LocatedA (body (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (body (GhcPass p))
body
]
ApplicativeStmt XApplicativeStmt
(GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))
_ [(SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))]
stmts Maybe (SyntaxExpr (GhcPass p))
_ ->
[ ((SyntaxExprGhc p, ApplicativeArg (GhcPass p))
-> HieM [HieAST Type])
-> [(SyntaxExprGhc p, ApplicativeArg (GhcPass p))]
-> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (RScoped (ApplicativeArg (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (ApplicativeArg (GhcPass p)) -> HieM [HieAST Type])
-> ((SyntaxExprGhc p, ApplicativeArg (GhcPass p))
-> RScoped (ApplicativeArg (GhcPass p)))
-> (SyntaxExprGhc p, ApplicativeArg (GhcPass p))
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Scope
-> ApplicativeArg (GhcPass p)
-> RScoped (ApplicativeArg (GhcPass p))
forall a. Scope -> a -> RScoped a
RS Scope
scope (ApplicativeArg (GhcPass p)
-> RScoped (ApplicativeArg (GhcPass p)))
-> ((SyntaxExprGhc p, ApplicativeArg (GhcPass p))
-> ApplicativeArg (GhcPass p))
-> (SyntaxExprGhc p, ApplicativeArg (GhcPass p))
-> RScoped (ApplicativeArg (GhcPass p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SyntaxExprGhc p, ApplicativeArg (GhcPass p))
-> ApplicativeArg (GhcPass p)
forall a b. (a, b) -> b
snd) [(SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))]
[(SyntaxExprGhc p, ApplicativeArg (GhcPass p))]
stmts
]
BodyStmt XBodyStmt (GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))
_ LocatedA (body (GhcPass p))
body SyntaxExpr (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ ->
[ LocatedA (body (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (body (GhcPass p))
body
]
LetStmt XLetStmt (GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))
_ HsLocalBindsLR (GhcPass p) (GhcPass p)
binds ->
[ RScoped (HsLocalBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsLocalBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type])
-> RScoped (HsLocalBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> HsLocalBindsLR (GhcPass p) (GhcPass p)
-> RScoped (HsLocalBindsLR (GhcPass p) (GhcPass p))
forall a. Scope -> a -> RScoped a
RS Scope
scope HsLocalBindsLR (GhcPass p) (GhcPass p)
binds
]
ParStmt XParStmt (GhcPass p) (GhcPass p) (LocatedA (body (GhcPass p)))
_ [ParStmtBlock (GhcPass p) (GhcPass p)]
parstmts HsExpr (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ ->
[ (ParStmtBlock (GhcPass p) (GhcPass p) -> HieM [HieAST Type])
-> [ParStmtBlock (GhcPass p) (GhcPass p)] -> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (\(ParStmtBlock XParStmtBlock (GhcPass p) (GhcPass p)
_ [ExprLStmt (GhcPass p)]
stmts [IdP (GhcPass p)]
_ SyntaxExpr (GhcPass p)
_) ->
[RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
NoScope [ExprLStmt (GhcPass p)]
[LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts)
[ParStmtBlock (GhcPass p) (GhcPass p)]
parstmts
]
TransStmt {trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_stmts = [ExprLStmt (GhcPass p)]
stmts, trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_using = LHsExpr (GhcPass p)
using, trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_by = Maybe (LHsExpr (GhcPass p))
by} ->
[ [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
scope [ExprLStmt (GhcPass p)]
[LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
using
, Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsExpr (GhcPass p))
Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
by
]
RecStmt {recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_stmts = L SrcSpanAnnL
_ [LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))]
stmts} ->
[ [RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))
-> RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))))
-> [LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))]
-> [RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))]
forall a b. (a -> b) -> [a] -> [b]
map (Scope
-> LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))
-> RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))
forall a. Scope -> a -> RScoped a
RS (Scope
-> LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))
-> RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))))
-> Scope
-> LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))
-> RScoped
(LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p)))))
forall a b. (a -> b) -> a -> b
$ Scope -> Scope -> Scope
combineScopes Scope
scope (SrcSpan -> Scope
mkScope (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span))) [LocatedA (Stmt (GhcPass p) (LocatedA (body (GhcPass p))))]
stmts
]
where
node :: HieM [HieAST Type]
node = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc -> Stmt (GhcPass p) (LocatedA (body (GhcPass p)))
-> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA Stmt (GhcPass p) (LocatedA (body (GhcPass p)))
stmt SrcSpanAnnA
span
HiePassEv p
HieRn -> Stmt (GhcPass p) (LocatedA (body (GhcPass p)))
-> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA Stmt (GhcPass p) (LocatedA (body (GhcPass p)))
stmt SrcSpanAnnA
span
instance HiePass p => ToHie (RScoped (HsLocalBinds (GhcPass p))) where
toHie :: RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
toHie (RS Scope
scope HsLocalBinds (GhcPass p)
binds) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsLocalBinds (GhcPass p) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsLocalBinds (GhcPass p)
binds (HsLocalBinds (GhcPass p) -> SrcSpan
forall (p :: Pass). HsLocalBinds (GhcPass p) -> SrcSpan
spanHsLocaLBinds HsLocalBinds (GhcPass p)
binds) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsLocalBinds (GhcPass p)
binds of
EmptyLocalBinds XEmptyLocalBinds (GhcPass p) (GhcPass p)
_ -> []
HsIPBinds XHsIPBinds (GhcPass p) (GhcPass p)
_ HsIPBinds (GhcPass p)
ipbinds -> case HsIPBinds (GhcPass p)
ipbinds of
IPBinds XIPBinds (GhcPass p)
evbinds [LIPBind (GhcPass p)]
xs -> let sc :: Scope
sc = Scope -> Scope -> Scope
combineScopes Scope
scope (Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ HsLocalBinds (GhcPass p) -> Scope
forall (p :: Pass). HsLocalBinds (GhcPass p) -> Scope
scopeHsLocaLBinds HsLocalBinds (GhcPass p)
binds
sp :: SrcSpanAnnA
sp :: SrcSpanAnnA
sp = SrcSpan -> SrcSpanAnnA
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcSpan -> SrcSpanAnnA) -> SrcSpan -> SrcSpanAnnA
forall a b. (a -> b) -> a -> b
$ HsLocalBinds (GhcPass p) -> SrcSpan
forall (p :: Pass). HsLocalBinds (GhcPass p) -> SrcSpan
spanHsLocaLBinds HsLocalBinds (GhcPass p)
binds in
[
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc -> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type])
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> Maybe Span
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a. Scope -> Maybe Span -> a -> EvBindContext a
EvBindContext Scope
sc (SrcSpan -> Maybe Span
getRealSpan (SrcSpan -> Maybe Span) -> SrcSpan -> Maybe Span
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
sp) (GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds))
-> GenLocated SrcSpanAnnA TcEvBinds
-> EvBindContext (GenLocated SrcSpanAnnA TcEvBinds)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> TcEvBinds -> GenLocated SrcSpanAnnA TcEvBinds
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
sp XIPBinds (GhcPass p)
TcEvBinds
evbinds
HiePassEv p
HieRn -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
, [RScoped (GenLocated SrcSpanAnnA (IPBind (GhcPass p)))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (GenLocated SrcSpanAnnA (IPBind (GhcPass p)))]
-> HieM [HieAST Type])
-> [RScoped (GenLocated SrcSpanAnnA (IPBind (GhcPass p)))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (IPBind (GhcPass p))
-> RScoped (GenLocated SrcSpanAnnA (IPBind (GhcPass p))))
-> [GenLocated SrcSpanAnnA (IPBind (GhcPass p))]
-> [RScoped (GenLocated SrcSpanAnnA (IPBind (GhcPass p)))]
forall a b. (a -> b) -> [a] -> [b]
map (Scope
-> GenLocated SrcSpanAnnA (IPBind (GhcPass p))
-> RScoped (GenLocated SrcSpanAnnA (IPBind (GhcPass p)))
forall a. Scope -> a -> RScoped a
RS Scope
sc) [LIPBind (GhcPass p)]
[GenLocated SrcSpanAnnA (IPBind (GhcPass p))]
xs
]
HsValBinds XHsValBinds (GhcPass p) (GhcPass p)
_ HsValBindsLR (GhcPass p) (GhcPass p)
valBinds ->
[
RScoped (HsValBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsValBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type])
-> RScoped (HsValBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> HsValBindsLR (GhcPass p) (GhcPass p)
-> RScoped (HsValBindsLR (GhcPass p) (GhcPass p))
forall a. Scope -> a -> RScoped a
RS (Scope -> Scope -> Scope
combineScopes Scope
scope (HsLocalBinds (GhcPass p) -> Scope
forall (p :: Pass). HsLocalBinds (GhcPass p) -> Scope
scopeHsLocaLBinds HsLocalBinds (GhcPass p)
binds))
HsValBindsLR (GhcPass p) (GhcPass p)
valBinds
]
scopeHsLocaLBinds :: HsLocalBinds (GhcPass p) -> Scope
scopeHsLocaLBinds :: forall (p :: Pass). HsLocalBinds (GhcPass p) -> Scope
scopeHsLocaLBinds (HsValBinds XHsValBinds (GhcPass p) (GhcPass p)
_ (ValBinds XValBinds (GhcPass p) (GhcPass p)
_ LHsBindsLR (GhcPass p) (GhcPass p)
bs [LSig (GhcPass p)]
sigs))
= (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ([Scope]
bsScope [Scope] -> [Scope] -> [Scope]
forall a. [a] -> [a] -> [a]
++ [Scope]
sigsScope)
where
bsScope :: [Scope]
bsScope :: [Scope]
bsScope = (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> Scope)
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA (SrcSpanAnnA -> Scope)
-> (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> SrcSpanAnnA)
-> GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> SrcSpanAnnA
forall l e. GenLocated l e -> l
getLoc) ([GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [Scope])
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [Scope]
forall a b. (a -> b) -> a -> b
$ Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
forall a. Bag a -> [a]
bagToList LHsBindsLR (GhcPass p) (GhcPass p)
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
bs
sigsScope :: [Scope]
sigsScope :: [Scope]
sigsScope = (GenLocated SrcSpanAnnA (Sig (GhcPass p)) -> Scope)
-> [GenLocated SrcSpanAnnA (Sig (GhcPass p))] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (SrcSpan -> Scope
mkScope (SrcSpan -> Scope)
-> (GenLocated SrcSpanAnnA (Sig (GhcPass p)) -> SrcSpan)
-> GenLocated SrcSpanAnnA (Sig (GhcPass p))
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (Sig (GhcPass p)) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) [LSig (GhcPass p)]
[GenLocated SrcSpanAnnA (Sig (GhcPass p))]
sigs
scopeHsLocaLBinds (HsValBinds XHsValBinds (GhcPass p) (GhcPass p)
_ (XValBindsLR (NValBinds [(RecFlag, LHsBindsLR (GhcPass p) (GhcPass p))]
bs [LSig GhcRn]
sigs)))
= (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ([Scope]
bsScope [Scope] -> [Scope] -> [Scope]
forall a. [a] -> [a] -> [a]
++ [Scope]
sigsScope)
where
bsScope :: [Scope]
bsScope :: [Scope]
bsScope = (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> Scope)
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA (SrcSpanAnnA -> Scope)
-> (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> SrcSpanAnnA)
-> GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> SrcSpanAnnA
forall l e. GenLocated l e -> l
getLoc) ([GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [Scope])
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [Scope]
forall a b. (a -> b) -> a -> b
$ ((RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))])
-> [(RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))]
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
forall a. Bag a -> [a]
bagToList (Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))])
-> ((RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> (RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
forall a b. (a, b) -> b
snd) [(RecFlag, LHsBindsLR (GhcPass p) (GhcPass p))]
[(RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))]
bs
sigsScope :: [Scope]
sigsScope :: [Scope]
sigsScope = (GenLocated SrcSpanAnnA (Sig GhcRn) -> Scope)
-> [GenLocated SrcSpanAnnA (Sig GhcRn)] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (SrcSpan -> Scope
mkScope (SrcSpan -> Scope)
-> (GenLocated SrcSpanAnnA (Sig GhcRn) -> SrcSpan)
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (Sig GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) [LSig GhcRn]
[GenLocated SrcSpanAnnA (Sig GhcRn)]
sigs
scopeHsLocaLBinds (HsIPBinds XHsIPBinds (GhcPass p) (GhcPass p)
_ (IPBinds XIPBinds (GhcPass p)
_ [LIPBind (GhcPass p)]
bs))
= (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ((GenLocated SrcSpanAnnA (IPBind (GhcPass p)) -> Scope)
-> [GenLocated SrcSpanAnnA (IPBind (GhcPass p))] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA (SrcSpanAnnA -> Scope)
-> (GenLocated SrcSpanAnnA (IPBind (GhcPass p)) -> SrcSpanAnnA)
-> GenLocated SrcSpanAnnA (IPBind (GhcPass p))
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (IPBind (GhcPass p)) -> SrcSpanAnnA
forall l e. GenLocated l e -> l
getLoc) [LIPBind (GhcPass p)]
[GenLocated SrcSpanAnnA (IPBind (GhcPass p))]
bs)
scopeHsLocaLBinds (EmptyLocalBinds XEmptyLocalBinds (GhcPass p) (GhcPass p)
_) = Scope
NoScope
instance HiePass p => ToHie (RScoped (LocatedA (IPBind (GhcPass p)))) where
toHie :: RScoped (LocatedA (IPBind (GhcPass p))) -> HieM [HieAST Type]
toHie (RS Scope
scope (L SrcSpanAnnA
sp bind :: IPBind (GhcPass p)
bind@(IPBind XCIPBind (GhcPass p)
v XRec (GhcPass p) HsIPName
_ LHsExpr (GhcPass p)
expr))) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IPBind (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA IPBind (GhcPass p)
bind SrcSpanAnnA
sp HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> [LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
LocatedA (HsExpr GhcRn)
expr]
HiePassEv p
HieTc -> [ Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnA Id) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a. ContextInfo -> a -> Context a
C (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind EvVarSource
EvImplicitBind Scope
scope (SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
sp))
(GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id))
-> GenLocated SrcSpanAnnA Id -> Context (GenLocated SrcSpanAnnA Id)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Id -> GenLocated SrcSpanAnnA Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
sp XCIPBind (GhcPass p)
Id
v
, GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr GhcTc)
expr
]
instance HiePass p => ToHie (RScoped (HsValBindsLR (GhcPass p) (GhcPass p))) where
toHie :: RScoped (HsValBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
toHie (RS Scope
sc HsValBindsLR (GhcPass p) (GhcPass p)
v) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case HsValBindsLR (GhcPass p) (GhcPass p)
v of
ValBinds XValBinds (GhcPass p) (GhcPass p)
_ LHsBindsLR (GhcPass p) (GhcPass p)
binds [LSig (GhcPass p)]
sigs ->
[ Bag
(BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag
(BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> HieM [HieAST Type])
-> Bag
(BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
-> Bag
(BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
forall a b. (a -> b) -> Bag a -> Bag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
sc) LHsBindsLR (GhcPass p) (GhcPass p)
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
binds
, [SigContext (GenLocated SrcSpanAnnA (Sig (GhcPass p)))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (GenLocated SrcSpanAnnA (Sig (GhcPass p)))]
-> HieM [HieAST Type])
-> [SigContext (GenLocated SrcSpanAnnA (Sig (GhcPass p)))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (Sig (GhcPass p))
-> SigContext (GenLocated SrcSpanAnnA (Sig (GhcPass p))))
-> [GenLocated SrcSpanAnnA (Sig (GhcPass p))]
-> [SigContext (GenLocated SrcSpanAnnA (Sig (GhcPass p)))]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SigInfo
-> GenLocated SrcSpanAnnA (Sig (GhcPass p))
-> SigContext (GenLocated SrcSpanAnnA (Sig (GhcPass p)))
forall a. SigInfo -> a -> SigContext a
SC (SigType -> Maybe Span -> SigInfo
SI SigType
BindSig Maybe Span
forall a. Maybe a
Nothing)) [LSig (GhcPass p)]
[GenLocated SrcSpanAnnA (Sig (GhcPass p))]
sigs
]
XValBindsLR XXValBindsLR (GhcPass p) (GhcPass p)
x -> [ RScoped (NHsValBindsLR (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (NHsValBindsLR (GhcPass p)) -> HieM [HieAST Type])
-> RScoped (NHsValBindsLR (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> NHsValBindsLR (GhcPass p) -> RScoped (NHsValBindsLR (GhcPass p))
forall a. Scope -> a -> RScoped a
RS Scope
sc XXValBindsLR (GhcPass p) (GhcPass p)
NHsValBindsLR (GhcPass p)
x ]
instance HiePass p => ToHie (RScoped (NHsValBindsLR (GhcPass p))) where
toHie :: RScoped (NHsValBindsLR (GhcPass p)) -> HieM [HieAST Type]
toHie (RS Scope
sc (NValBinds [(RecFlag, LHsBinds (GhcPass p))]
binds [LSig GhcRn]
sigs)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ [BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (((RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))])
-> [(RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))]
-> [BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ((GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))]
forall a b. (a -> b) -> [a] -> [b]
map (BindType
-> Scope
-> GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))
-> BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
sc) ([GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
-> [BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))])
-> ((RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))])
-> (RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [BindContext
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
forall a. Bag a -> [a]
bagToList (Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))])
-> ((RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> (RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))
-> Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
forall a b. (a, b) -> b
snd) [(RecFlag, LHsBinds (GhcPass p))]
[(RecFlag,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))]
binds)
, [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type])
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn)))
-> [GenLocated SrcSpanAnnA (Sig GhcRn)]
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))
forall a. SigInfo -> a -> SigContext a
SC (SigType -> Maybe Span -> SigInfo
SI SigType
BindSig Maybe Span
forall a. Maybe a
Nothing)) [LSig GhcRn]
[GenLocated SrcSpanAnnA (Sig GhcRn)]
sigs
]
instance ( ToHie arg , HasLoc arg , Data arg
, HiePass p ) => ToHie (RContext (HsRecFields (GhcPass p) arg)) where
toHie :: RContext (HsRecFields (GhcPass p) arg) -> HieM [HieAST Type]
toHie (RC RecFieldContext
c (HsRecFields [LHsRecField (GhcPass p) arg]
fields Maybe (XRec (GhcPass p) RecFieldsDotDot)
_)) = [RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg))]
-> HieM [HieAST Type])
-> [RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg)
-> RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg)))
-> [GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg)]
-> [RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg)
-> RContext
(GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
c) [LHsRecField (GhcPass p) arg]
[GenLocated
SrcSpanAnnA
(HsFieldBind
(GenLocated (SrcAnn NoEpAnns) (FieldOcc (GhcPass p))) arg)]
fields
instance ( ToHie (RFContext label)
, ToHie arg, HasLoc arg, Data arg
, Data label
) => ToHie (RContext (LocatedA (HsFieldBind label arg))) where
toHie :: RContext (LocatedA (HsFieldBind label arg)) -> HieM [HieAST Type]
toHie (RC RecFieldContext
c (L SrcSpanAnnA
span HsFieldBind label arg
recfld)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsFieldBind label arg -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsFieldBind label arg
recfld (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsFieldBind label arg
recfld of
HsFieldBind XHsFieldBind label
_ label
label arg
expr Bool
_ ->
[ RFContext label -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RFContext label -> HieM [HieAST Type])
-> RFContext label -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RecFieldContext -> Maybe Span -> label -> RFContext label
forall a. RecFieldContext -> Maybe Span -> a -> RFContext a
RFC RecFieldContext
c (SrcSpan -> Maybe Span
getRealSpan (SrcSpan -> Maybe Span) -> SrcSpan -> Maybe Span
forall a b. (a -> b) -> a -> b
$ arg -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc arg
expr) label
label
, arg -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie arg
expr
]
instance HiePass p => ToHie (RFContext (LocatedAn NoEpAnns (FieldOcc (GhcPass p)))) where
toHie :: RFContext (LocatedAn NoEpAnns (FieldOcc (GhcPass p)))
-> HieM [HieAST Type]
toHie (RFC RecFieldContext
c Maybe Span
rhs (L SrcAnn NoEpAnns
nspan FieldOcc (GhcPass p)
f)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case FieldOcc (GhcPass p)
f of
FieldOcc XCFieldOcc (GhcPass p)
fld XRec (GhcPass p) RdrName
_ ->
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> [Context (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Name) -> HieM [HieAST Type])
-> Context (Located Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe Span -> ContextInfo
RecField RecFieldContext
c Maybe Span
rhs) (SrcSpan -> Name -> Located Name
forall l e. l -> e -> GenLocated l e
L (SrcAnn NoEpAnns -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn NoEpAnns
nspan) XCFieldOcc (GhcPass p)
Name
fld)]
HiePassEv p
HieTc -> [Context (Located Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Id) -> HieM [HieAST Type])
-> Context (Located Id) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Id -> Context (Located Id)
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe Span -> ContextInfo
RecField RecFieldContext
c Maybe Span
rhs) (SrcSpan -> Id -> Located Id
forall l e. l -> e -> GenLocated l e
L (SrcAnn NoEpAnns -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn NoEpAnns
nspan) XCFieldOcc (GhcPass p)
Id
fld)]
instance HiePass p => ToHie (RFContext (LocatedAn NoEpAnns (AmbiguousFieldOcc (GhcPass p)))) where
toHie :: RFContext (LocatedAn NoEpAnns (AmbiguousFieldOcc (GhcPass p)))
-> HieM [HieAST Type]
toHie (RFC RecFieldContext
c Maybe Span
rhs (L SrcAnn NoEpAnns
nspan AmbiguousFieldOcc (GhcPass p)
afo)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case AmbiguousFieldOcc (GhcPass p)
afo of
Unambiguous XUnambiguous (GhcPass p)
fld XRec (GhcPass p) RdrName
_ ->
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> [Context (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Name) -> HieM [HieAST Type])
-> Context (Located Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe Span -> ContextInfo
RecField RecFieldContext
c Maybe Span
rhs) (Located Name -> Context (Located Name))
-> Located Name -> Context (Located Name)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Name -> Located Name
forall l e. l -> e -> GenLocated l e
L (SrcAnn NoEpAnns -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn NoEpAnns
nspan) XUnambiguous (GhcPass p)
Name
fld]
HiePassEv p
HieTc -> [Context (Located Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Id) -> HieM [HieAST Type])
-> Context (Located Id) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Id -> Context (Located Id)
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe Span -> ContextInfo
RecField RecFieldContext
c Maybe Span
rhs) (Located Id -> Context (Located Id))
-> Located Id -> Context (Located Id)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Id -> Located Id
forall l e. l -> e -> GenLocated l e
L (SrcAnn NoEpAnns -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn NoEpAnns
nspan) XUnambiguous (GhcPass p)
Id
fld]
Ambiguous XAmbiguous (GhcPass p)
fld XRec (GhcPass p) RdrName
_ ->
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> []
HiePassEv p
HieTc -> [ Context (Located Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Id) -> HieM [HieAST Type])
-> Context (Located Id) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Id -> Context (Located Id)
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe Span -> ContextInfo
RecField RecFieldContext
c Maybe Span
rhs) (SrcSpan -> Id -> Located Id
forall l e. l -> e -> GenLocated l e
L (SrcAnn NoEpAnns -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn NoEpAnns
nspan) XAmbiguous (GhcPass p)
Id
fld) ]
instance HiePass p => ToHie (RScoped (ApplicativeArg (GhcPass p))) where
toHie :: RScoped (ApplicativeArg (GhcPass p)) -> HieM [HieAST Type]
toHie (RS Scope
sc (ApplicativeArgOne XApplicativeArgOne (GhcPass p)
_ LPat (GhcPass p)
pat LHsExpr (GhcPass p)
expr Bool
_)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat (GhcPass p))
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
forall a. Maybe a
Nothing Scope
sc Scope
NoScope LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr
]
toHie (RS Scope
sc (ApplicativeArgMany XApplicativeArgMany (GhcPass p)
_ [ExprLStmt (GhcPass p)]
stmts HsExpr (GhcPass p)
_ LPat (GhcPass p)
pat HsDoFlavour
_)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [RScoped
(LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
NoScope [ExprLStmt (GhcPass p)]
[LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts
, PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type])
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat (GhcPass p))
-> PScoped (GenLocated SrcSpanAnnA (Pat (GhcPass p)))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
forall a. Maybe a
Nothing Scope
sc Scope
NoScope LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat
]
instance (ToHie tyarg, ToHie arg, ToHie rec) => ToHie (HsConDetails tyarg arg rec) where
toHie :: HsConDetails tyarg arg rec -> HieM [HieAST Type]
toHie (PrefixCon [tyarg]
tyargs [arg]
args) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM [ [tyarg] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [tyarg]
tyargs, [arg] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [arg]
args ]
toHie (RecCon rec
rec) = rec -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie rec
rec
toHie (InfixCon arg
a arg
b) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM [ arg -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie arg
a, arg -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie arg
b]
instance ToHie (HsConDeclGADTDetails GhcRn) where
toHie :: HsConDeclGADTDetails GhcRn -> HieM [HieAST Type]
toHie (PrefixConGADT [HsScaled GhcRn (LHsType GhcRn)]
args) = [HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [HsScaled GhcRn (LHsType GhcRn)]
[HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))]
args
toHie (RecConGADT XRec GhcRn [LConDeclField GhcRn]
rec LHsUniToken "->" "\8594" GhcRn
_) = GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie XRec GhcRn [LConDeclField GhcRn]
GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
rec
instance HiePass p => ToHie (LocatedAn NoEpAnns (HsCmdTop (GhcPass p))) where
toHie :: LocatedAn NoEpAnns (HsCmdTop (GhcPass p)) -> HieM [HieAST Type]
toHie (L SrcAnn NoEpAnns
span HsCmdTop (GhcPass p)
top) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsCmdTop (GhcPass p) -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsCmdTop (GhcPass p)
top SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsCmdTop (GhcPass p)
top of
HsCmdTop XCmdTop (GhcPass p)
_ LHsCmd (GhcPass p)
cmd ->
[ GenLocated SrcSpanAnnA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
cmd
]
instance HiePass p => ToHie (LocatedA (HsCmd (GhcPass p))) where
toHie :: LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span HsCmd (GhcPass p)
cmd) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsCmd (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsCmd (GhcPass p)
cmd SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsCmd (GhcPass p)
cmd of
HsCmdArrApp XCmdArrApp (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsExpr (GhcPass p)
b HsArrAppType
_ Bool
_ ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
a
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
b
]
HsCmdArrForm XCmdArrForm (GhcPass p)
_ LHsExpr (GhcPass p)
a LexicalFixity
_ Maybe Fixity
_ [LHsCmdTop (GhcPass p)]
cmdtops ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
a
, [GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsCmdTop (GhcPass p)]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))]
cmdtops
]
HsCmdApp XCmdApp (GhcPass p)
_ LHsCmd (GhcPass p)
a LHsExpr (GhcPass p)
b ->
[ LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
LocatedA (HsCmd (GhcPass p))
a
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
b
]
HsCmdLam XCmdLam (GhcPass p)
_ MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
mg ->
[ MatchGroup (GhcPass p) (LocatedA (HsCmd (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
MatchGroup (GhcPass p) (LocatedA (HsCmd (GhcPass p)))
mg
]
HsCmdPar XCmdPar (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ LHsCmd (GhcPass p)
a LHsToken ")" (GhcPass p)
_ ->
[ LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
LocatedA (HsCmd (GhcPass p))
a
]
HsCmdCase XCmdCase (GhcPass p)
_ LHsExpr (GhcPass p)
expr MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
alts ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr
, MatchGroup (GhcPass p) (LocatedA (HsCmd (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
MatchGroup (GhcPass p) (LocatedA (HsCmd (GhcPass p)))
alts
]
HsCmdLamCase XCmdLamCase (GhcPass p)
_ LamCaseVariant
_ MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
alts ->
[ MatchGroup (GhcPass p) (LocatedA (HsCmd (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
MatchGroup (GhcPass p) (LocatedA (HsCmd (GhcPass p)))
alts
]
HsCmdIf XCmdIf (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ LHsExpr (GhcPass p)
a LHsCmd (GhcPass p)
b LHsCmd (GhcPass p)
c ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
a
, LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
LocatedA (HsCmd (GhcPass p))
b
, LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
LocatedA (HsCmd (GhcPass p))
c
]
HsCmdLet XCmdLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ LHsCmd (GhcPass p)
cmd' ->
[ RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type])
-> RScoped (HsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> HsLocalBinds (GhcPass p) -> RScoped (HsLocalBinds (GhcPass p))
forall a. Scope -> a -> RScoped a
RS (LocatedA (HsCmd (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsCmd (GhcPass p)
LocatedA (HsCmd (GhcPass p))
cmd') HsLocalBinds (GhcPass p)
binds
, LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
LocatedA (HsCmd (GhcPass p))
cmd'
]
HsCmdDo XCmdDo (GhcPass p)
_ (L SrcSpanAnnL
ispan [LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p))))]
stmts) ->
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnnL -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
ispan)
, [RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p))))]
-> [RScoped
(LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
NoScope [LocatedA
(StmtLR (GhcPass p) (GhcPass p) (LocatedA (HsCmd (GhcPass p))))]
stmts
]
XCmd XXCmd (GhcPass p)
_ -> []
instance ToHie (TyClGroup GhcRn) where
toHie :: TyClGroup GhcRn -> HieM [HieAST Type]
toHie TyClGroup{ group_tyclds :: forall pass. TyClGroup pass -> [LTyClDecl pass]
group_tyclds = [LTyClDecl GhcRn]
classes
, group_roles :: forall pass. TyClGroup pass -> [LRoleAnnotDecl pass]
group_roles = [LRoleAnnotDecl GhcRn]
roles
, group_kisigs :: forall pass. TyClGroup pass -> [LStandaloneKindSig pass]
group_kisigs = [LStandaloneKindSig GhcRn]
sigs
, group_instds :: forall pass. TyClGroup pass -> [LInstDecl pass]
group_instds = [LInstDecl GhcRn]
instances } =
[HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ [GenLocated SrcSpanAnnA (TyClDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LTyClDecl GhcRn]
[GenLocated SrcSpanAnnA (TyClDecl GhcRn)]
classes
, [GenLocated SrcSpanAnnA (StandaloneKindSig GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LStandaloneKindSig GhcRn]
[GenLocated SrcSpanAnnA (StandaloneKindSig GhcRn)]
sigs
, [GenLocated SrcSpanAnnA (RoleAnnotDecl GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LRoleAnnotDecl GhcRn]
[GenLocated SrcSpanAnnA (RoleAnnotDecl GhcRn)]
roles
, [GenLocated SrcSpanAnnA (InstDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LInstDecl GhcRn]
[GenLocated SrcSpanAnnA (InstDecl GhcRn)]
instances
]
instance ToHie (LocatedA (TyClDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (TyClDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span TyClDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyClDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA TyClDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case TyClDecl GhcRn
decl of
FamDecl {tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl GhcRn
fdecl} ->
[ GenLocated SrcSpanAnnA (FamilyDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ((SrcSpanAnnA
-> FamilyDecl GhcRn -> GenLocated SrcSpanAnnA (FamilyDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span FamilyDecl GhcRn
fdecl) :: LFamilyDecl GhcRn)
]
SynDecl {tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP GhcRn
name, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
vars, tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
tcdRhs = LHsType GhcRn
typ} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
SynDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) LIdP GhcRn
LocatedN Name
name
, TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsQTyVars GhcRn -> TScoped (LHsQTyVars GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnA (HsType GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
typ]) LHsQTyVars GhcRn
vars
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
typ
]
DataDecl {tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP GhcRn
name, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
vars, tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn GhcRn
defn} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
DataDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) LIdP GhcRn
LocatedN Name
name
, TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsQTyVars GhcRn -> TScoped (LHsQTyVars GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
quant_scope, Scope
rhs_scope]) LHsQTyVars GhcRn
vars
, HsDataDefn GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsDataDefn GhcRn
defn
]
where
quant_scope :: Scope
quant_scope = GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope)
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
forall a. a -> Maybe a -> a
fromMaybe ([GenLocated SrcSpanAnnA (HsType GhcRn)]
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
forall a an. a -> LocatedAn an a
noLocA []) (Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> Maybe (LHsContext GhcRn)
forall pass. HsDataDefn pass -> Maybe (LHsContext pass)
dd_ctxt HsDataDefn GhcRn
defn
rhs_scope :: Scope
rhs_scope = Scope
sig_sc Scope -> Scope -> Scope
`combineScopes` Scope
con_sc Scope -> Scope -> Scope
`combineScopes` Scope
deriv_sc
sig_sc :: Scope
sig_sc = Scope
-> (GenLocated SrcSpanAnnA (HsType GhcRn) -> Scope)
-> Maybe (GenLocated SrcSpanAnnA (HsType GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope GenLocated SrcSpanAnnA (HsType GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA (Maybe (GenLocated SrcSpanAnnA (HsType GhcRn)) -> Scope)
-> Maybe (GenLocated SrcSpanAnnA (HsType GhcRn)) -> Scope
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> Maybe (LHsType GhcRn)
forall pass. HsDataDefn pass -> Maybe (LHsKind pass)
dd_kindSig HsDataDefn GhcRn
defn
con_sc :: Scope
con_sc = (Scope -> Scope -> Scope) -> Scope -> DataDefnCons Scope -> Scope
forall a b. (a -> b -> b) -> b -> DataDefnCons a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope (DataDefnCons Scope -> Scope) -> DataDefnCons Scope -> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnA (ConDecl GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA (GenLocated SrcSpanAnnA (ConDecl GhcRn) -> Scope)
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcRn))
-> DataDefnCons Scope
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HsDataDefn GhcRn -> DataDefnCons (LConDecl GhcRn)
forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons HsDataDefn GhcRn
defn
deriv_sc :: Scope
deriv_sc = (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA (GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn) -> Scope)
-> [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
-> [Scope]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HsDataDefn GhcRn -> HsDeriving GhcRn
forall pass. HsDataDefn pass -> HsDeriving pass
dd_derivs HsDataDefn GhcRn
defn
ClassDecl { tcdCtxt :: forall pass. TyClDecl pass -> Maybe (LHsContext pass)
tcdCtxt = Maybe (LHsContext GhcRn)
context
, tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP GhcRn
name
, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
vars
, tcdFDs :: forall pass. TyClDecl pass -> [LHsFunDep pass]
tcdFDs = [LHsFunDep GhcRn]
deps
, tcdSigs :: forall pass. TyClDecl pass -> [LSig pass]
tcdSigs = [LSig GhcRn]
sigs
, tcdMeths :: forall pass. TyClDecl pass -> LHsBinds pass
tcdMeths = LHsBinds GhcRn
meths
, tcdATs :: forall pass. TyClDecl pass -> [LFamilyDecl pass]
tcdATs = [XRec GhcRn (FamilyDecl GhcRn)]
typs
, tcdATDefs :: forall pass. TyClDecl pass -> [LTyFamDefltDecl pass]
tcdATDefs = [LTyFamDefltDecl GhcRn]
deftyps
} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
ClassDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) LIdP GhcRn
LocatedN Name
name
, Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
context
, TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsQTyVars GhcRn -> TScoped (LHsQTyVars GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
context_scope, Scope
rhs_scope]) LHsQTyVars GhcRn
vars
, [GenLocated SrcSpanAnnA (FunDep GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsFunDep GhcRn]
[GenLocated SrcSpanAnnA (FunDep GhcRn)]
deps
, [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type])
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn)))
-> [GenLocated SrcSpanAnnA (Sig GhcRn)]
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))
forall a. SigInfo -> a -> SigContext a
SC (SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn)))
-> SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))
forall a b. (a -> b) -> a -> b
$ SigType -> Maybe Span -> SigInfo
SI SigType
ClassSig (Maybe Span -> SigInfo) -> Maybe Span -> SigInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) [LSig GhcRn]
[GenLocated SrcSpanAnnA (Sig GhcRn)]
sigs
, Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> HieM [HieAST Type])
-> Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsBind GhcRn)
-> BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
-> Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
forall a b. (a -> b) -> Bag a -> Bag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> GenLocated SrcSpanAnnA (HsBind GhcRn)
-> BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
InstanceBind Scope
ModuleScope) LHsBinds GhcRn
Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
meths
, [GenLocated SrcSpanAnnA (FamilyDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [XRec GhcRn (FamilyDecl GhcRn)]
[GenLocated SrcSpanAnnA (FamilyDecl GhcRn)]
typs
, (GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type])
-> (GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn) -> SrcSpan)
-> GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) [LTyFamDefltDecl GhcRn]
[GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
deftyps
, [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LTyFamDefltDecl GhcRn]
[GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
deftyps
]
where
context_scope :: Scope
context_scope = GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope)
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
forall a. a -> Maybe a -> a
fromMaybe ([GenLocated SrcSpanAnnA (HsType GhcRn)]
-> GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
forall a an. a -> LocatedAn an a
noLocA []) Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
context
rhs_scope :: Scope
rhs_scope = (Scope -> Scope -> Scope) -> [Scope] -> Scope
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' Scope -> Scope -> Scope
combineScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ (SrcSpan -> Scope) -> [SrcSpan] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map SrcSpan -> Scope
mkScope
[ [GenLocated SrcSpanAnnA (FunDep GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LHsFunDep GhcRn]
[GenLocated SrcSpanAnnA (FunDep GhcRn)]
deps, [GenLocated SrcSpanAnnA (Sig GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LSig GhcRn]
[GenLocated SrcSpanAnnA (Sig GhcRn)]
sigs, [GenLocated SrcSpanAnnA (HsBind GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc (Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
-> [GenLocated SrcSpanAnnA (HsBind GhcRn)]
forall a. Bag a -> [a]
bagToList LHsBinds GhcRn
Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
meths), [GenLocated SrcSpanAnnA (FamilyDecl GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [XRec GhcRn (FamilyDecl GhcRn)]
[GenLocated SrcSpanAnnA (FamilyDecl GhcRn)]
typs, [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LTyFamDefltDecl GhcRn]
[GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
deftyps]
instance ToHie (LocatedA (FamilyDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (FamilyDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span FamilyDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ FamilyDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA FamilyDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case FamilyDecl GhcRn
decl of
FamilyDecl XCFamilyDecl GhcRn
_ FamilyInfo GhcRn
info TopLevelFlag
_ LIdP GhcRn
name LHsQTyVars GhcRn
vars LexicalFixity
_ LFamilyResultSig GhcRn
sig Maybe (LInjectivityAnn GhcRn)
inj ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
FamDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) LIdP GhcRn
LocatedN Name
name
, TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsQTyVars GhcRn -> TScoped (LHsQTyVars GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
rhsSpan]) LHsQTyVars GhcRn
vars
, FamilyInfo GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie FamilyInfo GhcRn
info
, RScoped (GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn))
-> HieM [HieAST Type])
-> RScoped (GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn))
forall a. Scope -> a -> RScoped a
RS Scope
injSpan LFamilyResultSig GhcRn
GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn)
sig
, Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LInjectivityAnn GhcRn)
Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn))
inj
]
where
rhsSpan :: Scope
rhsSpan = Scope
sigSpan Scope -> Scope -> Scope
`combineScopes` Scope
injSpan
sigSpan :: Scope
sigSpan = SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LFamilyResultSig GhcRn
GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn)
sig
injSpan :: Scope
injSpan = Scope
-> (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn) -> Scope)
-> Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope (SrcSpan -> Scope
mkScope (SrcSpan -> Scope)
-> (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn) -> SrcSpan)
-> GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn)
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) Maybe (LInjectivityAnn GhcRn)
Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn))
inj
instance ToHie (FamilyInfo GhcRn) where
toHie :: FamilyInfo GhcRn -> HieM [HieAST Type]
toHie (ClosedTypeFamily (Just [LTyFamInstEqn GhcRn]
eqns)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ (GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type])
-> [GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
-> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type])
-> (GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> SrcSpan)
-> GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) [LTyFamInstEqn GhcRn]
[GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
eqns
, [TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
-> HieM [HieAST Type])
-> [TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))))
-> [GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
-> [TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
forall {ann} {a}. GenLocated (SrcSpanAnn' ann) a -> TScoped a
go [LTyFamInstEqn GhcRn]
[GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
eqns
]
where
go :: GenLocated (SrcSpanAnn' ann) a -> TScoped a
go (L SrcSpanAnn' ann
l a
ib) = TyVarScope -> a -> TScoped a
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpanAnn' ann -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnn' ann
l]) a
ib
toHie FamilyInfo GhcRn
_ = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (RScoped (LocatedAn NoEpAnns (FamilyResultSig GhcRn))) where
toHie :: RScoped (GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcRn))
-> HieM [HieAST Type]
toHie (RS Scope
sc (L SrcAnn NoEpAnns
span FamilyResultSig GhcRn
sig)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ FamilyResultSig GhcRn -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA FamilyResultSig GhcRn
sig SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case FamilyResultSig GhcRn
sig of
NoSig XNoSig GhcRn
_ ->
[]
KindSig XCKindSig GhcRn
_ LHsType GhcRn
k ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
k
]
TyVarSig XTyVarSig GhcRn
_ LHsTyVarBndr () GhcRn
bndr ->
[ TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))
-> HieM [HieAST Type])
-> TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)
-> TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS ([Scope] -> TyVarScope
ResolvedScopes [Scope
sc]) Scope
NoScope LHsTyVarBndr () GhcRn
GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)
bndr
]
instance ToHie (LocatedA (FunDep GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (FunDep GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span fd :: FunDep GhcRn
fd@(FunDep XCFunDep GhcRn
_ [LIdP GhcRn]
lhs [LIdP GhcRn]
rhs)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ FunDep GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode FunDep GhcRn
fd (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span)
, [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [LIdP GhcRn]
[LocatedN Name]
lhs
, [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [LIdP GhcRn]
[LocatedN Name]
rhs
]
instance ToHie (TScoped (FamEqn GhcRn (HsDataDefn GhcRn))) where
toHie :: TScoped (FamEqn GhcRn (HsDataDefn GhcRn)) -> HieM [HieAST Type]
toHie (TS TyVarScope
_ FamEqn GhcRn (HsDataDefn GhcRn)
f) = FamEqn GhcRn (HsDataDefn GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie FamEqn GhcRn (HsDataDefn GhcRn)
f
instance ToHie (TScoped (FamEqn GhcRn (LocatedA (HsType GhcRn)))) where
toHie :: TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
toHie (TS TyVarScope
_ FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
f) = FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
f
instance (ToHie rhs, HasLoc rhs)
=> ToHie (FamEqn GhcRn rhs) where
toHie :: FamEqn GhcRn rhs -> HieM [HieAST Type]
toHie fe :: FamEqn GhcRn rhs
fe@(FamEqn XCFamEqn GhcRn rhs
_ LIdP GhcRn
var HsOuterFamEqnTyVarBndrs GhcRn
outer_bndrs HsTyPats GhcRn
pats LexicalFixity
_ rhs
rhs) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
InstDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe Span
getRealSpan (SrcSpan -> Maybe Span) -> SrcSpan -> Maybe Span
forall a b. (a -> b) -> a -> b
$ FamEqn GhcRn rhs -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc FamEqn GhcRn rhs
fe) LIdP GhcRn
LocatedN Name
var
, TVScoped (HsOuterFamEqnTyVarBndrs GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TVScoped (HsOuterFamEqnTyVarBndrs GhcRn) -> HieM [HieAST Type])
-> TVScoped (HsOuterFamEqnTyVarBndrs GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> HsOuterFamEqnTyVarBndrs GhcRn
-> TVScoped (HsOuterFamEqnTyVarBndrs GhcRn)
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS ([Scope] -> TyVarScope
ResolvedScopes []) Scope
scope HsOuterFamEqnTyVarBndrs GhcRn
outer_bndrs
, [HsArg
GhcRn
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsTyPats GhcRn
[HsArg
GhcRn
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
pats
, rhs -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie rhs
rhs
]
where scope :: Scope
scope = Scope -> Scope -> Scope
combineScopes Scope
patsScope Scope
rhsScope
patsScope :: Scope
patsScope = SrcSpan -> Scope
mkScope ([HsArg
GhcRn
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc HsTyPats GhcRn
[HsArg
GhcRn
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
pats)
rhsScope :: Scope
rhsScope = SrcSpan -> Scope
mkScope (rhs -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc rhs
rhs)
instance ToHie (LocatedAn NoEpAnns (InjectivityAnn GhcRn)) where
toHie :: GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcRn)
-> HieM [HieAST Type]
toHie (L SrcAnn NoEpAnns
span InjectivityAnn GhcRn
ann) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ InjectivityAnn GhcRn -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA InjectivityAnn GhcRn
ann SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case InjectivityAnn GhcRn
ann of
InjectivityAnn XCInjectivityAnn GhcRn
_ LIdP GhcRn
lhs [LIdP GhcRn]
rhs ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
lhs
, [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [LIdP GhcRn]
[LocatedN Name]
rhs
]
instance ToHie (HsDataDefn GhcRn) where
toHie :: HsDataDefn GhcRn -> HieM [HieAST Type]
toHie (HsDataDefn XCHsDataDefn GhcRn
_ Maybe (LHsContext GhcRn)
ctx Maybe (XRec GhcRn CType)
_ Maybe (LHsType GhcRn)
mkind DataDefnCons (LConDecl GhcRn)
cons HsDeriving GhcRn
derivs) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
ctx
, Maybe (GenLocated SrcSpanAnnA (HsType GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsType GhcRn)
Maybe (GenLocated SrcSpanAnnA (HsType GhcRn))
mkind
, DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie DataDefnCons (LConDecl GhcRn)
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcRn))
cons
, [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsDeriving GhcRn
[GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
derivs
]
instance ToHie (Located [LocatedAn NoEpAnns (HsDerivingClause GhcRn)]) where
toHie :: Located [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
-> HieM [HieAST Type]
toHie (L SrcSpan
span [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
clauses) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
span
, [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)]
clauses
]
instance ToHie (LocatedAn NoEpAnns (HsDerivingClause GhcRn)) where
toHie :: GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcRn)
-> HieM [HieAST Type]
toHie (L SrcAnn NoEpAnns
span HsDerivingClause GhcRn
cl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsDerivingClause GhcRn -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsDerivingClause GhcRn
cl SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsDerivingClause GhcRn
cl of
HsDerivingClause XCHsDerivingClause GhcRn
_ Maybe (LDerivStrategy GhcRn)
strat LDerivClauseTys GhcRn
dct ->
[ Maybe
(RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Scope
-> GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
forall a. Scope -> a -> RScoped a
RS (GenLocated SrcSpanAnnC (DerivClauseTys GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LDerivClauseTys GhcRn
GenLocated SrcSpanAnnC (DerivClauseTys GhcRn)
dct) (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
-> Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
-> Maybe
(RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (LDerivStrategy GhcRn)
Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
strat)
, GenLocated SrcSpanAnnC (DerivClauseTys GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LDerivClauseTys GhcRn
GenLocated SrcSpanAnnC (DerivClauseTys GhcRn)
dct
]
instance ToHie (LocatedC (DerivClauseTys GhcRn)) where
toHie :: GenLocated SrcSpanAnnC (DerivClauseTys GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnC
span DerivClauseTys GhcRn
dct) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ DerivClauseTys GhcRn -> SrcSpanAnnC -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA DerivClauseTys GhcRn
dct SrcSpanAnnC
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DerivClauseTys GhcRn
dct of
DctSingle XDctSingle GhcRn
_ LHsSigType GhcRn
ty -> [ TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType GhcRn
GenLocated SrcSpanAnnA (HsSigType GhcRn)
ty ]
DctMulti XDctMulti GhcRn
_ [LHsSigType GhcRn]
tys -> [ [TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
-> HieM [HieAST Type])
-> [TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> [GenLocated SrcSpanAnnA (HsSigType GhcRn)]
-> [TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [])) [LHsSigType GhcRn]
[GenLocated SrcSpanAnnA (HsSigType GhcRn)]
tys ]
instance ToHie (RScoped (LocatedAn NoEpAnns (DerivStrategy GhcRn))) where
toHie :: RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
-> HieM [HieAST Type]
toHie (RS Scope
sc (L SrcAnn NoEpAnns
span DerivStrategy GhcRn
strat)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ DerivStrategy GhcRn -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA DerivStrategy GhcRn
strat SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DerivStrategy GhcRn
strat of
StockStrategy XStockStrategy GhcRn
_ -> []
AnyclassStrategy XAnyClassStrategy GhcRn
_ -> []
NewtypeStrategy XNewtypeStrategy GhcRn
_ -> []
ViaStrategy XViaStrategy GhcRn
s -> [ TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
sc]) XViaStrategy GhcRn
GenLocated SrcSpanAnnA (HsSigType GhcRn)
s) ]
instance ToHie (LocatedP OverlapMode) where
toHie :: LocatedP OverlapMode -> HieM [HieAST Type]
toHie (L SrcSpanAnnP
span OverlapMode
_) = SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnnP -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnP
span)
instance ToHie a => ToHie (HsScaled GhcRn a) where
toHie :: HsScaled GhcRn a -> HieM [HieAST Type]
toHie (HsScaled HsArrow GhcRn
w a
t) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM [GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsArrow GhcRn -> LHsType GhcRn
arrowToHsType HsArrow GhcRn
w), a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie a
t]
instance ToHie (LocatedA (ConDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (ConDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span ConDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ConDecl GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode ConDecl GhcRn
decl (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case ConDecl GhcRn
decl of
ConDeclGADT { con_names :: forall pass. ConDecl pass -> NonEmpty (LIdP pass)
con_names = NonEmpty (LIdP GhcRn)
names, con_bndrs :: forall pass. ConDecl pass -> XRec pass (HsOuterSigTyVarBndrs pass)
con_bndrs = L SrcSpanAnnA
outer_bndrs_loc HsOuterSigTyVarBndrs GhcRn
outer_bndrs
, con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcRn)
ctx, con_g_args :: forall pass. ConDecl pass -> HsConDeclGADTDetails pass
con_g_args = HsConDeclGADTDetails GhcRn
args, con_res_ty :: forall pass. ConDecl pass -> LHsType pass
con_res_ty = LHsType GhcRn
typ
, con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_doc = Maybe (LHsDoc GhcRn)
doc} ->
[ NonEmpty (Context (LocatedN Name)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (NonEmpty (Context (LocatedN Name)) -> HieM [HieAST Type])
-> NonEmpty (Context (LocatedN Name)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
ConDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) (LocatedN Name -> Context (LocatedN Name))
-> NonEmpty (LocatedN Name) -> NonEmpty (Context (LocatedN Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (LIdP GhcRn)
NonEmpty (LocatedN Name)
names
, case HsOuterSigTyVarBndrs GhcRn
outer_bndrs of
HsOuterImplicit{hso_ximplicit :: forall flag pass.
HsOuterTyVarBndrs flag pass -> XHsOuterImplicit pass
hso_ximplicit = XHsOuterImplicit GhcRn
imp_vars} ->
[Context Name] -> HieM [HieAST Type]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly ([Context Name] -> HieM [HieAST Type])
-> [Context Name] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Name -> Context Name) -> [Name] -> [Context Name]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Name -> Context Name
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Name -> Context Name)
-> ContextInfo -> Name -> Context Name
forall a b. (a -> b) -> a -> b
$ Scope -> TyVarScope -> ContextInfo
TyVarBind (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
outer_bndrs_loc) TyVarScope
resScope)
[Name]
XHsOuterImplicit GhcRn
imp_vars
HsOuterExplicit{hso_bndrs :: forall flag pass.
HsOuterTyVarBndrs flag pass -> [LHsTyVarBndr flag (NoGhcTc pass)]
hso_bndrs = [LHsTyVarBndr Specificity (NoGhcTc GhcRn)]
exp_bndrs} ->
[TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type])
-> [TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> [LHsTyVarBndr Specificity GhcRn]
-> [TVScoped (LHsTyVarBndr Specificity GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes TyVarScope
resScope Scope
NoScope [LHsTyVarBndr Specificity (NoGhcTc GhcRn)]
[LHsTyVarBndr Specificity GhcRn]
exp_bndrs
, Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
ctx
, HsConDeclGADTDetails GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsConDeclGADTDetails GhcRn
args
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
typ
, Maybe (LHsDoc GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsDoc GhcRn)
doc
]
where
rhsScope :: Scope
rhsScope = Scope -> Scope -> Scope
combineScopes Scope
argsScope Scope
tyScope
ctxScope :: Scope
ctxScope = Scope
-> (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope)
-> Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
ctx
argsScope :: Scope
argsScope = case HsConDeclGADTDetails GhcRn
args of
PrefixConGADT [HsScaled GhcRn (LHsType GhcRn)]
xs -> [HsScaled GhcRn (LHsType GhcRn)] -> Scope
scaled_args_scope [HsScaled GhcRn (LHsType GhcRn)]
xs
RecConGADT XRec GhcRn [LConDeclField GhcRn]
x LHsUniToken "->" "\8594" GhcRn
_ -> GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA XRec GhcRn [LConDeclField GhcRn]
GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
x
tyScope :: Scope
tyScope = GenLocated SrcSpanAnnA (HsType GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
typ
resScope :: TyVarScope
resScope = [Scope] -> TyVarScope
ResolvedScopes [Scope
ctxScope, Scope
rhsScope]
ConDeclH98 { con_name :: forall pass. ConDecl pass -> LIdP pass
con_name = LIdP GhcRn
name, con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr Specificity pass]
con_ex_tvs = [LHsTyVarBndr Specificity GhcRn]
qvars
, con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcRn)
ctx, con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
con_args = HsConDeclH98Details GhcRn
dets
, con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_doc = Maybe (LHsDoc GhcRn)
doc} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe Span -> ContextInfo
Decl DeclType
ConDec (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe Span
getRealSpan (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span)) LIdP GhcRn
LocatedN Name
name
, [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type])
-> [TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> [LHsTyVarBndr Specificity GhcRn]
-> [TVScoped (LHsTyVarBndr Specificity GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
rhsScope [LHsTyVarBndr Specificity GhcRn]
qvars
, Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
ctx
, HsConDetails
Void
(HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
(GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsConDeclH98Details GhcRn
HsConDetails
Void
(HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
(GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
dets
, Maybe (LHsDoc GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsDoc GhcRn)
doc
]
where
rhsScope :: Scope
rhsScope = Scope -> Scope -> Scope
combineScopes Scope
ctxScope Scope
argsScope
ctxScope :: Scope
ctxScope = Scope
-> (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope)
-> Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA Maybe (LHsContext GhcRn)
Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
ctx
argsScope :: Scope
argsScope = case HsConDeclH98Details GhcRn
dets of
PrefixCon [Void]
_ [HsScaled GhcRn (LHsType GhcRn)]
xs -> [HsScaled GhcRn (LHsType GhcRn)] -> Scope
scaled_args_scope [HsScaled GhcRn (LHsType GhcRn)]
xs
InfixCon HsScaled GhcRn (LHsType GhcRn)
a HsScaled GhcRn (LHsType GhcRn)
b -> [HsScaled GhcRn (LHsType GhcRn)] -> Scope
scaled_args_scope [HsScaled GhcRn (LHsType GhcRn)
a, HsScaled GhcRn (LHsType GhcRn)
b]
RecCon XRec GhcRn [LConDeclField GhcRn]
x -> GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA XRec GhcRn [LConDeclField GhcRn]
GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
x
where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope
scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope
scaled_args_scope = (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Scope -> Scope -> Scope
combineScopes Scope
NoScope ([Scope] -> Scope)
-> ([HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))]
-> [Scope])
-> [HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))]
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)) -> Scope)
-> [HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))]
-> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (GenLocated SrcSpanAnnA (HsType GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA (GenLocated SrcSpanAnnA (HsType GhcRn) -> Scope)
-> (HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> GenLocated SrcSpanAnnA (HsType GhcRn))
-> HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> GenLocated SrcSpanAnnA (HsType GhcRn)
forall pass a. HsScaled pass a -> a
hsScaledThing)
instance ToHie (LocatedL [LocatedA (ConDeclField GhcRn)]) where
toHie :: GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> HieM [HieAST Type]
toHie (L SrcSpanAnnL
span [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
decls) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnnL -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
span)
, [GenLocated SrcSpanAnnA (ConDeclField GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
decls
]
instance ToHie (TScoped (HsWildCardBndrs GhcRn (LocatedA (HsSigType GhcRn)))) where
toHie :: TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
toHie (TS TyVarScope
sc (HsWC XHsWC GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
names GenLocated SrcSpanAnnA (HsSigType GhcRn)
a)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ [Context Name] -> HieM [HieAST Type]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly ([Context Name] -> HieM [HieAST Type])
-> [Context Name] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Name -> Context Name) -> [Name] -> [Context Name]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Name -> Context Name
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Name -> Context Name)
-> ContextInfo -> Name -> Context Name
forall a b. (a -> b) -> a -> b
$ Scope -> TyVarScope -> ContextInfo
TyVarBind (SrcSpan -> Scope
mkScope SrcSpan
span) TyVarScope
sc) [Name]
XHsWC GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
names
, TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS TyVarScope
sc GenLocated SrcSpanAnnA (HsSigType GhcRn)
a
]
where span :: SrcSpan
span = GenLocated SrcSpanAnnA (HsSigType GhcRn) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc GenLocated SrcSpanAnnA (HsSigType GhcRn)
a
instance ToHie (TScoped (HsWildCardBndrs GhcRn (LocatedA (HsType GhcRn)))) where
toHie :: TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
toHie (TS TyVarScope
sc (HsWC XHsWC GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
names GenLocated SrcSpanAnnA (HsType GhcRn)
a)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ [Context Name] -> HieM [HieAST Type]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly ([Context Name] -> HieM [HieAST Type])
-> [Context Name] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Name -> Context Name) -> [Name] -> [Context Name]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Name -> Context Name
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Name -> Context Name)
-> ContextInfo -> Name -> Context Name
forall a b. (a -> b) -> a -> b
$ Scope -> TyVarScope -> ContextInfo
TyVarBind (SrcSpan -> Scope
mkScope SrcSpan
span) TyVarScope
sc) [Name]
XHsWC GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
names
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
a
]
where span :: SrcSpan
span = GenLocated SrcSpanAnnA (HsType GhcRn) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc GenLocated SrcSpanAnnA (HsType GhcRn)
a
instance ToHie (LocatedA (StandaloneKindSig GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (StandaloneKindSig GhcRn)
-> HieM [HieAST Type]
toHie (L SrcSpanAnnA
sp StandaloneKindSig GhcRn
sig) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM [StandaloneKindSig GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA StandaloneKindSig GhcRn
sig SrcSpanAnnA
sp, StandaloneKindSig GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie StandaloneKindSig GhcRn
sig]
instance ToHie (StandaloneKindSig GhcRn) where
toHie :: StandaloneKindSig GhcRn -> HieM [HieAST Type]
toHie StandaloneKindSig GhcRn
sig = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ case StandaloneKindSig GhcRn
sig of
StandaloneKindSig XStandaloneKindSig GhcRn
_ LIdP GhcRn
name LHsSigType GhcRn
typ ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl LIdP GhcRn
LocatedN Name
name
, TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType GhcRn
GenLocated SrcSpanAnnA (HsSigType GhcRn)
typ
]
instance HiePass p => ToHie (SigContext (LocatedA (Sig (GhcPass p)))) where
toHie :: SigContext (LocatedA (Sig (GhcPass p))) -> HieM [HieAST Type]
toHie (SC (SI SigType
styp Maybe Span
msp) (L SrcSpanAnnA
sp Sig (GhcPass p)
sig)) =
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc -> [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
HiePassEv p
HieRn -> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Sig (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA Sig (GhcPass p)
sig SrcSpanAnnA
sp HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case Sig (GhcPass p)
sig of
TypeSig XTypeSig (GhcPass p)
_ [LIdP (GhcPass p)]
names LHsSigWcType (GhcPass p)
typ ->
[ [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl) [LIdP (GhcPass p)]
[LocatedN Name]
names
, TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type])
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
forall a. TyVarScope -> a -> TScoped a
TS ([Name] -> Maybe Span -> TyVarScope
UnresolvedScope ((LocatedN Name -> Name) -> [LocatedN Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map LocatedN Name -> Name
forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
[LocatedN Name]
names) Maybe Span
forall a. Maybe a
Nothing) LHsSigWcType (GhcPass p)
HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
typ
]
PatSynSig XPatSynSig (GhcPass p)
_ [LIdP (GhcPass p)]
names LHsSigType (GhcPass p)
typ ->
[ [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl) [LIdP (GhcPass p)]
[LocatedN Name]
names
, TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Name] -> Maybe Span -> TyVarScope
UnresolvedScope ((LocatedN Name -> Name) -> [LocatedN Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map LocatedN Name -> Name
forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
[LocatedN Name]
names) Maybe Span
forall a. Maybe a
Nothing) LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType GhcRn)
typ
]
ClassOpSig XClassOpSig (GhcPass p)
_ Bool
_ [LIdP (GhcPass p)]
names LHsSigType (GhcPass p)
typ ->
[ case SigType
styp of
SigType
ClassSig -> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> LocatedN Name -> Context (LocatedN Name))
-> ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a b. (a -> b) -> a -> b
$ Maybe Span -> ContextInfo
ClassTyDecl (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
sp) [LIdP (GhcPass p)]
[LocatedN Name]
names
SigType
_ -> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> LocatedN Name -> Context (LocatedN Name))
-> ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a b. (a -> b) -> a -> b
$ ContextInfo
TyDecl) [LIdP (GhcPass p)]
[LocatedN Name]
names
, TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Name] -> Maybe Span -> TyVarScope
UnresolvedScope ((LocatedN Name -> Name) -> [LocatedN Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map LocatedN Name -> Name
forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
[LocatedN Name]
names) Maybe Span
msp) LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType GhcRn)
typ
]
FixSig XFixSig (GhcPass p)
_ FixitySig (GhcPass p)
fsig ->
[ GenLocated SrcSpanAnnA (FixitySig (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (FixitySig (GhcPass p))
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (FixitySig (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> FixitySig (GhcPass p)
-> GenLocated SrcSpanAnnA (FixitySig (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
sp FixitySig (GhcPass p)
fsig
]
InlineSig XInlineSig (GhcPass p)
_ LIdP (GhcPass p)
name InlinePragma
_ ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) LIdP (GhcPass p)
LocatedN Name
name
]
SpecSig XSpecSig (GhcPass p)
_ LIdP (GhcPass p)
name [LHsSigType (GhcPass p)]
typs InlinePragma
_ ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) LIdP (GhcPass p)
LocatedN Name
name
, [TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
-> HieM [HieAST Type])
-> [TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> [GenLocated SrcSpanAnnA (HsSigType GhcRn)]
-> [TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [])) [LHsSigType (GhcPass p)]
[GenLocated SrcSpanAnnA (HsSigType GhcRn)]
typs
]
SpecInstSig XSpecInstSig (GhcPass p)
_ LHsSigType (GhcPass p)
typ ->
[ TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType GhcRn)
typ
]
MinimalSig XMinimalSig (GhcPass p)
_ LBooleanFormula (LIdP (GhcPass p))
form ->
[ LBooleanFormula (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LBooleanFormula (LIdP (GhcPass p))
LBooleanFormula (LocatedN Name)
form
]
SCCFunSig XSCCFunSig (GhcPass p)
_ LIdP (GhcPass p)
name Maybe (XRec (GhcPass p) StringLiteral)
mtxt ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) LIdP (GhcPass p)
LocatedN Name
name
, HieM [HieAST Type]
-> (GenLocated (SrcAnn NoEpAnns) StringLiteral
-> HieM [HieAST Type])
-> Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral)
-> HieM [HieAST Type]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []) (SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type])
-> (GenLocated (SrcAnn NoEpAnns) StringLiteral -> SrcSpan)
-> GenLocated (SrcAnn NoEpAnns) StringLiteral
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated (SrcAnn NoEpAnns) StringLiteral -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) Maybe (XRec (GhcPass p) StringLiteral)
Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral)
mtxt
]
CompleteMatchSig XCompleteMatchSig (GhcPass p)
_ (L SrcSpan
ispan [LocatedN Name]
names) Maybe (LIdP (GhcPass p))
typ ->
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
ispan
, [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [LocatedN Name]
names
, Maybe (Context (LocatedN Name)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (Context (LocatedN Name)) -> HieM [HieAST Type])
-> Maybe (Context (LocatedN Name)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> Maybe (LocatedN Name) -> Maybe (Context (LocatedN Name))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) Maybe (LIdP (GhcPass p))
Maybe (LocatedN Name)
typ
]
XSig XXSig (GhcPass p)
_ -> []
instance ToHie (TScoped (LocatedA (HsSigType GhcRn))) where
toHie :: TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
toHie (TS TyVarScope
tsc (L SrcSpanAnnA
span t :: HsSigType GhcRn
t@HsSig{sig_bndrs :: forall pass. HsSigType pass -> HsOuterSigTyVarBndrs pass
sig_bndrs=HsOuterSigTyVarBndrs GhcRn
bndrs,sig_body :: forall pass. HsSigType pass -> LHsType pass
sig_body=LHsType GhcRn
body})) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsSigType GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsSigType GhcRn
t SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
:
[ TVScoped (HsOuterSigTyVarBndrs GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TyVarScope
-> Scope
-> HsOuterSigTyVarBndrs GhcRn
-> TVScoped (HsOuterSigTyVarBndrs GhcRn)
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS TyVarScope
tsc (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span) HsOuterSigTyVarBndrs GhcRn
bndrs)
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
body
]
instance Data flag => ToHie (TVScoped (HsOuterTyVarBndrs flag GhcRn)) where
toHie :: TVScoped (HsOuterTyVarBndrs flag GhcRn) -> HieM [HieAST Type]
toHie (TVS TyVarScope
tsc Scope
sc HsOuterTyVarBndrs flag GhcRn
bndrs) = case HsOuterTyVarBndrs flag GhcRn
bndrs of
HsOuterImplicit XHsOuterImplicit GhcRn
xs -> [Context Name] -> HieM [HieAST Type]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly ([Context Name] -> HieM [HieAST Type])
-> [Context Name] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Name -> Context Name) -> [Name] -> [Context Name]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Name -> Context Name
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Name -> Context Name)
-> ContextInfo -> Name -> Context Name
forall a b. (a -> b) -> a -> b
$ Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) [Name]
XHsOuterImplicit GhcRn
xs
HsOuterExplicit XHsOuterExplicit GhcRn flag
_ [LHsTyVarBndr flag (NoGhcTc GhcRn)]
xs -> [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcRn))]
-> HieM [HieAST Type])
-> [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> [LHsTyVarBndr flag GhcRn]
-> [TVScoped (LHsTyVarBndr flag GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes TyVarScope
tsc Scope
sc [LHsTyVarBndr flag (NoGhcTc GhcRn)]
[LHsTyVarBndr flag GhcRn]
xs
instance ToHie (LocatedA (HsType GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span HsType GhcRn
t) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsType GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsType GhcRn
t (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsType GhcRn
t of
HsForAllTy XForAllTy GhcRn
_ HsForAllTelescope GhcRn
tele LHsType GhcRn
body ->
let scope :: Scope
scope = SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnA (HsType GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
body in
[ case HsForAllTelescope GhcRn
tele of
HsForAllVis { hsf_vis_bndrs :: forall pass. HsForAllTelescope pass -> [LHsTyVarBndr () pass]
hsf_vis_bndrs = [LHsTyVarBndr () GhcRn]
bndrs } ->
[TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
-> HieM [HieAST Type])
-> [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> [LHsTyVarBndr () GhcRn]
-> [TVScoped (LHsTyVarBndr () GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
scope [LHsTyVarBndr () GhcRn]
bndrs
HsForAllInvis { hsf_invis_bndrs :: forall pass.
HsForAllTelescope pass -> [LHsTyVarBndr Specificity pass]
hsf_invis_bndrs = [LHsTyVarBndr Specificity GhcRn]
bndrs } ->
[TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type])
-> [TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> [LHsTyVarBndr Specificity GhcRn]
-> [TVScoped (LHsTyVarBndr Specificity GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
scope [LHsTyVarBndr Specificity GhcRn]
bndrs
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
body
]
HsQualTy XQualTy GhcRn
_ LHsContext GhcRn
ctx LHsType GhcRn
body ->
[ GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsContext GhcRn
GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
ctx
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
body
]
HsTyVar XTyVar GhcRn
_ PromotionFlag
_ LIdP GhcRn
var ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
var
]
HsAppTy XAppTy GhcRn
_ LHsType GhcRn
a LHsType GhcRn
b ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
b
]
HsAppKindTy XAppKindTy GhcRn
_ LHsType GhcRn
ty LHsToken "@" GhcRn
_ LHsType GhcRn
ki ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
ty
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
ki
]
HsFunTy XFunTy GhcRn
_ HsArrow GhcRn
w LHsType GhcRn
a LHsType GhcRn
b ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsArrow GhcRn -> LHsType GhcRn
arrowToHsType HsArrow GhcRn
w)
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
b
]
HsListTy XListTy GhcRn
_ LHsType GhcRn
a ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
]
HsTupleTy XTupleTy GhcRn
_ HsTupleSort
_ [LHsType GhcRn]
tys ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsType GhcRn]
[GenLocated SrcSpanAnnA (HsType GhcRn)]
tys
]
HsSumTy XSumTy GhcRn
_ [LHsType GhcRn]
tys ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsType GhcRn]
[GenLocated SrcSpanAnnA (HsType GhcRn)]
tys
]
HsOpTy XOpTy GhcRn
_ PromotionFlag
_prom LHsType GhcRn
a LIdP GhcRn
op LHsType GhcRn
b ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
, Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
op
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
b
]
HsParTy XParTy GhcRn
_ LHsType GhcRn
a ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
]
HsIParamTy XIParamTy GhcRn
_ XRec GhcRn HsIPName
ip LHsType GhcRn
ty ->
[ GenLocated (SrcAnn NoEpAnns) HsIPName -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie XRec GhcRn HsIPName
GenLocated (SrcAnn NoEpAnns) HsIPName
ip
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
ty
]
HsKindSig XKindSig GhcRn
_ LHsType GhcRn
a LHsType GhcRn
b ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
b
]
HsSpliceTy XSpliceTy GhcRn
_ HsUntypedSplice GhcRn
a ->
[ GenLocated SrcSpanAnnA (HsUntypedSplice GhcRn)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsUntypedSplice GhcRn)
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsUntypedSplice GhcRn)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsUntypedSplice GhcRn
-> GenLocated SrcSpanAnnA (HsUntypedSplice GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span HsUntypedSplice GhcRn
a
]
HsDocTy XDocTy GhcRn
_ LHsType GhcRn
a LHsDoc GhcRn
doc ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
a
, LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
doc
]
HsBangTy XBangTy GhcRn
_ HsSrcBang
_ LHsType GhcRn
ty ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
ty
]
HsRecTy XRecTy GhcRn
_ [LConDeclField GhcRn]
fields ->
[ [GenLocated SrcSpanAnnA (ConDeclField GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LConDeclField GhcRn]
[GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
fields
]
HsExplicitListTy XExplicitListTy GhcRn
_ PromotionFlag
_ [LHsType GhcRn]
tys ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsType GhcRn]
[GenLocated SrcSpanAnnA (HsType GhcRn)]
tys
]
HsExplicitTupleTy XExplicitTupleTy GhcRn
_ [LHsType GhcRn]
tys ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsType GhcRn]
[GenLocated SrcSpanAnnA (HsType GhcRn)]
tys
]
HsTyLit XTyLit GhcRn
_ HsTyLit GhcRn
_ -> []
HsWildCardTy XWildCardTy GhcRn
_ -> []
HsStarTy XStarTy GhcRn
_ Bool
_ -> []
XHsType XXType GhcRn
_ -> []
instance (ToHie tm, ToHie ty) => ToHie (HsArg p tm ty) where
toHie :: HsArg p tm ty -> HieM [HieAST Type]
toHie (HsValArg tm
tm) = tm -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie tm
tm
toHie (HsTypeArg LHsToken "@" p
_ ty
ty) = ty -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ty
ty
toHie (HsArgPar SrcSpan
sp) = SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
sp
instance Data flag => ToHie (TVScoped (LocatedA (HsTyVarBndr flag GhcRn))) where
toHie :: TVScoped (LocatedA (HsTyVarBndr flag GhcRn)) -> HieM [HieAST Type]
toHie (TVS TyVarScope
tsc Scope
sc (L SrcSpanAnnA
span HsTyVarBndr flag GhcRn
bndr)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsTyVarBndr flag GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsTyVarBndr flag GhcRn
bndr SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsTyVarBndr flag GhcRn
bndr of
UserTyVar XUserTyVar GhcRn
_ flag
_ LIdP GhcRn
var ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) LIdP GhcRn
LocatedN Name
var
]
KindedTyVar XKindedTyVar GhcRn
_ flag
_ LIdP GhcRn
var LHsType GhcRn
kind ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) LIdP GhcRn
LocatedN Name
var
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
kind
]
instance ToHie (TScoped (LHsQTyVars GhcRn)) where
toHie :: TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
toHie (TS TyVarScope
sc (HsQTvs XHsQTvs GhcRn
implicits [LHsTyVarBndr (HsBndrVis GhcRn) GhcRn]
vars)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ [Context Name] -> HieM [HieAST Type]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly [Context Name]
bindings
, [TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcRn) GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcRn) GhcRn))]
-> HieM [HieAST Type])
-> [TVScoped
(GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcRn) GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope
-> [LHsTyVarBndr (HsBndrVis GhcRn) GhcRn]
-> [TVScoped (LHsTyVarBndr (HsBndrVis GhcRn) GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes TyVarScope
sc Scope
NoScope [LHsTyVarBndr (HsBndrVis GhcRn) GhcRn]
vars
]
where
varLoc :: SrcSpan
varLoc = [GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcRn) GhcRn)]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LHsTyVarBndr (HsBndrVis GhcRn) GhcRn]
[GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcRn) GhcRn)]
vars
bindings :: [Context Name]
bindings = (Name -> Context Name) -> [Name] -> [Context Name]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Name -> Context Name
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Name -> Context Name)
-> ContextInfo -> Name -> Context Name
forall a b. (a -> b) -> a -> b
$ Scope -> TyVarScope -> ContextInfo
TyVarBind (SrcSpan -> Scope
mkScope SrcSpan
varLoc) TyVarScope
sc) [Name]
XHsQTvs GhcRn
implicits
instance ToHie (LocatedC [LocatedA (HsType GhcRn)]) where
toHie :: GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)]
-> HieM [HieAST Type]
toHie (L SrcSpanAnnC
span [GenLocated SrcSpanAnnA (HsType GhcRn)]
tys) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnnC -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnC
span)
, [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (HsType GhcRn)]
tys
]
instance ToHie (LocatedA (ConDeclField GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (ConDeclField GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span ConDeclField GhcRn
field) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ConDeclField GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode ConDeclField GhcRn
field (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case ConDeclField GhcRn
field of
ConDeclField XConDeclField GhcRn
_ [LFieldOcc GhcRn]
fields LHsType GhcRn
typ Maybe (LHsDoc GhcRn)
doc ->
[ [RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn))]
-> HieM [HieAST Type])
-> [RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn)
-> RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn)))
-> [GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn)]
-> [RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> Maybe Span
-> GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn)
-> RFContext (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn))
forall a. RecFieldContext -> Maybe Span -> a -> RFContext a
RFC RecFieldContext
RecFieldDecl (SrcSpan -> Maybe Span
getRealSpan (SrcSpan -> Maybe Span) -> SrcSpan -> Maybe Span
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnA (HsType GhcRn) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
typ)) [LFieldOcc GhcRn]
[GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcRn)]
fields
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
typ
, Maybe (LHsDoc GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsDoc GhcRn)
doc
]
instance ToHie (LHsExpr a) => ToHie (ArithSeqInfo a) where
toHie :: ArithSeqInfo a -> HieM [HieAST Type]
toHie (From LHsExpr a
expr) = LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
expr
toHie (FromThen LHsExpr a
a LHsExpr a
b) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
a
, LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
b
]
toHie (FromTo LHsExpr a
a LHsExpr a
b) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
a
, LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
b
]
toHie (FromThenTo LHsExpr a
a LHsExpr a
b LHsExpr a
c) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
a
, LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
b
, LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
c
]
instance ToHie (LocatedA (SpliceDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (SpliceDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span SpliceDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SpliceDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA SpliceDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case SpliceDecl GhcRn
decl of
SpliceDecl XSpliceDecl GhcRn
_ XRec GhcRn (HsUntypedSplice GhcRn)
splice SpliceDecoration
_ ->
[ GenLocated SrcSpanAnnA (HsUntypedSplice GhcRn)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie XRec GhcRn (HsUntypedSplice GhcRn)
GenLocated SrcSpanAnnA (HsUntypedSplice GhcRn)
splice
]
instance ToHie (HsQuote GhcRn) where
toHie :: HsQuote GhcRn -> HieM [HieAST Type]
toHie (ExpBr XExpBr GhcRn
_ LHsExpr GhcRn
e) = LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
e
toHie (PatBr XPatBr GhcRn
_ LPat GhcRn
b) = PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe Span
-> Scope
-> Scope
-> GenLocated SrcSpanAnnA (Pat GhcRn)
-> PScoped (GenLocated SrcSpanAnnA (Pat GhcRn))
forall a. Maybe Span -> Scope -> Scope -> a -> PScoped a
PS Maybe Span
forall a. Maybe a
Nothing Scope
NoScope Scope
NoScope LPat GhcRn
GenLocated SrcSpanAnnA (Pat GhcRn)
b)
toHie (DecBrL {} ) = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
toHie (DecBrG XDecBrG GhcRn
_ HsGroup GhcRn
decls) = HsGroup GhcRn -> HieM [HieAST Type]
processGrp HsGroup GhcRn
decls
toHie (TypBr XTypBr GhcRn
_ LHsType GhcRn
ty) = GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
GenLocated SrcSpanAnnA (HsType GhcRn)
ty
toHie (VarBr {} ) = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie PendingRnSplice where
toHie :: PendingRnSplice -> HieM [HieAST Type]
toHie (PendingRnSplice UntypedSpliceFlavour
_ Name
_ LHsExpr GhcRn
e) = LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
e
instance ToHie PendingTcSplice where
toHie :: PendingTcSplice -> HieM [HieAST Type]
toHie (PendingTcSplice Name
_ LHsExpr GhcTc
e) = GenLocated SrcSpanAnnA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e
instance ToHie (LBooleanFormula (LocatedN Name)) where
toHie :: LBooleanFormula (LocatedN Name) -> HieM [HieAST Type]
toHie (L SrcSpanAnnL
span BooleanFormula (LocatedN Name)
form) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ BooleanFormula (LocatedN Name) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode BooleanFormula (LocatedN Name)
form (SrcSpanAnnL -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case BooleanFormula (LocatedN Name)
form of
Var LocatedN Name
a ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LocatedN Name
a
]
And [LBooleanFormula (LocatedN Name)]
forms ->
[ [LBooleanFormula (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LBooleanFormula (LocatedN Name)]
forms
]
Or [LBooleanFormula (LocatedN Name)]
forms ->
[ [LBooleanFormula (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LBooleanFormula (LocatedN Name)]
forms
]
Parens LBooleanFormula (LocatedN Name)
f ->
[ LBooleanFormula (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LBooleanFormula (LocatedN Name)
f
]
instance ToHie (LocatedAn NoEpAnns HsIPName) where
toHie :: GenLocated (SrcAnn NoEpAnns) HsIPName -> HieM [HieAST Type]
toHie (L SrcAnn NoEpAnns
span HsIPName
e) = HsIPName -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsIPName
e SrcAnn NoEpAnns
span
instance HiePass p => ToHie (LocatedA (HsUntypedSplice (GhcPass p))) where
toHie :: LocatedA (HsUntypedSplice (GhcPass p)) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span HsUntypedSplice (GhcPass p)
sp) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsUntypedSplice (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsUntypedSplice (GhcPass p)
sp SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsUntypedSplice (GhcPass p)
sp of
HsUntypedSpliceExpr XUntypedSpliceExpr (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr
]
HsQuasiQuote XQuasiQuote (GhcPass p)
_ IdP (GhcPass p)
_ XRec (GhcPass p) FastString
ispanFs ->
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (GenLocated (SrcAnn NoEpAnns) FastString -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA XRec (GhcPass p) FastString
GenLocated (SrcAnn NoEpAnns) FastString
ispanFs)
]
instance ToHie (LocatedA (RoleAnnotDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (RoleAnnotDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span RoleAnnotDecl GhcRn
annot) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RoleAnnotDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA RoleAnnotDecl GhcRn
annot SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case RoleAnnotDecl GhcRn
annot of
RoleAnnotDecl XCRoleAnnotDecl GhcRn
_ LIdP GhcRn
var [XRec GhcRn (Maybe Role)]
roles ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
var
, (GenLocated (SrcAnn NoEpAnns) (Maybe Role) -> HieM [HieAST Type])
-> [GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
-> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type])
-> (GenLocated (SrcAnn NoEpAnns) (Maybe Role) -> SrcSpan)
-> GenLocated (SrcAnn NoEpAnns) (Maybe Role)
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated (SrcAnn NoEpAnns) (Maybe Role) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) [XRec GhcRn (Maybe Role)]
[GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
roles
]
instance ToHie (LocatedA (InstDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (InstDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span InstDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ InstDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA InstDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case InstDecl GhcRn
decl of
ClsInstD XClsInstD GhcRn
_ ClsInstDecl GhcRn
d ->
[ GenLocated SrcSpanAnnA (ClsInstDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (ClsInstDecl GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (ClsInstDecl GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> ClsInstDecl GhcRn -> GenLocated SrcSpanAnnA (ClsInstDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span ClsInstDecl GhcRn
d
]
DataFamInstD XDataFamInstD GhcRn
_ DataFamInstDecl GhcRn
d ->
[ GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> DataFamInstDecl GhcRn
-> GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span DataFamInstDecl GhcRn
d
]
TyFamInstD XTyFamInstD GhcRn
_ TyFamInstDecl GhcRn
d ->
[ GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> TyFamInstDecl GhcRn
-> GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span TyFamInstDecl GhcRn
d
]
instance ToHie (LocatedA (ClsInstDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (ClsInstDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span ClsInstDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span]) (GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> LHsSigType GhcRn
forall pass. ClsInstDecl pass -> LHsSigType pass
cid_poly_ty ClsInstDecl GhcRn
decl
, Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> HieM [HieAST Type])
-> Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsBind GhcRn)
-> BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
-> Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
-> Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
forall a b. (a -> b) -> Bag a -> Bag b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> GenLocated SrcSpanAnnA (HsBind GhcRn)
-> BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
InstanceBind Scope
ModuleScope) (Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
-> Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn))))
-> Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
-> Bag (BindContext (GenLocated SrcSpanAnnA (HsBind GhcRn)))
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> LHsBinds GhcRn
forall pass. ClsInstDecl pass -> LHsBinds pass
cid_binds ClsInstDecl GhcRn
decl
, [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type])
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn)))
-> [GenLocated SrcSpanAnnA (Sig GhcRn)]
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))
forall a. SigInfo -> a -> SigContext a
SC (SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn)))
-> SigInfo
-> GenLocated SrcSpanAnnA (Sig GhcRn)
-> SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))
forall a b. (a -> b) -> a -> b
$ SigType -> Maybe Span -> SigInfo
SI SigType
InstSig (Maybe Span -> SigInfo) -> Maybe Span -> SigInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) ([GenLocated SrcSpanAnnA (Sig GhcRn)]
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))])
-> [GenLocated SrcSpanAnnA (Sig GhcRn)]
-> [SigContext (GenLocated SrcSpanAnnA (Sig GhcRn))]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [LSig GhcRn]
forall pass. ClsInstDecl pass -> [LSig pass]
cid_sigs ClsInstDecl GhcRn
decl
, (GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type])
-> (GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn) -> SrcSpan)
-> GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) ([GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [LTyFamDefltDecl GhcRn]
forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts ClsInstDecl GhcRn
decl
, [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [LTyFamDefltDecl GhcRn]
forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts ClsInstDecl GhcRn
decl
, (GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable f) =>
(a -> m [b]) -> f a -> m [b]
concatMapM (SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type])
-> (GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn) -> SrcSpan)
-> GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA) ([GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [LDataFamInstDecl GhcRn]
forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts ClsInstDecl GhcRn
decl
, [GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [LDataFamInstDecl GhcRn]
forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts ClsInstDecl GhcRn
decl
, Maybe (LocatedP OverlapMode) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (LocatedP OverlapMode) -> HieM [HieAST Type])
-> Maybe (LocatedP OverlapMode) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> Maybe (XRec GhcRn OverlapMode)
forall pass. ClsInstDecl pass -> Maybe (XRec pass OverlapMode)
cid_overlap_mode ClsInstDecl GhcRn
decl
]
instance ToHie (LocatedA (DataFamInstDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (DataFamInstDecl GhcRn)
-> HieM [HieAST Type]
toHie (L SrcSpanAnnA
sp (DataFamInstDecl FamEqn GhcRn (HsDataDefn GhcRn)
d)) = TScoped (FamEqn GhcRn (HsDataDefn GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (FamEqn GhcRn (HsDataDefn GhcRn)) -> HieM [HieAST Type])
-> TScoped (FamEqn GhcRn (HsDataDefn GhcRn)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> FamEqn GhcRn (HsDataDefn GhcRn)
-> TScoped (FamEqn GhcRn (HsDataDefn GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
sp]) FamEqn GhcRn (HsDataDefn GhcRn)
d
instance ToHie (LocatedA (TyFamInstDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
sp (TyFamInstDecl XCTyFamInstDecl GhcRn
_ TyFamInstEqn GhcRn
d)) = TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type])
-> TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
-> TScoped (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
sp]) TyFamInstEqn GhcRn
FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
d
instance HiePass p => ToHie (Context (FieldOcc (GhcPass p))) where
toHie :: Context (FieldOcc (GhcPass p)) -> HieM [HieAST Type]
toHie (C ContextInfo
c (FieldOcc XCFieldOcc (GhcPass p)
n (L SrcSpanAnnN
l RdrName
_))) = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc -> Context (GenLocated SrcSpanAnnN Id) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (ContextInfo
-> GenLocated SrcSpanAnnN Id -> Context (GenLocated SrcSpanAnnN Id)
forall a. ContextInfo -> a -> Context a
C ContextInfo
c (SrcSpanAnnN -> Id -> GenLocated SrcSpanAnnN Id
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l XCFieldOcc (GhcPass p)
Id
n))
HiePassEv p
HieRn -> Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
c (SrcSpanAnnN -> Name -> LocatedN Name
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l XCFieldOcc (GhcPass p)
Name
n))
instance HiePass p => ToHie (PatSynFieldContext (RecordPatSynField (GhcPass p))) where
toHie :: PatSynFieldContext (RecordPatSynField (GhcPass p))
-> HieM [HieAST Type]
toHie (PSC Maybe Span
sp (RecordPatSynField FieldOcc (GhcPass p)
a LIdP (GhcPass p)
b)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ Context (FieldOcc (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (FieldOcc (GhcPass p)) -> HieM [HieAST Type])
-> Context (FieldOcc (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> FieldOcc (GhcPass p) -> Context (FieldOcc (GhcPass p))
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe Span -> ContextInfo
RecField RecFieldContext
RecFieldDecl Maybe Span
sp) FieldOcc (GhcPass p)
a
, Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN (IdGhcP p)) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN (IdGhcP p)
-> Context (GenLocated SrcSpanAnnN (IdGhcP p))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdGhcP p)
b
]
instance ToHie (LocatedA (DerivDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (DerivDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span DerivDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ DerivDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA DerivDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DerivDecl GhcRn
decl of
DerivDecl XCDerivDecl GhcRn
_ LHsSigWcType GhcRn
typ Maybe (LDerivStrategy GhcRn)
strat Maybe (XRec GhcRn OverlapMode)
overlap ->
[ TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type])
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> TScoped
(HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn)))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigWcType GhcRn
HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
typ
, Maybe
(RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe
(RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
-> HieM [HieAST Type])
-> Maybe
(RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Scope
-> GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
forall a. Scope -> a -> RScoped a
RS (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span) (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
-> Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
-> Maybe
(RScoped (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (LDerivStrategy GhcRn)
Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcRn))
strat)
, Maybe (LocatedP OverlapMode) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (XRec GhcRn OverlapMode)
Maybe (LocatedP OverlapMode)
overlap
]
instance ToHie (LocatedA (FixitySig GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (FixitySig GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span FixitySig GhcRn
sig) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ FixitySig GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA FixitySig GhcRn
sig SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case FixitySig GhcRn
sig of
FixitySig XFixitySig GhcRn
_ [LIdP GhcRn]
vars Fixity
_ ->
[ [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [LIdP GhcRn]
[LocatedN Name]
vars
]
instance ToHie (LocatedA (DefaultDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (DefaultDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span DefaultDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ DefaultDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA DefaultDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DefaultDecl GhcRn
decl of
DefaultDecl XCDefaultDecl GhcRn
_ [LHsType GhcRn]
typs ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsType GhcRn]
[GenLocated SrcSpanAnnA (HsType GhcRn)]
typs
]
instance ToHie (LocatedA (ForeignDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (ForeignDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span ForeignDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ForeignDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA ForeignDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case ForeignDecl GhcRn
decl of
ForeignImport {fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_name = LIdP GhcRn
name, fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_sig_ty = LHsSigType GhcRn
sig, fd_fi :: forall pass. ForeignDecl pass -> ForeignImport pass
fd_fi = ForeignImport GhcRn
fi} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (BindType -> Scope -> Maybe Span -> ContextInfo
ValBind BindType
RegularBind Scope
ModuleScope (Maybe Span -> ContextInfo) -> Maybe Span -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
span) LIdP GhcRn
LocatedN Name
name
, TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType GhcRn
GenLocated SrcSpanAnnA (HsSigType GhcRn)
sig
, ForeignImport GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ForeignImport GhcRn
fi
]
ForeignExport {fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_name = LIdP GhcRn
name, fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_sig_ty = LHsSigType GhcRn
sig, fd_fe :: forall pass. ForeignDecl pass -> ForeignExport pass
fd_fe = ForeignExport GhcRn
fe} ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
name
, TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type])
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> GenLocated SrcSpanAnnA (HsSigType GhcRn)
-> TScoped (GenLocated SrcSpanAnnA (HsSigType GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType GhcRn
GenLocated SrcSpanAnnA (HsSigType GhcRn)
sig
, ForeignExport GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ForeignExport GhcRn
fe
]
instance ToHie (ForeignImport GhcRn) where
toHie :: ForeignImport GhcRn -> HieM [HieAST Type]
toHie (CImport (L SrcSpan
c SourceText
_) (L SrcSpan
a CCallConv
_) (L SrcSpan
b Safety
_) Maybe Header
_ CImportSpec
_) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
a
, SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
b
, SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
c
]
instance ToHie (ForeignExport GhcRn) where
toHie :: ForeignExport GhcRn -> HieM [HieAST Type]
toHie (CExport (L SrcSpan
b SourceText
_) (L SrcSpan
a CExportSpec
_)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
a
, SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
b
]
instance ToHie (LocatedA (WarnDecls GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (WarnDecls GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span WarnDecls GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ WarnDecls GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA WarnDecls GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case WarnDecls GhcRn
decl of
Warnings XWarnings GhcRn
_ [LWarnDecl GhcRn]
warnings ->
[ [GenLocated SrcSpanAnnA (WarnDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LWarnDecl GhcRn]
[GenLocated SrcSpanAnnA (WarnDecl GhcRn)]
warnings
]
instance ToHie (LocatedA (WarnDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (WarnDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span WarnDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ WarnDecl GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode WarnDecl GhcRn
decl (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case WarnDecl GhcRn
decl of
Warning XWarning GhcRn
_ [LIdP GhcRn]
vars WarningTxt GhcRn
_ ->
[ [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (LocatedN Name)] -> HieM [HieAST Type])
-> [Context (LocatedN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedN Name -> Context (LocatedN Name))
-> [LocatedN Name] -> [Context (LocatedN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [LIdP GhcRn]
[LocatedN Name]
vars
]
instance ToHie (LocatedA (AnnDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (AnnDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span AnnDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ AnnDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA AnnDecl GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case AnnDecl GhcRn
decl of
HsAnnotation XHsAnnotation GhcRn
_ AnnProvenance GhcRn
prov LHsExpr GhcRn
expr ->
[ AnnProvenance GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie AnnProvenance GhcRn
prov
, LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
expr
]
instance ToHie (AnnProvenance GhcRn) where
toHie :: AnnProvenance GhcRn -> HieM [HieAST Type]
toHie (ValueAnnProvenance LIdP GhcRn
a) = Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
a
toHie (TypeAnnProvenance LIdP GhcRn
a) = Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use LIdP GhcRn
LocatedN Name
a
toHie AnnProvenance GhcRn
ModuleAnnProvenance = [HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LocatedA (RuleDecls GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (RuleDecls GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span RuleDecls GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RuleDecls GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA RuleDecls GhcRn
decl SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case RuleDecls GhcRn
decl of
HsRules XCRuleDecls GhcRn
_ [LRuleDecl GhcRn]
rules ->
[ [GenLocated SrcSpanAnnA (RuleDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LRuleDecl GhcRn]
[GenLocated SrcSpanAnnA (RuleDecl GhcRn)]
rules
]
instance ToHie (LocatedA (RuleDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (RuleDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span r :: RuleDecl GhcRn
r@(HsRule XHsRule GhcRn
_ XRec GhcRn FastString
rname Activation
_ Maybe [LHsTyVarBndr () (NoGhcTc GhcRn)]
tybndrs [LRuleBndr GhcRn]
bndrs LHsExpr GhcRn
exprA LHsExpr GhcRn
exprB)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ RuleDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA RuleDecl GhcRn
r SrcSpanAnnA
span
, SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpan -> HieM [HieAST Type]) -> SrcSpan -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcAnn NoEpAnns) FastString -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA XRec GhcRn FastString
GenLocated (SrcAnn NoEpAnns) FastString
rname
, Maybe [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
-> HieM [HieAST Type])
-> Maybe [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ([GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)]
-> [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))])
-> Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)]
-> Maybe [TVScoped (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn))]
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TyVarScope
-> Scope
-> [LHsTyVarBndr () GhcRn]
-> [TVScoped (LHsTyVarBndr () GhcRn)]
forall flag (a :: Pass).
TyVarScope
-> Scope
-> [LHsTyVarBndr flag (GhcPass a)]
-> [TVScoped (LHsTyVarBndr flag (GhcPass a))]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
scope) Maybe [LHsTyVarBndr () (NoGhcTc GhcRn)]
Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)]
tybndrs
, [RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))]
-> HieM [HieAST Type])
-> [RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)))
-> [GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)]
-> [RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (Scope
-> GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))
forall a. Scope -> a -> RScoped a
RS (Scope
-> GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)))
-> Scope
-> GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)
-> RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Scope
mkScope (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span)) [LRuleBndr GhcRn]
[GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)]
bndrs
, LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
exprA
, LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
exprB
]
where scope :: Scope
scope = Scope
bndrs_sc Scope -> Scope -> Scope
`combineScopes` Scope
exprA_sc Scope -> Scope -> Scope
`combineScopes` Scope
exprB_sc
bndrs_sc :: Scope
bndrs_sc = Scope
-> (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn) -> Scope)
-> Maybe (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA ([GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)]
-> Maybe (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))
forall a. [a] -> Maybe a
listToMaybe [LRuleBndr GhcRn]
[GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn)]
bndrs)
exprA_sc :: Scope
exprA_sc = LocatedA (HsExpr GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
exprA
exprB_sc :: Scope
exprB_sc = LocatedA (HsExpr GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
exprB
instance ToHie (RScoped (LocatedAn NoEpAnns (RuleBndr GhcRn))) where
toHie :: RScoped (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcRn))
-> HieM [HieAST Type]
toHie (RS Scope
sc (L SrcAnn NoEpAnns
span RuleBndr GhcRn
bndr)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RuleBndr GhcRn -> SrcAnn NoEpAnns -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA RuleBndr GhcRn
bndr SrcAnn NoEpAnns
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case RuleBndr GhcRn
bndr of
RuleBndr XCRuleBndr GhcRn
_ LIdP GhcRn
var ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (BindType -> Scope -> Maybe Span -> ContextInfo
ValBind BindType
RegularBind Scope
sc Maybe Span
forall a. Maybe a
Nothing) LIdP GhcRn
LocatedN Name
var
]
RuleBndrSig XRuleBndrSig GhcRn
_ LIdP GhcRn
var HsPatSigType GhcRn
typ ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (BindType -> Scope -> Maybe Span -> ContextInfo
ValBind BindType
RegularBind Scope
sc Maybe Span
forall a. Maybe a
Nothing) LIdP GhcRn
LocatedN Name
var
, TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (HsPatSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> HsPatSigType GhcRn -> TScoped (HsPatSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
sc]) HsPatSigType GhcRn
typ
]
instance ToHie (LocatedA (ImportDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span ImportDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ImportDecl GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode ImportDecl GhcRn
decl (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case ImportDecl GhcRn
decl of
ImportDecl { ideclName :: forall pass. ImportDecl pass -> XRec pass ModuleName
ideclName = XRec GhcRn ModuleName
name, ideclAs :: forall pass. ImportDecl pass -> Maybe (XRec pass ModuleName)
ideclAs = Maybe (XRec GhcRn ModuleName)
as, ideclImportList :: forall pass.
ImportDecl pass
-> Maybe (ImportListInterpretation, XRec pass [LIE pass])
ideclImportList = Maybe (ImportListInterpretation, XRec GhcRn [LIE GhcRn])
hidden } ->
[ IEContext (LocatedA ModuleName) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (LocatedA ModuleName) -> HieM [HieAST Type])
-> IEContext (LocatedA ModuleName) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> LocatedA ModuleName -> IEContext (LocatedA ModuleName)
forall a. IEType -> a -> IEContext a
IEC IEType
Import XRec GhcRn ModuleName
LocatedA ModuleName
name
, Maybe (IEContext (LocatedA ModuleName)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (IEContext (LocatedA ModuleName)) -> HieM [HieAST Type])
-> Maybe (IEContext (LocatedA ModuleName)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedA ModuleName -> IEContext (LocatedA ModuleName))
-> Maybe (LocatedA ModuleName)
-> Maybe (IEContext (LocatedA ModuleName))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (IEType -> LocatedA ModuleName -> IEContext (LocatedA ModuleName)
forall a. IEType -> a -> IEContext a
IEC IEType
ImportAs) Maybe (XRec GhcRn ModuleName)
Maybe (LocatedA ModuleName)
as
, HieM [HieAST Type]
-> ((ImportListInterpretation,
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
-> HieM [HieAST Type])
-> Maybe
(ImportListInterpretation,
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
-> HieM [HieAST Type]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([HieAST Type] -> HieM [HieAST Type]
forall a. a -> ReaderT NodeOrigin (State HieState) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []) (ImportListInterpretation,
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
-> HieM [HieAST Type]
forall {a} {a}.
ToHie (IEContext a) =>
(ImportListInterpretation, GenLocated (SrcSpanAnn' a) [a])
-> HieM [HieAST Type]
goIE Maybe (ImportListInterpretation, XRec GhcRn [LIE GhcRn])
Maybe
(ImportListInterpretation,
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
hidden
]
where
goIE :: (ImportListInterpretation, GenLocated (SrcSpanAnn' a) [a])
-> HieM [HieAST Type]
goIE (ImportListInterpretation
hiding, (L SrcSpanAnn' a
sp [a]
liens)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' a
sp)
, [IEContext a] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([IEContext a] -> HieM [HieAST Type])
-> [IEContext a] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (a -> IEContext a) -> [a] -> [IEContext a]
forall a b. (a -> b) -> [a] -> [b]
map (IEType -> a -> IEContext a
forall a. IEType -> a -> IEContext a
IEC IEType
c) [a]
liens
]
where
c :: IEType
c = case ImportListInterpretation
hiding of
ImportListInterpretation
Exactly -> IEType
Import
ImportListInterpretation
EverythingBut -> IEType
ImportHiding
instance ToHie (IEContext (LocatedA (IE GhcRn))) where
toHie :: IEContext (GenLocated SrcSpanAnnA (IE GhcRn)) -> HieM [HieAST Type]
toHie (IEC IEType
c (L SrcSpanAnnA
span IE GhcRn
ie)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IE GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode IE GhcRn
ie (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span) HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case IE GhcRn
ie of
IEVar XIEVar GhcRn
_ LIEWrappedName GhcRn
n ->
[ IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type])
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType
-> GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName GhcRn
GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
n
]
IEThingAbs XIEThingAbs GhcRn
_ LIEWrappedName GhcRn
n ->
[ IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type])
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType
-> GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName GhcRn
GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
n
]
IEThingAll XIEThingAll GhcRn
_ LIEWrappedName GhcRn
n ->
[ IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type])
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType
-> GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName GhcRn
GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
n
]
IEThingWith XIEThingWith GhcRn
_ LIEWrappedName GhcRn
n IEWildcard
_ [LIEWrappedName GhcRn]
ns ->
[ IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type])
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType
-> GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName GhcRn
GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
n
, [IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))]
-> HieM [HieAST Type])
-> [IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn)))
-> [GenLocated SrcSpanAnnA (IEWrappedName GhcRn)]
-> [IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (IEType
-> GenLocated SrcSpanAnnA (IEWrappedName GhcRn)
-> IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
forall a. IEType -> a -> IEContext a
IEC IEType
c) [LIEWrappedName GhcRn]
[GenLocated SrcSpanAnnA (IEWrappedName GhcRn)]
ns
]
IEModuleContents XIEModuleContents GhcRn
_ XRec GhcRn ModuleName
n ->
[ IEContext (LocatedA ModuleName) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (LocatedA ModuleName) -> HieM [HieAST Type])
-> IEContext (LocatedA ModuleName) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> LocatedA ModuleName -> IEContext (LocatedA ModuleName)
forall a. IEType -> a -> IEContext a
IEC IEType
c XRec GhcRn ModuleName
LocatedA ModuleName
n
]
IEGroup XIEGroup GhcRn
_ TypeIndex
_ LHsDoc GhcRn
d -> [LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
d]
IEDoc XIEDoc GhcRn
_ LHsDoc GhcRn
d -> [LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
d]
IEDocNamed XIEDocNamed GhcRn
_ FilePath
_ -> []
instance ToHie (IEContext (LocatedA (IEWrappedName GhcRn))) where
toHie :: IEContext (GenLocated SrcSpanAnnA (IEWrappedName GhcRn))
-> HieM [HieAST Type]
toHie (IEC IEType
c (L SrcSpanAnnA
span IEWrappedName GhcRn
iewn)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEWrappedName GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA IEWrappedName GhcRn
iewn SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case IEWrappedName GhcRn
iewn of
IEName XIEName GhcRn
_ (L SrcSpanAnnN
l Name
n) ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) (SrcSpanAnnN -> Name -> LocatedN Name
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l Name
n)
]
IEPattern XIEPattern GhcRn
_ (L SrcSpanAnnN
l Name
p) ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) (SrcSpanAnnN -> Name -> LocatedN Name
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l Name
p)
]
IEType XIEType GhcRn
_ (L SrcSpanAnnN
l Name
n) ->
[ Context (LocatedN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (LocatedN Name) -> HieM [HieAST Type])
-> Context (LocatedN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> LocatedN Name -> Context (LocatedN Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) (SrcSpanAnnN -> Name -> LocatedN Name
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l Name
n)
]
instance ToHie (IEContext (Located RecFieldInfo)) where
toHie :: IEContext (Located RecFieldInfo) -> HieM [HieAST Type]
toHie (IEC IEType
c (L SrcSpan
span RecFieldInfo
info)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ RecFieldInfo -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode RecFieldInfo
info SrcSpan
span
, Context (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Name) -> HieM [HieAST Type])
-> Context (Located Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) (Located Name -> Context (Located Name))
-> Located Name -> Context (Located Name)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Name -> Located Name
forall l e. l -> e -> GenLocated l e
L SrcSpan
span (FieldLabel -> Name
flSelector (FieldLabel -> Name) -> FieldLabel -> Name
forall a b. (a -> b) -> a -> b
$ RecFieldInfo -> FieldLabel
recFieldLabel RecFieldInfo
info)
]
instance ToHie (LocatedA (DocDecl GhcRn)) where
toHie :: GenLocated SrcSpanAnnA (DocDecl GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span DocDecl GhcRn
d) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ DocDecl GhcRn -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA DocDecl GhcRn
d SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DocDecl GhcRn
d of
DocCommentNext LHsDoc GhcRn
d -> [ LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
d ]
DocCommentPrev LHsDoc GhcRn
d -> [ LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
d ]
DocCommentNamed FilePath
_ LHsDoc GhcRn
d -> [ LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
d ]
DocGroup TypeIndex
_ LHsDoc GhcRn
d -> [ LHsDoc GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsDoc GhcRn
d ]
instance ToHie (LHsDoc GhcRn) where
toHie :: LHsDoc GhcRn -> HieM [HieAST Type]
toHie (L SrcSpan
span d :: HsDoc GhcRn
d@(WithHsDocIdentifiers HsDocString
_ [Located (IdP GhcRn)]
ids)) =
[HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsDoc GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsDoc GhcRn
d SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: [[Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located (IdP GhcRn)]
[Located Name]
ids]