aboutsummaryrefslogtreecommitdiff
path: root/src/HaskellCodeExplorer/AST
diff options
context:
space:
mode:
authoralexwl <alexey.a.kiryushin@gmail.com>2018-10-14 18:56:06 +0300
committeralexwl <alexey.a.kiryushin@gmail.com>2018-10-14 18:56:06 +0300
commit9c5cb27828bcc3cbe505fba8ef8e6db0e87d2a9c (patch)
treed558ebcf13b4f5d42d27efea30e5f5697a0f456f /src/HaskellCodeExplorer/AST
parent1b8661d36ce9dcbcd5a833a79357445fe734426d (diff)
parent2b5cbccffa21d9f80f804bd9d95d4527ce3246b7 (diff)
Merge branch 'ghc-8.4.3'
Diffstat (limited to 'src/HaskellCodeExplorer/AST')
-rw-r--r--src/HaskellCodeExplorer/AST/RenamedSource.hs144
-rw-r--r--src/HaskellCodeExplorer/AST/TypecheckedSource.hs163
2 files changed, 276 insertions, 31 deletions
diff --git a/src/HaskellCodeExplorer/AST/RenamedSource.hs b/src/HaskellCodeExplorer/AST/RenamedSource.hs
index c1bf463..46ecc8f 100644
--- a/src/HaskellCodeExplorer/AST/RenamedSource.hs
+++ b/src/HaskellCodeExplorer/AST/RenamedSource.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StrictData #-}
@@ -54,10 +55,19 @@ import GHC
, PatSynBind(..)
, Sig(..)
, TyClDecl(..)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ , FamEqn(..)
+ , HsDataDefn(..)
+#else
, TyFamEqn(..)
+#endif
, Type
+ , RoleAnnotDecl(..)
, unLoc
)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+import HsExtension (GhcRn)
+#endif
import HaskellCodeExplorer.GhcUtils (hsPatSynDetails, ieLocNames)
import Prelude hiding (span)
import TysWiredIn
@@ -86,9 +96,14 @@ namesFromRenamedSource =
hsTypeNames `extQ`
tyClDeclNames `extQ`
familyDeclNames `extQ`
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ familyEqNames `extQ`
+ dataEqNames `extQ`
+#else
tyFamilyEqNames `extQ`
tyFamilyDefEqNames `extQ`
dataFamInstDeclNames `extQ`
+#endif
conDeclNames `extQ`
importNames `extQ`
hsTyVarBndrNames `extQ`
@@ -97,9 +112,14 @@ namesFromRenamedSource =
hsRecFieldExprNames `extQ`
hsRecAmbFieldExprNames `extQ`
hsRecFieldPatNames `extQ`
- foreignDeclNames)
+ foreignDeclNames `extQ`
+ roleAnnotationNames)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+fieldOccName :: Bool -> FieldOcc GhcRn -> NameOccurrence
+#else
fieldOccName :: Bool -> FieldOcc Name -> NameOccurrence
+#endif
fieldOccName isBinder (FieldOcc (L span _) name) =
NameOccurrence
{ locatedName = L span (Just name)
@@ -107,16 +127,26 @@ fieldOccName isBinder (FieldOcc (L span _) name) =
, isBinder = isBinder
}
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+conDeclFieldNames :: ConDeclField GhcRn -> [NameOccurrence]
+#else
conDeclFieldNames :: ConDeclField Name -> [NameOccurrence]
+#endif
conDeclFieldNames ConDeclField {..} =
map (fieldOccName True . unLoc) cd_fld_names
-hsRecFieldExprNames ::
- HsRecField' (FieldOcc Name) (LHsExpr Name) -> [NameOccurrence]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+hsRecFieldExprNames :: HsRecField' (FieldOcc GhcRn) (LHsExpr GhcRn) -> [NameOccurrence]
+#else
+hsRecFieldExprNames :: HsRecField' (FieldOcc Name) (LHsExpr Name) -> [NameOccurrence]
+#endif
hsRecFieldExprNames HsRecField {..} = [fieldOccName False $ unLoc hsRecFieldLbl]
-hsRecAmbFieldExprNames ::
- HsRecField' (AmbiguousFieldOcc Name) (LHsExpr Name) -> [NameOccurrence]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+hsRecAmbFieldExprNames :: HsRecField' (AmbiguousFieldOcc GhcRn) (LHsExpr GhcRn) -> [NameOccurrence]
+#else
+hsRecAmbFieldExprNames :: HsRecField' (AmbiguousFieldOcc Name) (LHsExpr Name) -> [NameOccurrence]
+#endif
hsRecAmbFieldExprNames HsRecField {..} =
let (L span recField) = hsRecFieldLbl
mbName =
@@ -130,11 +160,18 @@ hsRecAmbFieldExprNames HsRecField {..} =
}
]
-hsRecFieldPatNames ::
- HsRecField' (FieldOcc Name) (LPat Name) -> [NameOccurrence]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+hsRecFieldPatNames :: HsRecField' (FieldOcc GhcRn) (LPat GhcRn) -> [NameOccurrence]
+#else
+hsRecFieldPatNames :: HsRecField' (FieldOcc Name) (LPat Name) -> [NameOccurrence]
+#endif
hsRecFieldPatNames HsRecField {..} = [fieldOccName False $ unLoc hsRecFieldLbl]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+hsExprNames :: LHsExpr GhcRn -> [NameOccurrence]
+#else
hsExprNames :: LHsExpr Name -> [NameOccurrence]
+#endif
hsExprNames (L _span (HsVar name)) =
[ NameOccurrence
{ locatedName = Just <$> name
@@ -174,9 +211,13 @@ hsExprNames (L _span (HsRecFld (Ambiguous (L span _) _name))) =
]
hsExprNames _ = []
-matchGroupNames :: MatchGroup Name (LHsExpr Name) -> [NameOccurrence]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+matchGroupNames :: MatchGroup GhcRn (LHsExpr GhcRn) -> [NameOccurrence]
+#else
+matchGroupNames :: MatchGroup Name (LHsExpr Name) -> [NameOccurrence]
+#endif
matchGroupNames =
-#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
+#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
mapMaybe (fmap toNameOcc . matchContextName . m_ctxt . unLoc) .
#else
mapMaybe (fmap toNameOcc . matchFixityName . m_fixity . unLoc) .
@@ -184,20 +225,24 @@ matchGroupNames =
unLoc . mg_alts
where
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
- matchContextName :: HsMatchContext Name -> Maybe (Located Name)
+ --matchContextName :: HsMatchContext Name -> Maybe (Located Name)
matchContextName (FunRhs name _ _bool) = Just name
matchContextName _ = Nothing
#else
- matchFixityName :: MatchFixity Name -> Maybe (Located Name)
+ --matchFixityName :: MatchFixity Name -> Maybe (Located Name)
matchFixityName NonFunBindMatch = Nothing
matchFixityName (FunBindMatch name _bool) = Just name
#endif
- toNameOcc :: Located Name -> NameOccurrence
+ --toNameOcc :: Located Name -> NameOccurrence
toNameOcc n =
NameOccurrence
- {locatedName = Just <$> n, description = "Match", isBinder = True}
+ {locatedName = Just <$> n, description = "Match", isBinder = True}
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+bindNames :: LHsBindLR GhcRn GhcRn -> [NameOccurrence]
+#else
bindNames :: LHsBindLR Name Name -> [NameOccurrence]
+#endif
bindNames (L _span (PatSynBind PSB {..})) =
[ NameOccurrence
{ locatedName = Just <$> psb_id
@@ -218,7 +263,11 @@ hsPatSynDetailsNames =
}) .
hsPatSynDetails
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+importNames :: IE GhcRn -> [NameOccurrence]
+#else
importNames :: IE Name -> [NameOccurrence]
+#endif
importNames =
map
(\name ->
@@ -229,7 +278,12 @@ importNames =
}) .
ieLocNames
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+patNames :: LPat GhcRn -> [NameOccurrence]
+#else
patNames :: LPat Name -> [NameOccurrence]
+#endif
patNames (L _span (VarPat name)) =
[ NameOccurrence
{ locatedName = Just <$> name
@@ -260,7 +314,12 @@ patNames (L _span (NPlusKPat name _ _ _ _ _)) =
]
patNames _ = []
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+sigNames :: LSig GhcRn -> [NameOccurrence]
+#else
sigNames :: LSig Name -> [NameOccurrence]
+#endif
sigNames (L _span (TypeSig names _)) =
map
(\n ->
@@ -332,7 +391,11 @@ sigNames (L _span (MinimalSig _ (L _ boolFormula))) =
boolFormulaNames (Parens (L _ f)) = boolFormulaNames f
sigNames (L _ _) = []
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+hsTypeNames :: LHsType GhcRn -> [NameOccurrence]
+#else
hsTypeNames :: LHsType Name -> [NameOccurrence]
+#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
hsTypeNames (L _span (HsTyVar _promoted name)) =
#else
@@ -382,7 +445,12 @@ hsTypeNames (L span (HsTupleTy tupleSort types))
--hsTypeNames (L span (HsExplicitTupleTy _kind types)) = ...
hsTypeNames _ = []
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+hsTyVarBndrNames :: HsTyVarBndr GhcRn -> [NameOccurrence]
+#else
hsTyVarBndrNames :: HsTyVarBndr Name -> [NameOccurrence]
+#endif
hsTyVarBndrNames (UserTyVar n) =
[ NameOccurrence
{ locatedName = Just <$> n
@@ -398,7 +466,11 @@ hsTyVarBndrNames (KindedTyVar n _) =
}
]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+tyClDeclNames :: LTyClDecl GhcRn -> [NameOccurrence]
+#else
tyClDeclNames :: LTyClDecl Name -> [NameOccurrence]
+#endif
tyClDeclNames (L _span DataDecl {..}) =
[ NameOccurrence
{ locatedName = Just <$> tcdLName
@@ -432,7 +504,11 @@ tyClDeclNames (L _span ClassDecl {..}) =
}
tyClDeclNames _ = []
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+familyDeclNames :: FamilyDecl GhcRn -> [NameOccurrence]
+#else
familyDeclNames :: FamilyDecl Name -> [NameOccurrence]
+#endif
familyDeclNames FamilyDecl {..} =
[ NameOccurrence
{ locatedName = Just <$> fdLName
@@ -441,6 +517,26 @@ familyDeclNames FamilyDecl {..} =
}
]
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+familyEqNames :: FamEqn GhcRn (HsTyPats GhcRn) (LHsType GhcRn) -> [NameOccurrence]
+familyEqNames FamEqn {feqn_tycon = tyCon} =
+ [ NameOccurrence
+ { locatedName = Just <$> tyCon
+ , description = "FamEqn"
+ , isBinder = False
+ }
+ ]
+
+dataEqNames :: FamEqn GhcRn (HsTyPats GhcRn) (HsDataDefn GhcRn) -> [NameOccurrence]
+dataEqNames FamEqn {feqn_tycon = tyCon} =
+ [ NameOccurrence
+ { locatedName = Just <$> tyCon
+ , description = "FamEqn"
+ , isBinder = False
+ }
+ ]
+#else
tyFamilyEqNames :: TyFamEqn Name (HsTyPats Name) -> [NameOccurrence]
tyFamilyEqNames TyFamEqn {tfe_tycon = tyCon} =
[ NameOccurrence
@@ -467,8 +563,13 @@ dataFamInstDeclNames DataFamInstDecl {dfid_tycon = tyCon} =
, isBinder = False
}
]
+#endif
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+conDeclNames :: ConDecl GhcRn -> [NameOccurrence]
+#else
conDeclNames :: ConDecl Name -> [NameOccurrence]
+#endif
conDeclNames con =
case con of
ConDeclGADT {con_names = names} ->
@@ -488,7 +589,11 @@ conDeclNames con =
}
]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foreignDeclNames :: ForeignDecl GhcRn -> [NameOccurrence]
+#else
foreignDeclNames :: ForeignDecl Name -> [NameOccurrence]
+#endif
foreignDeclNames decl =
[ NameOccurrence
{ locatedName = Just <$> fd_name decl
@@ -496,3 +601,16 @@ foreignDeclNames decl =
, isBinder = True
}
]
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+roleAnnotationNames :: RoleAnnotDecl GhcRn -> [NameOccurrence]
+#else
+roleAnnotationNames :: RoleAnnotDecl Name -> [NameOccurrence]
+#endif
+roleAnnotationNames (RoleAnnotDecl n _) =
+ [ NameOccurrence
+ { locatedName = Just <$> n
+ , description = "RoleAnnotDecl"
+ , isBinder = False
+ }
+ ]
diff --git a/src/HaskellCodeExplorer/AST/TypecheckedSource.hs b/src/HaskellCodeExplorer/AST/TypecheckedSource.hs
index f97c33b..6f9a4cf 100644
--- a/src/HaskellCodeExplorer/AST/TypecheckedSource.hs
+++ b/src/HaskellCodeExplorer/AST/TypecheckedSource.hs
@@ -80,6 +80,9 @@ import HsSyn
, selectorAmbiguousFieldOcc
)
import HscTypes (TypeEnv, lookupTypeEnv)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+import HsExtension (GhcTc)
+#endif
import Id (idType)
import IdInfo (IdDetails(..))
import InstEnv
@@ -541,11 +544,19 @@ tidyType typ = do
let (tidyEnv', typ') = tidyOpenType tidyEnv typ
modify' (\s -> s {astStateTidyEnv = tidyEnv'})
return typ'
-
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldTypecheckedSource :: LHsBinds GhcTc -> State ASTState ()
+#else
foldTypecheckedSource :: LHsBinds Id -> State ASTState ()
+#endif
foldTypecheckedSource = foldLHsBindsLR
-foldLHsExpr :: LHsExpr Var -> State ASTState (Maybe Type)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsExpr :: LHsExpr GhcTc -> State ASTState (Maybe Type)
+#else
+foldLHsExpr :: LHsExpr Id -> State ASTState (Maybe Type)
+#endif
foldLHsExpr (L span (HsVar (L _ identifier))) =
restoreTidyEnv $ do
(identifier', mbTypes) <- tidyIdentifier identifier
@@ -801,8 +812,12 @@ foldLHsExpr (L span (HsWrap wrapper expr)) =
Composite -> return () -- Not sure if it is possible
typ <- foldLHsExpr (L span expr)
return $ applyWrapper wrapper <$> typ
-
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldHsRecFields :: HsRecFields GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
+#else
foldHsRecFields :: HsRecFields Id (LHsExpr Id) -> State ASTState (Maybe Type)
+#endif
foldHsRecFields HsRecFields {..} = do
let userWritten =
case rec_dotdot of
@@ -810,8 +825,12 @@ foldHsRecFields HsRecFields {..} = do
Nothing -> id
mapM_ foldLHsRecField $ userWritten rec_flds
return Nothing
-
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsRecField :: LHsRecField GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
+#else
foldLHsRecField :: LHsRecField Id (LHsExpr Id) -> State ASTState (Maybe Type)
+#endif
foldLHsRecField (L span (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun)) =
restoreTidyEnv $ do
(identifier', mbTypes) <- tidyIdentifier identifier
@@ -820,7 +839,11 @@ foldLHsRecField (L span (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun))
unless pun $ void (foldLHsExpr arg)
return . Just . varType $ identifier'
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsRecUpdField :: LHsRecUpdField GhcTc -> State ASTState (Maybe Type)
+#else
foldLHsRecUpdField :: LHsRecUpdField Id -> State ASTState (Maybe Type)
+#endif
foldLHsRecUpdField (L span (HsRecField (L idSpan recField) arg pun)) =
restoreTidyEnv $ do
let selectorId = selectorAmbiguousFieldOcc recField
@@ -844,7 +867,11 @@ data TupArg
| TupArgMissing
deriving (Show, Eq)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsTupArg :: LHsTupArg GhcTc -> State ASTState (Maybe Type, TupArg)
+#else
foldLHsTupArg :: LHsTupArg Id -> State ASTState (Maybe Type, TupArg)
+#endif
foldLHsTupArg (L _span (Present expr)) =
restoreTidyEnv $ do
typ <- foldLHsExpr expr
@@ -858,31 +885,51 @@ foldLHsTupArg (L _ (Missing typ)) =
typ' <- tidyType typ
return (Just typ', TupArgMissing)
-foldLMatch :: LMatch Id (LHsExpr Var) -> State ASTState (Maybe Type)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLMatch :: LMatch GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
+#else
+foldLMatch :: LMatch Id (LHsExpr Id) -> State ASTState (Maybe Type)
+#endif
foldLMatch (L _span Match {..}) = do
mapM_ foldLPat m_pats
_ <- foldGRHSs m_grhss
return Nothing
-
-foldLMatchCmd :: LMatch Id (LHsCmd Var) -> State ASTState (Maybe Type)
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLMatchCmd :: LMatch GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
+#else
+foldLMatchCmd :: LMatch Id (LHsCmd Id) -> State ASTState (Maybe Type)
+#endif
foldLMatchCmd (L _span Match {..}) = do
mapM_ foldLPat m_pats
_ <- foldGRHSsCmd m_grhss
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldGRHSsCmd :: GRHSs GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
+#else
foldGRHSsCmd :: GRHSs Id (LHsCmd Id) -> State ASTState (Maybe Type)
+#endif
foldGRHSsCmd GRHSs {..} = do
mapM_ foldLGRHSCmd grhssGRHSs
_ <- foldHsLocalBindsLR (unLoc grhssLocalBinds)
return Nothing
-foldGRHSs :: GRHSs Id (LHsExpr Var) -> State ASTState (Maybe Type)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldGRHSs :: GRHSs GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
+#else
+foldGRHSs :: GRHSs Id (LHsExpr Id) -> State ASTState (Maybe Type)
+#endif
foldGRHSs GRHSs {..} = do
mapM_ foldLGRHS grhssGRHSs
_ <- foldHsLocalBindsLR (unLoc grhssLocalBinds)
return Nothing
-foldLStmtLR :: LStmtLR Id Id (LHsExpr Var) -> State ASTState (Maybe Type)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLStmtLR :: LStmtLR GhcTc GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
+#else
+foldLStmtLR :: LStmtLR Id Id (LHsExpr Id) -> State ASTState (Maybe Type)
+#endif
foldLStmtLR (L span (LastStmt body _ _)) =
do typ <- foldLHsExpr body
addExprInfo span typ "LastStmt" Composite
@@ -916,10 +963,18 @@ foldLStmtLR (L span (ApplicativeStmt args _ typ)) =
addExprInfo span (Just typ') "ApplicativeStmt" Composite
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldApplicativeArg :: ApplicativeArg GhcTc GhcTc -> State ASTState (Maybe Type)
+#else
foldApplicativeArg :: ApplicativeArg Id Id -> State ASTState (Maybe Type)
+#endif
foldApplicativeArg appArg =
case appArg of
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ ApplicativeArgOne pat expr _bool -> do
+#else
ApplicativeArgOne pat expr -> do
+#endif
_ <- foldLPat pat
_ <- foldLHsExpr expr
return Nothing
@@ -927,9 +982,12 @@ foldApplicativeArg appArg =
_ <- mapM_ foldLStmtLR exprStmts
_ <- foldLPat pat
return Nothing
-
-foldLStmtLRCmd :: LStmtLR Id Id (LHsCmd Var)
- -> State ASTState (Maybe Type)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLStmtLRCmd ::
+ LStmtLR GhcTc GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
+#else
+foldLStmtLRCmd :: LStmtLR Id Id (LHsCmd Id) -> State ASTState (Maybe Type)
+#endif
foldLStmtLRCmd (L span (LastStmt body _syntaxExpr _)) = do
typ <- foldLHsCmd body
addExprInfo span typ "LastStmt Cmd" Composite
@@ -962,43 +1020,73 @@ foldLStmtLRCmd (L span (ApplicativeStmt args _ typ)) =
mapM_ (foldApplicativeArg . snd) args
addExprInfo span (Just typ') "ApplicativeStmt Cmd" Composite
return Nothing
-
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLGRHS :: LGRHS GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
+#else
foldLGRHS :: LGRHS Id (LHsExpr Id) -> State ASTState (Maybe Type)
+#endif
foldLGRHS (L _span (GRHS guards body)) = do
typ <- foldLHsExpr body
mapM_ foldLStmtLR guards
return typ
-
-foldLGRHSCmd :: LGRHS Id (LHsCmd Var) -> State ASTState (Maybe Type)
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLGRHSCmd :: LGRHS GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
+#else
+foldLGRHSCmd :: LGRHS Id (LHsCmd Id) -> State ASTState (Maybe Type)
+#endif
foldLGRHSCmd (L _span (GRHS guards body)) = do
typ <- foldLHsCmd body
mapM_ foldLStmtLR guards
return typ
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldParStmtBlock :: ParStmtBlock GhcTc GhcTc -> State ASTState (Maybe Type)
+#else
foldParStmtBlock :: ParStmtBlock Id Id -> State ASTState (Maybe Type)
+#endif
foldParStmtBlock (ParStmtBlock exprStmts _ids _syntaxExpr) = do
mapM_ foldLStmtLR exprStmts
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldHsLocalBindsLR :: HsLocalBindsLR GhcTc GhcTc -> State ASTState (Maybe Type)
+#else
foldHsLocalBindsLR :: HsLocalBindsLR Id Id -> State ASTState (Maybe Type)
+#endif
foldHsLocalBindsLR (HsValBinds binds) = do
_ <- foldHsValBindsLR binds
return Nothing
foldHsLocalBindsLR (HsIPBinds _binds) = return Nothing
foldHsLocalBindsLR EmptyLocalBinds = return Nothing
-foldHsValBindsLR :: HsValBindsLR Id Var -> State ASTState (Maybe Type)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldHsValBindsLR :: HsValBindsLR GhcTc GhcTc -> State ASTState (Maybe Type)
+#else
+foldHsValBindsLR :: HsValBindsLR Id Id -> State ASTState (Maybe Type)
+#endif
foldHsValBindsLR (ValBindsIn _ _) = return Nothing
foldHsValBindsLR (ValBindsOut binds _) = do
_ <- mapM_ (foldLHsBindsLR . snd) binds
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsBindsLR :: LHsBinds GhcTc -> State ASTState ()
+#else
foldLHsBindsLR :: LHsBinds Id -> State ASTState ()
+#endif
foldLHsBindsLR = mapM_ (`foldLHsBindLR` Nothing) . bagToList
-foldLHsBindLR :: LHsBindLR Id Var
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsBindLR :: LHsBindLR GhcTc GhcTc
-> Maybe Id -- ^ Polymorphic id
-> State ASTState (Maybe Type)
+#else
+foldLHsBindLR :: LHsBindLR Id Id
+ -> Maybe Id -- ^ Polymorphic id
+ -> State ASTState (Maybe Type)
+#endif
foldLHsBindLR (L _span FunBind {..}) mbPolyId
| mg_origin fun_matches == FromSource =
restoreTidyEnv $ do
@@ -1024,9 +1112,12 @@ foldLHsBindLR (L _ AbsBinds {..}) _ = do
mapM_ (\(bind, typ) -> foldLHsBindLR bind (Just typ)) $
zip (bagToList abs_binds) (map abe_poly abs_exports)
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+#else
foldLHsBindLR (L _ AbsBindsSig {..}) _ = do
_ <- foldLHsBindLR abs_sig_bind (Just abs_sig_export)
return Nothing
+#endif
foldLHsBindLR (L _ (PatSynBind PSB {..})) _ =
restoreTidyEnv $ do
_ <- foldLPat psb_def
@@ -1036,16 +1127,30 @@ foldLHsBindLR (L _ (PatSynBind PSB {..})) _ =
(i', _) <- tidyIdentifier i
addIdentifierToIdSrcSpanMap span i' Nothing
in case psb_args of
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ InfixCon id1 id2 -> addId id1 >> addId id2
+ PrefixCon ids -> mapM_ addId ids
+ RecCon recs ->
+ mapM_
+ (\(RecordPatSynField selId patVar) ->
+ addId selId >> addId patVar)
+ recs
+#else
InfixPatSyn id1 id2 -> addId id1 >> addId id2
PrefixPatSyn ids -> mapM_ addId ids
RecordPatSyn recs ->
mapM_
(\(RecordPatSynField selId patVar) ->
addId selId >> addId patVar)
- recs
+ recs
+#endif
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLPat :: LPat GhcTc -> State ASTState (Maybe Type)
+#else
foldLPat :: LPat Id -> State ASTState (Maybe Type)
+#endif
foldLPat (L span (VarPat (L _ identifier))) = do
(identifier', _) <- tidyIdentifier identifier
addIdentifierToIdSrcSpanMap span identifier' Nothing
@@ -1151,9 +1256,15 @@ foldLPat (L span p@(CoPat _ pat typ)) = do
_ <- foldLPat (L span pat)
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldHsConPatDetails
+ :: HsConPatDetails GhcTc
+ -> State ASTState (Maybe Type)
+#else
foldHsConPatDetails
:: HsConPatDetails Id
-> State ASTState (Maybe Type)
+#endif
foldHsConPatDetails (PrefixCon args) = do
_ <- mapM_ foldLPat args
return Nothing
@@ -1165,7 +1276,11 @@ foldHsConPatDetails (InfixCon arg1 arg2) = do
_ <- foldLPat arg2
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldHsRecFieldsPat :: HsRecFields GhcTc (LPat GhcTc) -> State ASTState (Maybe Type)
+#else
foldHsRecFieldsPat :: HsRecFields Id (LPat Id) -> State ASTState (Maybe Type)
+#endif
foldHsRecFieldsPat HsRecFields {..} = do
let onlyUserWritten =
case rec_dotdot of
@@ -1174,20 +1289,32 @@ foldHsRecFieldsPat HsRecFields {..} = do
_ <- mapM_ foldLHsRecFieldPat $ onlyUserWritten rec_flds
return Nothing
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsRecFieldPat :: LHsRecField GhcTc (LPat GhcTc) -> State ASTState (Maybe Type)
+#else
foldLHsRecFieldPat :: LHsRecField Id (LPat Id) -> State ASTState (Maybe Type)
+#endif
foldLHsRecFieldPat (L _ (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun)) = do
(identifier', mbTypes) <- tidyIdentifier identifier
addIdentifierToIdSrcSpanMap idSpan identifier' mbTypes
unless pun $ void $ foldLPat arg
return . Just . varType $ identifier'
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsCmdTop :: LHsCmdTop GhcTc -> State ASTState (Maybe Type)
+#else
foldLHsCmdTop :: LHsCmdTop Id -> State ASTState (Maybe Type)
+#endif
foldLHsCmdTop (L span (HsCmdTop cmd _ _ _)) = do
mbTyp <- foldLHsCmd cmd
addExprInfo span mbTyp "HsCmdTop" Composite
return mbTyp
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+foldLHsCmd :: LHsCmd GhcTc -> State ASTState (Maybe Type)
+#else
foldLHsCmd :: LHsCmd Id -> State ASTState (Maybe Type)
+#endif
foldLHsCmd (L _ (HsCmdArrApp expr1 expr2 _ _ _)) = do
_ <- foldLHsExpr expr1
_ <- foldLHsExpr expr2