{-# 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 #-}
#include "HsVersions.h"
module GHC.Iface.Ext.Ast ( mkHieFile, mkHieFileWithSource, getCompressedAsts, enrichHie) where
import GHC.Utils.Outputable(ppr)
import GHC.Prelude
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.Utils ( exprType )
import GHC.Core.ConLike ( conLikeName, ConLike(RealDataCon) )
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.Driver.Env
import GHC.Utils.Monad ( concatMapM, 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.SrcLoc
import GHC.Tc.Utils.Zonk ( hsLitType, hsPatType )
import GHC.Core.Type ( mkVisFunTys, Type )
import GHC.Core.Predicate
import GHC.Core.InstEnv
import GHC.Builtin.Types ( mkListTy, mkSumTy )
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.Misc
import GHC.Data.Maybe
import GHC.Data.FastString
import GHC.Iface.Ext.Types
import GHC.Iface.Ext.Utils
import GHC.Unit.Module ( ModuleName, 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.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 GHC.HsToCore.Types
import GHC.HsToCore.Expr
import GHC.HsToCore.Monad
type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn]
, Maybe [(LIE GhcRn, Avails)]
, Maybe LHsDocString )
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)
StateT HieState DsM () -> HieM ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (StateT HieState DsM () -> HieM ())
-> StateT HieState DsM () -> HieM ()
forall a b. (a -> b) -> a -> b
$ (HieState -> HieState) -> StateT HieState DsM ()
forall (m :: * -> *) s. Monad m => (s -> s) -> StateT s m ()
modify' ((HieState -> HieState) -> StateT HieState DsM ())
-> (HieState -> HieState) -> StateT HieState DsM ()
forall a b. (a -> b) -> a -> b
$ \HieState
s ->
HieState
s { unlocated_ev_binds :: VarMap (Set ContextInfo)
unlocated_ev_binds =
((Id, Set ContextInfo)
-> (Id, Set ContextInfo) -> (Id, Set ContextInfo))
-> VarMap (Set ContextInfo)
-> Id
-> (Id, Set ContextInfo)
-> VarMap (Set ContextInfo)
forall a. (a -> a -> a) -> DVarEnv a -> Id -> a -> DVarEnv a
extendDVarEnv_C (Id, Set ContextInfo)
-> (Id, Set ContextInfo) -> (Id, Set ContextInfo)
forall {a} {a} {a}. Ord a => (a, Set a) -> (a, Set a) -> (a, Set a)
go (HieState -> VarMap (Set ContextInfo)
unlocated_ev_binds HieState
s)
Id
var (Id
var,ContextInfo -> Set ContextInfo
forall a. a -> Set a
S.singleton ContextInfo
ci)
}
getUnlocatedEvBinds :: FastString -> HieM (NodeIdentifiers Type,[HieAST Type])
getUnlocatedEvBinds :: FastString -> HieM (NodeIdentifiers Type, [HieAST Type])
getUnlocatedEvBinds FastString
file = do
VarMap (Set ContextInfo)
binds <- StateT HieState DsM (VarMap (Set ContextInfo))
-> ReaderT
NodeOrigin (StateT HieState DsM) (VarMap (Set ContextInfo))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (StateT HieState DsM (VarMap (Set ContextInfo))
-> ReaderT
NodeOrigin (StateT HieState DsM) (VarMap (Set ContextInfo)))
-> StateT HieState DsM (VarMap (Set ContextInfo))
-> ReaderT
NodeOrigin (StateT HieState DsM) (VarMap (Set ContextInfo))
forall a b. (a -> b) -> a -> b
$ (HieState -> VarMap (Set ContextInfo))
-> StateT HieState DsM (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 (StateT HieState DsM) 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 (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 (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 :: NameEnv Id
name_remapping = NameEnv Id -> Name -> Id -> NameEnv Id
forall a. NameEnv a -> Name -> a -> NameEnv a
extendNameEnv (HieState -> NameEnv Id
name_remapping HieState
hs) (Id -> Name
varName Id
mono) Id
poly}
modifyState :: ModifyState (IdP p) => [ABExport p] -> HieState -> HieState
modifyState :: forall p.
ModifyState (IdP p) =>
[ABExport p] -> HieState -> HieState
modifyState = (ABExport p -> (HieState -> HieState) -> HieState -> HieState)
-> (HieState -> HieState) -> [ABExport p] -> HieState -> HieState
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ABExport p -> (HieState -> HieState) -> HieState -> HieState
forall {p} {a}.
ModifyState (IdP p) =>
ABExport p -> (a -> HieState) -> a -> HieState
go HieState -> HieState
forall a. a -> a
id
where
go :: ABExport p -> (a -> HieState) -> a -> HieState
go ABE{abe_poly :: forall p. ABExport p -> IdP p
abe_poly=IdP p
poly,abe_mono :: forall p. ABExport p -> IdP p
abe_mono=IdP p
mono} a -> HieState
f
= IdP p -> IdP p -> HieState -> HieState
forall a. ModifyState a => a -> a -> HieState -> HieState
addSubstitution IdP p
mono IdP p
poly (HieState -> HieState) -> (a -> HieState) -> a -> HieState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> HieState
f
go ABExport p
_ a -> HieState
f = a -> HieState
f
type HieM = ReaderT NodeOrigin (StateT HieState DsM)
mkHieFile :: ModSummary
-> TcGblEnv
-> RenamedSource -> Hsc HieFile
mkHieFile :: ModSummary -> TcGblEnv -> RenamedSource -> Hsc HieFile
mkHieFile ModSummary
ms TcGblEnv
ts RenamedSource
rs = do
let src_file :: FilePath
src_file = FilePath -> Maybe FilePath -> FilePath
forall a. HasCallStack => 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 -> Hsc ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> Hsc ByteString)
-> IO ByteString -> Hsc ByteString
forall a b. (a -> b) -> a -> b
$ FilePath -> IO ByteString
BS.readFile FilePath
src_file
FilePath
-> ByteString
-> ModSummary
-> TcGblEnv
-> RenamedSource
-> Hsc HieFile
mkHieFileWithSource FilePath
src_file ByteString
src ModSummary
ms TcGblEnv
ts RenamedSource
rs
mkHieFileWithSource :: FilePath
-> BS.ByteString
-> ModSummary
-> TcGblEnv
-> RenamedSource -> Hsc HieFile
mkHieFileWithSource :: FilePath
-> ByteString
-> ModSummary
-> TcGblEnv
-> RenamedSource
-> Hsc HieFile
mkHieFileWithSource FilePath
src_file ByteString
src ModSummary
ms TcGblEnv
ts RenamedSource
rs = do
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
HscEnv
hsc_env <- (HscEnv -> WarningMessages -> IO (HscEnv, WarningMessages))
-> Hsc HscEnv
forall a.
(HscEnv -> WarningMessages -> IO (a, WarningMessages)) -> Hsc a
Hsc ((HscEnv -> WarningMessages -> IO (HscEnv, WarningMessages))
-> Hsc HscEnv)
-> (HscEnv -> WarningMessages -> IO (HscEnv, WarningMessages))
-> Hsc HscEnv
forall a b. (a -> b) -> a -> b
$ \HscEnv
e WarningMessages
w -> (HscEnv, WarningMessages) -> IO (HscEnv, WarningMessages)
forall (m :: * -> *) a. Monad m => a -> m a
return (HscEnv
e, WarningMessages
w)
(Messages DecoratedSDoc
_msgs, Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
res) <- IO
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
-> Hsc
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
-> Hsc
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)))
-> IO
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
-> Hsc
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
forall a b. (a -> b) -> a -> b
$ HscEnv
-> TcGblEnv
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> IO
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
forall a.
HscEnv -> TcGblEnv -> DsM a -> IO (Messages DecoratedSDoc, Maybe a)
initDs HscEnv
hsc_env TcGblEnv
ts (DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> IO
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)))
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> IO
(Messages DecoratedSDoc,
Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
forall a b. (a -> b) -> a -> b
$ LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
getCompressedAsts LHsBinds GhcTc
tc_binds RenamedSource
rs Bag EvBind
top_ev_binds [ClsInst]
insts [TyCon]
tcs
let (HieASTs TypeIndex
asts',Array TypeIndex HieTypeFlat
arr) = FilePath
-> Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
forall a. HasCallStack => FilePath -> Maybe a -> a
expectJust FilePath
"mkHieFileWithSource" Maybe (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
res
HieFile -> Hsc HieFile
forall (m :: * -> *) a. Monad m => a -> m a
return (HieFile -> Hsc HieFile) -> HieFile -> Hsc HieFile
forall a b. (a -> b) -> a -> b
$ 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]
-> DsM (HieASTs TypeIndex, A.Array TypeIndex HieTypeFlat)
getCompressedAsts :: LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
getCompressedAsts LHsBinds GhcTc
ts RenamedSource
rs Bag EvBind
top_ev_binds [ClsInst]
insts [TyCon]
tcs = do
HieASTs Type
asts <- LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> DsM (HieASTs Type)
enrichHie LHsBinds GhcTc
ts RenamedSource
rs Bag EvBind
top_ev_binds [ClsInst]
insts [TyCon]
tcs
(HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
forall (m :: * -> *) a. Monad m => a -> m a
return ((HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
-> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
forall a b. (a -> b) -> a -> b
$ HieASTs Type -> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
compressTypes HieASTs Type
asts
enrichHie :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon]
-> DsM (HieASTs Type)
enrichHie :: LHsBinds GhcTc
-> RenamedSource
-> Bag EvBind
-> [ClsInst]
-> [TyCon]
-> DsM (HieASTs Type)
enrichHie LHsBinds GhcTc
ts (HsGroup GhcRn
hsGrp, [LImportDecl GhcRn]
imports, Maybe [(LIE GhcRn, [AvailInfo])]
exports, Maybe LHsDocString
_) Bag EvBind
ev_bs [ClsInst]
insts [TyCon]
tcs =
(StateT HieState DsM (HieASTs Type)
-> HieState -> DsM (HieASTs Type))
-> HieState
-> StateT HieState DsM (HieASTs Type)
-> DsM (HieASTs Type)
forall a b c. (a -> b -> c) -> b -> a -> c
flip StateT HieState DsM (HieASTs Type)
-> HieState -> DsM (HieASTs Type)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT HieState
initState (StateT HieState DsM (HieASTs Type) -> DsM (HieASTs Type))
-> StateT HieState DsM (HieASTs Type) -> DsM (HieASTs Type)
forall a b. (a -> b) -> a -> b
$ (ReaderT NodeOrigin (StateT HieState DsM) (HieASTs Type)
-> NodeOrigin -> StateT HieState DsM (HieASTs Type))
-> NodeOrigin
-> ReaderT NodeOrigin (StateT HieState DsM) (HieASTs Type)
-> StateT HieState DsM (HieASTs Type)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT NodeOrigin (StateT HieState DsM) (HieASTs Type)
-> NodeOrigin -> StateT HieState DsM (HieASTs Type)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT NodeOrigin
SourceInfo (ReaderT NodeOrigin (StateT HieState DsM) (HieASTs Type)
-> StateT HieState DsM (HieASTs Type))
-> ReaderT NodeOrigin (StateT HieState DsM) (HieASTs Type)
-> StateT HieState DsM (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 (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) Bag (GenLocated SrcSpanAnnA (HsBindLR GhcTc GhcTc))
LHsBinds GhcTc
ts
[HieAST Type]
rasts <- HsGroup GhcRn -> HieM [HieAST Type]
forall {p}.
(ToHie (XRec p (SpliceDecl p)), ToHie (XRec p (DerivDecl p)),
ToHie (XRec p (FixitySig p)), ToHie (XRec p (DefaultDecl p)),
ToHie (XRec p (ForeignDecl p)), ToHie (XRec p (WarnDecls p)),
ToHie (XRec p (AnnDecl p)), ToHie (XRec p (RuleDecls p)),
ToHie (RScoped (HsValBinds p)), ToHie (TyClGroup p)) =>
HsGroup p -> 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
. ImportDecl GhcRn -> Bool
forall pass. ImportDecl pass -> Bool
ideclImplicit (ImportDecl GhcRn -> Bool)
-> (GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> ImportDecl GhcRn)
-> GenLocated SrcSpanAnnA (ImportDecl GhcRn)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (ImportDecl GhcRn) -> ImportDecl GhcRn
forall l e. GenLocated l e -> e
unLoc) [GenLocated SrcSpanAnnA (ImportDecl GhcRn)]
[LImportDecl 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 (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 [(GenLocated SrcSpanAnnA (IE GhcRn), [AvailInfo])]
Maybe [(LIE GhcRn, [AvailInfo])]
exports
[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 (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]
children of
[] -> RealSrcLoc -> Span
realSrcLocSpan (FastString -> TypeIndex -> TypeIndex -> RealSrcLoc
mkRealSrcLoc FastString
file TypeIndex
1 TypeIndex
1)
[HieAST a]
_ -> 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 (HieAST a -> Span) -> HieAST a -> Span
forall a b. (a -> b) -> a -> b
$ [HieAST a] -> HieAST a
forall a. [a] -> a
head [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 (HieAST a -> Span) -> HieAST a -> Span
forall a b. (a -> b) -> a -> b
$ [HieAST a] -> HieAST a
forall a. [a] -> a
last [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
]
modulify :: HiePath
-> [HieAST Type]
-> ReaderT NodeOrigin (StateT HieState DsM) (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
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 :: NodeIdentifiers Type
nodeIdentifiers = NodeIdentifiers Type
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 (StateT HieState DsM) (HieAST Type)
forall (m :: * -> *) a. Monad m => a -> m a
return HieAST Type
x
[HieAST Type]
xs -> FilePath
-> SDoc -> ReaderT NodeOrigin (StateT HieState DsM) (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 (StateT HieState DsM) (HieAST Type))
-> ReaderT
NodeOrigin (StateT HieState DsM) (Map HiePath (HieAST Type))
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
(Map
HiePath (ReaderT NodeOrigin (StateT HieState DsM) (HieAST Type))
-> ReaderT
NodeOrigin (StateT HieState DsM) (Map HiePath (HieAST Type)))
-> Map
HiePath (ReaderT NodeOrigin (StateT HieState DsM) (HieAST Type))
-> ReaderT
NodeOrigin (StateT HieState DsM) (Map HiePath (HieAST Type))
forall a b. (a -> b) -> a -> b
$ (HiePath
-> [HieAST Type]
-> ReaderT NodeOrigin (StateT HieState DsM) (HieAST Type))
-> Map HiePath [HieAST Type]
-> Map
HiePath (ReaderT NodeOrigin (StateT HieState DsM) (HieAST Type))
forall k a b. (k -> a -> b) -> Map k a -> Map k b
M.mapWithKey HiePath
-> [HieAST Type]
-> ReaderT NodeOrigin (StateT HieState DsM) (HieAST Type)
modulify
(Map HiePath [HieAST Type]
-> Map
HiePath (ReaderT NodeOrigin (StateT HieState DsM) (HieAST Type)))
-> Map HiePath [HieAST Type]
-> Map
HiePath (ReaderT NodeOrigin (StateT HieState DsM) (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 (StateT HieState DsM) (HieASTs Type)
forall (m :: * -> *) a. Monad m => a -> m a
return HieASTs Type
asts
where
processGrp :: HsGroup p -> HieM [HieAST Type]
processGrp HsGroup p
grp = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ RScoped (HsValBinds p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsValBinds p) -> HieM [HieAST Type])
-> RScoped (HsValBinds p) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (HsValBinds p -> RScoped (HsValBinds p))
-> (HsGroup p -> HsValBinds p)
-> HsGroup p
-> RScoped (HsValBinds p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Scope -> HsValBinds p -> RScoped (HsValBinds p)
forall a. Scope -> a -> RScoped a
RS Scope
ModuleScope ) HsGroup p -> HsValBinds p
forall p. HsGroup p -> HsValBinds p
hs_valds HsGroup p
grp
, [XRec p (SpliceDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (SpliceDecl p)] -> HieM [HieAST Type])
-> [XRec p (SpliceDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (SpliceDecl p)]
forall p. HsGroup p -> [LSpliceDecl p]
hs_splcds HsGroup p
grp
, [TyClGroup p] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TyClGroup p] -> HieM [HieAST Type])
-> [TyClGroup p] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [TyClGroup p]
forall p. HsGroup p -> [TyClGroup p]
hs_tyclds HsGroup p
grp
, [XRec p (DerivDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (DerivDecl p)] -> HieM [HieAST Type])
-> [XRec p (DerivDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (DerivDecl p)]
forall p. HsGroup p -> [LDerivDecl p]
hs_derivds HsGroup p
grp
, [XRec p (FixitySig p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (FixitySig p)] -> HieM [HieAST Type])
-> [XRec p (FixitySig p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (FixitySig p)]
forall p. HsGroup p -> [LFixitySig p]
hs_fixds HsGroup p
grp
, [XRec p (DefaultDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (DefaultDecl p)] -> HieM [HieAST Type])
-> [XRec p (DefaultDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (DefaultDecl p)]
forall p. HsGroup p -> [LDefaultDecl p]
hs_defds HsGroup p
grp
, [XRec p (ForeignDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (ForeignDecl p)] -> HieM [HieAST Type])
-> [XRec p (ForeignDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (ForeignDecl p)]
forall p. HsGroup p -> [LForeignDecl p]
hs_fords HsGroup p
grp
, [XRec p (WarnDecls p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (WarnDecls p)] -> HieM [HieAST Type])
-> [XRec p (WarnDecls p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (WarnDecls p)]
forall p. HsGroup p -> [LWarnDecls p]
hs_warnds HsGroup p
grp
, [XRec p (AnnDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (AnnDecl p)] -> HieM [HieAST Type])
-> [XRec p (AnnDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (AnnDecl p)]
forall p. HsGroup p -> [LAnnDecl p]
hs_annds HsGroup p
grp
, [XRec p (RuleDecls p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([XRec p (RuleDecls p)] -> HieM [HieAST Type])
-> [XRec p (RuleDecls p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [XRec p (RuleDecls p)]
forall p. HsGroup p -> [LRuleDecls p]
hs_ruleds HsGroup p
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)))) ~ SrcSpan
, Data (HsLocalBinds (GhcPass p)))
=> GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) -> SrcSpan
grhss_span :: forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan,
Data (HsLocalBinds (GhcPass p))) =>
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 (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (HsLocalBinds (GhcPass p) -> SrcSpan
forall (p :: Pass).
Data (HsLocalBinds (GhcPass p)) =>
HsLocalBinds (GhcPass p) -> SrcSpan
spanHsLocaLBinds HsLocalBinds (GhcPass p)
bs) ((GenLocated
SrcSpan (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
-> SrcSpan)
-> [GenLocated
SrcSpan (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
-> [SrcSpan]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpan (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
-> SrcSpan
forall l e. GenLocated l e -> l
getLoc [GenLocated
SrcSpan (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
[LGRHS (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 (StateT HieState DsM) [HieAST a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
bindingsOnly (C ContextInfo
c Name
n : [Context Name]
xs) = do
NodeOrigin
org <- ReaderT NodeOrigin (StateT HieState DsM) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
[HieAST a]
rest <- [Context Name]
-> ReaderT NodeOrigin (StateT HieState DsM) [HieAST a]
forall a. [Context Name] -> HieM [HieAST a]
bindingsOnly [Context Name]
xs
[HieAST a] -> ReaderT NodeOrigin (StateT HieState DsM) [HieAST a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([HieAST a] -> ReaderT NodeOrigin (StateT HieState DsM) [HieAST a])
-> [HieAST a]
-> ReaderT NodeOrigin (StateT HieState DsM) [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 :: Set ContextInfo
identInfo = ContextInfo -> Set ContextInfo
forall a. a -> Set a
S.singleton ContextInfo
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)
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 -> DataType
PScoped a -> Constr
(forall b. Data b => b -> b) -> PScoped a -> PScoped a
forall {a}. Data a => Typeable (PScoped a)
forall a. Data a => PScoped a -> DataType
forall a. Data a => PScoped a -> Constr
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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> PScoped a -> m (PScoped a)
gmapQi :: forall u.
TypeIndex -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> PScoped a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> PScoped a -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PScoped a -> r
gmapT :: (forall b. Data b => b -> b) -> PScoped a -> PScoped a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> PScoped a -> PScoped a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PScoped a))
dataTypeOf :: PScoped a -> DataType
$cdataTypeOf :: forall a. Data a => PScoped a -> DataType
toConstr :: PScoped a -> Constr
$ctoConstr :: forall a. Data a => PScoped a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> 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)
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 [LocatedA (Pat (GhcPass p))]
[LPat (GhcPass p)]
xs
tScopes
:: Scope
-> Scope
-> [HsPatSigType (GhcPass a)]
-> [TScoped (HsPatSigType (GhcPass a))]
tScopes :: forall (a :: Pass).
Scope
-> Scope
-> [HsPatSigType (GhcPass a)]
-> [TScoped (HsPatSigType (GhcPass a))]
tScopes Scope
scope Scope
rhsScope [HsPatSigType (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 ((HsPatSigType (GhcPass a)
-> GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a)))
-> [HsPatSigType (GhcPass a)]
-> [GenLocated SrcSpanAnnA (HsPatSigType (GhcPass a))]
forall a b. (a -> b) -> [a] -> [b]
map (\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) [HsPatSigType (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 [LocatedA (HsTyVarBndr flag (GhcPass a))]
[LHsTyVarBndr 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. (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, 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. (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans [GenLocated SrcSpanAnnN (IdGhcP p) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass p)
a, [HsArg
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [HsArg
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
HsTyPats (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. (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans [GenLocated SrcSpanAnnN (IdGhcP p) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass p)
a, [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
[LHsTyVarBndr () (NoGhcTc (GhcPass p))]
tvs, [HsArg
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [HsArg
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))
(GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
HsTyPats (GhcPass p)
b, a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc a
c]
instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg tm ty) where
loc :: HsArg tm ty -> SrcSpan
loc (HsValArg tm
tm) = tm -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc tm
tm
loc (HsTypeArg SrcSpan
_ 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{}) = [GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc ([GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> SrcSpan)
-> [GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> SrcSpan
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> [LConDecl GhcRn]
forall pass. HsDataDefn pass -> [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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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 (f :: * -> *) a. Applicative f => a -> f a
pure []) a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie
instance ToHie (IEContext (Located ModuleName)) where
toHie :: IEContext (Located ModuleName) -> HieM [HieAST Type]
toHie (IEC IEType
c (L (RealSrcSpan Span
span Maybe BufSpan
_) ModuleName
mname)) = do
NodeOrigin
org <- ReaderT NodeOrigin (StateT HieState DsM) NodeOrigin
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
[HieAST Type] -> HieM [HieAST Type]
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 :: Set ContextInfo
identInfo = ContextInfo -> Set ContextInfo
forall a. a -> Set a
S.singleton (IEType -> ContextInfo
IEThing IEType
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 (Located ModuleName)
_ = [HieAST Type] -> HieM [HieAST Type]
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 (f :: * -> *) a. Applicative f => a -> f a
pure []
| Bool
otherwise -> do
NameEnv Id
m <- StateT HieState DsM (NameEnv Id)
-> ReaderT NodeOrigin (StateT HieState DsM) (NameEnv Id)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (StateT HieState DsM (NameEnv Id)
-> ReaderT NodeOrigin (StateT HieState DsM) (NameEnv Id))
-> StateT HieState DsM (NameEnv Id)
-> ReaderT NodeOrigin (StateT HieState DsM) (NameEnv Id)
forall a b. (a -> b) -> a -> b
$ (HieState -> NameEnv Id) -> StateT HieState DsM (NameEnv Id)
forall (m :: * -> *) s a. Monad m => (s -> a) -> StateT s m a
gets HieState -> NameEnv Id
name_remapping
NodeOrigin
org <- ReaderT NodeOrigin (StateT HieState DsM) 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 (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 (f :: * -> *) a. Applicative f => a -> f a
pure []
Context (Located Id)
_ -> [HieAST Type] -> HieM [HieAST Type]
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 (f :: * -> *) a. Applicative f => a -> f a
pure []
| Bool
otherwise -> do
NameEnv Id
m <- StateT HieState DsM (NameEnv Id)
-> ReaderT NodeOrigin (StateT HieState DsM) (NameEnv Id)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (StateT HieState DsM (NameEnv Id)
-> ReaderT NodeOrigin (StateT HieState DsM) (NameEnv Id))
-> StateT HieState DsM (NameEnv Id)
-> ReaderT NodeOrigin (StateT HieState DsM) (NameEnv Id)
forall a b. (a -> b) -> a -> b
$ (HieState -> NameEnv Id) -> StateT HieState DsM (NameEnv Id)
forall (m :: * -> *) s a. Monad m => (s -> a) -> StateT s m a
gets HieState -> NameEnv Id
name_remapping
NodeOrigin
org <- ReaderT NodeOrigin (StateT HieState DsM) 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 (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 (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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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 (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
_ SDoc
_) -> [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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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 (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 GenLocated SrcSpanAnnN Id
LIdP (GhcPass p)
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 e :: LocatedA (HsExpr (GhcPass p))
e@(L SrcSpanAnnA
spn HsExpr (GhcPass p)
e') =
case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> 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
HiePassEv p
HieTc ->
let tyOpt :: Maybe Type
tyOpt = case HsExpr (GhcPass p)
e' of
HsUnboundVar (HER IORef EvTerm
_ Type
ty Unique
_) OccName
_ -> Type -> Maybe Type
forall a. a -> Maybe a
Just Type
ty
HsLit XLitE (GhcPass p)
_ HsLit (GhcPass p)
l -> Type -> Maybe Type
forall a. a -> Maybe a
Just (HsLit (GhcPass p) -> Type
forall (p :: Pass). HsLit (GhcPass p) -> Type
hsLitType HsLit (GhcPass p)
l)
HsOverLit XOverLitE (GhcPass p)
_ HsOverLit (GhcPass p)
o -> Type -> Maybe Type
forall a. a -> Maybe a
Just (HsOverLit GhcTc -> Type
overLitType HsOverLit (GhcPass p)
HsOverLit GhcTc
o)
HsConLikeOut XConLikeOut (GhcPass p)
_ (RealDataCon DataCon
con) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (DataCon -> Type
dataConNonlinearType DataCon
con)
HsLam XLam (GhcPass p)
_ (MG { mg_ext :: forall p body. MatchGroup p body -> XMG p body
mg_ext = XMG (GhcPass p) (LHsExpr (GhcPass p))
groupTy }) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (MatchGroupTc -> Type
matchGroupType XMG (GhcPass p) (LHsExpr (GhcPass p))
MatchGroupTc
groupTy)
HsLamCase XLamCase (GhcPass p)
_ (MG { mg_ext :: forall p body. MatchGroup p body -> XMG p body
mg_ext = XMG (GhcPass p) (LHsExpr (GhcPass p))
groupTy }) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (MatchGroupTc -> Type
matchGroupType XMG (GhcPass p) (LHsExpr (GhcPass p))
MatchGroupTc
groupTy)
HsCase XCase (GhcPass p)
_ LHsExpr (GhcPass p)
_ (MG { mg_ext :: forall p body. MatchGroup p body -> XMG p body
mg_ext = XMG (GhcPass p) (LHsExpr (GhcPass p))
groupTy }) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (MatchGroupTc -> Type
mg_res_ty XMG (GhcPass p) (LHsExpr (GhcPass p))
MatchGroupTc
groupTy)
ExplicitList XExplicitList (GhcPass p)
ty [LHsExpr (GhcPass p)]
_ -> Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Type
mkListTy Type
XExplicitList (GhcPass p)
ty)
ExplicitSum XExplicitSum (GhcPass p)
ty TypeIndex
_ TypeIndex
_ LHsExpr (GhcPass p)
_ -> Type -> Maybe Type
forall a. a -> Maybe a
Just ([Type] -> Type
mkSumTy [Type]
XExplicitSum (GhcPass p)
ty)
HsDo XDo (GhcPass p)
ty HsStmtContext (HsDoRn (GhcPass p))
_ XRec (GhcPass p) [ExprLStmt (GhcPass p)]
_ -> Type -> Maybe Type
forall a. a -> Maybe a
Just Type
XDo (GhcPass p)
ty
HsMultiIf XMultiIf (GhcPass p)
ty [LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
_ -> Type -> Maybe Type
forall a. a -> Maybe a
Just Type
XMultiIf (GhcPass p)
ty
HsExpr (GhcPass p)
_ -> Maybe Type
forall a. Maybe a
Nothing
in
case Maybe Type
tyOpt of
Just Type
t -> 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
t
Maybe Type
Nothing
| HsExpr GhcTc -> Bool
skipDesugaring HsExpr (GhcPass p)
HsExpr GhcTc
e' -> HieM [HieAST Type]
fallback
| Bool
otherwise -> do
(EvExpr
e, Bool
no_errs) <- StateT HieState DsM (EvExpr, Bool)
-> ReaderT NodeOrigin (StateT HieState DsM) (EvExpr, Bool)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (StateT HieState DsM (EvExpr, Bool)
-> ReaderT NodeOrigin (StateT HieState DsM) (EvExpr, Bool))
-> StateT HieState DsM (EvExpr, Bool)
-> ReaderT NodeOrigin (StateT HieState DsM) (EvExpr, Bool)
forall a b. (a -> b) -> a -> b
$ DsM (EvExpr, Bool) -> StateT HieState DsM (EvExpr, Bool)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (DsM (EvExpr, Bool) -> StateT HieState DsM (EvExpr, Bool))
-> DsM (EvExpr, Bool) -> StateT HieState DsM (EvExpr, Bool)
forall a b. (a -> b) -> a -> b
$ DsM (EvExpr, Bool) -> DsM (EvExpr, Bool)
forall a. DsM a -> DsM a
discardWarningsDs (DsM (EvExpr, Bool) -> DsM (EvExpr, Bool))
-> DsM (EvExpr, Bool) -> DsM (EvExpr, Bool)
forall a b. (a -> b) -> a -> b
$ DsM EvExpr -> DsM (EvExpr, Bool)
forall a. DsM a -> DsM (a, Bool)
askNoErrsDs (DsM EvExpr -> DsM (EvExpr, Bool))
-> DsM EvExpr -> DsM (EvExpr, Bool)
forall a b. (a -> b) -> a -> b
$ LHsExpr GhcTc -> DsM EvExpr
dsLExpr LocatedA (HsExpr (GhcPass p))
LHsExpr GhcTc
e
if Bool
no_errs
then 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 -> HieM [HieAST Type])
-> (EvExpr -> Type) -> EvExpr -> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EvExpr -> Type
exprType (EvExpr -> HieM [HieAST Type]) -> EvExpr -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ EvExpr
e
else HieM [HieAST Type]
fallback
where
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
matchGroupType :: MatchGroupTc -> Type
matchGroupType :: MatchGroupTc -> Type
matchGroupType (MatchGroupTc [Scaled Type]
args Type
res) = [Scaled Type] -> Type -> Type
mkVisFunTys [Scaled Type]
args Type
res
skipDesugaring :: HsExpr GhcTc -> Bool
skipDesugaring :: HsExpr GhcTc -> Bool
skipDesugaring HsExpr GhcTc
e = case HsExpr GhcTc
e of
HsVar{} -> Bool
False
HsConLikeOut{} -> Bool
False
HsRecFld{} -> Bool
False
HsOverLabel{} -> Bool
False
HsIPVar{} -> Bool
False
XExpr (WrapExpr {}) -> Bool
False
HsExpr GhcTc
_ -> Bool
True
data HiePassEv p where
HieRn :: HiePassEv 'Renamed
HieTc :: HiePassEv 'Typechecked
class ( IsPass p
, HiePass (NoGhcTcPass p)
, 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 (HsSplice (GhcPass p))
, Data (HsLocalBinds (GhcPass p))
, Data (FieldOcc (GhcPass p))
, Data (HsTupArg (GhcPass p))
, Data (IPBind (GhcPass p))
, ToHie (Context (Located (IdGhcP p)))
, ToHie (RFContext (Located (AmbiguousFieldOcc (GhcPass p))))
, ToHie (RFContext (Located (FieldOcc (GhcPass p))))
, ToHie (TScoped (LHsWcType (GhcPass (NoGhcTcPass p))))
, ToHie (TScoped (LHsSigWcType (GhcPass (NoGhcTcPass 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 (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))))
~ SrcSpan
, 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))))
, IsPass 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)
wrap} ->
[ 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) GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass 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) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
matches
, case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc -> 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 XFunBind (GhcPass p) (GhcPass p)
HsWrapper
wrap
HiePassEv p
_ -> [HieAST Type] -> HieM [HieAST Type]
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 GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (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) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
GRHSs (GhcPass p) (LHsExpr (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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
AbsBinds{ abs_exports :: forall idL idR. HsBindLR idL idR -> [ABExport idL]
abs_exports = [ABExport (GhcPass p)]
xs, abs_binds :: forall idL idR. HsBindLR idL idR -> LHsBinds idL
abs_binds = LHsBinds (GhcPass p)
binds
, abs_ev_binds :: forall idL idR. HsBindLR idL idR -> [TcEvBinds]
abs_ev_binds = [TcEvBinds]
ev_binds
, abs_ev_vars :: forall idL idR. HsBindLR idL idR -> [Id]
abs_ev_vars = [Id]
ev_vars } ->
[ StateT HieState DsM () -> HieM ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((HieState -> HieState) -> StateT HieState DsM ()
forall (m :: * -> *) s. Monad m => (s -> s) -> StateT s m ()
modify ([ABExport (GhcPass p)] -> HieState -> HieState
forall p.
ModifyState (IdP p) =>
[ABExport p] -> HieState -> HieState
modifyState [ABExport (GhcPass p)]
xs)) HieM () -> HieM [HieAST Type] -> HieM [HieAST Type]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
(Bag (BindContext (LocatedA (HsBind (GhcPass p))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (LocatedA (HsBind (GhcPass p))))
-> HieM [HieAST Type])
-> Bag (BindContext (LocatedA (HsBind (GhcPass p))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LocatedA (HsBind (GhcPass p))
-> BindContext (LocatedA (HsBind (GhcPass p))))
-> Bag (LocatedA (HsBind (GhcPass p)))
-> Bag (BindContext (LocatedA (HsBind (GhcPass p))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> LocatedA (HsBind (GhcPass p))
-> BindContext (LocatedA (HsBind (GhcPass p)))
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
context Scope
scope) Bag (LocatedA (HsBind (GhcPass p)))
LHsBinds (GhcPass p)
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 (GhcPass p) -> LocatedA HsWrapper)
-> [ABExport (GhcPass p)] -> [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 (GhcPass p) -> HsWrapper)
-> ABExport (GhcPass p)
-> LocatedA HsWrapper
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ABExport (GhcPass p) -> HsWrapper
forall p. ABExport p -> HsWrapper
abe_wrap) [ABExport (GhcPass p)]
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) , mg_origin :: forall p body. MatchGroup p body -> Origin
mg_origin = Origin
origin} ->
(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
]
setOrigin :: Origin -> NodeOrigin -> NodeOrigin
setOrigin :: Origin -> NodeOrigin -> NodeOrigin
setOrigin Origin
FromSource NodeOrigin
_ = NodeOrigin
SourceInfo
setOrigin Origin
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) GenLocated SrcSpanAnnN (IdGhcP p)
XRec (GhcPass p) (IdP (GhcPass 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 HsConDetails
Void
(GenLocated SrcSpanAnnN (IdGhcP p))
[RecordPatSynField (GhcPass p)]
HsPatSynDetails (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 GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (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 GenLocated SrcSpanAnnN (IdGhcP p)
XRec (GhcPass p) (IdP (GhcPass 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 GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (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 (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 [GenLocated SrcSpanAnnN (IdGhcP p)]
[XRec (GhcPass p) (IdP (GhcPass 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 GenLocated SrcSpanAnnN (IdGhcP p)
XRec (GhcPass p) (IdP (GhcPass p))
a) (GenLocated SrcSpanAnnN (IdGhcP p) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN GenLocated SrcSpanAnnN (IdGhcP p)
XRec (GhcPass p) (IdP (GhcPass p))
b)
(RecCon [RecordPatSynField (GhcPass p)]
r) -> (RecordPatSynField (GhcPass p) -> Scope -> Scope)
-> Scope -> [RecordPatSynField (GhcPass p)] -> Scope
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) ~ GenLocated SrcSpanAnnN (IdP pass)) =>
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 -> LocatedN RdrName
forall pass. FieldOcc pass -> LocatedN RdrName
rdrNameFieldOcc FieldOcc pass
a)) (GenLocated SrcSpanAnnN (IdP pass) -> Scope
forall a. LocatedN a -> Scope
mkLScopeN GenLocated SrcSpanAnnN (IdP pass)
XRec pass (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) = ASSERT(null ts) PrefixCon ts $ map (C Use) 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) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg
HsPatSynDir (GhcPass p)
_ -> [HieAST Type] -> HieM [HieAST Type]
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
$ HieM [HieAST Type]
node 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 (NoGhcTc p)
m_ctxt=HsMatchContext (NoGhcTc (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 (NoGhcTcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsMatchContext (NoGhcTc (GhcPass p))
HsMatchContext (GhcPass (NoGhcTcPass 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)))) ~ SrcSpan,
Data (HsLocalBinds (GhcPass p))) =>
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
]
where
node :: HieM [HieAST Type]
node = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieTc -> 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
HiePassEv p
HieRn -> 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
instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where
toHie :: HsMatchContext (GhcPass p) -> HieM [HieAST Type]
toHie (FunRhs{mc_fun :: forall p. HsMatchContext p -> LIdP p
mc_fun=LIdP (GhcPass p)
name}) = 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
MatchBind GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass p)
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 (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 (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) GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass 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 LocatedA (Pat (GhcPass p))
LPat (GhcPass p)
p
]
AsPat XAsPat (GhcPass p)
_ LIdP (GhcPass p)
lname 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 LocatedA (Pat (GhcPass p))
LPat (GhcPass p)
pat) Scope
pscope)
Maybe Span
rsp)
GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass 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 LocatedA (Pat (GhcPass p))
LPat (GhcPass p)
pat
]
ParPat XParPat (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 LocatedA (Pat (GhcPass p))
LPat (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 LocatedA (Pat (GhcPass p))
LPat (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 LocatedA (Pat (GhcPass p))
LPat (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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a b. (a -> b) -> a -> b
$ (ConLike -> Name)
-> GenLocated SrcSpanAnnN ConLike -> GenLocated SrcSpanAnnN Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConLike -> Name
conLikeName GenLocated SrcSpanAnnN ConLike
XRec (GhcPass p) (ConLikeP (GhcPass p))
con
, HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields GhcTc (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 GhcTc (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
-> HieM [HieAST Type])
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields GhcTc (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p)))
(GenLocated SrcSpanAnnA (Pat GhcTc))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcTc)))
-> HsConDetails
(TScoped (HsPatSigType (NoGhcTc (GhcPass p))))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcTc)))))
forall a.
(a ~ LPat (GhcPass p)) =>
HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p))) a (HsRecFields (GhcPass p) a)
-> HsConDetails
(TScoped (HsPatSigType (NoGhcTc (GhcPass p))))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p)))
(GenLocated SrcSpanAnnA (Pat GhcTc))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcTc)))
HsConPatDetails (GhcPass p)
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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
XRec (GhcPass p) (ConLikeP (GhcPass p))
con
, HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields GhcRn (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 GhcRn (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
-> HieM [HieAST Type])
-> HsConDetails
(TScoped (HsPatSigType GhcRn))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields GhcRn (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p)))
(GenLocated SrcSpanAnnA (Pat GhcRn))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcRn)))
-> HsConDetails
(TScoped (HsPatSigType (NoGhcTc (GhcPass p))))
(PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))
(RContext
(HsRecFields
(GhcPass p) (PScoped (GenLocated SrcSpanAnnA (Pat GhcRn)))))
forall a.
(a ~ LPat (GhcPass p)) =>
HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p))) a (HsRecFields (GhcPass p) a)
-> HsConDetails
(TScoped (HsPatSigType (NoGhcTc (GhcPass p))))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p)))
(GenLocated SrcSpanAnnA (Pat GhcRn))
(HsRecFields (GhcPass p) (GenLocated SrcSpanAnnA (Pat GhcRn)))
HsConPatDetails (GhcPass p)
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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (Pat (GhcPass p))
LPat (GhcPass p)
pat
]
SplicePat XSplicePat (GhcPass p)
_ HsSplice (GhcPass p)
sp ->
[ GenLocated SrcSpanAnnA (HsSplice (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsSplice (GhcPass p))
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsSplice (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsSplice (GhcPass p)
-> GenLocated SrcSpanAnnA (HsSplice (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
ospan HsSplice (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) GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass 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 LocatedA (Pat (GhcPass p))
LPat (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 GenLocated SrcSpanAnnA (Pat GhcTc)
LPat (GhcPass p)
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 (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
HieTc ->
let CoPat HsWrapper
wrap Pat GhcTc
pat Type
_ = XXPat (GhcPass p)
e
in [ 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)
]
#if __GLASGOW_HASKELL__ < 811
HieRn -> []
#endif
where
contextify :: a ~ LPat (GhcPass p) => HsConDetails (HsPatSigType (NoGhcTc (GhcPass p))) a (HsRecFields (GhcPass p) a)
-> HsConDetails (TScoped (HsPatSigType (NoGhcTc (GhcPass p)))) (PScoped a) (RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify :: forall a.
(a ~ LPat (GhcPass p)) =>
HsConDetails
(HsPatSigType (NoGhcTc (GhcPass p))) a (HsRecFields (GhcPass p) a)
-> HsConDetails
(TScoped (HsPatSigType (NoGhcTc (GhcPass p))))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
contextify (PrefixCon [HsPatSigType (NoGhcTc (GhcPass p))]
tyargs [a]
args) = [TScoped (HsPatSigType (GhcPass (NoGhcTcPass p)))]
-> [PScoped a]
-> HsConDetails
(TScoped (HsPatSigType (GhcPass (NoGhcTcPass p))))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a)))
forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon (Scope
-> Scope
-> [HsPatSigType (GhcPass (NoGhcTcPass p))]
-> [TScoped (HsPatSigType (GhcPass (NoGhcTcPass p)))]
forall (a :: Pass).
Scope
-> Scope
-> [HsPatSigType (GhcPass a)]
-> [TScoped (HsPatSigType (GhcPass a))]
tScopes Scope
scope Scope
argscope [HsPatSigType (NoGhcTc (GhcPass p))]
[HsPatSigType (GhcPass (NoGhcTcPass p))]
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 (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 (GhcPass (NoGhcTcPass p))))
(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 (NoGhcTc (GhcPass p))))
(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 (NoGhcTc (GhcPass p))))
(PScoped a)
(RContext (HsRecFields (GhcPass p) (PScoped a))))
-> RContext (HsRecFields (GhcPass p) (PScoped a))
-> HsConDetails
(TScoped (HsPatSigType (NoGhcTc (GhcPass p))))
(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 (Located TypeIndex)
a) = [LHsRecField (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))]
-> Maybe (Located TypeIndex)
-> HsRecFields (GhcPass p) (PScoped (LocatedA (Pat (GhcPass p))))
forall p arg.
[LHsRecField p arg]
-> Maybe (Located TypeIndex) -> HsRecFields p arg
HsRecFields ((RScoped
(LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p)))))
-> LocatedA
(HsRecField'
(FieldOcc (GhcPass p)) (PScoped (LocatedA (Pat (GhcPass p))))))
-> [RScoped
(LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p)))))]
-> [LocatedA
(HsRecField'
(FieldOcc (GhcPass p)) (PScoped (LocatedA (Pat (GhcPass p)))))]
forall a b. (a -> b) -> [a] -> [b]
map RScoped
(LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p)))))
-> LocatedA
(HsRecField'
(FieldOcc (GhcPass p)) (PScoped (LocatedA (Pat (GhcPass p)))))
forall id a1.
RScoped (LocatedA (HsRecField' id a1))
-> LocatedA (HsRecField' id (PScoped a1))
go [RScoped
(LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p)))))]
scoped_fds) Maybe (Located TypeIndex)
a
where
go :: RScoped (LocatedA (HsRecField' id a1))
-> LocatedA (HsRecField' id (PScoped a1))
go :: forall id a1.
RScoped (LocatedA (HsRecField' id a1))
-> LocatedA (HsRecField' id (PScoped a1))
go (RS Scope
fscope (L SrcSpanAnnA
spn (HsRecField XHsRecField id
x Located id
lbl a1
pat Bool
pun))) =
SrcSpanAnnA
-> HsRecField' id (PScoped a1)
-> GenLocated SrcSpanAnnA (HsRecField' id (PScoped a1))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
spn (HsRecField' id (PScoped a1)
-> GenLocated SrcSpanAnnA (HsRecField' id (PScoped a1)))
-> HsRecField' id (PScoped a1)
-> GenLocated SrcSpanAnnA (HsRecField' id (PScoped a1))
forall a b. (a -> b) -> a -> b
$ XHsRecField id
-> Located id -> PScoped a1 -> Bool -> HsRecField' id (PScoped a1)
forall id arg.
XHsRecField id -> Located id -> arg -> Bool -> HsRecField' id arg
HsRecField XHsRecField id
x Located 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
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p)))))]
scoped_fds = Scope
-> [LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p))))]
-> [RScoped
(LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p)))))]
forall a. Scope -> [LocatedA a] -> [RScoped (LocatedA a)]
listScopes Scope
pscope [LocatedA
(HsRecField' (FieldOcc (GhcPass p)) (LocatedA (Pat (GhcPass p))))]
[LHsRecField (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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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
SrcSpan (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated
SrcSpan (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))]
[LGRHS (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)))) ~ SrcSpan,
Data (HsLocalBinds (GhcPass p))) =>
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 (Located (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))) where
toHie :: Located (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
-> HieM [HieAST Type]
toHie (L SrcSpan
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
$ HieM [HieAST Type]
node 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) [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
[GuardLStmt (GhcPass p)]
guards
, LocatedA (body (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (body (GhcPass p))
body
]
where
node :: HieM [HieAST Type]
node = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
-> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
g SrcSpan
span
HiePassEv p
HieTc -> GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
-> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode GRHS (GhcPass p) (LocatedA (body (GhcPass p)))
g SrcSpan
span
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)
_ OccName
_ -> []
HsConLikeOut XConLikeOut (GhcPass p)
_ ConLike
con ->
[ 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
]
HsRecFld XRecFld (GhcPass p)
_ AmbiguousFieldOcc (GhcPass p)
fld ->
[ RFContext (GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RFContext (GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p)))
-> HieM [HieAST Type])
-> RFContext (GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RecFieldContext
-> Maybe Span
-> GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p))
-> RFContext (GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p)))
forall a. RecFieldContext -> Maybe Span -> a -> RFContext a
RFC RecFieldContext
RecFieldOcc Maybe Span
forall a. Maybe a
Nothing (SrcSpan
-> AmbiguousFieldOcc (GhcPass p)
-> GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p))
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
mspan) AmbiguousFieldOcc (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) (LocatedA (HsExpr (GhcPass p)))
MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg
]
HsLamCase XLamCase (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) (LocatedA (HsExpr (GhcPass p)))
MatchGroup (GhcPass p) (LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
b
]
HsAppType XAppTypeE (GhcPass p)
_ LHsExpr (GhcPass p)
expr LHsWcType (NoGhcTc (GhcPass p))
sig ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
, TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> HieM [HieAST Type])
-> TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p))))
-> TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p))))
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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
b
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
]
HsPar XPar (GhcPass p)
_ LHsExpr (GhcPass p)
a ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (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) (LocatedA (HsExpr (GhcPass p)))
MatchGroup (GhcPass p) (LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
b
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
c
]
HsMultiIf XMultiIf (GhcPass p)
_ [LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
grhss ->
[ [GenLocated
SrcSpan (GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated
SrcSpan (GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p))))]
[LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
grhss
]
HsLet XLet (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds 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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr) HsLocalBinds (GhcPass p)
binds
, LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
HsDo XDo (GhcPass p)
_ HsStmtContext (HsDoRn (GhcPass p))
_ (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 [LocatedA (HsExpr (GhcPass p))]
[LHsExpr (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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnN 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 :: GenLocated SrcSpanAnnN Name
con_name = case forall (p :: Pass). HiePass p => HiePassEv p
hiePass @p of
HiePassEv p
HieRn -> GenLocated SrcSpanAnnN Name
XRec (GhcPass p) (ConLikeP (GhcPass p))
con
HiePassEv p
HieTc -> (ConLike -> Name)
-> GenLocated SrcSpanAnnN ConLike -> GenLocated SrcSpanAnnN Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConLike -> Name
conLikeName GenLocated SrcSpanAnnN ConLike
XRec (GhcPass p) (ConLikeP (GhcPass p))
con
RecordUpd {rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr (GhcPass p)
expr, rupd_flds :: forall p. HsExpr p -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
rupd_flds = Left [LHsRecUpdField (GhcPass p)]
upds}->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
, [RContext
(GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RContext
(GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type])
-> [RContext
(GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p)))))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p))))
-> RContext
(GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p))))))
-> [GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p))))]
-> [RContext
(GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p)))))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p))))
-> RContext
(GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p)))))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
RecFieldAssign) [GenLocated
SrcSpanAnnA
(HsRecField'
(AmbiguousFieldOcc (GhcPass p)) (LocatedA (HsExpr (GhcPass p))))]
[LHsRecUpdField (GhcPass p)]
upds
]
RecordUpd {rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr (GhcPass p)
expr, rupd_flds :: forall p. HsExpr p -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
rupd_flds = Right [LHsRecUpdProj (GhcPass p)]
_}->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
, TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p)))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p)))))
-> HieM [HieAST Type])
-> TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p))))
-> TScoped
(HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p)))))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [LocatedA (HsExpr (GhcPass p)) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr]) LHsSigWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs
(GhcPass (NoGhcTcPass p))
(GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p))))
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 LocatedA (HsExpr (GhcPass p))
LHsExpr (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 SrcSpan (HsCmdTop (GhcPass p)) -> Scope
forall a. Located a -> Scope
mkLScope GenLocated SrcSpan (HsCmdTop (GhcPass p))
LHsCmdTop (GhcPass p)
cmdtop) Scope
NoScope GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (GhcPass p)
pat
, GenLocated SrcSpan (HsCmdTop (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpan (HsCmdTop (GhcPass p))
LHsCmdTop (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 LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
HsTick XTick (GhcPass p)
_ CoreTickish
_ LHsExpr (GhcPass p)
expr ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
HsBinTick XBinTick (GhcPass p)
_ TypeIndex
_ TypeIndex
_ LHsExpr (GhcPass p)
expr ->
[ LocatedA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
HsBracket XBracket (GhcPass p)
_ HsBracket (GhcPass p)
b ->
[ HsBracket (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsBracket (GhcPass p)
b
]
HsRnBracketOut XRnBracketOut (GhcPass p)
_ HsBracket (HsBracketRn (GhcPass p))
b [PendingRnSplice' (GhcPass p)]
p ->
[ HsBracket GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsBracket GhcRn
HsBracket (HsBracketRn (GhcPass p))
b
, [PendingRnSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingRnSplice' (GhcPass p)]
[PendingRnSplice]
p
]
HsTcBracketOut XTcBracketOut (GhcPass p)
_ Maybe QuoteWrapper
_wrap HsBracket (HsBracketRn (GhcPass p))
b [PendingTcSplice' (GhcPass p)]
p ->
[ HsBracket GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsBracket GhcRn
HsBracket (HsBracketRn (GhcPass p))
b
, [PendingTcSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingTcSplice' (GhcPass p)]
[PendingTcSplice]
p
]
HsSpliceE XSpliceE (GhcPass p)
_ HsSplice (GhcPass p)
x ->
[ GenLocated SrcSpanAnnA (HsSplice (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsSplice (GhcPass p))
-> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsSplice (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsSplice (GhcPass p)
-> GenLocated SrcSpanAnnA (HsSplice (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan HsSplice (GhcPass p)
x
]
HsGetField {} -> []
HsProjection {} -> []
XExpr XXExpr (GhcPass p)
x
| GhcPass p
GhcTc <- forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p
, WrapExpr (HsWrap HsWrapper
w HsExpr GhcTc
a) <- XXExpr (GhcPass p)
x
-> [ LocatedA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (LocatedA (HsExpr GhcTc) -> HieM [HieAST Type])
-> LocatedA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> HsExpr GhcTc -> LocatedA (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)
]
| GhcPass p
GhcTc <- forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p
, ExpansionExpr (HsExpanded HsExpr GhcRn
_ HsExpr GhcTc
b) <- XXExpr (GhcPass p)
x
-> [ LocatedA (HsExpr GhcTc) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpanAnnA -> HsExpr GhcTc -> LocatedA (HsExpr GhcTc)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mspan HsExpr GhcTc
b)
]
| 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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (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 GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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 [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
[ExprLStmt (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 [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
[ExprLStmt (GhcPass p)]
stmts
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
using
, Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
Maybe (LHsExpr (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).
Data (HsLocalBinds (GhcPass p)) =>
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).
Data (HsLocalBinds (GhcPass p)) =>
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 (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) [GenLocated SrcSpanAnnA (IPBind (GhcPass p))]
[LIPBind (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 (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 Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
LHsBindsLR (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) [GenLocated SrcSpanAnnA (Sig (GhcPass p))]
[LSig (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 (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,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))]
[(RecFlag, LHsBindsLR (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) [GenLocated SrcSpanAnnA (Sig GhcRn)]
[LSig GhcRn]
sigs
scopeHsLocaLBinds (HsIPBinds XHsIPBinds (GhcPass p) (GhcPass p)
_ (IPBinds XIPBinds (GhcPass p)
_ [LIPBind (GhcPass p)]
bs))
= (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
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) [GenLocated SrcSpanAnnA (IPBind (GhcPass p))]
[LIPBind (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 IPBind (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
$ 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 IPBind (GhcPass p)
bind of
IPBind XCIPBind (GhcPass p)
_ (Left XRec (GhcPass p) HsIPName
_) LHsExpr (GhcPass p)
expr -> [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr]
IPBind XCIPBind (GhcPass p)
_ (Right IdP (GhcPass p)
v) LHsExpr (GhcPass p)
expr ->
[ 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 (EvVarSource -> Scope -> Maybe Span -> ContextInfo
EvidenceVarBind EvVarSource
EvImplicitBind Scope
scope (SrcSpanAnnA -> Maybe Span
forall ann. SrcSpanAnn' ann -> Maybe Span
getRealSpanA SrcSpanAnnA
sp))
(GenLocated SrcSpanAnnA (IdGhcP p)
-> Context (GenLocated SrcSpanAnnA (IdGhcP p)))
-> GenLocated SrcSpanAnnA (IdGhcP p)
-> Context (GenLocated SrcSpanAnnA (IdGhcP p))
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> IdGhcP p -> GenLocated SrcSpanAnnA (IdGhcP p)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
sp IdP (GhcPass p)
IdGhcP p
v
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
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 (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) Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p)))
LHsBindsLR (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 (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)) [GenLocated SrcSpanAnnA (Sig (GhcPass p))]
[LSig (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,
Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))))]
[(RecFlag, LHsBinds (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 (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)) [GenLocated SrcSpanAnnA (Sig GhcRn)]
[LSig 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 (Located TypeIndex)
_)) = [RContext
(GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RContext
(GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg))]
-> HieM [HieAST Type])
-> [RContext
(GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg)
-> RContext
(GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg)))
-> [GenLocated
SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg)]
-> [RContext
(GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg)
-> RContext
(GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
c) [GenLocated SrcSpanAnnA (HsRecField' (FieldOcc (GhcPass p)) arg)]
[LHsRecField (GhcPass p) arg]
fields
instance ( ToHie (RFContext (Located label))
, ToHie arg, HasLoc arg, Data arg
, Data label
) => ToHie (RContext (LocatedA (HsRecField' label arg))) where
toHie :: RContext (LocatedA (HsRecField' label arg)) -> HieM [HieAST Type]
toHie (RC RecFieldContext
c (L SrcSpanAnnA
span HsRecField' 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
$ HsRecField' label arg -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsRecField' 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 HsRecField' label arg
recfld of
HsRecField XHsRecField label
_ Located label
label arg
expr Bool
_ ->
[ RFContext (Located label) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RFContext (Located label) -> HieM [HieAST Type])
-> RFContext (Located label) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ RecFieldContext
-> Maybe Span -> Located label -> RFContext (Located 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) Located label
label
, arg -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie arg
expr
]
instance ToHie (RFContext (Located (FieldOcc GhcRn))) where
toHie :: RFContext (Located (FieldOcc GhcRn)) -> HieM [HieAST Type]
toHie (RFC RecFieldContext
c Maybe Span
rhs (L SrcSpan
nspan FieldOcc GhcRn
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 GhcRn
f of
FieldOcc XCFieldOcc GhcRn
name LocatedN RdrName
_ ->
[ 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 SrcSpan
nspan Name
XCFieldOcc GhcRn
name)
]
instance ToHie (RFContext (Located (FieldOcc GhcTc))) where
toHie :: RFContext (Located (FieldOcc GhcTc)) -> HieM [HieAST Type]
toHie (RFC RecFieldContext
c Maybe Span
rhs (L SrcSpan
nspan FieldOcc GhcTc
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 GhcTc
f of
FieldOcc XCFieldOcc GhcTc
var LocatedN RdrName
_ ->
[ 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 SrcSpan
nspan Id
XCFieldOcc GhcTc
var)
]
instance ToHie (RFContext (Located (AmbiguousFieldOcc GhcRn))) where
toHie :: RFContext (Located (AmbiguousFieldOcc GhcRn)) -> HieM [HieAST Type]
toHie (RFC RecFieldContext
c Maybe Span
rhs (L SrcSpan
nspan AmbiguousFieldOcc GhcRn
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 GhcRn
afo of
Unambiguous XUnambiguous GhcRn
name LocatedN RdrName
_ ->
[ 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 SrcSpan
nspan Name
XUnambiguous GhcRn
name
]
Ambiguous XAmbiguous GhcRn
_name LocatedN RdrName
_ ->
[ ]
instance ToHie (RFContext (Located (AmbiguousFieldOcc GhcTc))) where
toHie :: RFContext (Located (AmbiguousFieldOcc GhcTc)) -> HieM [HieAST Type]
toHie (RFC RecFieldContext
c Maybe Span
rhs (L SrcSpan
nspan AmbiguousFieldOcc GhcTc
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 GhcTc
afo of
Unambiguous XUnambiguous GhcTc
var LocatedN RdrName
_ ->
[ 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 SrcSpan
nspan Id
XUnambiguous GhcTc
var)
]
Ambiguous XAmbiguous GhcTc
var LocatedN RdrName
_ ->
[ 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 SrcSpan
nspan Id
XAmbiguous GhcTc
var)
]
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 GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (GhcPass p)
pat
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
toHie (RS Scope
sc (ApplicativeArgMany XApplicativeArgMany (GhcPass p)
_ [ExprLStmt (GhcPass p)]
stmts HsExpr (GhcPass p)
_ LPat (GhcPass p)
pat HsStmtContext (ApplicativeArgStmCtxPass (GhcPass p))
_)) = [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 [LocatedA
(StmtLR
(GhcPass p)
(GhcPass p)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
[ExprLStmt (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 GenLocated SrcSpanAnnA (Pat (GhcPass p))
LPat (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 (GenLocated SrcSpanAnnA (HsType GhcRn))]
[HsScaled GhcRn (LHsType GhcRn)]
args
toHie (RecConGADT XRec GhcRn [LConDeclField GhcRn]
rec) = GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
XRec GhcRn [LConDeclField GhcRn]
rec
instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where
toHie :: Located (HsCmdTop (GhcPass p)) -> HieM [HieAST Type]
toHie (L SrcSpan
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) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsCmdTop (GhcPass p)
top SrcSpan
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 GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
LHsCmd (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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, [GenLocated SrcSpan (HsCmdTop (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpan (HsCmdTop (GhcPass p))]
[LHsCmdTop (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 LocatedA (HsCmd (GhcPass p))
LHsCmd (GhcPass p)
a
, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (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) (LocatedA (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
mg
]
HsCmdPar XCmdPar (GhcPass p)
_ LHsCmd (GhcPass p)
a ->
[ LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsCmd (GhcPass p))
LHsCmd (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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (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) (LocatedA (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
alts
]
HsCmdLamCase XCmdLamCase (GhcPass p)
_ 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) (LocatedA (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (LHsCmd (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 GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
a
, LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsCmd (GhcPass p))
LHsCmd (GhcPass p)
b
, LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsCmd (GhcPass p))
LHsCmd (GhcPass p)
c
]
HsCmdLet XCmdLet (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds 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 LocatedA (HsCmd (GhcPass p))
LHsCmd (GhcPass p)
cmd') HsLocalBinds (GhcPass p)
binds
, LocatedA (HsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsCmd (GhcPass p))
LHsCmd (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 [GenLocated SrcSpanAnnA (TyClDecl GhcRn)]
[LTyClDecl GhcRn]
classes
, [GenLocated SrcSpanAnnA (StandaloneKindSig GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (StandaloneKindSig GhcRn)]
[LStandaloneKindSig GhcRn]
sigs
, [GenLocated SrcSpanAnnA (RoleAnnotDecl GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (RoleAnnotDecl GhcRn)]
[LRoleAnnotDecl GhcRn]
roles
, [GenLocated SrcSpanAnnA (InstDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (InstDecl GhcRn)]
[LInstDecl 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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
typ]) LHsQTyVars GhcRn
vars
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 -> [Scope] -> Scope
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 SrcSpanAnnA (ConDecl GhcRn) -> Scope)
-> [GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (ConDecl GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA ([GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> [Scope])
-> [GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> [Scope]
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> [LConDecl GhcRn]
forall pass. HsDataDefn pass -> [LConDecl pass]
dd_cons HsDataDefn GhcRn
defn
deriv_sc :: Scope
deriv_sc = (Scope -> Scope -> Scope) -> Scope -> [Scope] -> Scope
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
$ (Located (HsDerivingClause GhcRn) -> Scope)
-> [Located (HsDerivingClause GhcRn)] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map Located (HsDerivingClause GhcRn) -> Scope
forall a. Located a -> Scope
mkLScope ([Located (HsDerivingClause GhcRn)] -> [Scope])
-> [Located (HsDerivingClause GhcRn)] -> [Scope]
forall a b. (a -> b) -> a -> 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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
name
, Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext 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 [GenLocated SrcSpanAnnA (FunDep GhcRn)]
[LHsFunDep 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) [GenLocated SrcSpanAnnA (Sig GhcRn)]
[LSig 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 (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))
LHsBinds GhcRn
meths
, [GenLocated SrcSpanAnnA (FamilyDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (FamilyDecl GhcRn)]
[XRec GhcRn (FamilyDecl GhcRn)]
typs
, (GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)
-> HieM [HieAST Type])
-> [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall (m :: * -> *) a b. Monad m => (a -> m [b]) -> [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)]
[LTyFamDefltDecl GhcRn]
deftyps
, [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
[LTyFamDefltDecl 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
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext GhcRn)
context
rhs_scope :: Scope
rhs_scope = (Scope -> Scope -> Scope) -> [Scope] -> Scope
forall a. (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 [GenLocated SrcSpanAnnA (FunDep GhcRn)]
[LHsFunDep GhcRn]
deps, [GenLocated SrcSpanAnnA (Sig GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [GenLocated SrcSpanAnnA (Sig GhcRn)]
[LSig 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 Bag (GenLocated SrcSpanAnnA (HsBind GhcRn))
LHsBinds GhcRn
meths), [GenLocated SrcSpanAnnA (FamilyDecl GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [GenLocated SrcSpanAnnA (FamilyDecl GhcRn)]
[XRec GhcRn (FamilyDecl GhcRn)]
typs, [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [GenLocated SrcSpanAnnA (TyFamInstDecl GhcRn)]
[LTyFamDefltDecl 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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 SrcSpan (FamilyResultSig GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (GenLocated SrcSpan (FamilyResultSig GhcRn))
-> HieM [HieAST Type])
-> RScoped (GenLocated SrcSpan (FamilyResultSig GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> GenLocated SrcSpan (FamilyResultSig GhcRn)
-> RScoped (GenLocated SrcSpan (FamilyResultSig GhcRn))
forall a. Scope -> a -> RScoped a
RS Scope
injSpan GenLocated SrcSpan (FamilyResultSig GhcRn)
LFamilyResultSig GhcRn
sig
, Maybe (GenLocated SrcSpan (InjectivityAnn GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (GenLocated SrcSpan (InjectivityAnn GhcRn))
Maybe (LInjectivityAnn 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 SrcSpan (FamilyResultSig GhcRn) -> SrcSpan
forall l e. GenLocated l e -> l
getLoc GenLocated SrcSpan (FamilyResultSig GhcRn)
LFamilyResultSig GhcRn
sig
injSpan :: Scope
injSpan = Scope
-> (GenLocated SrcSpan (InjectivityAnn GhcRn) -> Scope)
-> Maybe (GenLocated SrcSpan (InjectivityAnn GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope (SrcSpan -> Scope
mkScope (SrcSpan -> Scope)
-> (GenLocated SrcSpan (InjectivityAnn GhcRn) -> SrcSpan)
-> GenLocated SrcSpan (InjectivityAnn GhcRn)
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpan (InjectivityAnn GhcRn) -> SrcSpan
forall l e. GenLocated l e -> l
getLoc) Maybe (GenLocated SrcSpan (InjectivityAnn GhcRn))
Maybe (LInjectivityAnn 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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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) [GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
[LTyFamInstEqn 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 [GenLocated
SrcSpanAnnA (FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))]
[LTyFamInstEqn 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 (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (RScoped (Located (FamilyResultSig GhcRn))) where
toHie :: RScoped (GenLocated SrcSpan (FamilyResultSig GhcRn))
-> HieM [HieAST Type]
toHie (RS Scope
sc (L SrcSpan
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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode FamilyResultSig GhcRn
sig SrcSpan
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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)
LHsTyVarBndr () 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 (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN Name]
[LIdP GhcRn]
lhs
, [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN Name]
[LIdP GhcRn]
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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [HsArg
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
HsTyPats 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
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
-> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [HsArg
(GenLocated SrcSpanAnnA (HsType GhcRn))
(GenLocated SrcSpanAnnA (HsType GhcRn))]
HsTyPats GhcRn
pats)
rhsScope :: Scope
rhsScope = SrcSpan -> Scope
mkScope (rhs -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc rhs
rhs)
instance ToHie (Located (InjectivityAnn GhcRn)) where
toHie :: GenLocated SrcSpan (InjectivityAnn GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpan
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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode InjectivityAnn GhcRn
ann SrcSpan
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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
lhs
, [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN Name]
[LIdP GhcRn]
rhs
]
instance ToHie (HsDataDefn GhcRn) where
toHie :: HsDataDefn GhcRn -> HieM [HieAST Type]
toHie (HsDataDefn XCHsDataDefn GhcRn
_ NewOrData
_ Maybe (LHsContext GhcRn)
ctx Maybe (XRec GhcRn CType)
_ Maybe (LHsType GhcRn)
mkind [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
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext GhcRn)
ctx
, Maybe (GenLocated SrcSpanAnnA (HsType GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (GenLocated SrcSpanAnnA (HsType GhcRn))
Maybe (LHsType GhcRn)
mkind
, [GenLocated SrcSpanAnnA (ConDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (ConDecl GhcRn)]
[LConDecl GhcRn]
cons
, [Located (HsDerivingClause GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [Located (HsDerivingClause GhcRn)]
HsDeriving GhcRn
derivs
]
instance ToHie (Located [Located (HsDerivingClause GhcRn)]) where
toHie :: Located [Located (HsDerivingClause GhcRn)] -> HieM [HieAST Type]
toHie (L SrcSpan
span [Located (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
, [Located (HsDerivingClause GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [Located (HsDerivingClause GhcRn)]
clauses
]
instance ToHie (Located (HsDerivingClause GhcRn)) where
toHie :: Located (HsDerivingClause GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpan
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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsDerivingClause GhcRn
cl SrcSpan
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 (GenLocated SrcSpan (DerivStrategy GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (GenLocated SrcSpan (DerivStrategy GhcRn))
Maybe (LDerivStrategy GhcRn)
strat
, GenLocated SrcSpanAnnC (DerivClauseTys GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnC (DerivClauseTys GhcRn)
LDerivClauseTys 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 []) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType 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 [])) [GenLocated SrcSpanAnnA (HsSigType GhcRn)]
[LHsSigType GhcRn]
tys ]
instance ToHie (Located (DerivStrategy GhcRn)) where
toHie :: GenLocated SrcSpan (DerivStrategy GhcRn) -> HieM [HieAST Type]
toHie (L SrcSpan
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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode DerivStrategy GhcRn
strat SrcSpan
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 []) GenLocated SrcSpanAnnA (HsSigType GhcRn)
XViaStrategy 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 -> [LIdP pass]
con_names = [LIdP GhcRn]
names, con_bndrs :: forall pass. ConDecl pass -> XRec pass (HsOuterSigTyVarBndrs pass)
con_bndrs = L SrcSpanAnnA
outer_bndrs_loc HsOuterTyVarBndrs Specificity 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 } ->
[ [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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)) [GenLocated SrcSpanAnnN Name]
[LIdP GhcRn]
names
, case HsOuterTyVarBndrs Specificity 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
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext 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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
typ
]
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
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext 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 -> GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
XRec GhcRn [LConDeclField GhcRn]
x
tyScope :: Scope
tyScope = GenLocated SrcSpanAnnA (HsType GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 } ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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)) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext 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 HsConDetails
Void
(HsScaled GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn)))
(GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
HsConDeclH98Details GhcRn
dets
]
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
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext 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 GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
XRec GhcRn [LConDeclField 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 (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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 []) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType 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 (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 (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl) [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
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 ((GenLocated SrcSpanAnnN Name -> Name)
-> [GenLocated SrcSpanAnnN Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnN Name -> Name
forall l e. GenLocated l e -> e
unLoc [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
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 (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl) [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
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 ((GenLocated SrcSpanAnnN Name -> Name)
-> [GenLocated SrcSpanAnnN Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnN Name -> Name
forall l e. GenLocated l e -> e
unLoc [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
names) Maybe Span
forall a. Maybe a
Nothing) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType (GhcPass p)
typ
]
ClassOpSig XClassOpSig (GhcPass p)
_ Bool
_ [LIdP (GhcPass p)]
names LHsSigType (GhcPass p)
typ ->
[ case SigType
styp of
SigType
ClassSig -> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
names
SigType
_ -> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a b. (a -> b) -> a -> b
$ ContextInfo
TyDecl) [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
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 ((GenLocated SrcSpanAnnN Name -> Name)
-> [GenLocated SrcSpanAnnN Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnN Name -> Name
forall l e. GenLocated l e -> e
unLoc [GenLocated SrcSpanAnnN Name]
[LIdP (GhcPass p)]
names) Maybe Span
msp) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType (GhcPass p)
typ
]
IdSig XIdSig (GhcPass p)
_ Id
_ -> []
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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) GenLocated SrcSpanAnnN Name
LIdP (GhcPass p)
name
]
SpecSig XSpecSig (GhcPass p)
_ LIdP (GhcPass p)
name [LHsSigType (GhcPass p)]
typs InlinePragma
_ ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) GenLocated SrcSpanAnnN Name
LIdP (GhcPass p)
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 [])) [GenLocated SrcSpanAnnA (HsSigType GhcRn)]
[LHsSigType (GhcPass p)]
typs
]
SpecInstSig XSpecInstSig (GhcPass p)
_ SourceText
_ 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 []) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType (GhcPass p)
typ
]
MinimalSig XMinimalSig (GhcPass p)
_ SourceText
_ LBooleanFormula (LIdP (GhcPass p))
form ->
[ LBooleanFormula (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LBooleanFormula (GenLocated SrcSpanAnnN Name)
LBooleanFormula (LIdP (GhcPass p))
form
]
SCCFunSig XSCCFunSig (GhcPass p)
_ SourceText
_ LIdP (GhcPass p)
name Maybe (XRec (GhcPass p) StringLiteral)
mtxt ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) GenLocated SrcSpanAnnN Name
LIdP (GhcPass p)
name
, HieM [HieAST Type]
-> (GenLocated SrcSpan StringLiteral -> HieM [HieAST Type])
-> Maybe (GenLocated SrcSpan StringLiteral)
-> HieM [HieAST Type]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([HieAST Type] -> HieM [HieAST Type]
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 SrcSpan StringLiteral -> SrcSpan)
-> GenLocated SrcSpan StringLiteral
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpan StringLiteral -> SrcSpan
forall l e. GenLocated l e -> l
getLoc) Maybe (GenLocated SrcSpan StringLiteral)
Maybe (XRec (GhcPass p) StringLiteral)
mtxt
]
CompleteMatchSig XCompleteMatchSig (GhcPass p)
_ SourceText
_ (L SrcSpan
ispan [GenLocated SrcSpanAnnN 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 (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN Name]
names
, Maybe (Context (GenLocated SrcSpanAnnN Name)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (Context (GenLocated SrcSpanAnnN Name))
-> HieM [HieAST Type])
-> Maybe (Context (GenLocated SrcSpanAnnN Name))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> Maybe (GenLocated SrcSpanAnnN Name)
-> Maybe (Context (GenLocated SrcSpanAnnN Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) Maybe (GenLocated SrcSpanAnnN Name)
Maybe (LIdP (GhcPass p))
typ
]
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=HsOuterTyVarBndrs Specificity 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 (HsOuterTyVarBndrs Specificity GhcRn)
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TyVarScope
-> Scope
-> HsOuterTyVarBndrs Specificity GhcRn
-> TVScoped (HsOuterTyVarBndrs Specificity GhcRn)
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS TyVarScope
tsc (SrcSpanAnnA -> Scope
forall ann. SrcSpanAnn' ann -> Scope
mkScopeA SrcSpanAnnA
span) HsOuterTyVarBndrs Specificity GhcRn
bndrs)
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
body
]
HsQualTy XQualTy GhcRn
_ Maybe (LHsContext GhcRn)
ctx LHsType GhcRn
body ->
[ Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe
(GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcRn)])
Maybe (LHsContext GhcRn)
ctx
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
body
]
HsTyVar XTyVar GhcRn
_ PromotionFlag
_ LIdP GhcRn
var ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
a
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
b
]
HsAppKindTy XAppKindTy GhcRn
_ LHsType GhcRn
ty LHsType GhcRn
ki ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
ty
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
a
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
b
]
HsListTy XListTy GhcRn
_ LHsType GhcRn
a ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 [GenLocated SrcSpanAnnA (HsType GhcRn)]
[LHsType GhcRn]
tys
]
HsSumTy XSumTy GhcRn
_ [LHsType GhcRn]
tys ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (HsType GhcRn)]
[LHsType GhcRn]
tys
]
HsOpTy XOpTy GhcRn
_ 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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
a
, Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
op
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
b
]
HsParTy XParTy GhcRn
_ LHsType GhcRn
a ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
a
]
HsIParamTy XIParamTy GhcRn
_ XRec GhcRn HsIPName
ip LHsType GhcRn
ty ->
[ GenLocated SrcSpan HsIPName -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpan HsIPName
XRec GhcRn HsIPName
ip
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType 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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
a
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
b
]
HsSpliceTy XSpliceTy GhcRn
_ HsSplice GhcRn
a ->
[ GenLocated SrcSpanAnnA (HsSplice GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpanAnnA (HsSplice GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpanAnnA (HsSplice GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA
-> HsSplice GhcRn -> GenLocated SrcSpanAnnA (HsSplice GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
span HsSplice GhcRn
a
]
HsDocTy XDocTy GhcRn
_ LHsType GhcRn
a LHsDocString
_ ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
a
]
HsBangTy XBangTy GhcRn
_ HsSrcBang
_ LHsType GhcRn
ty ->
[ GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
ty
]
HsRecTy XRecTy GhcRn
_ [LConDeclField GhcRn]
fields ->
[ [GenLocated SrcSpanAnnA (ConDeclField GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
[LConDeclField 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 [GenLocated SrcSpanAnnA (HsType GhcRn)]
[LHsType GhcRn]
tys
]
HsExplicitTupleTy XExplicitTupleTy GhcRn
_ [LHsType GhcRn]
tys ->
[ [GenLocated SrcSpanAnnA (HsType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (HsType GhcRn)]
[LHsType GhcRn]
tys
]
HsTyLit XTyLit GhcRn
_ HsTyLit
_ -> []
HsWildCardTy XWildCardTy GhcRn
_ -> []
HsStarTy XStarTy GhcRn
_ Bool
_ -> []
XHsType XXType GhcRn
_ -> []
instance (ToHie tm, ToHie ty) => ToHie (HsArg tm ty) where
toHie :: HsArg 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 SrcSpan
_ 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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) GenLocated SrcSpanAnnN Name
LIdP GhcRn
var
]
KindedTyVar XKindedTyVar GhcRn
_ flag
_ LIdP GhcRn
var LHsType GhcRn
kind ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) GenLocated SrcSpanAnnN Name
LIdP GhcRn
var
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
kind
]
instance ToHie (TScoped (LHsQTyVars GhcRn)) where
toHie :: TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
toHie (TS TyVarScope
sc (HsQTvs XHsQTvs GhcRn
implicits [LHsTyVarBndr () 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 () 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 TyVarScope
sc Scope
NoScope [LHsTyVarBndr () GhcRn]
vars
]
where
varLoc :: SrcSpan
varLoc = [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)]
[LHsTyVarBndr () 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 LHsDocString
_ ->
[ [RFContext (Located (FieldOcc GhcRn))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RFContext (Located (FieldOcc GhcRn))] -> HieM [HieAST Type])
-> [RFContext (Located (FieldOcc GhcRn))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located (FieldOcc GhcRn) -> RFContext (Located (FieldOcc GhcRn)))
-> [Located (FieldOcc GhcRn)]
-> [RFContext (Located (FieldOcc GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> Maybe Span
-> Located (FieldOcc GhcRn)
-> RFContext (Located (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 GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
typ)) [Located (FieldOcc GhcRn)]
[LFieldOcc GhcRn]
fields
, GenLocated SrcSpanAnnA (HsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsType GhcRn)
LHsType GhcRn
typ
]
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 (HsSplice GhcRn)
splice SpliceExplicitFlag
_ ->
[ GenLocated SrcSpanAnnA (HsSplice GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsSplice GhcRn)
XRec GhcRn (HsSplice GhcRn)
splice
]
instance ToHie (HsBracket a) where
toHie :: HsBracket a -> HieM [HieAST Type]
toHie HsBracket a
_ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie PendingRnSplice where
toHie :: PendingRnSplice -> HieM [HieAST Type]
toHie PendingRnSplice
_ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie PendingTcSplice where
toHie :: PendingTcSplice -> HieM [HieAST Type]
toHie PendingTcSplice
_ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LBooleanFormula (LocatedN Name)) where
toHie :: LBooleanFormula (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
toHie (L SrcSpanAnnL
span BooleanFormula (GenLocated SrcSpanAnnN 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 (GenLocated SrcSpanAnnN Name)
-> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode BooleanFormula (GenLocated SrcSpanAnnN 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 (GenLocated SrcSpanAnnN Name)
form of
Var GenLocated SrcSpanAnnN Name
a ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
a
]
And [LBooleanFormula (GenLocated SrcSpanAnnN Name)]
forms ->
[ [LBooleanFormula (GenLocated SrcSpanAnnN Name)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LBooleanFormula (GenLocated SrcSpanAnnN Name)]
forms
]
Or [LBooleanFormula (GenLocated SrcSpanAnnN Name)]
forms ->
[ [LBooleanFormula (GenLocated SrcSpanAnnN Name)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LBooleanFormula (GenLocated SrcSpanAnnN Name)]
forms
]
Parens LBooleanFormula (GenLocated SrcSpanAnnN Name)
f ->
[ LBooleanFormula (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LBooleanFormula (GenLocated SrcSpanAnnN Name)
f
]
instance ToHie (Located HsIPName) where
toHie :: GenLocated SrcSpan HsIPName -> HieM [HieAST Type]
toHie (L SrcSpan
span HsIPName
e) = HsIPName -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode HsIPName
e SrcSpan
span
instance HiePass p => ToHie (LocatedA (HsSplice (GhcPass p))) where
toHie :: LocatedA (HsSplice (GhcPass p)) -> HieM [HieAST Type]
toHie (L SrcSpanAnnA
span HsSplice (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
$ HsSplice (GhcPass p) -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA HsSplice (GhcPass p)
sp SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsSplice (GhcPass p)
sp of
HsTypedSplice XTypedSplice (GhcPass p)
_ SpliceDecoration
_ IdP (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
HsUntypedSplice XUntypedSplice (GhcPass p)
_ SpliceDecoration
_ IdP (GhcPass p)
_ LHsExpr (GhcPass p)
expr ->
[ GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
LHsExpr (GhcPass p)
expr
]
HsQuasiQuote XQuasiQuote (GhcPass p)
_ IdP (GhcPass p)
_ IdP (GhcPass p)
_ SrcSpan
ispan FastString
_ ->
[ SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a.
Monad m =>
SrcSpan -> ReaderT NodeOrigin m [HieAST a]
locOnly SrcSpan
ispan
]
HsSpliced XSpliced (GhcPass p)
_ ThModFinalizers
_ HsSplicedThing (GhcPass p)
_ ->
[]
XSplice XXSplice (GhcPass p)
x -> case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 811
GhcPs -> noExtCon x
GhcRn -> noExtCon x
#endif
GhcPass p
GhcTc -> case XXSplice (GhcPass p)
x of
HsSplicedT DelayedSplice
_ -> []
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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
var
, (GenLocated SrcSpan (Maybe Role) -> HieM [HieAST Type])
-> [GenLocated SrcSpan (Maybe Role)] -> HieM [HieAST Type]
forall (m :: * -> *) a b. Monad m => (a -> m [b]) -> [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 SrcSpan (Maybe Role) -> SrcSpan)
-> GenLocated SrcSpan (Maybe Role)
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpan (Maybe Role) -> SrcSpan
forall l e. GenLocated l e -> l
getLoc) [GenLocated SrcSpan (Maybe Role)]
[XRec GhcRn (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 (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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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 :: * -> *) a b. Monad m => (a -> m [b]) -> [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]) FamEqn GhcRn (GenLocated SrcSpanAnnA (HsType GhcRn))
TyFamInstEqn 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 Id
XCFieldOcc (GhcPass p)
n))
HiePassEv p
HieRn -> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
c (SrcSpanAnnN -> Name -> GenLocated SrcSpanAnnN Name
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l Name
XCFieldOcc (GhcPass p)
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 GenLocated SrcSpanAnnN (IdGhcP p)
LIdP (GhcPass 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 []) HsWildCardBndrs GhcRn (GenLocated SrcSpanAnnA (HsSigType GhcRn))
LHsSigWcType GhcRn
typ
, Maybe (GenLocated SrcSpan (DerivStrategy GhcRn))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (GenLocated SrcSpan (DerivStrategy GhcRn))
Maybe (LDerivStrategy GhcRn)
strat
, Maybe (LocatedP OverlapMode) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LocatedP OverlapMode)
Maybe (XRec GhcRn 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 (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN Name]
[LIdP GhcRn]
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 [GenLocated SrcSpanAnnA (HsType GhcRn)]
[LHsType 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
fd_fi = ForeignImport
fi} ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 []) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType GhcRn
sig
, ForeignImport -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ForeignImport
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
fd_fe = ForeignExport
fe} ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
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 []) GenLocated SrcSpanAnnA (HsSigType GhcRn)
LHsSigType GhcRn
sig
, ForeignExport -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ForeignExport
fe
]
instance ToHie ForeignImport where
toHie :: ForeignImport -> HieM [HieAST Type]
toHie (CImport (L SrcSpan
a CCallConv
_) (L SrcSpan
b Safety
_) Maybe Header
_ CImportSpec
_ (L SrcSpan
c SourceText
_)) = [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 where
toHie :: ForeignExport -> HieM [HieAST Type]
toHie (CExport (L SrcSpan
a CExportSpec
_) (L SrcSpan
b SourceText
_)) = [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
_ SourceText
_ [LWarnDecl GhcRn]
warnings ->
[ [GenLocated SrcSpanAnnA (WarnDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (WarnDecl GhcRn)]
[LWarnDecl 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
_ ->
[ [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type])
-> [Context (GenLocated SrcSpanAnnN Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name))
-> [GenLocated SrcSpanAnnN Name]
-> [Context (GenLocated SrcSpanAnnN Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [GenLocated SrcSpanAnnN Name]
[LIdP GhcRn]
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
_ SourceText
_ AnnProvenance GhcRn
prov XRec GhcRn (HsExpr 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 LocatedA (HsExpr GhcRn)
XRec GhcRn (HsExpr GhcRn)
expr
]
instance ToHie (AnnProvenance GhcRn) where
toHie :: AnnProvenance GhcRn -> HieM [HieAST Type]
toHie (ValueAnnProvenance LIdP GhcRn
a) = Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
a
toHie (TypeAnnProvenance LIdP GhcRn
a) = Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpanAnnN Name
LIdP GhcRn
a
toHie AnnProvenance GhcRn
ModuleAnnProvenance = [HieAST Type] -> HieM [HieAST Type]
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
_ SourceText
_ [LRuleDecl GhcRn]
rules ->
[ [GenLocated SrcSpanAnnA (RuleDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpanAnnA (RuleDecl GhcRn)]
[LRuleDecl 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 (SourceText, FastString)
rname Activation
_ Maybe [LHsTyVarBndr () (NoGhcTc GhcRn)]
tybndrs [LRuleBndr GhcRn]
bndrs XRec GhcRn (HsExpr GhcRn)
exprA XRec GhcRn (HsExpr 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 SrcSpan (SourceText, FastString) -> SrcSpan
forall l e. GenLocated l e -> l
getLoc GenLocated SrcSpan (SourceText, FastString)
XRec GhcRn (SourceText, 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 (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 [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcRn)]
Maybe [LHsTyVarBndr () (NoGhcTc GhcRn)]
tybndrs
, [RScoped (GenLocated SrcSpan (RuleBndr GhcRn))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (GenLocated SrcSpan (RuleBndr GhcRn))]
-> HieM [HieAST Type])
-> [RScoped (GenLocated SrcSpan (RuleBndr GhcRn))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (GenLocated SrcSpan (RuleBndr GhcRn)
-> RScoped (GenLocated SrcSpan (RuleBndr GhcRn)))
-> [GenLocated SrcSpan (RuleBndr GhcRn)]
-> [RScoped (GenLocated SrcSpan (RuleBndr GhcRn))]
forall a b. (a -> b) -> [a] -> [b]
map (Scope
-> GenLocated SrcSpan (RuleBndr GhcRn)
-> RScoped (GenLocated SrcSpan (RuleBndr GhcRn))
forall a. Scope -> a -> RScoped a
RS (Scope
-> GenLocated SrcSpan (RuleBndr GhcRn)
-> RScoped (GenLocated SrcSpan (RuleBndr GhcRn)))
-> Scope
-> GenLocated SrcSpan (RuleBndr GhcRn)
-> RScoped (GenLocated SrcSpan (RuleBndr GhcRn))
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Scope
mkScope (SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
span)) [GenLocated SrcSpan (RuleBndr GhcRn)]
[LRuleBndr GhcRn]
bndrs
, LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr GhcRn)
XRec GhcRn (HsExpr GhcRn)
exprA
, LocatedA (HsExpr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LocatedA (HsExpr GhcRn)
XRec GhcRn (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 SrcSpan (RuleBndr GhcRn) -> Scope)
-> Maybe (GenLocated SrcSpan (RuleBndr GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope GenLocated SrcSpan (RuleBndr GhcRn) -> Scope
forall a. Located a -> Scope
mkLScope ([GenLocated SrcSpan (RuleBndr GhcRn)]
-> Maybe (GenLocated SrcSpan (RuleBndr GhcRn))
forall a. [a] -> Maybe a
listToMaybe [GenLocated SrcSpan (RuleBndr GhcRn)]
[LRuleBndr GhcRn]
bndrs)
exprA_sc :: Scope
exprA_sc = LocatedA (HsExpr GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LocatedA (HsExpr GhcRn)
XRec GhcRn (HsExpr GhcRn)
exprA
exprB_sc :: Scope
exprB_sc = LocatedA (HsExpr GhcRn) -> Scope
forall a e. GenLocated (SrcSpanAnn' a) e -> Scope
mkLScopeA LocatedA (HsExpr GhcRn)
XRec GhcRn (HsExpr GhcRn)
exprB
instance ToHie (RScoped (Located (RuleBndr GhcRn))) where
toHie :: RScoped (GenLocated SrcSpan (RuleBndr GhcRn)) -> HieM [HieAST Type]
toHie (RS Scope
sc (L SrcSpan
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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode RuleBndr GhcRn
bndr SrcSpan
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 (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
var
]
RuleBndrSig XRuleBndrSig GhcRn
_ LIdP GhcRn
var HsPatSigType GhcRn
typ ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN 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) GenLocated SrcSpanAnnN Name
LIdP GhcRn
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, ideclHiding :: forall pass. ImportDecl pass -> Maybe (Bool, XRec pass [LIE pass])
ideclHiding = Maybe (Bool, XRec GhcRn [LIE GhcRn])
hidden } ->
[ IEContext (Located ModuleName) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (Located ModuleName) -> HieM [HieAST Type])
-> IEContext (Located ModuleName) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> Located ModuleName -> IEContext (Located ModuleName)
forall a. IEType -> a -> IEContext a
IEC IEType
Import Located ModuleName
XRec GhcRn ModuleName
name
, Maybe (IEContext (Located ModuleName)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (IEContext (Located ModuleName)) -> HieM [HieAST Type])
-> Maybe (IEContext (Located ModuleName)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located ModuleName -> IEContext (Located ModuleName))
-> Maybe (Located ModuleName)
-> Maybe (IEContext (Located ModuleName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (IEType -> Located ModuleName -> IEContext (Located ModuleName)
forall a. IEType -> a -> IEContext a
IEC IEType
ImportAs) Maybe (Located ModuleName)
Maybe (XRec GhcRn ModuleName)
as
, HieM [HieAST Type]
-> ((Bool,
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
-> HieM [HieAST Type])
-> Maybe
(Bool, 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 (f :: * -> *) a. Applicative f => a -> f a
pure []) (Bool, GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
-> HieM [HieAST Type]
forall {a} {a}.
ToHie (IEContext a) =>
(Bool, GenLocated (SrcSpanAnn' a) [a]) -> HieM [HieAST Type]
goIE Maybe
(Bool, GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcRn)])
Maybe (Bool, XRec GhcRn [LIE GhcRn])
hidden
]
where
goIE :: (Bool, GenLocated (SrcSpanAnn' a) [a]) -> HieM [HieAST Type]
goIE (Bool
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 = if Bool
hiding then IEType
ImportHiding else IEType
Import
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 (IdP GhcRn)
n ->
[ IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (LIEWrappedName Name) -> HieM [HieAST Type])
-> IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> LIEWrappedName Name -> IEContext (LIEWrappedName Name)
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName Name
LIEWrappedName (IdP GhcRn)
n
]
IEThingAbs XIEThingAbs GhcRn
_ LIEWrappedName (IdP GhcRn)
n ->
[ IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (LIEWrappedName Name) -> HieM [HieAST Type])
-> IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> LIEWrappedName Name -> IEContext (LIEWrappedName Name)
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName Name
LIEWrappedName (IdP GhcRn)
n
]
IEThingAll XIEThingAll GhcRn
_ LIEWrappedName (IdP GhcRn)
n ->
[ IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (LIEWrappedName Name) -> HieM [HieAST Type])
-> IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> LIEWrappedName Name -> IEContext (LIEWrappedName Name)
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName Name
LIEWrappedName (IdP GhcRn)
n
]
IEThingWith XIEThingWith GhcRn
flds LIEWrappedName (IdP GhcRn)
n IEWildcard
_ [LIEWrappedName (IdP GhcRn)]
ns ->
[ IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (LIEWrappedName Name) -> HieM [HieAST Type])
-> IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> LIEWrappedName Name -> IEContext (LIEWrappedName Name)
forall a. IEType -> a -> IEContext a
IEC IEType
c LIEWrappedName Name
LIEWrappedName (IdP GhcRn)
n
, [IEContext (LIEWrappedName Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([IEContext (LIEWrappedName Name)] -> HieM [HieAST Type])
-> [IEContext (LIEWrappedName Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LIEWrappedName Name -> IEContext (LIEWrappedName Name))
-> [LIEWrappedName Name] -> [IEContext (LIEWrappedName Name)]
forall a b. (a -> b) -> [a] -> [b]
map (IEType -> LIEWrappedName Name -> IEContext (LIEWrappedName Name)
forall a. IEType -> a -> IEContext a
IEC IEType
c) [LIEWrappedName Name]
[LIEWrappedName (IdP GhcRn)]
ns
, [IEContext (Located FieldLabel)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([IEContext (Located FieldLabel)] -> HieM [HieAST Type])
-> [IEContext (Located FieldLabel)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located FieldLabel -> IEContext (Located FieldLabel))
-> [Located FieldLabel] -> [IEContext (Located FieldLabel)]
forall a b. (a -> b) -> [a] -> [b]
map (IEType -> Located FieldLabel -> IEContext (Located FieldLabel)
forall a. IEType -> a -> IEContext a
IEC IEType
c) [Located FieldLabel]
XIEThingWith GhcRn
flds
]
IEModuleContents XIEModuleContents GhcRn
_ XRec GhcRn ModuleName
n ->
[ IEContext (Located ModuleName) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (IEContext (Located ModuleName) -> HieM [HieAST Type])
-> IEContext (Located ModuleName) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ IEType -> Located ModuleName -> IEContext (Located ModuleName)
forall a. IEType -> a -> IEContext a
IEC IEType
c Located ModuleName
XRec GhcRn ModuleName
n
]
IEGroup XIEGroup GhcRn
_ TypeIndex
_ HsDocString
_ -> []
IEDoc XIEDoc GhcRn
_ HsDocString
_ -> []
IEDocNamed XIEDocNamed GhcRn
_ FilePath
_ -> []
instance ToHie (IEContext (LIEWrappedName Name)) where
toHie :: IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
toHie (IEC IEType
c (L SrcSpanAnnA
span IEWrappedName Name
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 Name -> SrcSpanAnnA -> HieM [HieAST Type]
forall (m :: * -> *) a ann b.
(Monad m, Data a) =>
a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b]
makeNodeA IEWrappedName Name
iewn SrcSpanAnnA
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case IEWrappedName Name
iewn of
IEName GenLocated SrcSpanAnnN Name
n ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) GenLocated SrcSpanAnnN Name
n
]
IEPattern EpaLocation
_ GenLocated SrcSpanAnnN Name
p ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) GenLocated SrcSpanAnnN Name
p
]
IEType EpaLocation
_ GenLocated SrcSpanAnnN Name
n ->
[ Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type])
-> Context (GenLocated SrcSpanAnnN Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpanAnnN Name
-> Context (GenLocated SrcSpanAnnN Name)
forall a. ContextInfo -> a -> Context a
C (IEType -> ContextInfo
IEThing IEType
c) GenLocated SrcSpanAnnN Name
n
]
instance ToHie (IEContext (Located FieldLabel)) where
toHie :: IEContext (Located FieldLabel) -> HieM [HieAST Type]
toHie (IEC IEType
c (L SrcSpan
span FieldLabel
lbl)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ FieldLabel -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Monad m, Data a) =>
a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b]
makeNode FieldLabel
lbl 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
lbl)
]