aboutsummaryrefslogtreecommitdiff
path: root/src/HaskellCodeExplorer/ModuleInfo.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/HaskellCodeExplorer/ModuleInfo.hs')
-rw-r--r--src/HaskellCodeExplorer/ModuleInfo.hs42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/HaskellCodeExplorer/ModuleInfo.hs b/src/HaskellCodeExplorer/ModuleInfo.hs
index cc81a36..ddd7e9f 100644
--- a/src/HaskellCodeExplorer/ModuleInfo.hs
+++ b/src/HaskellCodeExplorer/ModuleInfo.hs
@@ -6,6 +6,7 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StrictData #-}
module HaskellCodeExplorer.ModuleInfo
@@ -23,8 +24,11 @@ import qualified Data.Map.Strict as M
import qualified Data.IntMap.Strict as IM
import qualified Data.IntervalMap.Strict as IVM
import qualified Data.List as L hiding (span)
-import Data.Maybe(fromMaybe,mapMaybe)
-import Data.Ord(comparing)
+import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Ord (comparing)
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+import HsExtension (GhcRn)
+#endif
import qualified Data.Set as S
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
@@ -307,10 +311,17 @@ createDefinitionSiteMap ::
-> HCE.SourceCodeTransformation
-> ModuleInfo
-> [Name]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ -> HsGroup GhcRn
+#else
-> HsGroup Name
+#endif
-> (HCE.DefinitionSiteMap, [Name])
createDefinitionSiteMap flags currentPackageId compId defSiteMap fileMap globalRdrEnv transformation modInfo dataFamTyCons hsGroup =
- let allDecls :: [GenLocated SrcSpan (HsDecl Name)]
+ let
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ allDecls :: [GenLocated SrcSpan (HsDecl GhcRn)]
+#endif
allDecls = L.sortBy (comparing getLoc) . ungroup $ hsGroup
(instanceDeclsWithDocs, valueAndTypeDeclsWithDocs) =
L.partition
@@ -465,7 +476,11 @@ docWithNamesToHtml flags packageId compId transformation fileMap defSiteMap =
createDeclarations ::
DynFlags
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ -> HsGroup GhcRn
+#else
-> HsGroup Name
+#endif
-> TypeEnv
-> S.Set Name
-> HCE.SourceCodeTransformation
@@ -483,8 +498,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
Nothing -> Nothing
-- | Top-level functions
--------------------------------------------------------------------------------
- valToDeclarations ::
- GenLocated SrcSpan (HsBindLR Name Name) -> [HCE.Declaration]
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ valToDeclarations :: GenLocated SrcSpan (HsBindLR GhcRn GhcRn) -> [HCE.Declaration]
+#endif
valToDeclarations (L loc bind) =
map
(\name ->
@@ -498,7 +514,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
vals = concatMap valToDeclarations $ hsGroupVals hsGroup
-- | Data, newtype, type, type family, data family or class declaration
--------------------------------------------------------------------------------
- tyClToDeclaration :: GenLocated SrcSpan (TyClDecl Name) -> HCE.Declaration
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ tyClToDeclaration :: GenLocated SrcSpan (TyClDecl GhcRn) -> HCE.Declaration
+#endif
tyClToDeclaration (L loc tyClDecl) =
HCE.Declaration
HCE.TyClD
@@ -512,7 +530,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
hsGroup
-- | Instances
--------------------------------------------------------------------------------
- instToDeclaration :: GenLocated SrcSpan (InstDecl Name) -> HCE.Declaration
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ instToDeclaration :: GenLocated SrcSpan (InstDecl GhcRn) -> HCE.Declaration
+#endif
instToDeclaration (L loc inst) =
HCE.Declaration
HCE.InstD
@@ -529,8 +549,10 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
hsGroup
-- | Foreign functions
--------------------------------------------------------------------------------
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foreignFunToDeclaration ::
- GenLocated SrcSpan (ForeignDecl Name) -> HCE.Declaration
+ GenLocated SrcSpan (ForeignDecl GhcRn) -> HCE.Declaration
+#endif
foreignFunToDeclaration (L loc fd) =
let name = unLoc $ fd_name fd
in HCE.Declaration
@@ -588,7 +610,11 @@ foldAST environment typecheckedModule =
case mbExported of
Just lieNames ->
mapMaybe
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
+ (\(L span ie,_) ->
+#else
(\(L span ie) ->
+#endif
case ie of
IEModuleContents (L _ modName) ->
Just