{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE DeriveDataTypeable #-}
module HieAst ( mkHieFile ) where
import GhcPrelude
import Avail ( Avails )
import Bag ( Bag, bagToList )
import BasicTypes
import BooleanFormula
import Class ( FunDep )
import CoreUtils ( exprType )
import ConLike ( conLikeName )
import Desugar ( deSugarExpr )
import FieldLabel
import HsSyn
import HscTypes
import Module ( ModuleName, ml_hs_file )
import MonadUtils ( concatMapM, liftIO )
import Name ( Name, nameSrcSpan, setNameLoc )
import SrcLoc
import TcHsSyn ( hsLitType, hsPatType )
import Type ( mkFunTys, Type )
import TysWiredIn ( mkListTy, mkSumTy )
import Var ( Id, Var, setVarName, varName, varType )
import TcRnTypes
import MkIface ( mkIfaceExports )
import HieTypes
import HieUtils
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.List ( foldl1' )
import Data.Maybe ( listToMaybe )
import Control.Monad.Trans.Reader
import Control.Monad.Trans.Class ( lift )
type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn]
, Maybe [(LIE GhcRn, Avails)]
, Maybe LHsDocString )
type TypecheckedSource = LHsBinds GhcTc
newtype HieState = HieState
{ HieState -> Map Name Id
name_remapping :: M.Map Name Id
}
initState :: HieState
initState :: HieState
initState = Map Name Id -> HieState
HieState Map Name Id
forall k a. Map k a
M.empty
class ModifyState a where
addSubstitution :: a -> a -> HieState -> HieState
instance ModifyState Name where
addSubstitution :: Name -> Name -> HieState -> HieState
addSubstitution _ _ hs :: HieState
hs = HieState
hs
instance ModifyState Id where
addSubstitution :: Id -> Id -> HieState -> HieState
addSubstitution mono :: Id
mono poly :: Id
poly hs :: HieState
hs =
HieState
hs{name_remapping :: Map Name Id
name_remapping = Name -> Id -> Map Name Id -> Map Name Id
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert (Id -> Name
varName Id
mono) Id
poly (HieState -> Map Name Id
name_remapping HieState
hs)}
modifyState :: ModifyState (IdP p) => [ABExport p] -> HieState -> HieState
modifyState :: [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} f :: 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 _ f :: a -> HieState
f = a -> HieState
f
type HieM = ReaderT HieState Hsc
mkHieFile :: ModSummary
-> TcGblEnv
-> RenamedSource -> Hsc HieFile
mkHieFile :: ModSummary -> TcGblEnv -> RenamedSource -> Hsc HieFile
mkHieFile ms :: ModSummary
ms ts :: TcGblEnv
ts rs :: RenamedSource
rs = do
let tc_binds :: LHsBinds GhcTc
tc_binds = TcGblEnv -> LHsBinds GhcTc
tcg_binds TcGblEnv
ts
(asts' :: HieASTs TypeIndex
asts', arr :: Array TypeIndex HieTypeFlat
arr) <- LHsBinds GhcTc
-> RenamedSource
-> Hsc (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
getCompressedAsts LHsBinds GhcTc
tc_binds RenamedSource
rs
let Just src_file :: FilePath
src_file = 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
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 :: FilePath
-> Module
-> Array TypeIndex HieTypeFlat
-> HieASTs TypeIndex
-> [AvailInfo]
-> ByteString
-> HieFile
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
-> Hsc (HieASTs TypeIndex, A.Array TypeIndex HieTypeFlat)
getCompressedAsts :: LHsBinds GhcTc
-> RenamedSource
-> Hsc (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
getCompressedAsts ts :: LHsBinds GhcTc
ts rs :: RenamedSource
rs = do
HieASTs Type
asts <- LHsBinds GhcTc -> RenamedSource -> Hsc (HieASTs Type)
enrichHie LHsBinds GhcTc
ts RenamedSource
rs
(HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> Hsc (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
forall (m :: * -> *) a. Monad m => a -> m a
return ((HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> Hsc (HieASTs TypeIndex, Array TypeIndex HieTypeFlat))
-> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat)
-> Hsc (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 -> Hsc (HieASTs Type)
enrichHie :: LHsBinds GhcTc -> RenamedSource -> Hsc (HieASTs Type)
enrichHie ts :: LHsBinds GhcTc
ts (hsGrp :: HsGroup GhcRn
hsGrp, imports :: [LImportDecl GhcRn]
imports, exports :: Maybe [(LIE GhcRn, [AvailInfo])]
exports, _) = (ReaderT HieState Hsc (HieASTs Type)
-> HieState -> Hsc (HieASTs Type))
-> HieState
-> ReaderT HieState Hsc (HieASTs Type)
-> Hsc (HieASTs Type)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT HieState Hsc (HieASTs Type)
-> HieState -> Hsc (HieASTs Type)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT HieState
initState (ReaderT HieState Hsc (HieASTs Type) -> Hsc (HieASTs Type))
-> ReaderT HieState Hsc (HieASTs Type) -> Hsc (HieASTs Type)
forall a b. (a -> b) -> a -> b
$ do
[HieAST Type]
tasts <- Bag (BindContext (LHsBindLR GhcTc GhcTc)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (LHsBindLR GhcTc GhcTc)) -> HieM [HieAST Type])
-> Bag (BindContext (LHsBindLR GhcTc GhcTc)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsBindLR GhcTc GhcTc -> BindContext (LHsBindLR GhcTc GhcTc))
-> LHsBinds GhcTc -> Bag (BindContext (LHsBindLR GhcTc GhcTc))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType
-> Scope
-> LHsBindLR GhcTc GhcTc
-> BindContext (LHsBindLR GhcTc GhcTc)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
ModuleScope) LHsBinds GhcTc
ts
[HieAST Type]
rasts <- HsGroup GhcRn -> HieM [HieAST Type]
forall p.
(HasType (LHsBind p), ModifyState (IdP p),
Data (GRHS p (Located (HsExpr p))), Data (HsLocalBinds p),
Data (HsBind p), ToHie (LMatch p (Located (HsExpr p))),
ToHie (Located (HsExpr p)),
ToHie (GenLocated SrcSpan (SpliceDecl p)),
ToHie (GenLocated SrcSpan (DerivDecl p)),
ToHie (GenLocated SrcSpan (FixitySig p)),
ToHie (GenLocated SrcSpan (DefaultDecl p)),
ToHie (GenLocated SrcSpan (ForeignDecl p)),
ToHie (GenLocated SrcSpan (WarnDecls p)),
ToHie (GenLocated SrcSpan (AnnDecl p)),
ToHie (GenLocated SrcSpan (RuleDecls p)),
ToHie (Context (Located (IdP p))), ToHie (PScoped (LPat p)),
ToHie (SigContext (LSig p)), ToHie (RScoped (XXValBindsLR p p)),
ToHie (RScoped (GuardLStmt p)), ToHie (TyClGroup p)) =>
HsGroup p -> HieM [HieAST Type]
processGrp HsGroup GhcRn
hsGrp
[HieAST Type]
imps <- [LImportDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([LImportDecl GhcRn] -> HieM [HieAST Type])
-> [LImportDecl GhcRn] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LImportDecl GhcRn -> Bool)
-> [LImportDecl GhcRn] -> [LImportDecl GhcRn]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (LImportDecl GhcRn -> Bool) -> LImportDecl GhcRn -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ImportDecl GhcRn -> Bool
forall pass. ImportDecl pass -> Bool
ideclImplicit (ImportDecl GhcRn -> Bool)
-> (LImportDecl GhcRn -> ImportDecl GhcRn)
-> LImportDecl GhcRn
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LImportDecl GhcRn -> ImportDecl GhcRn
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc) [LImportDecl GhcRn]
imports
[HieAST Type]
exps <- Maybe [IEContext (LIE GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe [IEContext (LIE GhcRn)] -> HieM [HieAST Type])
-> Maybe [IEContext (LIE GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ([(LIE GhcRn, [AvailInfo])] -> [IEContext (LIE GhcRn)])
-> Maybe [(LIE GhcRn, [AvailInfo])]
-> Maybe [IEContext (LIE GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((LIE GhcRn, [AvailInfo]) -> IEContext (LIE GhcRn))
-> [(LIE GhcRn, [AvailInfo])] -> [IEContext (LIE GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (((LIE GhcRn, [AvailInfo]) -> IEContext (LIE GhcRn))
-> [(LIE GhcRn, [AvailInfo])] -> [IEContext (LIE GhcRn)])
-> ((LIE GhcRn, [AvailInfo]) -> IEContext (LIE GhcRn))
-> [(LIE GhcRn, [AvailInfo])]
-> [IEContext (LIE GhcRn)]
forall a b. (a -> b) -> a -> b
$ IEType -> LIE GhcRn -> IEContext (LIE GhcRn)
forall a. IEType -> a -> IEContext a
IEC IEType
Export (LIE GhcRn -> IEContext (LIE GhcRn))
-> ((LIE GhcRn, [AvailInfo]) -> LIE GhcRn)
-> (LIE GhcRn, [AvailInfo])
-> IEContext (LIE GhcRn)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LIE GhcRn, [AvailInfo]) -> LIE GhcRn
forall a b. (a, b) -> a
fst) Maybe [(LIE GhcRn, [AvailInfo])]
exports
let spanFile :: [HieAST a] -> RealSrcSpan
spanFile children :: [HieAST a]
children = case [HieAST a]
children of
[] -> RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan (FastString -> TypeIndex -> TypeIndex -> RealSrcLoc
mkRealSrcLoc "" 1 1) (FastString -> TypeIndex -> TypeIndex -> RealSrcLoc
mkRealSrcLoc "" 1 1)
_ -> RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan (RealSrcSpan -> RealSrcLoc
realSrcSpanStart (RealSrcSpan -> RealSrcLoc) -> RealSrcSpan -> RealSrcLoc
forall a b. (a -> b) -> a -> b
$ HieAST a -> RealSrcSpan
forall a. HieAST a -> RealSrcSpan
nodeSpan (HieAST a -> RealSrcSpan) -> HieAST a -> RealSrcSpan
forall a b. (a -> b) -> a -> b
$ [HieAST a] -> HieAST a
forall a. [a] -> a
head [HieAST a]
children)
(RealSrcSpan -> RealSrcLoc
realSrcSpanEnd (RealSrcSpan -> RealSrcLoc) -> RealSrcSpan -> RealSrcLoc
forall a b. (a -> b) -> a -> b
$ HieAST a -> RealSrcSpan
forall a. HieAST a -> RealSrcSpan
nodeSpan (HieAST a -> RealSrcSpan) -> HieAST a -> RealSrcSpan
forall a b. (a -> b) -> a -> b
$ [HieAST a] -> HieAST a
forall a. [a] -> a
last [HieAST a]
children)
modulify :: [HieAST a] -> HieAST a
modulify xs :: [HieAST a]
xs =
NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
forall a. NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
Node (FastString -> FastString -> NodeInfo a
forall a. FastString -> FastString -> NodeInfo a
simpleNodeInfo "Module" "Module") ([HieAST a] -> RealSrcSpan
forall a. [HieAST a] -> RealSrcSpan
spanFile [HieAST a]
xs) [HieAST a]
xs
asts :: HieASTs Type
asts = Map FastString (HieAST Type) -> HieASTs Type
forall a. Map FastString (HieAST a) -> HieASTs a
HieASTs
(Map FastString (HieAST Type) -> HieASTs Type)
-> Map FastString (HieAST Type) -> HieASTs Type
forall a b. (a -> b) -> a -> b
$ Map FastString (HieAST Type) -> Map FastString (HieAST Type)
forall a. Map FastString (HieAST a) -> Map FastString (HieAST a)
resolveTyVarScopes
(Map FastString (HieAST Type) -> Map FastString (HieAST Type))
-> Map FastString (HieAST Type) -> Map FastString (HieAST Type)
forall a b. (a -> b) -> a -> b
$ ([HieAST Type] -> HieAST Type)
-> Map FastString [HieAST Type] -> Map FastString (HieAST Type)
forall a b k. (a -> b) -> Map k a -> Map k b
M.map ([HieAST Type] -> HieAST Type
forall a. [HieAST a] -> HieAST a
modulify ([HieAST Type] -> HieAST Type)
-> ([HieAST Type] -> [HieAST Type]) -> [HieAST Type] -> HieAST Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [HieAST Type] -> [HieAST Type]
mergeSortAsts)
(Map FastString [HieAST Type] -> Map FastString (HieAST Type))
-> Map FastString [HieAST Type] -> Map FastString (HieAST Type)
forall a b. (a -> b) -> a -> b
$ ([HieAST Type] -> [HieAST Type] -> [HieAST Type])
-> [(FastString, [HieAST Type])] -> Map FastString [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]
(++)
([(FastString, [HieAST Type])] -> Map FastString [HieAST Type])
-> [(FastString, [HieAST Type])] -> Map FastString [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (HieAST Type -> (FastString, [HieAST Type]))
-> [HieAST Type] -> [(FastString, [HieAST Type])]
forall a b. (a -> b) -> [a] -> [b]
map (\x :: HieAST Type
x -> (RealSrcSpan -> FastString
srcSpanFile (HieAST Type -> RealSrcSpan
forall a. HieAST a -> RealSrcSpan
nodeSpan HieAST Type
x),[HieAST Type
x])) [HieAST Type]
flat_asts
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
]
HieASTs Type -> ReaderT HieState Hsc (HieASTs Type)
forall (m :: * -> *) a. Monad m => a -> m a
return HieASTs Type
asts
where
processGrp :: HsGroup p -> HieM [HieAST Type]
processGrp grp :: 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
, [GenLocated SrcSpan (SpliceDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (SpliceDecl p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (SpliceDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (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
, [GenLocated SrcSpan (DerivDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (DerivDecl p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (DerivDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (DerivDecl p)]
forall p. HsGroup p -> [LDerivDecl p]
hs_derivds HsGroup p
grp
, [GenLocated SrcSpan (FixitySig p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (FixitySig p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (FixitySig p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (FixitySig p)]
forall p. HsGroup p -> [LFixitySig p]
hs_fixds HsGroup p
grp
, [GenLocated SrcSpan (DefaultDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (DefaultDecl p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (DefaultDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (DefaultDecl p)]
forall p. HsGroup p -> [LDefaultDecl p]
hs_defds HsGroup p
grp
, [GenLocated SrcSpan (ForeignDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (ForeignDecl p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (ForeignDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (ForeignDecl p)]
forall p. HsGroup p -> [LForeignDecl p]
hs_fords HsGroup p
grp
, [GenLocated SrcSpan (WarnDecls p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (WarnDecls p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (WarnDecls p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (WarnDecls p)]
forall p. HsGroup p -> [LWarnDecls p]
hs_warnds HsGroup p
grp
, [GenLocated SrcSpan (AnnDecl p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (AnnDecl p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (AnnDecl p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (AnnDecl p)]
forall p. HsGroup p -> [LAnnDecl p]
hs_annds HsGroup p
grp
, [GenLocated SrcSpan (RuleDecls p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (RuleDecls p)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (RuleDecls p)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsGroup p -> [GenLocated SrcSpan (RuleDecls p)]
forall p. HsGroup p -> [LRuleDecls p]
hs_ruleds HsGroup p
grp
]
getRealSpan :: SrcSpan -> Maybe Span
getRealSpan :: SrcSpan -> Maybe RealSrcSpan
getRealSpan (RealSrcSpan sp :: RealSrcSpan
sp) = RealSrcSpan -> Maybe RealSrcSpan
forall a. a -> Maybe a
Just RealSrcSpan
sp
getRealSpan _ = Maybe RealSrcSpan
forall a. Maybe a
Nothing
grhss_span :: GRHSs p body -> SrcSpan
grhss_span :: GRHSs p body -> SrcSpan
grhss_span (GRHSs _ xs :: [LGRHS p body]
xs bs :: LHsLocalBinds 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 (LHsLocalBinds p -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc LHsLocalBinds p
bs) ((LGRHS p body -> SrcSpan) -> [LGRHS p body] -> [SrcSpan]
forall a b. (a -> b) -> [a] -> [b]
map LGRHS p body -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc [LGRHS p body]
xs)
grhss_span (XGRHSs _) = FilePath -> SrcSpan
forall a. HasCallStack => FilePath -> a
error "XGRHS has no span"
bindingsOnly :: [Context Name] -> [HieAST a]
bindingsOnly :: [Context Name] -> [HieAST a]
bindingsOnly [] = []
bindingsOnly (C c :: ContextInfo
c n :: Name
n : xs :: [Context Name]
xs) = case Name -> SrcSpan
nameSrcSpan Name
n of
RealSrcSpan span :: RealSrcSpan
span -> NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
forall a. NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
Node NodeInfo a
nodeinfo RealSrcSpan
span [] HieAST a -> [HieAST a] -> [HieAST a]
forall a. a -> [a] -> [a]
: [Context Name] -> [HieAST a]
forall a. [Context Name] -> [HieAST a]
bindingsOnly [Context Name]
xs
where nodeinfo :: NodeInfo a
nodeinfo = Set (FastString, FastString)
-> [a] -> NodeIdentifiers a -> NodeInfo a
forall a.
Set (FastString, FastString)
-> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set (FastString, FastString)
forall a. Set a
S.empty [] (Either ModuleName Name -> IdentifierDetails a -> NodeIdentifiers a
forall k a. k -> a -> Map k a
M.singleton (Name -> Either ModuleName Name
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}
_ -> [Context Name] -> [HieAST a]
forall a. [Context Name] -> [HieAST a]
bindingsOnly [Context Name]
xs
concatM :: Monad m => [m [a]] -> m [a]
concatM :: [m [a]] -> m [a]
concatM xs :: [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 RScoped a = RS Scope a
data PScoped a = PS (Maybe Span)
Scope
Scope
a
deriving (Typeable, Typeable (PScoped a)
DataType
Constr
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 d. Data d => c (t d)) -> Maybe (c (PScoped a))
(forall b. Data b => b -> b) -> PScoped a -> PScoped a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PScoped a -> c (PScoped a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (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))
$cPS :: Constr
$tPScoped :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> PScoped a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> PScoped a -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall a. Data a => Typeable (PScoped a)
Data)
data TScoped a = TS TyVarScope a
data TVScoped a = TVS TyVarScope Scope a
listScopes :: Scope -> [Located a] -> [RScoped (Located a)]
listScopes :: Scope -> [Located a] -> [RScoped (Located a)]
listScopes _ [] = []
listScopes rhsScope :: Scope
rhsScope [pat :: Located a
pat] = [Scope -> Located a -> RScoped (Located a)
forall a. Scope -> a -> RScoped a
RS Scope
rhsScope Located a
pat]
listScopes rhsScope :: Scope
rhsScope (pat :: Located a
pat : pats :: [Located a]
pats) = Scope -> Located a -> RScoped (Located a)
forall a. Scope -> a -> RScoped a
RS Scope
sc Located a
pat RScoped (Located a)
-> [RScoped (Located a)] -> [RScoped (Located a)]
forall a. a -> [a] -> [a]
: [RScoped (Located a)]
pats'
where
pats' :: [RScoped (Located a)]
pats'@((RS scope :: Scope
scope p :: Located a
p):_) = Scope -> [Located a] -> [RScoped (Located a)]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
rhsScope [Located 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
$ Located a -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc Located a
p
patScopes
:: Maybe Span
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes :: Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes rsp :: Maybe RealSrcSpan
rsp useScope :: Scope
useScope patScope :: Scope
patScope xs :: [LPat (GhcPass p)]
xs =
(RScoped (Located (LPat (GhcPass p)))
-> PScoped (LPat (GhcPass p)))
-> [RScoped (Located (LPat (GhcPass p)))]
-> [PScoped (LPat (GhcPass p))]
forall a b. (a -> b) -> [a] -> [b]
map (\(RS sc :: Scope
sc a :: Located (LPat (GhcPass p))
a) -> Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
useScope Scope
sc (Located (LPat (GhcPass p))
-> SrcSpanLess (Located (LPat (GhcPass p)))
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc Located (LPat (GhcPass p))
a)) ([RScoped (Located (LPat (GhcPass p)))]
-> [PScoped (LPat (GhcPass p))])
-> [RScoped (Located (LPat (GhcPass p)))]
-> [PScoped (LPat (GhcPass p))]
forall a b. (a -> b) -> a -> b
$
Scope
-> [Located (LPat (GhcPass p))]
-> [RScoped (Located (LPat (GhcPass p)))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
patScope ((LPat (GhcPass p) -> Located (LPat (GhcPass p)))
-> [LPat (GhcPass p)] -> [Located (LPat (GhcPass p))]
forall a b. (a -> b) -> [a] -> [b]
map LPat (GhcPass p) -> Located (LPat (GhcPass p))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL [LPat (GhcPass p)]
xs)
tvScopes
:: TyVarScope
-> Scope
-> [LHsTyVarBndr a]
-> [TVScoped (LHsTyVarBndr a)]
tvScopes :: TyVarScope
-> Scope -> [LHsTyVarBndr a] -> [TVScoped (LHsTyVarBndr a)]
tvScopes tvScope :: TyVarScope
tvScope rhsScope :: Scope
rhsScope xs :: [LHsTyVarBndr a]
xs =
(RScoped (LHsTyVarBndr a) -> TVScoped (LHsTyVarBndr a))
-> [RScoped (LHsTyVarBndr a)] -> [TVScoped (LHsTyVarBndr a)]
forall a b. (a -> b) -> [a] -> [b]
map (\(RS sc :: Scope
sc a :: LHsTyVarBndr a
a)-> TyVarScope -> Scope -> LHsTyVarBndr a -> TVScoped (LHsTyVarBndr a)
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS TyVarScope
tvScope Scope
sc LHsTyVarBndr a
a) ([RScoped (LHsTyVarBndr a)] -> [TVScoped (LHsTyVarBndr a)])
-> [RScoped (LHsTyVarBndr a)] -> [TVScoped (LHsTyVarBndr a)]
forall a b. (a -> b) -> a -> b
$ Scope -> [LHsTyVarBndr a] -> [RScoped (LHsTyVarBndr a)]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
rhsScope [LHsTyVarBndr a]
xs
data Shielded a = SH Scope a
type family ProtectedSig a where
ProtectedSig GhcRn = HsWildCardBndrs GhcRn (HsImplicitBndrs
GhcRn
(Shielded (LHsType GhcRn)))
ProtectedSig GhcTc = NoExt
class ProtectSig a where
protectSig :: Scope -> LHsSigWcType (NoGhcTc a) -> ProtectedSig a
instance (HasLoc a) => HasLoc (Shielded a) where
loc :: Shielded a -> SrcSpan
loc (SH _ a :: a
a) = a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc a
a
instance (ToHie (TScoped a)) => ToHie (TScoped (Shielded a)) where
toHie :: TScoped (Shielded a) -> HieM [HieAST Type]
toHie (TS _ (SH sc :: Scope
sc a :: a
a)) = TScoped a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TyVarScope -> a -> TScoped a
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
sc]) a
a)
instance ProtectSig GhcTc where
protectSig :: Scope -> LHsSigWcType (NoGhcTc GhcTc) -> ProtectedSig GhcTc
protectSig _ _ = NoExt
ProtectedSig GhcTc
NoExt
instance ProtectSig GhcRn where
protectSig :: Scope -> LHsSigWcType (NoGhcTc GhcRn) -> ProtectedSig GhcRn
protectSig sc :: Scope
sc (HsWC a :: XHsWC (NoGhcTc GhcRn) (LHsSigType (NoGhcTc GhcRn))
a (HsIB b :: XHsIB (NoGhcTc GhcRn) (LHsType (NoGhcTc GhcRn))
b sig :: LHsType (NoGhcTc GhcRn)
sig)) =
XHsWC GhcRn (HsImplicitBndrs GhcRn (Shielded (LHsType GhcRn)))
-> HsImplicitBndrs GhcRn (Shielded (LHsType GhcRn))
-> HsWildCardBndrs
GhcRn (HsImplicitBndrs GhcRn (Shielded (LHsType GhcRn)))
forall pass thing.
XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
HsWC XHsWC (NoGhcTc GhcRn) (LHsSigType (NoGhcTc GhcRn))
XHsWC GhcRn (HsImplicitBndrs GhcRn (Shielded (LHsType GhcRn)))
a (XHsIB GhcRn (Shielded (LHsType GhcRn))
-> Shielded (LHsType GhcRn)
-> HsImplicitBndrs GhcRn (Shielded (LHsType GhcRn))
forall pass thing.
XHsIB pass thing -> thing -> HsImplicitBndrs pass thing
HsIB XHsIB (NoGhcTc GhcRn) (LHsType (NoGhcTc GhcRn))
XHsIB GhcRn (Shielded (LHsType GhcRn))
b (Scope -> LHsType GhcRn -> Shielded (LHsType GhcRn)
forall a. Scope -> a -> Shielded a
SH Scope
sc LHsType (NoGhcTc GhcRn)
LHsType GhcRn
sig))
protectSig _ _ = FilePath
-> HsWildCardBndrs
GhcRn (HsImplicitBndrs GhcRn (Shielded (LHsType GhcRn)))
forall a. HasCallStack => FilePath -> a
error "protectSig not given HsWC (HsIB)"
class HasLoc a where
loc :: a -> SrcSpan
instance HasLoc thing => HasLoc (TScoped thing) where
loc :: TScoped thing -> SrcSpan
loc (TS _ a :: thing
a) = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
instance HasLoc thing => HasLoc (PScoped thing) where
loc :: PScoped thing -> SrcSpan
loc (PS _ _ _ a :: thing
a) = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
instance HasLoc (LHsQTyVars GhcRn) where
loc :: LHsQTyVars GhcRn -> SrcSpan
loc (HsQTvs _ vs :: [LHsTyVarBndr GhcRn]
vs) = [LHsTyVarBndr GhcRn] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LHsTyVarBndr GhcRn]
vs
loc _ = SrcSpan
noSrcSpan
instance HasLoc thing => HasLoc (HsImplicitBndrs a thing) where
loc :: HsImplicitBndrs a thing -> SrcSpan
loc (HsIB _ a :: thing
a) = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
loc _ = SrcSpan
noSrcSpan
instance HasLoc thing => HasLoc (HsWildCardBndrs a thing) where
loc :: HsWildCardBndrs a thing -> SrcSpan
loc (HsWC _ a :: thing
a) = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
loc _ = SrcSpan
noSrcSpan
instance HasLoc (Located a) where
loc :: Located a -> SrcSpan
loc (L l :: SrcSpan
l _) = SrcSpan
l
instance HasLoc a => HasLoc [a] where
loc :: [a] -> SrcSpan
loc [] = SrcSpan
noSrcSpan
loc xs :: [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, HasLoc b) => HasLoc (FamEqn s a b) where
loc :: FamEqn s a b -> SrcSpan
loc (FamEqn _ a :: Located (IdP s)
a Nothing b :: a
b _ c :: b
c) = (SrcSpan -> SrcSpan -> SrcSpan) -> [SrcSpan] -> SrcSpan
forall a. (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans [Located (IdP s) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc Located (IdP s)
a, a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc a
b, b -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc b
c]
loc (FamEqn _ a :: Located (IdP s)
a (Just tvs :: [LHsTyVarBndr s]
tvs) b :: a
b _ c :: b
c) = (SrcSpan -> SrcSpan -> SrcSpan) -> [SrcSpan] -> SrcSpan
forall a. (a -> a -> a) -> [a] -> a
foldl1' SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans
[Located (IdP s) -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc Located (IdP s)
a, [LHsTyVarBndr s] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LHsTyVarBndr s]
tvs, a -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc a
b, b -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc b
c]
loc _ = SrcSpan
noSrcSpan
instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg tm ty) where
loc :: HsArg tm ty -> SrcSpan
loc (HsValArg tm :: tm
tm) = tm -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc tm
tm
loc (HsTypeArg _ ty :: ty
ty) = ty -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc ty
ty
loc (HsArgPar sp :: SrcSpan
sp) = SrcSpan
sp
instance HasLoc (HsDataDefn GhcRn) where
loc :: HsDataDefn GhcRn -> SrcSpan
loc def :: HsDataDefn GhcRn
def@(HsDataDefn{}) = [LConDecl GhcRn] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc ([LConDecl GhcRn] -> SrcSpan) -> [LConDecl GhcRn] -> SrcSpan
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> [LConDecl GhcRn]
forall pass. HsDataDefn pass -> [LConDecl pass]
dd_cons HsDataDefn GhcRn
def
loc _ = SrcSpan
noSrcSpan
instance HasLoc (Pat (GhcPass a)) where
loc :: Pat (GhcPass a) -> SrcSpan
loc (Pat (GhcPass a) -> Located (SrcSpanLess (Pat (GhcPass a)))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL -> L l :: SrcSpan
l _) = SrcSpan
l
class ToHie a where
toHie :: a -> HieM [HieAST Type]
class Data a => HasType a where
getTypeNode :: a -> HieM [HieAST Type]
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 (Context (Located NoExt)) where
toHie :: Context (Located NoExt) -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (TScoped NoExt) where
toHie :: TScoped NoExt -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (IEContext (Located ModuleName)) where
toHie :: IEContext (Located ModuleName) -> HieM [HieAST Type]
toHie (IEC c :: IEType
c (L (RealSrcSpan span :: RealSrcSpan
span) mname :: ModuleName
mname)) =
[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
$ [NodeInfo Type -> RealSrcSpan -> [HieAST Type] -> HieAST Type
forall a. NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
Node (Set (FastString, FastString)
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set (FastString, FastString)
-> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set (FastString, FastString)
forall a. Set a
S.empty [] NodeIdentifiers Type
idents) RealSrcSpan
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 = Either ModuleName Name
-> IdentifierDetails Type -> NodeIdentifiers Type
forall k a. k -> a -> Map k a
M.singleton (ModuleName -> Either ModuleName Name
forall a b. a -> Either a b
Left ModuleName
mname) IdentifierDetails Type
details
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (Context (Located Var)) where
toHie :: Context (Located Id) -> HieM [HieAST Type]
toHie c :: Context (Located Id)
c = case Context (Located Id)
c of
C context :: ContextInfo
context (L (RealSrcSpan span :: RealSrcSpan
span) name' :: Id
name')
-> do
Map Name Id
m <- (HieState -> Map Name Id) -> ReaderT HieState Hsc (Map Name Id)
forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks HieState -> Map Name Id
name_remapping
let name :: Id
name = Id -> Name -> Map Name Id -> Id
forall k a. Ord k => a -> k -> Map k a -> a
M.findWithDefault Id
name' (Id -> Name
varName Id
name') Map Name Id
m
[HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure
[NodeInfo Type -> RealSrcSpan -> [HieAST Type] -> HieAST Type
forall a. NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
Node
(Set (FastString, FastString)
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set (FastString, FastString)
-> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set (FastString, FastString)
forall a. Set a
S.empty [] (NodeIdentifiers Type -> NodeInfo Type)
-> NodeIdentifiers Type -> NodeInfo Type
forall a b. (a -> b) -> a -> b
$
Either ModuleName Name
-> IdentifierDetails Type -> NodeIdentifiers Type
forall k a. k -> a -> Map k a
M.singleton (Name -> Either ModuleName Name
forall a b. b -> Either a b
Right (Name -> Either ModuleName Name) -> Name -> Either ModuleName Name
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 -> Maybe Type) -> Type -> Maybe Type
forall a b. (a -> b) -> a -> b
$ Id -> Type
varType Id
name')
(ContextInfo -> Set ContextInfo
forall a. a -> Set a
S.singleton ContextInfo
context)))
RealSrcSpan
span
[]]
_ -> [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 c :: Context (Located Name)
c = case Context (Located Name)
c of
C context :: ContextInfo
context (L (RealSrcSpan span :: RealSrcSpan
span) name' :: Name
name') -> do
Map Name Id
m <- (HieState -> Map Name Id) -> ReaderT HieState Hsc (Map Name Id)
forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks HieState -> Map Name Id
name_remapping
let name :: Name
name = case Name -> Map Name Id -> Maybe Id
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
name' Map Name Id
m of
Just var :: Id
var -> Id -> Name
varName Id
var
Nothing -> Name
name'
[HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure
[NodeInfo Type -> RealSrcSpan -> [HieAST Type] -> HieAST Type
forall a. NodeInfo a -> RealSrcSpan -> [HieAST a] -> HieAST a
Node
(Set (FastString, FastString)
-> [Type] -> NodeIdentifiers Type -> NodeInfo Type
forall a.
Set (FastString, FastString)
-> [a] -> NodeIdentifiers a -> NodeInfo a
NodeInfo Set (FastString, FastString)
forall a. Set a
S.empty [] (NodeIdentifiers Type -> NodeInfo Type)
-> NodeIdentifiers Type -> NodeInfo Type
forall a b. (a -> b) -> a -> b
$
Either ModuleName Name
-> IdentifierDetails Type -> NodeIdentifiers Type
forall k a. k -> a -> Map k a
M.singleton (Name -> Either ModuleName Name
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)))
RealSrcSpan
span
[]]
_ -> [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (TScoped (LHsSigWcType GhcTc)) where
toHie :: TScoped (LHsSigWcType GhcTc) -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (TScoped (LHsWcType GhcTc)) where
toHie :: TScoped (LHsWcType GhcTc) -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (SigContext (LSig GhcTc)) where
toHie :: SigContext (LSig GhcTc) -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (TScoped Type) where
toHie :: TScoped Type -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance HasType (LHsBind GhcRn) where
getTypeNode :: LHsBind GhcRn -> HieM [HieAST Type]
getTypeNode (L spn :: SrcSpan
spn bind :: HsBindLR GhcRn GhcRn
bind) = HsBindLR GhcRn GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsBindLR GhcRn GhcRn
bind SrcSpan
spn
instance HasType (LHsBind GhcTc) where
getTypeNode :: LHsBindLR GhcTc GhcTc -> HieM [HieAST Type]
getTypeNode (L spn :: SrcSpan
spn bind :: HsBindLR GhcTc GhcTc
bind) = case HsBindLR GhcTc GhcTc
bind of
FunBind{fun_id :: forall idL idR. HsBindLR idL idR -> Located (IdP idL)
fun_id = Located (IdP GhcTc)
name} -> HsBindLR GhcTc GhcTc -> SrcSpan -> Type -> HieM [HieAST Type]
forall (m :: * -> *) a.
(Applicative m, Data a) =>
a -> SrcSpan -> Type -> m [HieAST Type]
makeTypeNode HsBindLR GhcTc GhcTc
bind SrcSpan
spn (Id -> Type
varType (Id -> Type) -> Id -> Type
forall a b. (a -> b) -> a -> b
$ Located Id -> SrcSpanLess (Located Id)
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc Located Id
Located (IdP GhcTc)
name)
_ -> HsBindLR GhcTc GhcTc -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsBindLR GhcTc GhcTc
bind SrcSpan
spn
instance HasType (LPat GhcRn) where
getTypeNode :: LPat GhcRn -> HieM [HieAST Type]
getTypeNode (LPat GhcRn -> Located (SrcSpanLess (LPat GhcRn))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL -> L spn :: SrcSpan
spn pat :: SrcSpanLess (LPat GhcRn)
pat) = LPat GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode SrcSpanLess (LPat GhcRn)
LPat GhcRn
pat SrcSpan
spn
instance HasType (LPat GhcTc) where
getTypeNode :: LPat GhcTc -> HieM [HieAST Type]
getTypeNode (LPat GhcTc -> Located (SrcSpanLess (LPat GhcTc))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL -> L spn :: SrcSpan
spn opat :: SrcSpanLess (LPat GhcTc)
opat) = LPat GhcTc -> SrcSpan -> Type -> HieM [HieAST Type]
forall (m :: * -> *) a.
(Applicative m, Data a) =>
a -> SrcSpan -> Type -> m [HieAST Type]
makeTypeNode SrcSpanLess (LPat GhcTc)
LPat GhcTc
opat SrcSpan
spn (LPat GhcTc -> Type
hsPatType SrcSpanLess (LPat GhcTc)
LPat GhcTc
opat)
instance HasType (LHsExpr GhcRn) where
getTypeNode :: LHsExpr GhcRn -> HieM [HieAST Type]
getTypeNode (L spn :: SrcSpan
spn e :: HsExpr GhcRn
e) = HsExpr GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsExpr GhcRn
e SrcSpan
spn
instance HasType (LHsExpr GhcTc) where
getTypeNode :: LHsExpr GhcTc -> HieM [HieAST Type]
getTypeNode e :: LHsExpr GhcTc
e@(L spn :: SrcSpan
spn e' :: HsExpr GhcTc
e') = Hsc [HieAST Type] -> HieM [HieAST Type]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Hsc [HieAST Type] -> HieM [HieAST Type])
-> Hsc [HieAST Type] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
let tyOpt :: Maybe Type
tyOpt = case HsExpr GhcTc
e' of
HsLit _ l :: HsLit GhcTc
l -> Type -> Maybe Type
forall a. a -> Maybe a
Just (HsLit GhcTc -> Type
forall (p :: Pass). HsLit (GhcPass p) -> Type
hsLitType HsLit GhcTc
l)
HsOverLit _ o :: HsOverLit GhcTc
o -> Type -> Maybe Type
forall a. a -> Maybe a
Just (HsOverLit GhcTc -> Type
overLitType HsOverLit GhcTc
o)
HsLam _ (MG { mg_ext :: forall p body. MatchGroup p body -> XMG p body
mg_ext = XMG GhcTc (LHsExpr GhcTc)
groupTy }) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (MatchGroupTc -> Type
matchGroupType XMG GhcTc (LHsExpr GhcTc)
MatchGroupTc
groupTy)
HsLamCase _ (MG { mg_ext :: forall p body. MatchGroup p body -> XMG p body
mg_ext = XMG GhcTc (LHsExpr GhcTc)
groupTy }) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (MatchGroupTc -> Type
matchGroupType XMG GhcTc (LHsExpr GhcTc)
MatchGroupTc
groupTy)
HsCase _ _ (MG { mg_ext :: forall p body. MatchGroup p body -> XMG p body
mg_ext = XMG GhcTc (LHsExpr GhcTc)
groupTy }) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (MatchGroupTc -> Type
mg_res_ty XMG GhcTc (LHsExpr GhcTc)
MatchGroupTc
groupTy)
ExplicitList ty :: XExplicitList GhcTc
ty _ _ -> Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Type
mkListTy Type
XExplicitList GhcTc
ty)
ExplicitSum ty :: XExplicitSum GhcTc
ty _ _ _ -> Type -> Maybe Type
forall a. a -> Maybe a
Just ([Type] -> Type
mkSumTy [Type]
XExplicitSum GhcTc
ty)
HsDo ty :: XDo GhcTc
ty _ _ -> Type -> Maybe Type
forall a. a -> Maybe a
Just Type
XDo GhcTc
ty
HsMultiIf ty :: XMultiIf GhcTc
ty _ -> Type -> Maybe Type
forall a. a -> Maybe a
Just Type
XMultiIf GhcTc
ty
_ -> Maybe Type
forall a. Maybe a
Nothing
in
case Maybe Type
tyOpt of
_ | HsExpr GhcTc -> Bool
forall a. HsExpr a -> Bool
skipDesugaring HsExpr GhcTc
e' -> Hsc [HieAST Type]
fallback
| Bool
otherwise -> do
HscEnv
hs_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
$ \e :: HscEnv
e w :: WarningMessages
w -> (HscEnv, WarningMessages) -> IO (HscEnv, WarningMessages)
forall (m :: * -> *) a. Monad m => a -> m a
return (HscEnv
e,WarningMessages
w)
(_,mbe :: Maybe CoreExpr
mbe) <- IO (Messages, Maybe CoreExpr) -> Hsc (Messages, Maybe CoreExpr)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Messages, Maybe CoreExpr) -> Hsc (Messages, Maybe CoreExpr))
-> IO (Messages, Maybe CoreExpr) -> Hsc (Messages, Maybe CoreExpr)
forall a b. (a -> b) -> a -> b
$ HscEnv -> LHsExpr GhcTc -> IO (Messages, Maybe CoreExpr)
deSugarExpr HscEnv
hs_env LHsExpr GhcTc
e
Hsc [HieAST Type]
-> (CoreExpr -> Hsc [HieAST Type])
-> Maybe CoreExpr
-> Hsc [HieAST Type]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Hsc [HieAST Type]
fallback (HsExpr GhcTc -> SrcSpan -> Type -> Hsc [HieAST Type]
forall (m :: * -> *) a.
(Applicative m, Data a) =>
a -> SrcSpan -> Type -> m [HieAST Type]
makeTypeNode HsExpr GhcTc
e' SrcSpan
spn (Type -> Hsc [HieAST Type])
-> (CoreExpr -> Type) -> CoreExpr -> Hsc [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoreExpr -> Type
exprType) Maybe CoreExpr
mbe
where
fallback :: Hsc [HieAST Type]
fallback = HsExpr GhcTc -> SrcSpan -> Hsc [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsExpr GhcTc
e' SrcSpan
spn
matchGroupType :: MatchGroupTc -> Type
matchGroupType :: MatchGroupTc -> Type
matchGroupType (MatchGroupTc args :: [Type]
args res :: Type
res) = [Type] -> Type -> Type
mkFunTys [Type]
args Type
res
skipDesugaring :: HsExpr a -> Bool
skipDesugaring :: HsExpr a -> Bool
skipDesugaring e :: HsExpr a
e = case HsExpr a
e of
HsVar{} -> Bool
False
HsUnboundVar{} -> Bool
False
HsConLikeOut{} -> Bool
False
HsRecFld{} -> Bool
False
HsOverLabel{} -> Bool
False
HsIPVar{} -> Bool
False
HsWrap{} -> Bool
False
_ -> Bool
True
instance ( ToHie (Context (Located (IdP a)))
, ToHie (MatchGroup a (LHsExpr a))
, ToHie (PScoped (LPat a))
, ToHie (GRHSs a (LHsExpr a))
, ToHie (LHsExpr a)
, ToHie (Located (PatSynBind a a))
, HasType (LHsBind a)
, ModifyState (IdP a)
, Data (HsBind a)
) => ToHie (BindContext (LHsBind a)) where
toHie :: BindContext (LHsBind a) -> HieM [HieAST Type]
toHie (BC context :: BindType
context scope :: Scope
scope b :: LHsBind a
b@(L span :: SrcSpan
span bind :: HsBind a
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
$ LHsBind a -> HieM [HieAST Type]
forall a. HasType a => a -> HieM [HieAST Type]
getTypeNode LHsBind a
b HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsBind a
bind of
FunBind{fun_id :: forall idL idR. HsBindLR idL idR -> Located (IdP idL)
fun_id = Located (IdP a)
name, fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches = MatchGroup a (LHsExpr a)
matches} ->
[ Context (Located (IdP a)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located (IdP a)) -> HieM [HieAST Type])
-> Context (Located (IdP a)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located (IdP a) -> Context (Located (IdP a))
forall a. ContextInfo -> a -> Context a
C (BindType -> Scope -> Maybe RealSrcSpan -> ContextInfo
ValBind BindType
context Scope
scope (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located (IdP a)
name
, MatchGroup a (LHsExpr a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup a (LHsExpr a)
matches
]
PatBind{pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat a
lhs, pat_rhs :: forall idL idR. HsBindLR idL idR -> GRHSs idR (LHsExpr idR)
pat_rhs = GRHSs a (LHsExpr a)
rhs} ->
[ PScoped (LPat a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat a) -> HieM [HieAST Type])
-> PScoped (LPat a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan -> Scope -> Scope -> LPat a -> PScoped (LPat a)
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS (SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Scope
scope Scope
NoScope LPat a
lhs
, GRHSs a (LHsExpr a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GRHSs a (LHsExpr a)
rhs
]
VarBind{var_rhs :: forall idL idR. HsBindLR idL idR -> LHsExpr idR
var_rhs = LHsExpr a
expr} ->
[ LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
expr
]
AbsBinds{abs_exports :: forall idL idR. HsBindLR idL idR -> [ABExport idL]
abs_exports = [ABExport a]
xs, abs_binds :: forall idL idR. HsBindLR idL idR -> LHsBinds idL
abs_binds = LHsBinds a
binds} ->
[ (HieState -> HieState) -> HieM [HieAST Type] -> HieM [HieAST Type]
forall r (m :: * -> *) a.
(r -> r) -> ReaderT r m a -> ReaderT r m a
local ([ABExport a] -> HieState -> HieState
forall p.
ModifyState (IdP p) =>
[ABExport p] -> HieState -> HieState
modifyState [ABExport a]
xs) (HieM [HieAST Type] -> HieM [HieAST Type])
-> HieM [HieAST Type] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$
Bag (BindContext (LHsBind a)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (LHsBind a)) -> HieM [HieAST Type])
-> Bag (BindContext (LHsBind a)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsBind a -> BindContext (LHsBind a))
-> LHsBinds a -> Bag (BindContext (LHsBind a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType -> Scope -> LHsBind a -> BindContext (LHsBind a)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
context Scope
scope) LHsBinds a
binds
]
PatSynBind _ psb :: PatSynBind a a
psb ->
[ Located (PatSynBind a a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Located (PatSynBind a a) -> HieM [HieAST Type])
-> Located (PatSynBind a a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan -> PatSynBind a a -> Located (PatSynBind a a)
forall l e. l -> e -> GenLocated l e
L SrcSpan
span PatSynBind a a
psb
]
XHsBindsLR _ -> []
instance ( ToHie (LMatch a body)
) => ToHie (MatchGroup a body) where
toHie :: MatchGroup a body -> HieM [HieAST Type]
toHie mg :: MatchGroup a body
mg = [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 MatchGroup a body
mg of
MG{ mg_alts :: forall p body. MatchGroup p body -> Located [LMatch p body]
mg_alts = (L span :: SrcSpan
span alts :: [LMatch a body]
alts) , mg_origin :: forall p body. MatchGroup p body -> Origin
mg_origin = Origin
FromSource } ->
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
span
, [LMatch a body] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LMatch a body]
alts
]
MG{} -> []
XMatchGroup _ -> []
instance ( ToHie (Context (Located (IdP a)))
, ToHie (PScoped (LPat a))
, ToHie (HsPatSynDir a)
) => ToHie (Located (PatSynBind a a)) where
toHie :: Located (PatSynBind a a) -> HieM [HieAST Type]
toHie (L sp :: SrcSpan
sp psb :: PatSynBind a a
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 a a
psb of
PSB{psb_id :: forall idL idR. PatSynBind idL idR -> Located (IdP idL)
psb_id=Located (IdP a)
var, psb_args :: forall idL idR.
PatSynBind idL idR -> HsPatSynDetails (Located (IdP idR))
psb_args=HsPatSynDetails (Located (IdP a))
dets, psb_def :: forall idL idR. PatSynBind idL idR -> LPat idR
psb_def=LPat a
pat, psb_dir :: forall idL idR. PatSynBind idL idR -> HsPatSynDir idR
psb_dir=HsPatSynDir a
dir} ->
[ Context (Located (IdP a)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located (IdP a)) -> HieM [HieAST Type])
-> Context (Located (IdP a)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located (IdP a) -> Context (Located (IdP a))
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
PatSynDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
sp) Located (IdP a)
var
, HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
-> HieM [HieAST Type])
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsPatSynDetails (Located (IdP a))
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
toBind HsPatSynDetails (Located (IdP a))
dets
, PScoped (LPat a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat a) -> HieM [HieAST Type])
-> PScoped (LPat a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan -> Scope -> Scope -> LPat a -> PScoped (LPat a)
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
forall a. Maybe a
Nothing Scope
lhsScope Scope
NoScope LPat a
pat
, HsPatSynDir a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsPatSynDir a
dir
]
where
lhsScope :: Scope
lhsScope = Scope -> Scope -> Scope
combineScopes Scope
varScope Scope
detScope
varScope :: Scope
varScope = Located (IdP a) -> Scope
forall a. Located a -> Scope
mkLScope Located (IdP a)
var
detScope :: Scope
detScope = case HsPatSynDetails (Located (IdP a))
dets of
(PrefixCon args :: [Located (IdP a)]
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
$ (Located (IdP a) -> Scope) -> [Located (IdP a)] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map Located (IdP a) -> Scope
forall a. Located a -> Scope
mkLScope [Located (IdP a)]
args
(InfixCon a :: Located (IdP a)
a b :: Located (IdP a)
b) -> Scope -> Scope -> Scope
combineScopes (Located (IdP a) -> Scope
forall a. Located a -> Scope
mkLScope Located (IdP a)
a) (Located (IdP a) -> Scope
forall a. Located a -> Scope
mkLScope Located (IdP a)
b)
(RecCon r :: [RecordPatSynField (Located (IdP a))]
r) -> (RecordPatSynField (Located (IdP a)) -> Scope -> Scope)
-> Scope -> [RecordPatSynField (Located (IdP a))] -> Scope
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr RecordPatSynField (Located (IdP a)) -> Scope -> Scope
forall a. RecordPatSynField (Located a) -> Scope -> Scope
go Scope
NoScope [RecordPatSynField (Located (IdP a))]
r
go :: RecordPatSynField (Located a) -> Scope -> Scope
go (RecordPatSynField a :: Located a
a b :: Located a
b) c :: Scope
c = Scope -> Scope -> Scope
combineScopes Scope
c
(Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ Scope -> Scope -> Scope
combineScopes (Located a -> Scope
forall a. Located a -> Scope
mkLScope Located a
a) (Located a -> Scope
forall a. Located a -> Scope
mkLScope Located a
b)
detSpan :: Maybe RealSrcSpan
detSpan = case Scope
detScope of
LocalScope a :: RealSrcSpan
a -> RealSrcSpan -> Maybe RealSrcSpan
forall a. a -> Maybe a
Just RealSrcSpan
a
_ -> Maybe RealSrcSpan
forall a. Maybe a
Nothing
toBind :: HsPatSynDetails (Located (IdP a))
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
toBind (PrefixCon args :: [Located (IdP a)]
args) = [Context (Located (IdP a))]
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
forall arg rec. [arg] -> HsConDetails arg rec
PrefixCon ([Context (Located (IdP a))]
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))])
-> [Context (Located (IdP a))]
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
forall a b. (a -> b) -> a -> b
$ (Located (IdP a) -> Context (Located (IdP a)))
-> [Located (IdP a)] -> [Context (Located (IdP a))]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located (IdP a) -> Context (Located (IdP a))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located (IdP a)]
args
toBind (InfixCon a :: Located (IdP a)
a b :: Located (IdP a)
b) = Context (Located (IdP a))
-> Context (Located (IdP a))
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
forall arg rec. arg -> arg -> HsConDetails arg rec
InfixCon (ContextInfo -> Located (IdP a) -> Context (Located (IdP a))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located (IdP a)
a) (ContextInfo -> Located (IdP a) -> Context (Located (IdP a))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located (IdP a)
b)
toBind (RecCon r :: [RecordPatSynField (Located (IdP a))]
r) = [PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
forall arg rec. rec -> HsConDetails arg rec
RecCon ([PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))])
-> [PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
-> HsConDetails
(Context (Located (IdP a)))
[PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
forall a b. (a -> b) -> a -> b
$ (RecordPatSynField (Located (IdP a))
-> PatSynFieldContext (RecordPatSynField (Located (IdP a))))
-> [RecordPatSynField (Located (IdP a))]
-> [PatSynFieldContext (RecordPatSynField (Located (IdP a)))]
forall a b. (a -> b) -> [a] -> [b]
map (Maybe RealSrcSpan
-> RecordPatSynField (Located (IdP a))
-> PatSynFieldContext (RecordPatSynField (Located (IdP a)))
forall a. Maybe RealSrcSpan -> a -> PatSynFieldContext a
PSC Maybe RealSrcSpan
detSpan) [RecordPatSynField (Located (IdP a))]
r
XPatSynBind _ -> []
instance ( ToHie (MatchGroup a (LHsExpr a))
) => ToHie (HsPatSynDir a) where
toHie :: HsPatSynDir a -> HieM [HieAST Type]
toHie dir :: HsPatSynDir a
dir = case HsPatSynDir a
dir of
ExplicitBidirectional mg :: MatchGroup a (LHsExpr a)
mg -> MatchGroup a (LHsExpr a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup a (LHsExpr a)
mg
_ -> [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ( a ~ GhcPass p
, ToHie body
, ToHie (HsMatchContext (NameOrRdrName (IdP a)))
, ToHie (PScoped (LPat a))
, ToHie (GRHSs a body)
, Data (Match a body)
) => ToHie (LMatch (GhcPass p) body) where
toHie :: LMatch (GhcPass p) body -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span m :: Match (GhcPass p) body
m ) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Match (GhcPass p) body -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode Match (GhcPass p) body
m SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case Match (GhcPass p) body
m of
Match{m_ctxt :: forall p body.
Match p body -> HsMatchContext (NameOrRdrName (IdP p))
m_ctxt=HsMatchContext (NameOrRdrName (IdP (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) body
grhss } ->
[ HsMatchContext (NameOrRdrName (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsMatchContext (NameOrRdrName (IdP (GhcPass p)))
mctx
, let rhsScope :: Scope
rhsScope = SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GRHSs (GhcPass p) body -> SrcSpan
forall p body. GRHSs p body -> SrcSpan
grhss_span GRHSs (GhcPass p) body
grhss
in [PScoped (LPat (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([PScoped (LPat (GhcPass p))] -> HieM [HieAST Type])
-> [PScoped (LPat (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe RealSrcSpan
forall a. Maybe a
Nothing Scope
rhsScope Scope
NoScope [LPat (GhcPass p)]
pats
, GRHSs (GhcPass p) body -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GRHSs (GhcPass p) body
grhss
]
XMatch _ -> []
instance ( ToHie (Context (Located a))
) => ToHie (HsMatchContext a) where
toHie :: HsMatchContext a -> HieM [HieAST Type]
toHie (FunRhs{mc_fun :: forall id. HsMatchContext id -> Located id
mc_fun=Located a
name}) = Context (Located a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located a) -> HieM [HieAST Type])
-> Context (Located a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located a -> Context (Located a)
forall a. ContextInfo -> a -> Context a
C ContextInfo
MatchBind Located a
name
toHie (StmtCtxt a :: HsStmtContext a
a) = HsStmtContext a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsStmtContext a
a
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ( ToHie (HsMatchContext a)
) => ToHie (HsStmtContext a) where
toHie :: HsStmtContext a -> HieM [HieAST Type]
toHie (PatGuard a :: HsMatchContext a
a) = HsMatchContext a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsMatchContext a
a
toHie (ParStmtCtxt a :: HsStmtContext a
a) = HsStmtContext a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsStmtContext a
a
toHie (TransStmtCtxt a :: HsStmtContext a
a) = HsStmtContext a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsStmtContext a
a
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ( a ~ GhcPass p
, ToHie (Context (Located (IdP a)))
, ToHie (RContext (HsRecFields a (PScoped (LPat a))))
, ToHie (LHsExpr a)
, ToHie (TScoped (LHsSigWcType a))
, ProtectSig a
, ToHie (TScoped (ProtectedSig a))
, HasType (LPat a)
, Data (HsSplice a)
) => ToHie (PScoped (LPat (GhcPass p))) where
toHie :: PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
toHie (PS rsp :: Maybe RealSrcSpan
rsp scope :: Scope
scope pscope :: Scope
pscope lpat :: LPat (GhcPass p)
lpat@(LPat (GhcPass p) -> Located (SrcSpanLess (LPat (GhcPass p)))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL -> L ospan :: SrcSpan
ospan opat :: SrcSpanLess (LPat (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
$ LPat (GhcPass p) -> HieM [HieAST Type]
forall a. HasType a => a -> HieM [HieAST Type]
getTypeNode LPat (GhcPass p)
lpat HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case SrcSpanLess (LPat (GhcPass p))
opat of
WildPat _ ->
[]
VarPat _ lname ->
[ Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type])
-> Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> Located (IdP (GhcPass p)) -> Context (Located (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C (Scope -> Scope -> Maybe RealSrcSpan -> ContextInfo
PatternBind Scope
scope Scope
pscope Maybe RealSrcSpan
rsp) Located (IdP (GhcPass p))
lname
]
LazyPat _ p ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
p
]
AsPat _ lname pat ->
[ Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type])
-> Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> Located (IdP (GhcPass p)) -> Context (Located (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C (Scope -> Scope -> Maybe RealSrcSpan -> ContextInfo
PatternBind Scope
scope
(Scope -> Scope -> Scope
combineScopes (Located (LPat (GhcPass p)) -> Scope
forall a. Located a -> Scope
mkLScope (LPat (GhcPass p) -> Located (SrcSpanLess (LPat (GhcPass p)))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL LPat (GhcPass p)
pat)) Scope
pscope)
Maybe RealSrcSpan
rsp)
Located (IdP (GhcPass p))
lname
, PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
pat
]
ParPat _ pat ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
pat
]
BangPat _ pat ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
pat
]
ListPat _ pats ->
[ [PScoped (LPat (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([PScoped (LPat (GhcPass p))] -> HieM [HieAST Type])
-> [PScoped (LPat (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe RealSrcSpan
rsp Scope
scope Scope
pscope [LPat (GhcPass p)]
pats
]
TuplePat _ pats _ ->
[ [PScoped (LPat (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([PScoped (LPat (GhcPass p))] -> HieM [HieAST Type])
-> [PScoped (LPat (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe RealSrcSpan
rsp Scope
scope Scope
pscope [LPat (GhcPass p)]
pats
]
SumPat _ pat _ _ ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
pat
]
ConPatIn c dets ->
[ Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type])
-> Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> Located (IdP (GhcPass p)) -> Context (Located (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located (IdP (GhcPass p))
c
, HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HieM [HieAST Type])
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
(LPat (GhcPass p)) (HsRecFields (GhcPass p) (LPat (GhcPass p)))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
contextify HsConDetails
(LPat (GhcPass p)) (HsRecFields (GhcPass p) (LPat (GhcPass p)))
dets
]
ConPatOut {pat_con = con, pat_args = dets}->
[ 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 ContextInfo
Use (Located Name -> Context (Located Name))
-> Located Name -> Context (Located Name)
forall a b. (a -> b) -> a -> b
$ (ConLike -> Name) -> GenLocated SrcSpan ConLike -> Located Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConLike -> Name
conLikeName GenLocated SrcSpan ConLike
con
, HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HieM [HieAST Type])
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ HsConDetails
(LPat (GhcPass p)) (HsRecFields (GhcPass p) (LPat (GhcPass p)))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
contextify HsConDetails
(LPat (GhcPass p)) (HsRecFields (GhcPass p) (LPat (GhcPass p)))
dets
]
ViewPat _ expr pat ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
pat
]
SplicePat _ sp ->
[ GenLocated SrcSpan (HsSplice (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (HsSplice (GhcPass p)) -> HieM [HieAST Type])
-> GenLocated SrcSpan (HsSplice (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> HsSplice (GhcPass p)
-> GenLocated SrcSpan (HsSplice (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpan
ospan HsSplice (GhcPass p)
sp
]
LitPat _ _ ->
[]
NPat _ _ _ _ ->
[]
NPlusKPat _ n _ _ _ _ ->
[ Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type])
-> Context (Located (IdP (GhcPass p))) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> Located (IdP (GhcPass p)) -> Context (Located (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C (Scope -> Scope -> Maybe RealSrcSpan -> ContextInfo
PatternBind Scope
scope Scope
pscope Maybe RealSrcSpan
rsp) Located (IdP (GhcPass p))
n
]
SigPat _ pat sig ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
pscope LPat (GhcPass p)
pat
, let cscope :: Scope
cscope = Located (LPat (GhcPass p)) -> Scope
forall a. Located a -> Scope
mkLScope (LPat (GhcPass p) -> Located (SrcSpanLess (LPat (GhcPass p)))
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL LPat (GhcPass p)
pat) in
TScoped (ProtectedSig (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (ProtectedSig (GhcPass p)) -> HieM [HieAST Type])
-> TScoped (ProtectedSig (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> ProtectedSig (GhcPass p) -> TScoped (ProtectedSig (GhcPass p))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
cscope, Scope
scope, Scope
pscope])
(Scope -> LHsSigWcType (NoGhcTc a) -> ProtectedSig a
forall a.
ProtectSig a =>
Scope -> LHsSigWcType (NoGhcTc a) -> ProtectedSig a
protectSig @a Scope
cscope LHsSigWcType (NoGhcTc a)
LHsSigWcType (NoGhcTc (GhcPass p))
sig)
]
CoPat _ _ _ _ ->
[]
XPat _ -> []
where
contextify :: HsConDetails
(LPat (GhcPass p)) (HsRecFields (GhcPass p) (LPat (GhcPass p)))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
contextify (PrefixCon args :: [LPat (GhcPass p)]
args) = [PScoped (LPat (GhcPass p))]
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
forall arg rec. [arg] -> HsConDetails arg rec
PrefixCon ([PScoped (LPat (GhcPass p))]
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))))
-> [PScoped (LPat (GhcPass p))]
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe RealSrcSpan
rsp Scope
scope Scope
pscope [LPat (GhcPass p)]
args
contextify (InfixCon a :: LPat (GhcPass p)
a b :: LPat (GhcPass p)
b) = PScoped (LPat (GhcPass p))
-> PScoped (LPat (GhcPass p))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
forall arg rec. arg -> arg -> HsConDetails arg rec
InfixCon PScoped (LPat (GhcPass p))
a' PScoped (LPat (GhcPass p))
b'
where [a' :: PScoped (LPat (GhcPass p))
a', b' :: PScoped (LPat (GhcPass p))
b'] = Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
forall (p :: Pass).
Maybe RealSrcSpan
-> Scope
-> Scope
-> [LPat (GhcPass p)]
-> [PScoped (LPat (GhcPass p))]
patScopes Maybe RealSrcSpan
rsp Scope
scope Scope
pscope [LPat (GhcPass p)
a,LPat (GhcPass p)
b]
contextify (RecCon r :: HsRecFields (GhcPass p) (LPat (GhcPass p))
r) = RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
forall arg rec. rec -> HsConDetails arg rec
RecCon (RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))))
-> RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))
-> HsConDetails
(PScoped (LPat (GhcPass p)))
(RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
forall a b. (a -> b) -> a -> b
$ RecFieldContext
-> HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))
-> RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
RecFieldMatch (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))
-> RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))))
-> HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))
-> RContext (HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p))))
forall a b. (a -> b) -> a -> b
$ HsRecFields (GhcPass p) (LPat (GhcPass p))
-> HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))
contextify_rec HsRecFields (GhcPass p) (LPat (GhcPass p))
r
contextify_rec :: HsRecFields (GhcPass p) (LPat (GhcPass p))
-> HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))
contextify_rec (HsRecFields fds :: [LHsRecField (GhcPass p) (LPat (GhcPass p))]
fds a :: Maybe TypeIndex
a) = [LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p)))]
-> Maybe TypeIndex
-> HsRecFields (GhcPass p) (PScoped (LPat (GhcPass p)))
forall p arg.
[LHsRecField p arg] -> Maybe TypeIndex -> HsRecFields p arg
HsRecFields ((RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))
-> LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p))))
-> [RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))]
-> [LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p)))]
forall a b. (a -> b) -> [a] -> [b]
map RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))
-> LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p)))
go [RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))]
scoped_fds) Maybe TypeIndex
a
where
go :: RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))
-> LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p)))
go (RS fscope :: Scope
fscope (L spn :: SrcSpan
spn (HsRecField lbl :: Located (FieldOcc (GhcPass p))
lbl pat :: LPat (GhcPass p)
pat pun :: Bool
pun))) =
SrcSpan
-> HsRecField' (FieldOcc (GhcPass p)) (PScoped (LPat (GhcPass p)))
-> LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p)))
forall l e. l -> e -> GenLocated l e
L SrcSpan
spn (HsRecField' (FieldOcc (GhcPass p)) (PScoped (LPat (GhcPass p)))
-> LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p))))
-> HsRecField' (FieldOcc (GhcPass p)) (PScoped (LPat (GhcPass p)))
-> LHsRecField (GhcPass p) (PScoped (LPat (GhcPass p)))
forall a b. (a -> b) -> a -> b
$ Located (FieldOcc (GhcPass p))
-> PScoped (LPat (GhcPass p))
-> Bool
-> HsRecField' (FieldOcc (GhcPass p)) (PScoped (LPat (GhcPass p)))
forall id arg. Located id -> arg -> Bool -> HsRecField' id arg
HsRecField Located (FieldOcc (GhcPass p))
lbl (Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
rsp Scope
scope Scope
fscope LPat (GhcPass p)
pat) Bool
pun
scoped_fds :: [RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))]
scoped_fds = Scope
-> [LHsRecField (GhcPass p) (LPat (GhcPass p))]
-> [RScoped (LHsRecField (GhcPass p) (LPat (GhcPass p)))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
pscope [LHsRecField (GhcPass p) (LPat (GhcPass p))]
fds
instance ( ToHie body
, ToHie (LGRHS a body)
, ToHie (RScoped (LHsLocalBinds a))
) => ToHie (GRHSs a body) where
toHie :: GRHSs a body -> HieM [HieAST Type]
toHie grhs :: GRHSs a body
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 a body
grhs of
GRHSs _ grhss :: [LGRHS a body]
grhss binds :: LHsLocalBinds a
binds ->
[ [LGRHS a body] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LGRHS a body]
grhss
, RScoped (LHsLocalBinds a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (LHsLocalBinds a) -> HieM [HieAST Type])
-> RScoped (LHsLocalBinds a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope -> LHsLocalBinds a -> RScoped (LHsLocalBinds a)
forall a. Scope -> a -> RScoped a
RS (SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ GRHSs a body -> SrcSpan
forall p body. GRHSs p body -> SrcSpan
grhss_span GRHSs a body
grhs) LHsLocalBinds a
binds
]
XGRHSs _ -> []
instance ( ToHie (Located body)
, ToHie (RScoped (GuardLStmt a))
, Data (GRHS a (Located body))
) => ToHie (LGRHS a (Located body)) where
toHie :: LGRHS a (Located body) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span g :: GRHS a (Located body)
g) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM ([HieM [HieAST Type]] -> HieM [HieAST Type])
-> [HieM [HieAST Type]] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ GRHS a (Located body) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode GRHS a (Located body)
g SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case GRHS a (Located body)
g of
GRHS _ guards :: [GuardLStmt a]
guards body :: Located body
body ->
[ [RScoped (GuardLStmt a)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (GuardLStmt a)] -> HieM [HieAST Type])
-> [RScoped (GuardLStmt a)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope -> [GuardLStmt a] -> [RScoped (GuardLStmt a)]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes (Located body -> Scope
forall a. Located a -> Scope
mkLScope Located body
body) [GuardLStmt a]
guards
, Located body -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located body
body
]
XGRHS _ -> []
instance ( a ~ GhcPass p
, ToHie (Context (Located (IdP a)))
, HasType (LHsExpr a)
, ToHie (PScoped (LPat a))
, ToHie (MatchGroup a (LHsExpr a))
, ToHie (LGRHS a (LHsExpr a))
, ToHie (RContext (HsRecordBinds a))
, ToHie (RFContext (Located (AmbiguousFieldOcc a)))
, ToHie (ArithSeqInfo a)
, ToHie (LHsCmdTop a)
, ToHie (RScoped (GuardLStmt a))
, ToHie (RScoped (LHsLocalBinds a))
, ToHie (TScoped (LHsWcType (NoGhcTc a)))
, ToHie (TScoped (LHsSigWcType (NoGhcTc a)))
, Data (HsExpr a)
, Data (HsSplice a)
, Data (HsTupArg a)
, Data (AmbiguousFieldOcc a)
) => ToHie (LHsExpr (GhcPass p)) where
toHie :: LHsExpr (GhcPass p) -> HieM [HieAST Type]
toHie e :: LHsExpr (GhcPass p)
e@(L mspan :: SrcSpan
mspan oexpr :: 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
$ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. HasType a => a -> HieM [HieAST Type]
getTypeNode LHsExpr (GhcPass p)
e HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsExpr (GhcPass p)
oexpr of
HsVar _ (L _ var :: IdP (GhcPass p)
var) ->
[ Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type])
-> Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpan (IdP (GhcPass p))
-> Context (GenLocated SrcSpan (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use (SrcSpan -> IdP (GhcPass p) -> GenLocated SrcSpan (IdP (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpan
mspan IdP (GhcPass p)
var)
]
HsUnboundVar _ _ ->
[]
HsConLikeOut _ con :: ConLike
con ->
[ 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 ContextInfo
Use (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
mspan (Name -> Located Name) -> Name -> Located Name
forall a b. (a -> b) -> a -> b
$ ConLike -> Name
conLikeName ConLike
con
]
HsRecFld _ fld :: 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 RealSrcSpan
-> GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p))
-> RFContext (GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p)))
forall a. RecFieldContext -> Maybe RealSrcSpan -> a -> RFContext a
RFC RecFieldContext
RecFieldOcc Maybe RealSrcSpan
forall a. Maybe a
Nothing (SrcSpan
-> AmbiguousFieldOcc (GhcPass p)
-> GenLocated SrcSpan (AmbiguousFieldOcc (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpan
mspan AmbiguousFieldOcc (GhcPass p)
fld)
]
HsOverLabel _ _ _ -> []
HsIPVar _ _ -> []
HsOverLit _ _ -> []
HsLit _ _ -> []
HsLam _ mg :: MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg ->
[ MatchGroup (GhcPass p) (LHsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg
]
HsLamCase _ mg :: MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg ->
[ MatchGroup (GhcPass p) (LHsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
mg
]
HsApp _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
HsAppType _ expr :: LHsExpr (GhcPass p)
expr sig :: LHsWcType (NoGhcTc (GhcPass p))
sig ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, TScoped (LHsWcType (GhcPass (NoGhcTcPass p))) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsWcType (GhcPass (NoGhcTcPass p)))
-> HieM [HieAST Type])
-> TScoped (LHsWcType (GhcPass (NoGhcTcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> LHsWcType (GhcPass (NoGhcTcPass p))
-> TScoped (LHsWcType (GhcPass (NoGhcTcPass p)))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsWcType (NoGhcTc (GhcPass p))
LHsWcType (GhcPass (NoGhcTcPass p))
sig
]
OpApp _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b c :: LHsExpr (GhcPass p)
c ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
c
]
NegApp _ a :: LHsExpr (GhcPass p)
a _ ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
]
HsPar _ a :: LHsExpr (GhcPass p)
a ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
]
SectionL _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
SectionR _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
ExplicitTuple _ args :: [LHsTupArg (GhcPass p)]
args _ ->
[ [LHsTupArg (GhcPass p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsTupArg (GhcPass p)]
args
]
ExplicitSum _ _ _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsCase _ expr :: LHsExpr (GhcPass p)
expr matches :: MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
matches ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, MatchGroup (GhcPass p) (LHsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsExpr (GhcPass p))
matches
]
HsIf _ _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b c :: LHsExpr (GhcPass p)
c ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
c
]
HsMultiIf _ grhss :: [LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
grhss ->
[ [LGRHS (GhcPass p) (LHsExpr (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LGRHS (GhcPass p) (LHsExpr (GhcPass p))]
grhss
]
HsLet _ binds :: LHsLocalBinds (GhcPass p)
binds expr :: LHsExpr (GhcPass p)
expr ->
[ RScoped (LHsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (LHsLocalBinds (GhcPass p)) -> HieM [HieAST Type])
-> RScoped (LHsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> LHsLocalBinds (GhcPass p) -> RScoped (LHsLocalBinds (GhcPass p))
forall a. Scope -> a -> RScoped a
RS (LHsExpr (GhcPass p) -> Scope
forall a. Located a -> Scope
mkLScope LHsExpr (GhcPass p)
expr) LHsLocalBinds (GhcPass p)
binds
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsDo _ _ (L ispan :: SrcSpan
ispan stmts :: [ExprLStmt (GhcPass p)]
stmts) ->
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
ispan
, [RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type])
-> [RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [ExprLStmt (GhcPass p)] -> [RScoped (ExprLStmt (GhcPass p))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
NoScope [ExprLStmt (GhcPass p)]
stmts
]
ExplicitList _ _ exprs :: [LHsExpr (GhcPass p)]
exprs ->
[ [LHsExpr (GhcPass p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsExpr (GhcPass p)]
exprs
]
RecordCon {rcon_con_name :: forall p. HsExpr p -> Located (IdP p)
rcon_con_name = GenLocated SrcSpan (IdP (GhcPass p))
name, rcon_flds :: forall p. HsExpr p -> HsRecordBinds p
rcon_flds = HsRecordBinds (GhcPass p)
binds}->
[ Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type])
-> Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpan (IdP (GhcPass p))
-> Context (GenLocated SrcSpan (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpan (IdP (GhcPass p))
name
, RContext (HsRecordBinds (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RContext (HsRecordBinds (GhcPass p)) -> HieM [HieAST Type])
-> RContext (HsRecordBinds (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
]
RecordUpd {rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = LHsExpr (GhcPass p)
expr, rupd_flds :: forall p. HsExpr p -> [LHsRecUpdField p]
rupd_flds = [LHsRecUpdField (GhcPass p)]
upds}->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, [RContext (LHsRecUpdField (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RContext (LHsRecUpdField (GhcPass p))] -> HieM [HieAST Type])
-> [RContext (LHsRecUpdField (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsRecUpdField (GhcPass p)
-> RContext (LHsRecUpdField (GhcPass p)))
-> [LHsRecUpdField (GhcPass p)]
-> [RContext (LHsRecUpdField (GhcPass p))]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> LHsRecUpdField (GhcPass p)
-> RContext (LHsRecUpdField (GhcPass p))
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
RecFieldAssign) [LHsRecUpdField (GhcPass p)]
upds
]
ExprWithTySig _ expr :: LHsExpr (GhcPass p)
expr sig :: LHsSigWcType (NoGhcTc (GhcPass p))
sig ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, TScoped (LHsSigWcType (GhcPass (NoGhcTcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigWcType (GhcPass (NoGhcTcPass p)))
-> HieM [HieAST Type])
-> TScoped (LHsSigWcType (GhcPass (NoGhcTcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> LHsSigWcType (GhcPass (NoGhcTcPass p))
-> TScoped (LHsSigWcType (GhcPass (NoGhcTcPass p)))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [LHsExpr (GhcPass p) -> Scope
forall a. Located a -> Scope
mkLScope LHsExpr (GhcPass p)
expr]) LHsSigWcType (NoGhcTc (GhcPass p))
LHsSigWcType (GhcPass (NoGhcTcPass p))
sig
]
ArithSeq _ _ info :: ArithSeqInfo (GhcPass p)
info ->
[ ArithSeqInfo (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ArithSeqInfo (GhcPass p)
info
]
HsSCC _ _ _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsCoreAnn _ _ _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsProc _ pat :: LPat (GhcPass p)
pat cmdtop :: LHsCmdTop (GhcPass p)
cmdtop ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
forall a. Maybe a
Nothing (LHsCmdTop (GhcPass p) -> Scope
forall a. Located a -> Scope
mkLScope LHsCmdTop (GhcPass p)
cmdtop) Scope
NoScope LPat (GhcPass p)
pat
, LHsCmdTop (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmdTop (GhcPass p)
cmdtop
]
HsStatic _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsArrApp _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b _ _ ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
HsArrForm _ expr :: LHsExpr (GhcPass p)
expr _ cmds :: [LHsCmdTop (GhcPass p)]
cmds ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, [LHsCmdTop (GhcPass p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsCmdTop (GhcPass p)]
cmds
]
HsTick _ _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsBinTick _ _ _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsTickPragma _ _ _ _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
HsWrap _ _ a :: HsExpr (GhcPass p)
a ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (LHsExpr (GhcPass p) -> HieM [HieAST Type])
-> LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan -> HsExpr (GhcPass p) -> LHsExpr (GhcPass p)
forall l e. l -> e -> GenLocated l e
L SrcSpan
mspan HsExpr (GhcPass p)
a
]
HsBracket _ b :: HsBracket (GhcPass p)
b ->
[ HsBracket (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsBracket (GhcPass p)
b
]
HsRnBracketOut _ b :: HsBracket GhcRn
b p :: [PendingRnSplice]
p ->
[ HsBracket GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsBracket GhcRn
b
, [PendingRnSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingRnSplice]
p
]
HsTcBracketOut _ b :: HsBracket GhcRn
b p :: [PendingTcSplice]
p ->
[ HsBracket GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsBracket GhcRn
b
, [PendingTcSplice] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [PendingTcSplice]
p
]
HsSpliceE _ x :: HsSplice (GhcPass p)
x ->
[ GenLocated SrcSpan (HsSplice (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (HsSplice (GhcPass p)) -> HieM [HieAST Type])
-> GenLocated SrcSpan (HsSplice (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> HsSplice (GhcPass p)
-> GenLocated SrcSpan (HsSplice (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpan
mspan HsSplice (GhcPass p)
x
]
EWildPat _ -> []
EAsPat _ a :: GenLocated SrcSpan (IdP (GhcPass p))
a b :: LHsExpr (GhcPass p)
b ->
[ Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type])
-> Context (GenLocated SrcSpan (IdP (GhcPass p)))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo
-> GenLocated SrcSpan (IdP (GhcPass p))
-> Context (GenLocated SrcSpan (IdP (GhcPass p)))
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use GenLocated SrcSpan (IdP (GhcPass p))
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
EViewPat _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
ELazyPat _ a :: LHsExpr (GhcPass p)
a ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
]
XExpr _ -> []
instance ( a ~ GhcPass p
, ToHie (LHsExpr a)
, Data (HsTupArg a)
) => ToHie (LHsTupArg (GhcPass p)) where
toHie :: LHsTupArg (GhcPass p) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span arg :: 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
$ HsTupArg (GhcPass p) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsTupArg (GhcPass p)
arg SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsTupArg (GhcPass p)
arg of
Present _ expr :: LHsExpr (GhcPass p)
expr ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
Missing _ -> []
XTupArg _ -> []
instance ( a ~ GhcPass p
, ToHie (PScoped (LPat a))
, ToHie (LHsExpr a)
, ToHie (SigContext (LSig a))
, ToHie (RScoped (LHsLocalBinds a))
, ToHie (RScoped (ApplicativeArg a))
, ToHie (Located body)
, Data (StmtLR a a (Located body))
, Data (StmtLR a a (Located (HsExpr a)))
) => ToHie (RScoped (LStmt (GhcPass p) (Located body))) where
toHie :: RScoped (LStmt (GhcPass p) (Located body)) -> HieM [HieAST Type]
toHie (RS scope :: Scope
scope (L span :: SrcSpan
span stmt :: StmtLR (GhcPass p) (GhcPass p) (Located body)
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
$ StmtLR (GhcPass p) (GhcPass p) (Located body)
-> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode StmtLR (GhcPass p) (GhcPass p) (Located body)
stmt SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case StmtLR (GhcPass p) (GhcPass p) (Located body)
stmt of
LastStmt _ body :: Located body
body _ _ ->
[ Located body -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located body
body
]
BindStmt _ pat :: LPat (GhcPass p)
pat body :: Located body
body _ _ ->
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS (SrcSpan -> Maybe RealSrcSpan
getRealSpan (SrcSpan -> Maybe RealSrcSpan) -> SrcSpan -> Maybe RealSrcSpan
forall a b. (a -> b) -> a -> b
$ Located body -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc Located body
body) Scope
scope Scope
NoScope LPat (GhcPass p)
pat
, Located body -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located body
body
]
ApplicativeStmt _ stmts :: [(SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))]
stmts _ ->
[ ((SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))
-> HieM [HieAST Type])
-> [(SyntaxExpr (GhcPass 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])
-> ((SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))
-> RScoped (ApplicativeArg (GhcPass p)))
-> (SyntaxExpr (GhcPass 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)))
-> ((SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))
-> ApplicativeArg (GhcPass p))
-> (SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))
-> RScoped (ApplicativeArg (GhcPass p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))
-> ApplicativeArg (GhcPass p)
forall a b. (a, b) -> b
snd) [(SyntaxExpr (GhcPass p), ApplicativeArg (GhcPass p))]
stmts
]
BodyStmt _ body :: Located body
body _ _ ->
[ Located body -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located body
body
]
LetStmt _ binds :: LHsLocalBindsLR (GhcPass p) (GhcPass p)
binds ->
[ RScoped (LHsLocalBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (LHsLocalBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type])
-> RScoped (LHsLocalBindsLR (GhcPass p) (GhcPass p))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> LHsLocalBindsLR (GhcPass p) (GhcPass p)
-> RScoped (LHsLocalBindsLR (GhcPass p) (GhcPass p))
forall a. Scope -> a -> RScoped a
RS Scope
scope LHsLocalBindsLR (GhcPass p) (GhcPass p)
binds
]
ParStmt _ parstmts :: [ParStmtBlock (GhcPass p) (GhcPass p)]
parstmts _ _ ->
[ (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 _ stmts :: [ExprLStmt (GhcPass p)]
stmts _ _) ->
[RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type])
-> [RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [ExprLStmt (GhcPass p)] -> [RScoped (ExprLStmt (GhcPass p))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
NoScope [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 (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type])
-> [RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [ExprLStmt (GhcPass p)] -> [RScoped (ExprLStmt (GhcPass p))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
scope [ExprLStmt (GhcPass p)]
stmts
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
using
, Maybe (LHsExpr (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsExpr (GhcPass p))
by
]
RecStmt {recS_stmts :: forall idL idR body. StmtLR idL idR body -> [LStmtLR idL idR body]
recS_stmts = [LStmt (GhcPass p) (Located body)]
stmts} ->
[ [RScoped (LStmt (GhcPass p) (Located body))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (LStmt (GhcPass p) (Located body))]
-> HieM [HieAST Type])
-> [RScoped (LStmt (GhcPass p) (Located body))]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LStmt (GhcPass p) (Located body)
-> RScoped (LStmt (GhcPass p) (Located body)))
-> [LStmt (GhcPass p) (Located body)]
-> [RScoped (LStmt (GhcPass p) (Located body))]
forall a b. (a -> b) -> [a] -> [b]
map (Scope
-> LStmt (GhcPass p) (Located body)
-> RScoped (LStmt (GhcPass p) (Located body))
forall a. Scope -> a -> RScoped a
RS (Scope
-> LStmt (GhcPass p) (Located body)
-> RScoped (LStmt (GhcPass p) (Located body)))
-> Scope
-> LStmt (GhcPass p) (Located body)
-> RScoped (LStmt (GhcPass p) (Located body))
forall a b. (a -> b) -> a -> b
$ Scope -> Scope -> Scope
combineScopes Scope
scope (SrcSpan -> Scope
mkScope SrcSpan
span)) [LStmt (GhcPass p) (Located body)]
stmts
]
XStmtLR _ -> []
instance ( ToHie (LHsExpr a)
, ToHie (PScoped (LPat a))
, ToHie (BindContext (LHsBind a))
, ToHie (SigContext (LSig a))
, ToHie (RScoped (HsValBindsLR a a))
, Data (HsLocalBinds a)
) => ToHie (RScoped (LHsLocalBinds a)) where
toHie :: RScoped (LHsLocalBinds a) -> HieM [HieAST Type]
toHie (RS scope :: Scope
scope (L sp :: SrcSpan
sp binds :: HsLocalBinds a
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 a -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsLocalBinds a
binds SrcSpan
sp HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsLocalBinds a
binds of
EmptyLocalBinds _ -> []
HsIPBinds _ _ -> []
HsValBinds _ valBinds :: HsValBindsLR a a
valBinds ->
[ RScoped (HsValBindsLR a a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (HsValBindsLR a a) -> HieM [HieAST Type])
-> RScoped (HsValBindsLR a a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope -> HsValBindsLR a a -> RScoped (HsValBindsLR a a)
forall a. Scope -> a -> RScoped a
RS (Scope -> Scope -> Scope
combineScopes Scope
scope (Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Scope
mkScope SrcSpan
sp)
HsValBindsLR a a
valBinds
]
XHsLocalBindsLR _ -> []
instance ( ToHie (BindContext (LHsBind a))
, ToHie (SigContext (LSig a))
, ToHie (RScoped (XXValBindsLR a a))
) => ToHie (RScoped (HsValBindsLR a a)) where
toHie :: RScoped (HsValBindsLR a a) -> HieM [HieAST Type]
toHie (RS sc :: Scope
sc v :: HsValBindsLR a a
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 a a
v of
ValBinds _ binds :: LHsBindsLR a a
binds sigs :: [LSig a]
sigs ->
[ Bag (BindContext (LHsBind a)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (LHsBind a)) -> HieM [HieAST Type])
-> Bag (BindContext (LHsBind a)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsBind a -> BindContext (LHsBind a))
-> LHsBindsLR a a -> Bag (BindContext (LHsBind a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType -> Scope -> LHsBind a -> BindContext (LHsBind a)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
sc) LHsBindsLR a a
binds
, [SigContext (LSig a)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (LSig a)] -> HieM [HieAST Type])
-> [SigContext (LSig a)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LSig a -> SigContext (LSig a))
-> [LSig a] -> [SigContext (LSig a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SigInfo -> LSig a -> SigContext (LSig a)
forall a. SigInfo -> a -> SigContext a
SC (SigType -> Maybe RealSrcSpan -> SigInfo
SI SigType
BindSig Maybe RealSrcSpan
forall a. Maybe a
Nothing)) [LSig a]
sigs
]
XValBindsLR x :: XXValBindsLR a a
x -> [ RScoped (XXValBindsLR a a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (XXValBindsLR a a) -> HieM [HieAST Type])
-> RScoped (XXValBindsLR a a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope -> XXValBindsLR a a -> RScoped (XXValBindsLR a a)
forall a. Scope -> a -> RScoped a
RS Scope
sc XXValBindsLR a a
x ]
instance ToHie (RScoped (NHsValBindsLR GhcTc)) where
toHie :: RScoped (NHsValBindsLR GhcTc) -> HieM [HieAST Type]
toHie (RS sc :: Scope
sc (NValBinds binds :: [(RecFlag, LHsBinds GhcTc)]
binds sigs :: [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 (LHsBindLR GhcTc GhcTc)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (((RecFlag, LHsBinds GhcTc)
-> [BindContext (LHsBindLR GhcTc GhcTc)])
-> [(RecFlag, LHsBinds GhcTc)]
-> [BindContext (LHsBindLR GhcTc GhcTc)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ((LHsBindLR GhcTc GhcTc -> BindContext (LHsBindLR GhcTc GhcTc))
-> [LHsBindLR GhcTc GhcTc] -> [BindContext (LHsBindLR GhcTc GhcTc)]
forall a b. (a -> b) -> [a] -> [b]
map (BindType
-> Scope
-> LHsBindLR GhcTc GhcTc
-> BindContext (LHsBindLR GhcTc GhcTc)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
sc) ([LHsBindLR GhcTc GhcTc] -> [BindContext (LHsBindLR GhcTc GhcTc)])
-> ((RecFlag, LHsBinds GhcTc) -> [LHsBindLR GhcTc GhcTc])
-> (RecFlag, LHsBinds GhcTc)
-> [BindContext (LHsBindLR GhcTc GhcTc)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LHsBinds GhcTc -> [LHsBindLR GhcTc GhcTc]
forall a. Bag a -> [a]
bagToList (LHsBinds GhcTc -> [LHsBindLR GhcTc GhcTc])
-> ((RecFlag, LHsBinds GhcTc) -> LHsBinds GhcTc)
-> (RecFlag, LHsBinds GhcTc)
-> [LHsBindLR GhcTc GhcTc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RecFlag, LHsBinds GhcTc) -> LHsBinds GhcTc
forall a b. (a, b) -> b
snd) [(RecFlag, LHsBinds GhcTc)]
binds)
, [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (LSig GhcRn)] -> HieM [HieAST Type])
-> [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LSig GhcRn -> SigContext (LSig GhcRn))
-> [LSig GhcRn] -> [SigContext (LSig GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn)
forall a. SigInfo -> a -> SigContext a
SC (SigType -> Maybe RealSrcSpan -> SigInfo
SI SigType
BindSig Maybe RealSrcSpan
forall a. Maybe a
Nothing)) [LSig GhcRn]
sigs
]
instance ToHie (RScoped (NHsValBindsLR GhcRn)) where
toHie :: RScoped (NHsValBindsLR GhcRn) -> HieM [HieAST Type]
toHie (RS sc :: Scope
sc (NValBinds binds :: [(RecFlag, LHsBinds GhcRn)]
binds sigs :: [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 (LHsBind GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (((RecFlag, LHsBinds GhcRn) -> [BindContext (LHsBind GhcRn)])
-> [(RecFlag, LHsBinds GhcRn)] -> [BindContext (LHsBind GhcRn)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ((LHsBind GhcRn -> BindContext (LHsBind GhcRn))
-> [LHsBind GhcRn] -> [BindContext (LHsBind GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (BindType -> Scope -> LHsBind GhcRn -> BindContext (LHsBind GhcRn)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
RegularBind Scope
sc) ([LHsBind GhcRn] -> [BindContext (LHsBind GhcRn)])
-> ((RecFlag, LHsBinds GhcRn) -> [LHsBind GhcRn])
-> (RecFlag, LHsBinds GhcRn)
-> [BindContext (LHsBind GhcRn)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LHsBinds GhcRn -> [LHsBind GhcRn]
forall a. Bag a -> [a]
bagToList (LHsBinds GhcRn -> [LHsBind GhcRn])
-> ((RecFlag, LHsBinds GhcRn) -> LHsBinds GhcRn)
-> (RecFlag, LHsBinds GhcRn)
-> [LHsBind GhcRn]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RecFlag, LHsBinds GhcRn) -> LHsBinds GhcRn
forall a b. (a, b) -> b
snd) [(RecFlag, LHsBinds GhcRn)]
binds)
, [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (LSig GhcRn)] -> HieM [HieAST Type])
-> [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LSig GhcRn -> SigContext (LSig GhcRn))
-> [LSig GhcRn] -> [SigContext (LSig GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn)
forall a. SigInfo -> a -> SigContext a
SC (SigType -> Maybe RealSrcSpan -> SigInfo
SI SigType
BindSig Maybe RealSrcSpan
forall a. Maybe a
Nothing)) [LSig GhcRn]
sigs
]
instance ( ToHie (RContext (LHsRecField a arg))
) => ToHie (RContext (HsRecFields a arg)) where
toHie :: RContext (HsRecFields a arg) -> HieM [HieAST Type]
toHie (RC c :: RecFieldContext
c (HsRecFields fields :: [LHsRecField a arg]
fields _)) = [RContext (LHsRecField a arg)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RContext (LHsRecField a arg)] -> HieM [HieAST Type])
-> [RContext (LHsRecField a arg)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsRecField a arg -> RContext (LHsRecField a arg))
-> [LHsRecField a arg] -> [RContext (LHsRecField a arg)]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> LHsRecField a arg -> RContext (LHsRecField a arg)
forall a. RecFieldContext -> a -> RContext a
RC RecFieldContext
c) [LHsRecField a arg]
fields
instance ( ToHie (RFContext (Located label))
, ToHie arg
, HasLoc arg
, Data label
, Data arg
) => ToHie (RContext (LHsRecField' label arg)) where
toHie :: RContext (LHsRecField' label arg) -> HieM [HieAST Type]
toHie (RC c :: RecFieldContext
c (L span :: SrcSpan
span recfld :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsRecField' label arg
recfld SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsRecField' label arg
recfld of
HsRecField label :: Located label
label expr :: arg
expr _ ->
[ 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 RealSrcSpan -> Located label -> RFContext (Located label)
forall a. RecFieldContext -> Maybe RealSrcSpan -> a -> RFContext a
RFC RecFieldContext
c (SrcSpan -> Maybe RealSrcSpan
getRealSpan (SrcSpan -> Maybe RealSrcSpan) -> SrcSpan -> Maybe RealSrcSpan
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
]
removeDefSrcSpan :: Name -> Name
removeDefSrcSpan :: Name -> Name
removeDefSrcSpan n :: Name
n = Name -> SrcSpan -> Name
setNameLoc Name
n SrcSpan
noSrcSpan
instance ToHie (RFContext (LFieldOcc GhcRn)) where
toHie :: RFContext (LFieldOcc GhcRn) -> HieM [HieAST Type]
toHie (RFC c :: RecFieldContext
c rhs :: Maybe RealSrcSpan
rhs (L nspan :: SrcSpan
nspan f :: 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 name :: XCFieldOcc GhcRn
name _ ->
[ 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 RealSrcSpan -> ContextInfo
RecField RecFieldContext
c Maybe RealSrcSpan
rhs) (SrcSpan -> Name -> Located Name
forall l e. l -> e -> GenLocated l e
L SrcSpan
nspan (Name -> Located Name) -> Name -> Located Name
forall a b. (a -> b) -> a -> b
$ Name -> Name
removeDefSrcSpan Name
XCFieldOcc GhcRn
name)
]
XFieldOcc _ -> []
instance ToHie (RFContext (LFieldOcc GhcTc)) where
toHie :: RFContext (LFieldOcc GhcTc) -> HieM [HieAST Type]
toHie (RFC c :: RecFieldContext
c rhs :: Maybe RealSrcSpan
rhs (L nspan :: SrcSpan
nspan f :: 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 var :: XCFieldOcc GhcTc
var _ ->
let var' :: Id
var' = Id -> Name -> Id
setVarName Id
XCFieldOcc GhcTc
var (Name -> Name
removeDefSrcSpan (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ Id -> Name
varName Id
XCFieldOcc GhcTc
var)
in [ 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 RealSrcSpan -> ContextInfo
RecField RecFieldContext
c Maybe RealSrcSpan
rhs) (SrcSpan -> Id -> Located Id
forall l e. l -> e -> GenLocated l e
L SrcSpan
nspan Id
var')
]
XFieldOcc _ -> []
instance ToHie (RFContext (Located (AmbiguousFieldOcc GhcRn))) where
toHie :: RFContext (Located (AmbiguousFieldOcc GhcRn)) -> HieM [HieAST Type]
toHie (RFC c :: RecFieldContext
c rhs :: Maybe RealSrcSpan
rhs (L nspan :: SrcSpan
nspan afo :: 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 name :: XUnambiguous GhcRn
name _ ->
[ 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 RealSrcSpan -> ContextInfo
RecField RecFieldContext
c Maybe RealSrcSpan
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 -> Located Name) -> Name -> Located Name
forall a b. (a -> b) -> a -> b
$ Name -> Name
removeDefSrcSpan Name
XUnambiguous GhcRn
name
]
Ambiguous _name :: XAmbiguous GhcRn
_name _ ->
[ ]
XAmbiguousFieldOcc _ -> []
instance ToHie (RFContext (Located (AmbiguousFieldOcc GhcTc))) where
toHie :: RFContext (Located (AmbiguousFieldOcc GhcTc)) -> HieM [HieAST Type]
toHie (RFC c :: RecFieldContext
c rhs :: Maybe RealSrcSpan
rhs (L nspan :: SrcSpan
nspan afo :: 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 var :: XUnambiguous GhcTc
var _ ->
let var' :: Id
var' = Id -> Name -> Id
setVarName Id
XUnambiguous GhcTc
var (Name -> Name
removeDefSrcSpan (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ Id -> Name
varName Id
XUnambiguous GhcTc
var)
in [ 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 RealSrcSpan -> ContextInfo
RecField RecFieldContext
c Maybe RealSrcSpan
rhs) (SrcSpan -> Id -> Located Id
forall l e. l -> e -> GenLocated l e
L SrcSpan
nspan Id
var')
]
Ambiguous var :: XAmbiguous GhcTc
var _ ->
let var' :: Id
var' = Id -> Name -> Id
setVarName Id
XAmbiguous GhcTc
var (Name -> Name
removeDefSrcSpan (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ Id -> Name
varName Id
XAmbiguous GhcTc
var)
in [ 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 RealSrcSpan -> ContextInfo
RecField RecFieldContext
c Maybe RealSrcSpan
rhs) (SrcSpan -> Id -> Located Id
forall l e. l -> e -> GenLocated l e
L SrcSpan
nspan Id
var')
]
XAmbiguousFieldOcc _ -> []
instance ( a ~ GhcPass p
, ToHie (PScoped (LPat a))
, ToHie (BindContext (LHsBind a))
, ToHie (LHsExpr a)
, ToHie (SigContext (LSig a))
, ToHie (RScoped (HsValBindsLR a a))
, Data (StmtLR a a (Located (HsExpr a)))
, Data (HsLocalBinds a)
) => ToHie (RScoped (ApplicativeArg (GhcPass p))) where
toHie :: RScoped (ApplicativeArg (GhcPass p)) -> HieM [HieAST Type]
toHie (RS sc :: Scope
sc (ApplicativeArgOne _ pat :: LPat (GhcPass p)
pat expr :: LHsExpr (GhcPass p)
expr _)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
forall a. Maybe a
Nothing Scope
sc Scope
NoScope LPat (GhcPass p)
pat
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
]
toHie (RS sc :: Scope
sc (ApplicativeArgMany _ stmts :: [ExprLStmt (GhcPass p)]
stmts _ pat :: LPat (GhcPass p)
pat)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ [RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type])
-> [RScoped (ExprLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> [ExprLStmt (GhcPass p)] -> [RScoped (ExprLStmt (GhcPass p))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
NoScope [ExprLStmt (GhcPass p)]
stmts
, PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (PScoped (LPat (GhcPass p)) -> HieM [HieAST Type])
-> PScoped (LPat (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan
-> Scope -> Scope -> LPat (GhcPass p) -> PScoped (LPat (GhcPass p))
forall a. Maybe RealSrcSpan -> Scope -> Scope -> a -> PScoped a
PS Maybe RealSrcSpan
forall a. Maybe a
Nothing Scope
sc Scope
NoScope LPat (GhcPass p)
pat
]
toHie (RS _ (XApplicativeArg _)) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where
toHie :: HsConDetails arg rec -> HieM [HieAST Type]
toHie (PrefixCon args :: [arg]
args) = [arg] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [arg]
args
toHie (RecCon rec :: rec
rec) = rec -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie rec
rec
toHie (InfixCon a :: arg
a b :: 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 (LHsCmd a)
, Data (HsCmdTop a)
) => ToHie (LHsCmdTop a) where
toHie :: LHsCmdTop a -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span top :: HsCmdTop a
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 a -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsCmdTop a
top SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsCmdTop a
top of
HsCmdTop _ cmd :: LHsCmd a
cmd ->
[ LHsCmd a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd a
cmd
]
XCmdTop _ -> []
instance ( a ~ GhcPass p
, ToHie (PScoped (LPat a))
, ToHie (BindContext (LHsBind a))
, ToHie (LHsExpr a)
, ToHie (MatchGroup a (LHsCmd a))
, ToHie (SigContext (LSig a))
, ToHie (RScoped (HsValBindsLR a a))
, Data (HsCmd a)
, Data (HsCmdTop a)
, Data (StmtLR a a (Located (HsCmd a)))
, Data (HsLocalBinds a)
, Data (StmtLR a a (Located (HsExpr a)))
) => ToHie (LHsCmd (GhcPass p)) where
toHie :: LHsCmd (GhcPass p) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span cmd :: 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) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsCmd (GhcPass p)
cmd SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsCmd (GhcPass p)
cmd of
HsCmdArrApp _ a :: LHsExpr (GhcPass p)
a b :: LHsExpr (GhcPass p)
b _ _ ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
HsCmdArrForm _ a :: LHsExpr (GhcPass p)
a _ _ cmdtops :: [LHsCmdTop (GhcPass p)]
cmdtops ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, [LHsCmdTop (GhcPass p)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsCmdTop (GhcPass p)]
cmdtops
]
HsCmdApp _ a :: LHsCmd (GhcPass p)
a b :: LHsExpr (GhcPass p)
b ->
[ LHsCmd (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
a
, LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
b
]
HsCmdLam _ mg :: MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
mg ->
[ MatchGroup (GhcPass p) (LHsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
mg
]
HsCmdPar _ a :: LHsCmd (GhcPass p)
a ->
[ LHsCmd (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
a
]
HsCmdCase _ expr :: LHsExpr (GhcPass p)
expr alts :: MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
alts ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
expr
, MatchGroup (GhcPass p) (LHsCmd (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie MatchGroup (GhcPass p) (LHsCmd (GhcPass p))
alts
]
HsCmdIf _ _ a :: LHsExpr (GhcPass p)
a b :: LHsCmd (GhcPass p)
b c :: LHsCmd (GhcPass p)
c ->
[ LHsExpr (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr (GhcPass p)
a
, LHsCmd (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
b
, LHsCmd (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
c
]
HsCmdLet _ binds :: LHsLocalBinds (GhcPass p)
binds cmd' :: LHsCmd (GhcPass p)
cmd' ->
[ RScoped (LHsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (LHsLocalBinds (GhcPass p)) -> HieM [HieAST Type])
-> RScoped (LHsLocalBinds (GhcPass p)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope
-> LHsLocalBinds (GhcPass p) -> RScoped (LHsLocalBinds (GhcPass p))
forall a. Scope -> a -> RScoped a
RS (LHsCmd (GhcPass p) -> Scope
forall a. Located a -> Scope
mkLScope LHsCmd (GhcPass p)
cmd') LHsLocalBinds (GhcPass p)
binds
, LHsCmd (GhcPass p) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsCmd (GhcPass p)
cmd'
]
HsCmdDo _ (L ispan :: SrcSpan
ispan stmts :: [CmdLStmt (GhcPass p)]
stmts) ->
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
ispan
, [RScoped (CmdLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (CmdLStmt (GhcPass p))] -> HieM [HieAST Type])
-> [RScoped (CmdLStmt (GhcPass p))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope -> [CmdLStmt (GhcPass p)] -> [RScoped (CmdLStmt (GhcPass p))]
forall a. Scope -> [Located a] -> [RScoped (Located a)]
listScopes Scope
NoScope [CmdLStmt (GhcPass p)]
stmts
]
HsCmdWrap _ _ _ -> []
XCmd _ -> []
instance ToHie (TyClGroup GhcRn) where
toHie :: TyClGroup GhcRn -> HieM [HieAST Type]
toHie (TyClGroup _ classes :: [LTyClDecl GhcRn]
classes roles :: [LRoleAnnotDecl GhcRn]
roles instances :: [LInstDecl GhcRn]
instances) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ [LTyClDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LTyClDecl GhcRn]
classes
, [LRoleAnnotDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LRoleAnnotDecl GhcRn]
roles
, [LInstDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LInstDecl GhcRn]
instances
]
toHie (XTyClGroup _) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LTyClDecl GhcRn) where
toHie :: LTyClDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode TyClDecl GhcRn
decl SrcSpan
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 SrcSpan (FamilyDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (SrcSpan
-> FamilyDecl GhcRn -> GenLocated SrcSpan (FamilyDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpan
span FamilyDecl GhcRn
fdecl)
]
SynDecl {tcdLName :: forall pass. TyClDecl pass -> Located (IdP pass)
tcdLName = Located (IdP 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 (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 (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
SynDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located Name
Located (IdP 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
$ LHsType GhcRn -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc LHsType GhcRn
typ]) LHsQTyVars GhcRn
vars
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
typ
]
DataDecl {tcdLName :: forall pass. TyClDecl pass -> Located (IdP pass)
tcdLName = Located (IdP 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 (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 (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
DataDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located Name
Located (IdP 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 = Located (HsContext GhcRn) -> Scope
forall a. Located a -> Scope
mkLScope (Located (HsContext GhcRn) -> Scope)
-> Located (HsContext GhcRn) -> Scope
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> Located (HsContext GhcRn)
forall pass. HsDataDefn pass -> 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 -> (LHsType GhcRn -> Scope) -> Maybe (LHsType GhcRn) -> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope LHsType GhcRn -> Scope
forall a. Located a -> Scope
mkLScope (Maybe (LHsType GhcRn) -> Scope) -> Maybe (LHsType 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
$ (LConDecl GhcRn -> Scope) -> [LConDecl GhcRn] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map LConDecl GhcRn -> Scope
forall a. Located a -> Scope
mkLScope ([LConDecl GhcRn] -> [Scope]) -> [LConDecl 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 = Located [LHsDerivingClause GhcRn] -> Scope
forall a. Located a -> Scope
mkLScope (Located [LHsDerivingClause GhcRn] -> Scope)
-> Located [LHsDerivingClause GhcRn] -> Scope
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcRn -> Located [LHsDerivingClause GhcRn]
forall pass. HsDataDefn pass -> HsDeriving pass
dd_derivs HsDataDefn GhcRn
defn
ClassDecl { tcdCtxt :: forall pass. TyClDecl pass -> LHsContext pass
tcdCtxt = Located (HsContext GhcRn)
context
, tcdLName :: forall pass. TyClDecl pass -> Located (IdP pass)
tcdLName = Located (IdP 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 = [GenLocated SrcSpan (FamilyDecl GhcRn)]
typs
, tcdATDefs :: forall pass. TyClDecl pass -> [LTyFamDefltEqn pass]
tcdATDefs = [LTyFamDefltEqn GhcRn]
deftyps
} ->
[ 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 (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
ClassDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located Name
Located (IdP GhcRn)
name
, Located (HsContext GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located (HsContext 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
, [Located (FunDep (Located Name))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [Located (FunDep (Located Name))]
[LHsFunDep GhcRn]
deps
, [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (LSig GhcRn)] -> HieM [HieAST Type])
-> [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LSig GhcRn -> SigContext (LSig GhcRn))
-> [LSig GhcRn] -> [SigContext (LSig GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn)
forall a. SigInfo -> a -> SigContext a
SC (SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn))
-> SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn)
forall a b. (a -> b) -> a -> b
$ SigType -> Maybe RealSrcSpan -> SigInfo
SI SigType
ClassSig (Maybe RealSrcSpan -> SigInfo) -> Maybe RealSrcSpan -> SigInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) [LSig GhcRn]
sigs
, Bag (BindContext (LHsBind GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (LHsBind GhcRn)) -> HieM [HieAST Type])
-> Bag (BindContext (LHsBind GhcRn)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsBind GhcRn -> BindContext (LHsBind GhcRn))
-> LHsBinds GhcRn -> Bag (BindContext (LHsBind GhcRn))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType -> Scope -> LHsBind GhcRn -> BindContext (LHsBind GhcRn)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
InstanceBind Scope
ModuleScope) LHsBinds GhcRn
meths
, [GenLocated SrcSpan (FamilyDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [GenLocated SrcSpan (FamilyDecl GhcRn)]
typs
, (LTyFamDefltEqn GhcRn -> HieM [HieAST Type])
-> [LTyFamDefltEqn GhcRn] -> HieM [HieAST Type]
forall (m :: * -> *) a b. Monad m => (a -> m [b]) -> [a] -> m [b]
concatMapM ([HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([HieAST Type] -> HieM [HieAST Type])
-> (LTyFamDefltEqn GhcRn -> [HieAST Type])
-> LTyFamDefltEqn GhcRn
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type])
-> (LTyFamDefltEqn GhcRn -> SrcSpan)
-> LTyFamDefltEqn GhcRn
-> [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LTyFamDefltEqn GhcRn -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) [LTyFamDefltEqn GhcRn]
deftyps
, [FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)]
-> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)]
-> HieM [HieAST Type])
-> [FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LTyFamDefltEqn GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn))
-> [LTyFamDefltEqn GhcRn]
-> [FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (TyFamDefltEqn GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
go (TyFamDefltEqn GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn))
-> (LTyFamDefltEqn GhcRn -> TyFamDefltEqn GhcRn)
-> LTyFamDefltEqn GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LTyFamDefltEqn GhcRn -> TyFamDefltEqn GhcRn
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc) [LTyFamDefltEqn GhcRn]
deftyps
]
where
context_scope :: Scope
context_scope = Located (HsContext GhcRn) -> Scope
forall a. Located a -> Scope
mkLScope Located (HsContext 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
[ [Located (FunDep (Located Name))] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [Located (FunDep (Located Name))]
[LHsFunDep GhcRn]
deps, [LSig GhcRn] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LSig GhcRn]
sigs, [LHsBind GhcRn] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc (LHsBinds GhcRn -> [LHsBind GhcRn]
forall a. Bag a -> [a]
bagToList LHsBinds GhcRn
meths), [GenLocated SrcSpan (FamilyDecl GhcRn)] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [GenLocated SrcSpan (FamilyDecl GhcRn)]
typs, [LTyFamDefltEqn GhcRn] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [LTyFamDefltEqn GhcRn]
deftyps]
go :: TyFamDefltEqn GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
go :: TyFamDefltEqn GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
go (FamEqn a :: XCFamEqn GhcRn (LHsQTyVars GhcRn) (LHsType GhcRn)
a var :: Located (IdP GhcRn)
var bndrs :: Maybe [LHsTyVarBndr GhcRn]
bndrs pat :: LHsQTyVars GhcRn
pat b :: LexicalFixity
b rhs :: LHsType GhcRn
rhs) =
XCFamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
-> Located (IdP GhcRn)
-> Maybe [LHsTyVarBndr GhcRn]
-> TScoped (LHsQTyVars GhcRn)
-> LexicalFixity
-> LHsType GhcRn
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
forall pass pats rhs.
XCFamEqn pass pats rhs
-> Located (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> pats
-> LexicalFixity
-> rhs
-> FamEqn pass pats rhs
FamEqn XCFamEqn GhcRn (LHsQTyVars GhcRn) (LHsType GhcRn)
XCFamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
a Located (IdP GhcRn)
var Maybe [LHsTyVarBndr GhcRn]
bndrs (TyVarScope -> LHsQTyVars GhcRn -> TScoped (LHsQTyVars GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [LHsType GhcRn -> Scope
forall a. Located a -> Scope
mkLScope LHsType GhcRn
rhs]) LHsQTyVars GhcRn
pat) LexicalFixity
b LHsType GhcRn
rhs
go (XFamEqn NoExt) = XXFamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
-> FamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
forall pass pats rhs.
XXFamEqn pass pats rhs -> FamEqn pass pats rhs
XFamEqn XXFamEqn GhcRn (TScoped (LHsQTyVars GhcRn)) (LHsType GhcRn)
NoExt
NoExt
XTyClDecl _ -> []
instance ToHie (LFamilyDecl GhcRn) where
toHie :: GenLocated SrcSpan (FamilyDecl GhcRn) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode FamilyDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case FamilyDecl GhcRn
decl of
FamilyDecl _ info :: FamilyInfo GhcRn
info name :: Located (IdP GhcRn)
name vars :: LHsQTyVars GhcRn
vars _ sig :: LFamilyResultSig GhcRn
sig inj :: Maybe (LInjectivityAnn GhcRn)
inj ->
[ 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 (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
FamDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located Name
Located (IdP 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 (LFamilyResultSig GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (RScoped (LFamilyResultSig GhcRn) -> HieM [HieAST Type])
-> RScoped (LFamilyResultSig GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Scope -> LFamilyResultSig GhcRn -> RScoped (LFamilyResultSig GhcRn)
forall a. Scope -> a -> RScoped a
RS Scope
injSpan LFamilyResultSig GhcRn
sig
, Maybe (LInjectivityAnn GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie 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
$ LFamilyResultSig GhcRn -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc LFamilyResultSig GhcRn
sig
injSpan :: Scope
injSpan = Scope
-> (LInjectivityAnn GhcRn -> Scope)
-> Maybe (LInjectivityAnn GhcRn)
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope (SrcSpan -> Scope
mkScope (SrcSpan -> Scope)
-> (LInjectivityAnn GhcRn -> SrcSpan)
-> LInjectivityAnn GhcRn
-> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LInjectivityAnn GhcRn -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) Maybe (LInjectivityAnn GhcRn)
inj
XFamilyDecl _ -> []
instance ToHie (FamilyInfo GhcRn) where
toHie :: FamilyInfo GhcRn -> HieM [HieAST Type]
toHie (ClosedTypeFamily (Just eqns :: [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
$
[ (LTyFamInstEqn GhcRn -> HieM [HieAST Type])
-> [LTyFamInstEqn GhcRn] -> HieM [HieAST Type]
forall (m :: * -> *) a b. Monad m => (a -> m [b]) -> [a] -> m [b]
concatMapM ([HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([HieAST Type] -> HieM [HieAST Type])
-> (LTyFamInstEqn GhcRn -> [HieAST Type])
-> LTyFamInstEqn GhcRn
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type])
-> (LTyFamInstEqn GhcRn -> SrcSpan)
-> LTyFamInstEqn GhcRn
-> [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LTyFamInstEqn GhcRn -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) [LTyFamInstEqn GhcRn]
eqns
, [TScoped (TyFamInstEqn GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TScoped (TyFamInstEqn GhcRn)] -> HieM [HieAST Type])
-> [TScoped (TyFamInstEqn GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LTyFamInstEqn GhcRn -> TScoped (TyFamInstEqn GhcRn))
-> [LTyFamInstEqn GhcRn] -> [TScoped (TyFamInstEqn GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map LTyFamInstEqn GhcRn -> TScoped (TyFamInstEqn GhcRn)
forall a. GenLocated SrcSpan a -> TScoped a
go [LTyFamInstEqn GhcRn]
eqns
]
where
go :: GenLocated SrcSpan a -> TScoped a
go (L l :: SrcSpan
l ib :: a
ib) = TyVarScope -> a -> TScoped a
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpan -> Scope
mkScope SrcSpan
l]) a
ib
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (RScoped (LFamilyResultSig GhcRn)) where
toHie :: RScoped (LFamilyResultSig GhcRn) -> HieM [HieAST Type]
toHie (RS sc :: Scope
sc (L span :: SrcSpan
span sig :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> 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 _ ->
[]
KindSig _ k :: LHsType GhcRn
k ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
k
]
TyVarSig _ bndr :: LHsTyVarBndr GhcRn
bndr ->
[ TVScoped (LHsTyVarBndr GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TVScoped (LHsTyVarBndr GhcRn) -> HieM [HieAST Type])
-> TVScoped (LHsTyVarBndr GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope -> LHsTyVarBndr GhcRn -> TVScoped (LHsTyVarBndr GhcRn)
forall a. TyVarScope -> Scope -> a -> TVScoped a
TVS ([Scope] -> TyVarScope
ResolvedScopes [Scope
sc]) Scope
NoScope LHsTyVarBndr GhcRn
bndr
]
XFamilyResultSig _ -> []
instance ToHie (Located (FunDep (Located Name))) where
toHie :: Located (FunDep (Located Name)) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span fd :: FunDep (Located Name)
fd@(lhs :: [Located Name]
lhs, rhs :: [Located Name]
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 (Located Name) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode FunDep (Located Name)
fd 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
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located Name]
lhs
, [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located Name]
rhs
]
instance (ToHie pats, ToHie rhs, HasLoc pats, HasLoc rhs)
=> ToHie (TScoped (FamEqn GhcRn pats rhs)) where
toHie :: TScoped (FamEqn GhcRn pats rhs) -> HieM [HieAST Type]
toHie (TS _ f :: FamEqn GhcRn pats rhs
f) = FamEqn GhcRn pats rhs -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie FamEqn GhcRn pats rhs
f
instance ( ToHie pats
, ToHie rhs
, HasLoc pats
, HasLoc rhs
) => ToHie (FamEqn GhcRn pats rhs) where
toHie :: FamEqn GhcRn pats rhs -> HieM [HieAST Type]
toHie fe :: FamEqn GhcRn pats rhs
fe@(FamEqn _ var :: Located (IdP GhcRn)
var tybndrs :: Maybe [LHsTyVarBndr GhcRn]
tybndrs pats :: pats
pats _ rhs :: 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 (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 (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
InstDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan (SrcSpan -> Maybe RealSrcSpan) -> SrcSpan -> Maybe RealSrcSpan
forall a b. (a -> b) -> a -> b
$ FamEqn GhcRn pats rhs -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc FamEqn GhcRn pats rhs
fe) Located Name
Located (IdP GhcRn)
var
, Maybe [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type])
-> Maybe [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ([LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)])
-> Maybe [LHsTyVarBndr GhcRn]
-> Maybe [TVScoped (LHsTyVarBndr GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TyVarScope
-> Scope -> [LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)]
forall a.
TyVarScope
-> Scope -> [LHsTyVarBndr a] -> [TVScoped (LHsTyVarBndr a)]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
scope) Maybe [LHsTyVarBndr GhcRn]
tybndrs
, pats -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie pats
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 (pats -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc pats
pats)
rhsScope :: Scope
rhsScope = SrcSpan -> Scope
mkScope (rhs -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc rhs
rhs)
toHie (XFamEqn _) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LInjectivityAnn GhcRn) where
toHie :: LInjectivityAnn GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span ann :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> 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 lhs :: Located (IdP GhcRn)
lhs rhs :: [Located (IdP GhcRn)]
rhs ->
[ 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 ContextInfo
Use Located Name
Located (IdP GhcRn)
lhs
, [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located Name]
[Located (IdP GhcRn)]
rhs
]
instance ToHie (HsDataDefn GhcRn) where
toHie :: HsDataDefn GhcRn -> HieM [HieAST Type]
toHie (HsDataDefn _ _ ctx :: Located (HsContext GhcRn)
ctx _ mkind :: Maybe (LHsType GhcRn)
mkind cons :: [LConDecl GhcRn]
cons derivs :: Located [LHsDerivingClause GhcRn]
derivs) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ Located (HsContext GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located (HsContext GhcRn)
ctx
, Maybe (LHsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LHsType GhcRn)
mkind
, [LConDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LConDecl GhcRn]
cons
, Located [LHsDerivingClause GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located [LHsDerivingClause GhcRn]
derivs
]
toHie (XHsDataDefn _) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (HsDeriving GhcRn) where
toHie :: Located [LHsDerivingClause GhcRn] -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span clauses :: [LHsDerivingClause GhcRn]
clauses) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
span
, [LHsDerivingClause GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LHsDerivingClause GhcRn]
clauses
]
instance ToHie (LHsDerivingClause GhcRn) where
toHie :: LHsDerivingClause GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span cl :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> 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 _ strat :: Maybe (LDerivStrategy GhcRn)
strat (L ispan :: SrcSpan
ispan tys :: [LHsSigType GhcRn]
tys) ->
[ Maybe (LDerivStrategy GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LDerivStrategy GhcRn)
strat
, [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
ispan
, [TScoped (LHsSigType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TScoped (LHsSigType GhcRn)] -> HieM [HieAST Type])
-> [TScoped (LHsSigType GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsSigType GhcRn -> TScoped (LHsSigType GhcRn))
-> [LHsSigType GhcRn] -> [TScoped (LHsSigType GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [])) [LHsSigType GhcRn]
tys
]
XHsDerivingClause _ -> []
instance ToHie (Located (DerivStrategy GhcRn)) where
toHie :: LDerivStrategy GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span strat :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> 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 -> []
AnyclassStrategy -> []
NewtypeStrategy -> []
ViaStrategy s :: XViaStrategy GhcRn
s -> [ TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) XViaStrategy GhcRn
LHsSigType GhcRn
s ]
instance ToHie (Located OverlapMode) where
toHie :: Located OverlapMode -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span _) = [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
span
instance ToHie (LConDecl GhcRn) where
toHie :: LConDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode ConDecl GhcRn
decl SrcSpan
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 -> [Located (IdP pass)]
con_names = [Located (IdP GhcRn)]
names, con_qvars :: forall pass. ConDecl pass -> LHsQTyVars pass
con_qvars = LHsQTyVars GhcRn
qvars
, con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (Located (HsContext GhcRn))
ctx, con_args :: forall pass. ConDecl pass -> HsConDeclDetails pass
con_args = HsConDeclDetails GhcRn
args, con_res_ty :: forall pass. ConDecl pass -> LHsType pass
con_res_ty = LHsType GhcRn
typ } ->
[ [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
ConDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span)) [Located Name]
[Located (IdP GhcRn)]
names
, 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
ctxScope, Scope
rhsScope]) LHsQTyVars GhcRn
qvars
, Maybe (Located (HsContext GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (Located (HsContext GhcRn))
ctx
, HsConDeclDetails GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsConDeclDetails GhcRn
args
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
typ
]
where
rhsScope :: Scope
rhsScope = Scope -> Scope -> Scope
combineScopes Scope
argsScope Scope
tyScope
ctxScope :: Scope
ctxScope = Scope
-> (Located (HsContext GhcRn) -> Scope)
-> Maybe (Located (HsContext GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope Located (HsContext GhcRn) -> Scope
forall a. Located a -> Scope
mkLScope Maybe (Located (HsContext GhcRn))
ctx
argsScope :: Scope
argsScope = HsConDeclDetails GhcRn -> Scope
forall a a. HsConDetails (Located a) (Located a) -> Scope
condecl_scope HsConDeclDetails GhcRn
args
tyScope :: Scope
tyScope = LHsType GhcRn -> Scope
forall a. Located a -> Scope
mkLScope LHsType GhcRn
typ
ConDeclH98 { con_name :: forall pass. ConDecl pass -> Located (IdP pass)
con_name = Located (IdP GhcRn)
name, con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr pass]
con_ex_tvs = [LHsTyVarBndr GhcRn]
qvars
, con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (Located (HsContext GhcRn))
ctx, con_args :: forall pass. ConDecl pass -> HsConDeclDetails pass
con_args = HsConDeclDetails GhcRn
dets } ->
[ 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 (DeclType -> Maybe RealSrcSpan -> ContextInfo
Decl DeclType
ConDec (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located Name
Located (IdP GhcRn)
name
, [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type])
-> [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope -> [LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)]
forall a.
TyVarScope
-> Scope -> [LHsTyVarBndr a] -> [TVScoped (LHsTyVarBndr a)]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
rhsScope [LHsTyVarBndr GhcRn]
qvars
, Maybe (Located (HsContext GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (Located (HsContext GhcRn))
ctx
, HsConDeclDetails GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsConDeclDetails GhcRn
dets
]
where
rhsScope :: Scope
rhsScope = Scope -> Scope -> Scope
combineScopes Scope
ctxScope Scope
argsScope
ctxScope :: Scope
ctxScope = Scope
-> (Located (HsContext GhcRn) -> Scope)
-> Maybe (Located (HsContext GhcRn))
-> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope Located (HsContext GhcRn) -> Scope
forall a. Located a -> Scope
mkLScope Maybe (Located (HsContext GhcRn))
ctx
argsScope :: Scope
argsScope = HsConDeclDetails GhcRn -> Scope
forall a a. HsConDetails (Located a) (Located a) -> Scope
condecl_scope HsConDeclDetails GhcRn
dets
XConDecl _ -> []
where condecl_scope :: HsConDetails (Located a) (Located a) -> Scope
condecl_scope args :: HsConDetails (Located a) (Located a)
args = case HsConDetails (Located a) (Located a)
args of
PrefixCon xs :: [Located a]
xs -> (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 a -> Scope) -> [Located a] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map Located a -> Scope
forall a. Located a -> Scope
mkLScope [Located a]
xs
InfixCon a :: Located a
a b :: Located a
b -> Scope -> Scope -> Scope
combineScopes (Located a -> Scope
forall a. Located a -> Scope
mkLScope Located a
a) (Located a -> Scope
forall a. Located a -> Scope
mkLScope Located a
b)
RecCon x :: Located a
x -> Located a -> Scope
forall a. Located a -> Scope
mkLScope Located a
x
instance ToHie (Located [LConDeclField GhcRn]) where
toHie :: Located [LConDeclField GhcRn] -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decls :: [LConDeclField 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
$
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
span
, [LConDeclField GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LConDeclField GhcRn]
decls
]
instance ( HasLoc thing
, ToHie (TScoped thing)
) => ToHie (TScoped (HsImplicitBndrs GhcRn thing)) where
toHie :: TScoped (HsImplicitBndrs GhcRn thing) -> HieM [HieAST Type]
toHie (TS sc :: TyVarScope
sc (HsIB ibrn :: XHsIB GhcRn thing
ibrn a :: thing
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
$
[ [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
$ [Context Name] -> [HieAST Type]
forall a. [Context Name] -> [HieAST a]
bindingsOnly ([Context Name] -> [HieAST Type])
-> [Context Name] -> [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]
XHsIB GhcRn thing
ibrn
, TScoped thing -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped thing -> HieM [HieAST Type])
-> TScoped thing -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> thing -> TScoped thing
forall a. TyVarScope -> a -> TScoped a
TS TyVarScope
sc thing
a
]
where span :: SrcSpan
span = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
toHie (TS _ (XHsImplicitBndrs _)) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ( HasLoc thing
, ToHie (TScoped thing)
) => ToHie (TScoped (HsWildCardBndrs GhcRn thing)) where
toHie :: TScoped (HsWildCardBndrs GhcRn thing) -> HieM [HieAST Type]
toHie (TS sc :: TyVarScope
sc (HsWC names :: XHsWC GhcRn thing
names a :: thing
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
$
[ [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
$ [Context Name] -> [HieAST Type]
forall a. [Context Name] -> [HieAST a]
bindingsOnly ([Context Name] -> [HieAST Type])
-> [Context Name] -> [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 thing
names
, TScoped thing -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped thing -> HieM [HieAST Type])
-> TScoped thing -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> thing -> TScoped thing
forall a. TyVarScope -> a -> TScoped a
TS TyVarScope
sc thing
a
]
where span :: SrcSpan
span = thing -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc thing
a
toHie (TS _ (XHsWildCardBndrs _)) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (SigContext (LSig GhcRn)) where
toHie :: SigContext (LSig GhcRn) -> HieM [HieAST Type]
toHie (SC (SI styp :: SigType
styp msp :: Maybe RealSrcSpan
msp) (L sp :: SrcSpan
sp sig :: Sig 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
$ Sig GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode Sig GhcRn
sig SrcSpan
sp HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case Sig GhcRn
sig of
TypeSig _ names :: [Located (IdP GhcRn)]
names typ :: LHsSigWcType GhcRn
typ ->
[ [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl) [Located Name]
[Located (IdP GhcRn)]
names
, TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigWcType GhcRn -> TScoped (LHsSigWcType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Name] -> Maybe RealSrcSpan -> TyVarScope
UnresolvedScope ((Located Name -> Name) -> [Located Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Located Name -> Name
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc [Located Name]
[Located (IdP GhcRn)]
names) Maybe RealSrcSpan
forall a. Maybe a
Nothing) LHsSigWcType GhcRn
typ
]
PatSynSig _ names :: [Located (IdP GhcRn)]
names typ :: LHsSigType GhcRn
typ ->
[ [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
TyDecl) [Located Name]
[Located (IdP GhcRn)]
names
, TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Name] -> Maybe RealSrcSpan -> TyVarScope
UnresolvedScope ((Located Name -> Name) -> [Located Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Located Name -> Name
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc [Located Name]
[Located (IdP GhcRn)]
names) Maybe RealSrcSpan
forall a. Maybe a
Nothing) LHsSigType GhcRn
typ
]
ClassOpSig _ _ names :: [Located (IdP GhcRn)]
names typ :: LHsSigType GhcRn
typ ->
[ case SigType
styp of
ClassSig -> [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Located Name -> Context (Located Name))
-> ContextInfo -> Located Name -> Context (Located Name)
forall a b. (a -> b) -> a -> b
$ Maybe RealSrcSpan -> ContextInfo
ClassTyDecl (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
sp) [Located Name]
[Located (IdP GhcRn)]
names
_ -> [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C (ContextInfo -> Located Name -> Context (Located Name))
-> ContextInfo -> Located Name -> Context (Located Name)
forall a b. (a -> b) -> a -> b
$ ContextInfo
TyDecl) [Located Name]
[Located (IdP GhcRn)]
names
, TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Name] -> Maybe RealSrcSpan -> TyVarScope
UnresolvedScope ((Located Name -> Name) -> [Located Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Located Name -> Name
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc [Located Name]
[Located (IdP GhcRn)]
names) Maybe RealSrcSpan
msp) LHsSigType GhcRn
typ
]
IdSig _ _ -> []
FixSig _ fsig :: FixitySig GhcRn
fsig ->
[ GenLocated SrcSpan (FixitySig GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (FixitySig GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpan (FixitySig GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan -> FixitySig GhcRn -> GenLocated SrcSpan (FixitySig GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpan
sp FixitySig GhcRn
fsig
]
InlineSig _ name :: Located (IdP GhcRn)
name _ ->
[ 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 ContextInfo
Use) Located Name
Located (IdP GhcRn)
name
]
SpecSig _ name :: Located (IdP GhcRn)
name typs :: [LHsSigType GhcRn]
typs _ ->
[ 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 ContextInfo
Use) Located Name
Located (IdP GhcRn)
name
, [TScoped (LHsSigType GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TScoped (LHsSigType GhcRn)] -> HieM [HieAST Type])
-> [TScoped (LHsSigType GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsSigType GhcRn -> TScoped (LHsSigType GhcRn))
-> [LHsSigType GhcRn] -> [TScoped (LHsSigType GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [])) [LHsSigType GhcRn]
typs
]
SpecInstSig _ _ typ :: LHsSigType GhcRn
typ ->
[ TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType GhcRn
typ
]
MinimalSig _ _ form :: LBooleanFormula (Located (IdP GhcRn))
form ->
[ LBooleanFormula (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LBooleanFormula (Located Name)
LBooleanFormula (Located (IdP GhcRn))
form
]
SCCFunSig _ _ name :: Located (IdP GhcRn)
name mtxt :: Maybe (Located StringLiteral)
mtxt ->
[ 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 ContextInfo
Use) Located Name
Located (IdP GhcRn)
name
, [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
$ [HieAST Type]
-> (Located StringLiteral -> [HieAST Type])
-> Maybe (Located StringLiteral)
-> [HieAST Type]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type])
-> (Located StringLiteral -> SrcSpan)
-> Located StringLiteral
-> [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Located StringLiteral -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) Maybe (Located StringLiteral)
mtxt
]
CompleteMatchSig _ _ (L ispan :: SrcSpan
ispan names :: [Located (IdP GhcRn)]
names) typ :: Maybe (Located (IdP GhcRn))
typ ->
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
ispan
, [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located Name]
[Located (IdP GhcRn)]
names
, Maybe (Context (Located Name)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (Context (Located Name)) -> HieM [HieAST Type])
-> Maybe (Context (Located Name)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> Maybe (Located Name) -> Maybe (Context (Located Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) Maybe (Located Name)
Maybe (Located (IdP GhcRn))
typ
]
XSig _ -> []
instance ToHie (LHsType GhcRn) where
toHie :: LHsType GhcRn -> HieM [HieAST Type]
toHie x :: LHsType GhcRn
x = TScoped (LHsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsType GhcRn -> TScoped (LHsType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsType GhcRn
x
instance ToHie (TScoped (LHsType GhcRn)) where
toHie :: TScoped (LHsType GhcRn) -> HieM [HieAST Type]
toHie (TS tsc :: TyVarScope
tsc (L span :: SrcSpan
span t :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsType GhcRn
t SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsType GhcRn
t of
HsForAllTy _ bndrs :: [LHsTyVarBndr GhcRn]
bndrs body :: LHsType GhcRn
body ->
[ [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type])
-> [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope -> [LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)]
forall a.
TyVarScope
-> Scope -> [LHsTyVarBndr a] -> [TVScoped (LHsTyVarBndr a)]
tvScopes TyVarScope
tsc (SrcSpan -> Scope
mkScope (SrcSpan -> Scope) -> SrcSpan -> Scope
forall a b. (a -> b) -> a -> b
$ LHsType GhcRn -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc LHsType GhcRn
body) [LHsTyVarBndr GhcRn]
bndrs
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
body
]
HsQualTy _ ctx :: Located (HsContext GhcRn)
ctx body :: LHsType GhcRn
body ->
[ Located (HsContext GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located (HsContext GhcRn)
ctx
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
body
]
HsTyVar _ _ var :: Located (IdP GhcRn)
var ->
[ 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 ContextInfo
Use Located Name
Located (IdP GhcRn)
var
]
HsAppTy _ a :: LHsType GhcRn
a b :: LHsType GhcRn
b ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
b
]
HsAppKindTy _ ty :: LHsType GhcRn
ty ki :: LHsType GhcRn
ki ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
ty
, TScoped (LHsType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsType GhcRn -> TScoped (LHsType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsType GhcRn
ki
]
HsFunTy _ a :: LHsType GhcRn
a b :: LHsType GhcRn
b ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
b
]
HsListTy _ a :: LHsType GhcRn
a ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
]
HsTupleTy _ _ tys :: HsContext GhcRn
tys ->
[ HsContext GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsContext GhcRn
tys
]
HsSumTy _ tys :: HsContext GhcRn
tys ->
[ HsContext GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsContext GhcRn
tys
]
HsOpTy _ a :: LHsType GhcRn
a op :: Located (IdP GhcRn)
op b :: LHsType GhcRn
b ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
, Context (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Name) -> HieM [HieAST Type])
-> Context (Located Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located Name
Located (IdP GhcRn)
op
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
b
]
HsParTy _ a :: LHsType GhcRn
a ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
]
HsIParamTy _ ip :: Located HsIPName
ip ty :: LHsType GhcRn
ty ->
[ Located HsIPName -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Located HsIPName
ip
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
ty
]
HsKindSig _ a :: LHsType GhcRn
a b :: LHsType GhcRn
b ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
b
]
HsSpliceTy _ a :: HsSplice GhcRn
a ->
[ GenLocated SrcSpan (HsSplice GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (HsSplice GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpan (HsSplice GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan -> HsSplice GhcRn -> GenLocated SrcSpan (HsSplice GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpan
span HsSplice GhcRn
a
]
HsDocTy _ a :: LHsType GhcRn
a _ ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
a
]
HsBangTy _ _ ty :: LHsType GhcRn
ty ->
[ LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
ty
]
HsRecTy _ fields :: [LConDeclField GhcRn]
fields ->
[ [LConDeclField GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LConDeclField GhcRn]
fields
]
HsExplicitListTy _ _ tys :: HsContext GhcRn
tys ->
[ HsContext GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsContext GhcRn
tys
]
HsExplicitTupleTy _ tys :: HsContext GhcRn
tys ->
[ HsContext GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsContext GhcRn
tys
]
HsTyLit _ _ -> []
HsWildCardTy _ -> []
HsStarTy _ _ -> []
XHsType _ -> []
instance (ToHie tm, ToHie ty) => ToHie (HsArg tm ty) where
toHie :: HsArg tm ty -> HieM [HieAST Type]
toHie (HsValArg tm :: tm
tm) = tm -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie tm
tm
toHie (HsTypeArg _ ty :: ty
ty) = ty -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ty
ty
toHie (HsArgPar sp :: SrcSpan
sp) = [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
sp
instance ToHie (TVScoped (LHsTyVarBndr GhcRn)) where
toHie :: TVScoped (LHsTyVarBndr GhcRn) -> HieM [HieAST Type]
toHie (TVS tsc :: TyVarScope
tsc sc :: Scope
sc (L span :: SrcSpan
span bndr :: HsTyVarBndr 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 GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsTyVarBndr GhcRn
bndr SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsTyVarBndr GhcRn
bndr of
UserTyVar _ var :: Located (IdP GhcRn)
var ->
[ 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 (Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) Located Name
Located (IdP GhcRn)
var
]
KindedTyVar _ var :: Located (IdP GhcRn)
var kind :: LHsType GhcRn
kind ->
[ 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 (Scope -> TyVarScope -> ContextInfo
TyVarBind Scope
sc TyVarScope
tsc) Located Name
Located (IdP GhcRn)
var
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
kind
]
XTyVarBndr _ -> []
instance ToHie (TScoped (LHsQTyVars GhcRn)) where
toHie :: TScoped (LHsQTyVars GhcRn) -> HieM [HieAST Type]
toHie (TS sc :: TyVarScope
sc (HsQTvs (HsQTvsRn implicits _) vars :: [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
$
[ [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
$ [Context Name] -> [HieAST Type]
forall a. [Context Name] -> [HieAST a]
bindingsOnly [Context Name]
bindings
, [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type])
-> [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> Scope -> [LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)]
forall a.
TyVarScope
-> Scope -> [LHsTyVarBndr a] -> [TVScoped (LHsTyVarBndr a)]
tvScopes TyVarScope
sc Scope
NoScope [LHsTyVarBndr GhcRn]
vars
]
where
varLoc :: SrcSpan
varLoc = [LHsTyVarBndr GhcRn] -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc [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]
implicits
toHie (TS _ (XLHsQTyVars _)) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LHsContext GhcRn) where
toHie :: Located (HsContext GhcRn) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span tys :: HsContext 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
$
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
span
, HsContext GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsContext GhcRn
tys
]
instance ToHie (LConDeclField GhcRn) where
toHie :: LConDeclField GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span field :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode ConDeclField GhcRn
field SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case ConDeclField GhcRn
field of
ConDeclField _ fields :: [LFieldOcc GhcRn]
fields typ :: LHsType GhcRn
typ _ ->
[ [RFContext (LFieldOcc GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RFContext (LFieldOcc GhcRn)] -> HieM [HieAST Type])
-> [RFContext (LFieldOcc GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LFieldOcc GhcRn -> RFContext (LFieldOcc GhcRn))
-> [LFieldOcc GhcRn] -> [RFContext (LFieldOcc GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (RecFieldContext
-> Maybe RealSrcSpan
-> LFieldOcc GhcRn
-> RFContext (LFieldOcc GhcRn)
forall a. RecFieldContext -> Maybe RealSrcSpan -> a -> RFContext a
RFC RecFieldContext
RecFieldDecl (SrcSpan -> Maybe RealSrcSpan
getRealSpan (SrcSpan -> Maybe RealSrcSpan) -> SrcSpan -> Maybe RealSrcSpan
forall a b. (a -> b) -> a -> b
$ LHsType GhcRn -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
loc LHsType GhcRn
typ)) [LFieldOcc GhcRn]
fields
, LHsType GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsType GhcRn
typ
]
XConDeclField _ -> []
instance ToHie (LHsExpr a) => ToHie (ArithSeqInfo a) where
toHie :: ArithSeqInfo a -> HieM [HieAST Type]
toHie (From expr :: LHsExpr a
expr) = LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
expr
toHie (FromThen a :: LHsExpr a
a b :: 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 a :: LHsExpr a
a b :: 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 a :: LHsExpr a
a b :: LHsExpr a
b c :: 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 (LSpliceDecl GhcRn) where
toHie :: LSpliceDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode SpliceDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case SpliceDecl GhcRn
decl of
SpliceDecl _ splice :: GenLocated SrcSpan (HsSplice GhcRn)
splice _ ->
[ GenLocated SrcSpan (HsSplice GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie GenLocated SrcSpan (HsSplice GhcRn)
splice
]
XSpliceDecl _ -> []
instance ToHie (HsBracket a) where
toHie :: HsBracket a -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie PendingRnSplice where
toHie :: PendingRnSplice -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie PendingTcSplice where
toHie :: PendingTcSplice -> HieM [HieAST Type]
toHie _ = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LBooleanFormula (Located Name)) where
toHie :: LBooleanFormula (Located Name) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span form :: BooleanFormula (Located 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 (Located Name) -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode BooleanFormula (Located Name)
form SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case BooleanFormula (Located Name)
form of
Var a :: Located Name
a ->
[ Context (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located Name) -> HieM [HieAST Type])
-> Context (Located Name) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located Name
a
]
And forms :: [LBooleanFormula (Located Name)]
forms ->
[ [LBooleanFormula (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LBooleanFormula (Located Name)]
forms
]
Or forms :: [LBooleanFormula (Located Name)]
forms ->
[ [LBooleanFormula (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LBooleanFormula (Located Name)]
forms
]
Parens f :: LBooleanFormula (Located Name)
f ->
[ LBooleanFormula (Located Name) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LBooleanFormula (Located Name)
f
]
instance ToHie (Located HsIPName) where
toHie :: Located HsIPName -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span e :: HsIPName
e) = HsIPName -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsIPName
e SrcSpan
span
instance ( ToHie (LHsExpr a)
, Data (HsSplice a)
) => ToHie (Located (HsSplice a)) where
toHie :: Located (HsSplice a) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span sp :: HsSplice a
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 a -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode HsSplice a
sp SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case HsSplice a
sp of
HsTypedSplice _ _ _ expr :: LHsExpr a
expr ->
[ LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
expr
]
HsUntypedSplice _ _ _ expr :: LHsExpr a
expr ->
[ LHsExpr a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr a
expr
]
HsQuasiQuote _ _ _ ispan :: SrcSpan
ispan _ ->
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
ispan
]
HsSpliced _ _ _ ->
[]
HsSplicedT _ ->
[]
XSplice _ -> []
instance ToHie (LRoleAnnotDecl GhcRn) where
toHie :: LRoleAnnotDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span annot :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode RoleAnnotDecl GhcRn
annot SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case RoleAnnotDecl GhcRn
annot of
RoleAnnotDecl _ var :: Located (IdP GhcRn)
var roles :: [Located (Maybe Role)]
roles ->
[ 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 ContextInfo
Use Located Name
Located (IdP GhcRn)
var
, (Located (Maybe Role) -> HieM [HieAST Type])
-> [Located (Maybe Role)] -> HieM [HieAST Type]
forall (m :: * -> *) a b. Monad m => (a -> m [b]) -> [a] -> m [b]
concatMapM ([HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([HieAST Type] -> HieM [HieAST Type])
-> (Located (Maybe Role) -> [HieAST Type])
-> Located (Maybe Role)
-> HieM [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type])
-> (Located (Maybe Role) -> SrcSpan)
-> Located (Maybe Role)
-> [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Located (Maybe Role) -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) [Located (Maybe Role)]
roles
]
XRoleAnnotDecl _ -> []
instance ToHie (LInstDecl GhcRn) where
toHie :: LInstDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode InstDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case InstDecl GhcRn
decl of
ClsInstD _ d :: ClsInstDecl GhcRn
d ->
[ GenLocated SrcSpan (ClsInstDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (ClsInstDecl GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpan (ClsInstDecl GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> ClsInstDecl GhcRn -> GenLocated SrcSpan (ClsInstDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpan
span ClsInstDecl GhcRn
d
]
DataFamInstD _ d :: DataFamInstDecl GhcRn
d ->
[ GenLocated SrcSpan (DataFamInstDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (DataFamInstDecl GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpan (DataFamInstDecl GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> DataFamInstDecl GhcRn
-> GenLocated SrcSpan (DataFamInstDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpan
span DataFamInstDecl GhcRn
d
]
TyFamInstD _ d :: TyFamInstDecl GhcRn
d ->
[ GenLocated SrcSpan (TyFamInstDecl GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (GenLocated SrcSpan (TyFamInstDecl GhcRn) -> HieM [HieAST Type])
-> GenLocated SrcSpan (TyFamInstDecl GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> TyFamInstDecl GhcRn -> GenLocated SrcSpan (TyFamInstDecl GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpan
span TyFamInstDecl GhcRn
d
]
XInstDecl _ -> []
instance ToHie (LClsInstDecl GhcRn) where
toHie :: GenLocated SrcSpan (ClsInstDecl GhcRn) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: ClsInstDecl GhcRn
decl) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpan -> Scope
mkScope SrcSpan
span]) (LHsSigType GhcRn -> TScoped (LHsSigType GhcRn))
-> LHsSigType GhcRn -> TScoped (LHsSigType 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 (LHsBind GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Bag (BindContext (LHsBind GhcRn)) -> HieM [HieAST Type])
-> Bag (BindContext (LHsBind GhcRn)) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LHsBind GhcRn -> BindContext (LHsBind GhcRn))
-> LHsBinds GhcRn -> Bag (BindContext (LHsBind GhcRn))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (BindType -> Scope -> LHsBind GhcRn -> BindContext (LHsBind GhcRn)
forall a. BindType -> Scope -> a -> BindContext a
BC BindType
InstanceBind Scope
ModuleScope) (LHsBinds GhcRn -> Bag (BindContext (LHsBind GhcRn)))
-> LHsBinds GhcRn -> Bag (BindContext (LHsBind GhcRn))
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> LHsBinds GhcRn
forall pass. ClsInstDecl pass -> LHsBinds pass
cid_binds ClsInstDecl GhcRn
decl
, [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([SigContext (LSig GhcRn)] -> HieM [HieAST Type])
-> [SigContext (LSig GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LSig GhcRn -> SigContext (LSig GhcRn))
-> [LSig GhcRn] -> [SigContext (LSig GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn)
forall a. SigInfo -> a -> SigContext a
SC (SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn))
-> SigInfo -> LSig GhcRn -> SigContext (LSig GhcRn)
forall a b. (a -> b) -> a -> b
$ SigType -> Maybe RealSrcSpan -> SigInfo
SI SigType
InstSig (Maybe RealSrcSpan -> SigInfo) -> Maybe RealSrcSpan -> SigInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) ([LSig GhcRn] -> [SigContext (LSig GhcRn)])
-> [LSig GhcRn] -> [SigContext (LSig GhcRn)]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [LSig GhcRn]
forall pass. ClsInstDecl pass -> [LSig pass]
cid_sigs ClsInstDecl GhcRn
decl
, [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
$ (GenLocated SrcSpan (TyFamInstDecl GhcRn) -> [HieAST Type])
-> [GenLocated SrcSpan (TyFamInstDecl GhcRn)] -> [HieAST Type]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type])
-> (GenLocated SrcSpan (TyFamInstDecl GhcRn) -> SrcSpan)
-> GenLocated SrcSpan (TyFamInstDecl GhcRn)
-> [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpan (TyFamInstDecl GhcRn) -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) ([GenLocated SrcSpan (TyFamInstDecl GhcRn)] -> [HieAST Type])
-> [GenLocated SrcSpan (TyFamInstDecl GhcRn)] -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [GenLocated SrcSpan (TyFamInstDecl GhcRn)]
forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts ClsInstDecl GhcRn
decl
, [GenLocated SrcSpan (TyFamInstDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (TyFamInstDecl GhcRn)] -> HieM [HieAST Type])
-> [GenLocated SrcSpan (TyFamInstDecl GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [GenLocated SrcSpan (TyFamInstDecl GhcRn)]
forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts ClsInstDecl GhcRn
decl
, [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
$ (GenLocated SrcSpan (DataFamInstDecl GhcRn) -> [HieAST Type])
-> [GenLocated SrcSpan (DataFamInstDecl GhcRn)] -> [HieAST Type]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type])
-> (GenLocated SrcSpan (DataFamInstDecl GhcRn) -> SrcSpan)
-> GenLocated SrcSpan (DataFamInstDecl GhcRn)
-> [HieAST Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpan (DataFamInstDecl GhcRn) -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) ([GenLocated SrcSpan (DataFamInstDecl GhcRn)] -> [HieAST Type])
-> [GenLocated SrcSpan (DataFamInstDecl GhcRn)] -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [GenLocated SrcSpan (DataFamInstDecl GhcRn)]
forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts ClsInstDecl GhcRn
decl
, [GenLocated SrcSpan (DataFamInstDecl GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([GenLocated SrcSpan (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type])
-> [GenLocated SrcSpan (DataFamInstDecl GhcRn)]
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> [GenLocated SrcSpan (DataFamInstDecl GhcRn)]
forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts ClsInstDecl GhcRn
decl
, Maybe (Located OverlapMode) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe (Located OverlapMode) -> HieM [HieAST Type])
-> Maybe (Located OverlapMode) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcRn -> Maybe (Located OverlapMode)
forall pass. ClsInstDecl pass -> Maybe (Located OverlapMode)
cid_overlap_mode ClsInstDecl GhcRn
decl
]
instance ToHie (LDataFamInstDecl GhcRn) where
toHie :: GenLocated SrcSpan (DataFamInstDecl GhcRn) -> HieM [HieAST Type]
toHie (L sp :: SrcSpan
sp (DataFamInstDecl d :: FamInstEqn GhcRn (HsDataDefn GhcRn)
d)) = TScoped (FamInstEqn GhcRn (HsDataDefn GhcRn)) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (FamInstEqn GhcRn (HsDataDefn GhcRn))
-> HieM [HieAST Type])
-> TScoped (FamInstEqn GhcRn (HsDataDefn GhcRn))
-> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope
-> FamInstEqn GhcRn (HsDataDefn GhcRn)
-> TScoped (FamInstEqn GhcRn (HsDataDefn GhcRn))
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpan -> Scope
mkScope SrcSpan
sp]) FamInstEqn GhcRn (HsDataDefn GhcRn)
d
instance ToHie (LTyFamInstDecl GhcRn) where
toHie :: GenLocated SrcSpan (TyFamInstDecl GhcRn) -> HieM [HieAST Type]
toHie (L sp :: SrcSpan
sp (TyFamInstDecl d :: TyFamInstEqn GhcRn
d)) = TScoped (TyFamInstEqn GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (TyFamInstEqn GhcRn) -> HieM [HieAST Type])
-> TScoped (TyFamInstEqn GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> TyFamInstEqn GhcRn -> TScoped (TyFamInstEqn GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [SrcSpan -> Scope
mkScope SrcSpan
sp]) TyFamInstEqn GhcRn
d
instance ToHie (Context a)
=> ToHie (PatSynFieldContext (RecordPatSynField a)) where
toHie :: PatSynFieldContext (RecordPatSynField a) -> HieM [HieAST Type]
toHie (PSC sp :: Maybe RealSrcSpan
sp (RecordPatSynField a :: a
a b :: 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
$
[ Context a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context a -> HieM [HieAST Type])
-> Context a -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> a -> Context a
forall a. ContextInfo -> a -> Context a
C (RecFieldContext -> Maybe RealSrcSpan -> ContextInfo
RecField RecFieldContext
RecFieldDecl Maybe RealSrcSpan
sp) a
a
, Context a -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context a -> HieM [HieAST Type])
-> Context a -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> a -> Context a
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use a
b
]
instance ToHie (LDerivDecl GhcRn) where
toHie :: LDerivDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode DerivDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DerivDecl GhcRn
decl of
DerivDecl _ typ :: LHsSigWcType GhcRn
typ strat :: Maybe (LDerivStrategy GhcRn)
strat overlap :: Maybe (Located OverlapMode)
overlap ->
[ TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigWcType GhcRn -> TScoped (LHsSigWcType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigWcType GhcRn
typ
, Maybe (LDerivStrategy GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (LDerivStrategy GhcRn)
strat
, Maybe (Located OverlapMode) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie Maybe (Located OverlapMode)
overlap
]
XDerivDecl _ -> []
instance ToHie (LFixitySig GhcRn) where
toHie :: GenLocated SrcSpan (FixitySig GhcRn) -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span sig :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode FixitySig GhcRn
sig SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case FixitySig GhcRn
sig of
FixitySig _ vars :: [Located (IdP GhcRn)]
vars _ ->
[ [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located Name]
[Located (IdP GhcRn)]
vars
]
XFixitySig _ -> []
instance ToHie (LDefaultDecl GhcRn) where
toHie :: LDefaultDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode DefaultDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case DefaultDecl GhcRn
decl of
DefaultDecl _ typs :: HsContext GhcRn
typs ->
[ HsContext GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie HsContext GhcRn
typs
]
XDefaultDecl _ -> []
instance ToHie (LForeignDecl GhcRn) where
toHie :: LForeignDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode ForeignDecl GhcRn
decl SrcSpan
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 -> Located (IdP pass)
fd_name = Located (IdP 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 (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 (BindType -> Scope -> Maybe RealSrcSpan -> ContextInfo
ValBind BindType
RegularBind Scope
ModuleScope (Maybe RealSrcSpan -> ContextInfo)
-> Maybe RealSrcSpan -> ContextInfo
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Maybe RealSrcSpan
getRealSpan SrcSpan
span) Located Name
Located (IdP GhcRn)
name
, TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) 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 -> Located (IdP pass)
fd_name = Located (IdP 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 (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 ContextInfo
Use Located Name
Located (IdP GhcRn)
name
, TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigType GhcRn -> TScoped (LHsSigType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes []) LHsSigType GhcRn
sig
, ForeignExport -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ForeignExport
fe
]
XForeignDecl _ -> []
instance ToHie ForeignImport where
toHie :: ForeignImport -> HieM [HieAST Type]
toHie (CImport (L a :: SrcSpan
a _) (L b :: SrcSpan
b _) _ _ (L c :: SrcSpan
c _)) = [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
$ [[HieAST Type]] -> [HieAST Type]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[HieAST Type]] -> [HieAST Type])
-> [[HieAST Type]] -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
a
, SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
b
, SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
c
]
instance ToHie ForeignExport where
toHie :: ForeignExport -> HieM [HieAST Type]
toHie (CExport (L a :: SrcSpan
a _) (L b :: SrcSpan
b _)) = [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
$ [[HieAST Type]] -> [HieAST Type]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[HieAST Type]] -> [HieAST Type])
-> [[HieAST Type]] -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$
[ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
a
, SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
b
]
instance ToHie (LWarnDecls GhcRn) where
toHie :: LWarnDecls GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode WarnDecls GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case WarnDecls GhcRn
decl of
Warnings _ _ warnings :: [LWarnDecl GhcRn]
warnings ->
[ [LWarnDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LWarnDecl GhcRn]
warnings
]
XWarnDecls _ -> []
instance ToHie (LWarnDecl GhcRn) where
toHie :: LWarnDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode WarnDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case WarnDecl GhcRn
decl of
Warning _ vars :: [Located (IdP GhcRn)]
vars _ ->
[ [Context (Located Name)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([Context (Located Name)] -> HieM [HieAST Type])
-> [Context (Located Name)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located Name -> Context (Located Name))
-> [Located Name] -> [Context (Located Name)]
forall a b. (a -> b) -> [a] -> [b]
map (ContextInfo -> Located Name -> Context (Located Name)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use) [Located Name]
[Located (IdP GhcRn)]
vars
]
XWarnDecl _ -> []
instance ToHie (LAnnDecl GhcRn) where
toHie :: LAnnDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode AnnDecl GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case AnnDecl GhcRn
decl of
HsAnnotation _ _ prov :: AnnProvenance (IdP GhcRn)
prov expr :: LHsExpr GhcRn
expr ->
[ AnnProvenance Name -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie AnnProvenance Name
AnnProvenance (IdP GhcRn)
prov
, LHsExpr GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
expr
]
XAnnDecl _ -> []
instance ToHie (Context (Located a)) => ToHie (AnnProvenance a) where
toHie :: AnnProvenance a -> HieM [HieAST Type]
toHie (ValueAnnProvenance a :: Located a
a) = Context (Located a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located a) -> HieM [HieAST Type])
-> Context (Located a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located a -> Context (Located a)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located a
a
toHie (TypeAnnProvenance a :: Located a
a) = Context (Located a) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Context (Located a) -> HieM [HieAST Type])
-> Context (Located a) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ContextInfo -> Located a -> Context (Located a)
forall a. ContextInfo -> a -> Context a
C ContextInfo
Use Located a
a
toHie ModuleAnnProvenance = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance ToHie (LRuleDecls GhcRn) where
toHie :: LRuleDecls GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode RuleDecls GhcRn
decl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case RuleDecls GhcRn
decl of
HsRules _ _ rules :: [LRuleDecl GhcRn]
rules ->
[ [LRuleDecl GhcRn] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie [LRuleDecl GhcRn]
rules
]
XRuleDecls _ -> []
instance ToHie (LRuleDecl GhcRn) where
toHie :: LRuleDecl GhcRn -> HieM [HieAST Type]
toHie (L _ (XRuleDecl _)) = [HieAST Type] -> HieM [HieAST Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
toHie (L span :: SrcSpan
span r :: RuleDecl GhcRn
r@(HsRule _ rname :: Located (SourceText, FastString)
rname _ tybndrs :: Maybe [LHsTyVarBndr (NoGhcTc GhcRn)]
tybndrs bndrs :: [LRuleBndr GhcRn]
bndrs exprA :: LHsExpr GhcRn
exprA exprB :: LHsExpr GhcRn
exprB)) = [HieM [HieAST Type]] -> HieM [HieAST Type]
forall (m :: * -> *) a. Monad m => [m [a]] -> m [a]
concatM
[ RuleDecl GhcRn -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode RuleDecl GhcRn
r SrcSpan
span
, [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly (SrcSpan -> [HieAST Type]) -> SrcSpan -> [HieAST Type]
forall a b. (a -> b) -> a -> b
$ Located (SourceText, FastString) -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc Located (SourceText, FastString)
rname
, Maybe [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (Maybe [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type])
-> Maybe [TVScoped (LHsTyVarBndr GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ ([LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)])
-> Maybe [LHsTyVarBndr GhcRn]
-> Maybe [TVScoped (LHsTyVarBndr GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TyVarScope
-> Scope -> [LHsTyVarBndr GhcRn] -> [TVScoped (LHsTyVarBndr GhcRn)]
forall a.
TyVarScope
-> Scope -> [LHsTyVarBndr a] -> [TVScoped (LHsTyVarBndr a)]
tvScopes ([Scope] -> TyVarScope
ResolvedScopes []) Scope
scope) Maybe [LHsTyVarBndr (NoGhcTc GhcRn)]
Maybe [LHsTyVarBndr GhcRn]
tybndrs
, [RScoped (LRuleBndr GhcRn)] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([RScoped (LRuleBndr GhcRn)] -> HieM [HieAST Type])
-> [RScoped (LRuleBndr GhcRn)] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (LRuleBndr GhcRn -> RScoped (LRuleBndr GhcRn))
-> [LRuleBndr GhcRn] -> [RScoped (LRuleBndr GhcRn)]
forall a b. (a -> b) -> [a] -> [b]
map (Scope -> LRuleBndr GhcRn -> RScoped (LRuleBndr GhcRn)
forall a. Scope -> a -> RScoped a
RS (Scope -> LRuleBndr GhcRn -> RScoped (LRuleBndr GhcRn))
-> Scope -> LRuleBndr GhcRn -> RScoped (LRuleBndr GhcRn)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Scope
mkScope SrcSpan
span) [LRuleBndr GhcRn]
bndrs
, LHsExpr GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr GhcRn
exprA
, LHsExpr GhcRn -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie LHsExpr 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
-> (LRuleBndr GhcRn -> Scope) -> Maybe (LRuleBndr GhcRn) -> Scope
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Scope
NoScope LRuleBndr GhcRn -> Scope
forall a. Located a -> Scope
mkLScope ([LRuleBndr GhcRn] -> Maybe (LRuleBndr GhcRn)
forall a. [a] -> Maybe a
listToMaybe [LRuleBndr GhcRn]
bndrs)
exprA_sc :: Scope
exprA_sc = LHsExpr GhcRn -> Scope
forall a. Located a -> Scope
mkLScope LHsExpr GhcRn
exprA
exprB_sc :: Scope
exprB_sc = LHsExpr GhcRn -> Scope
forall a. Located a -> Scope
mkLScope LHsExpr GhcRn
exprB
instance ToHie (RScoped (LRuleBndr GhcRn)) where
toHie :: RScoped (LRuleBndr GhcRn) -> HieM [HieAST Type]
toHie (RS sc :: Scope
sc (L span :: SrcSpan
span bndr :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> 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 _ var :: Located (IdP GhcRn)
var ->
[ 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 (BindType -> Scope -> Maybe RealSrcSpan -> ContextInfo
ValBind BindType
RegularBind Scope
sc Maybe RealSrcSpan
forall a. Maybe a
Nothing) Located Name
Located (IdP GhcRn)
var
]
RuleBndrSig _ var :: Located (IdP GhcRn)
var typ :: LHsSigWcType GhcRn
typ ->
[ 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 (BindType -> Scope -> Maybe RealSrcSpan -> ContextInfo
ValBind BindType
RegularBind Scope
sc Maybe RealSrcSpan
forall a. Maybe a
Nothing) Located Name
Located (IdP GhcRn)
var
, TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie (TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type])
-> TScoped (LHsSigWcType GhcRn) -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ TyVarScope -> LHsSigWcType GhcRn -> TScoped (LHsSigWcType GhcRn)
forall a. TyVarScope -> a -> TScoped a
TS ([Scope] -> TyVarScope
ResolvedScopes [Scope
sc]) LHsSigWcType GhcRn
typ
]
XRuleBndr _ -> []
instance ToHie (LImportDecl GhcRn) where
toHie :: LImportDecl GhcRn -> HieM [HieAST Type]
toHie (L span :: SrcSpan
span decl :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode ImportDecl GhcRn
decl SrcSpan
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 -> Located ModuleName
ideclName = Located ModuleName
name, ideclAs :: forall pass. ImportDecl pass -> Maybe (Located ModuleName)
ideclAs = Maybe (Located ModuleName)
as, ideclHiding :: forall pass. ImportDecl pass -> Maybe (Bool, Located [LIE pass])
ideclHiding = Maybe (Bool, Located [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
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)
as
, HieM [HieAST Type]
-> ((Bool, Located [LIE GhcRn]) -> HieM [HieAST Type])
-> Maybe (Bool, Located [LIE 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, Located [LIE GhcRn]) -> HieM [HieAST Type]
forall a.
ToHie (IEContext a) =>
(Bool, GenLocated SrcSpan [a]) -> HieM [HieAST Type]
goIE Maybe (Bool, Located [LIE GhcRn])
hidden
]
XImportDecl _ -> []
where
goIE :: (Bool, GenLocated SrcSpan [a]) -> HieM [HieAST Type]
goIE (hiding :: Bool
hiding, (L sp :: SrcSpan
sp liens :: [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
$
[ [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
$ SrcSpan -> [HieAST Type]
forall a. SrcSpan -> [HieAST a]
locOnly SrcSpan
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 (LIE GhcRn)) where
toHie :: IEContext (LIE GhcRn) -> HieM [HieAST Type]
toHie (IEC c :: IEType
c (L span :: SrcSpan
span ie :: 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.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode IE GhcRn
ie SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case IE GhcRn
ie of
IEVar _ n :: 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 _ n :: 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 _ n :: 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 _ n :: LIEWrappedName (IdP GhcRn)
n _ ns :: [LIEWrappedName (IdP GhcRn)]
ns flds :: [Located (FieldLbl (IdP GhcRn))]
flds ->
[ 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 (FieldLbl Name))] -> HieM [HieAST Type]
forall a. ToHie a => a -> HieM [HieAST Type]
toHie ([IEContext (Located (FieldLbl Name))] -> HieM [HieAST Type])
-> [IEContext (Located (FieldLbl Name))] -> HieM [HieAST Type]
forall a b. (a -> b) -> a -> b
$ (Located (FieldLbl Name) -> IEContext (Located (FieldLbl Name)))
-> [Located (FieldLbl Name)]
-> [IEContext (Located (FieldLbl Name))]
forall a b. (a -> b) -> [a] -> [b]
map (IEType
-> Located (FieldLbl Name) -> IEContext (Located (FieldLbl Name))
forall a. IEType -> a -> IEContext a
IEC IEType
c) [Located (FieldLbl Name)]
[Located (FieldLbl (IdP GhcRn))]
flds
]
IEModuleContents _ n :: Located 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
n
]
IEGroup _ _ _ -> []
IEDoc _ _ -> []
IEDocNamed _ _ -> []
XIE _ -> []
instance ToHie (IEContext (LIEWrappedName Name)) where
toHie :: IEContext (LIEWrappedName Name) -> HieM [HieAST Type]
toHie (IEC c :: IEType
c (L span :: SrcSpan
span iewn :: 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 -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode IEWrappedName Name
iewn SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case IEWrappedName Name
iewn of
IEName n :: Located Name
n ->
[ 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
n
]
IEPattern p :: Located Name
p ->
[ 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
p
]
IEType n :: Located Name
n ->
[ 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
n
]
instance ToHie (IEContext (Located (FieldLbl Name))) where
toHie :: IEContext (Located (FieldLbl Name)) -> HieM [HieAST Type]
toHie (IEC c :: IEType
c (L span :: SrcSpan
span lbl :: FieldLbl Name
lbl)) = [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
$ FieldLbl Name -> SrcSpan -> HieM [HieAST Type]
forall (m :: * -> *) a b.
(Applicative m, Data a) =>
a -> SrcSpan -> m [HieAST b]
makeNode FieldLbl Name
lbl SrcSpan
span HieM [HieAST Type] -> [HieM [HieAST Type]] -> [HieM [HieAST Type]]
forall a. a -> [a] -> [a]
: case FieldLbl Name
lbl of
FieldLabel _ _ n :: Name
n ->
[ 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 Name
n
]