Skip to content

Commit

Permalink
Support up to and including GHC 9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjaguarpaw committed Oct 12, 2023
1 parent 8f0175d commit 3843f7f
Show file tree
Hide file tree
Showing 30 changed files with 1,115 additions and 267 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@ jobs:
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
strategy:
# Don't fail fast because we test a lot of versions and it's
# good to know which ones work and which ones don't
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["3.2"]
cabal: ["3.8"]
ghc:
- "8.8.4"
- "8.10.4"
- "9.0.1"
- "9.0.2"
- "9.2.1"
- "9.4.1"
- "9.4.2"
- "9.4.4"
- "9.4.5"
- "9.4.6"
- "9.4.7"
exclude:
- os: macOS-latest
ghc: 8.8.4
Expand Down
6 changes: 3 additions & 3 deletions src/Stan/Analysis/Analyser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Stan.Core.List (nonRepeatingPairs)
import Stan.FileInfo (isExtensionDisabled)
import Stan.Ghc.Compat (RealSrcSpan, isSymOcc, nameOccName, occNameString)
import Stan.Hie (eqAst)
import Stan.Hie.Compat (HieAST (..), HieFile (..), Identifier, NodeInfo (..), TypeIndex)
import Stan.Hie.Compat (HieAST (..), HieFile (..), Identifier, NodeInfo (..), TypeIndex, nodeInfo)
import Stan.Hie.MatchAst (hieMatchPatternAst)
import Stan.Inspection (Inspection (..), InspectionAnalysis (..))
import Stan.NameMeta (NameMeta, ghcPrimNameFrom)
Expand Down Expand Up @@ -331,10 +331,10 @@ analyseInfix hie curNode = do
Right name -> [toText $ occNameString $ nameOccName name]

extractOperatorName :: HieAST TypeIndex -> [(Text, RealSrcSpan)]
extractOperatorName Node{..} =
extractOperatorName n@Node{..} =
concatMap (topLevelOperatorName nodeSpan)
$ Map.keys
$ nodeIdentifiers nodeInfo
$ nodeIdentifiers (Stan.Hie.Compat.nodeInfo n)

topLevelOperatorName :: RealSrcSpan -> Identifier -> [(Text, RealSrcSpan)]
topLevelOperatorName srcSpan = \case
Expand Down
72 changes: 13 additions & 59 deletions src/Stan/Ghc/Compat.hs
Original file line number Diff line number Diff line change
@@ -1,59 +1,13 @@
{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Maintainer: Kowainik <[email protected]>
Compatibility module for GHC types and functions. Reexports all
required API to work with the GHC API.
-}

module Stan.Ghc.Compat
( -- * Modules
Module
, ModuleName
, moduleNameString
, moduleName
, moduleStableString
, moduleUnitId

-- * Names
, Name
, isExternalName
, isSymOcc
, nameModule
, nameOccName
, nameStableString
, occNameString

-- * Source locations
, RealSrcSpan
, srcSpanEndCol
, srcSpanStartCol
, srcSpanStartLine
, srcSpanEndLine
, srcSpanFile

-- * Other common types (for debugging and not only)
, ArgFlag (..)
, AvailInfo (..)
, FastString
, FieldLbl (..)
, IfaceTyCon (..)
, IfaceTyConInfo (..)
, IfaceTyConSort (..)
, IfaceTyLit (..)
, PromotionFlag (..)
, TupleSort (..)
) where

import Avail (AvailInfo (..))
import BasicTypes (PromotionFlag (..), TupleSort (..))
import FastString (FastString)
import FieldLabel (FieldLbl (..))
import IfaceType (IfaceTyCon (..), IfaceTyConInfo (..), IfaceTyConSort (..), IfaceTyLit (..))
import Module (Module, ModuleName, moduleName, moduleNameString, moduleStableString, moduleUnitId)
import Name (Name, isExternalName, nameModule, nameOccName, nameStableString)
import OccName (isSymOcc, occNameString)
import SrcLoc (RealSrcSpan, srcSpanEndCol, srcSpanEndLine, srcSpanFile, srcSpanStartCol,
srcSpanStartLine)
import Var (ArgFlag (..))
{-# LANGUAGE CPP #-}

module Stan.Ghc.Compat (module Compat) where

#if __GLASGOW_HASKELL__ <= 810
import Stan.Ghc.Compat810 as Compat
#elif __GLASGOW_HASKELL__ == 900
import Stan.Ghc.Compat900 as Compat
#elif __GLASGOW_HASKELL__ == 902
import Stan.Ghc.Compat902 as Compat
#elif __GLASGOW_HASKELL__ == 904
import Stan.Ghc.Compat902 as Compat
#endif
75 changes: 75 additions & 0 deletions src/Stan/Ghc/Compat810.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{-# LANGUAGE CPP #-}

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.7

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.2.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.0.2

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.4

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.6

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.2

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.5

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.0.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.2

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.0.2

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.0.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.0.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.2.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.0.2

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.7

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.6

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.5

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.4

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.2.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.7

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.1

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.2

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.5

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.6

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

Check warning on line 1 in src/Stan/Ghc/Compat810.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.4

The export item ‘module Stan.Ghc.Compat810’ is missing an export list

{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Maintainer: Kowainik <[email protected]>
Compatibility module for GHC types and functions. Reexports all
required API to work with the GHC API.
-}

module Stan.Ghc.Compat810
#if __GLASGOW_HASKELL__ <= 810
( -- * Modules
Module
, ModuleName
, moduleNameString
, moduleName
, moduleStableString
, moduleUnitId

-- * Names
, Name
, isExternalName
, isSymOcc
, nameModule
, nameOccName
, nameStableString
, occNameString

-- * Source locations
, RealSrcSpan
, srcSpanEndCol
, srcSpanStartCol
, srcSpanStartLine
, srcSpanEndLine
, srcSpanFile
, mkRealSrcLoc
, mkRealSrcSpan

-- * Other common types (for debugging and not only)
, ArgFlag (..)
, AvailInfo (..)
, FastString
, mkFastString
, FieldLbl (..)
, IfaceTyCon (..)
, IfaceTyConInfo (..)
, IfaceTyConSort (..)
, IfaceTyLit (..)
, PromotionFlag (..)
, TupleSort (..)
, showTUnitId
) where

import Avail (AvailInfo (..))
import BasicTypes (PromotionFlag (..), TupleSort (..))
import FastString (FastString, mkFastString)
import FieldLabel (FieldLbl (..))
import IfaceType (IfaceTyCon (..), IfaceTyConInfo (..), IfaceTyConSort (..), IfaceTyLit (..))
import Module (Module, ModuleName, moduleName, moduleNameString, moduleStableString, moduleUnitId,
UnitId, unitIdString)
import Name (Name, isExternalName, nameModule, nameOccName, nameStableString)
import OccName (isSymOcc, occNameString)
import SrcLoc (RealSrcSpan, srcSpanEndCol, srcSpanEndLine, srcSpanFile, srcSpanStartCol,
srcSpanStartLine, mkRealSrcLoc, mkRealSrcSpan)
import Var (ArgFlag (..))

import qualified Data.Text as T

showTUnitId :: UnitId -> Text
showTUnitId = T.pack . unitIdString
#else
where
#endif
80 changes: 80 additions & 0 deletions src/Stan/Ghc/Compat900.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{-# LANGUAGE CPP #-}

{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Maintainer: Kowainik <[email protected]>
Compatibility module for GHC types and functions. Reexports all
required API to work with the GHC API.
-}

module Stan.Ghc.Compat900
#if __GLASGOW_HASKELL__ == 900
( -- * Modules
Module
, ModuleName
, moduleNameString
, moduleName
, moduleStableString
, moduleUnitId

-- * Names
, Name
, isExternalName
, isSymOcc
, nameModule
, nameOccName
, nameStableString
, occNameString

-- * Source locations
, RealSrcSpan
, srcSpanEndCol
, srcSpanStartCol
, srcSpanStartLine
, srcSpanEndLine
, srcSpanFile
, mkRealSrcLoc
, mkRealSrcSpan

-- * Other common types (for debugging and not only)
, ArgFlag (..)
, AvailInfo (..)
, FastString
, mkFastString
, FieldLbl (..)
, IfaceTyCon (..)
, IfaceTyConInfo (..)
, IfaceTyConSort (..)
, IfaceTyLit (..)
, PromotionFlag (..)
, TupleSort (..)
, showTUnitId
) where

import GHC.Types.Avail (AvailInfo (..))
import GHC.Types.Basic (PromotionFlag (..), TupleSort (..))
import GHC.Data.FastString (FastString, mkFastString)
import GHC.Types.FieldLabel (FieldLbl (..))
import GHC.Iface.Type (IfaceTyCon (..), IfaceTyConInfo (..), IfaceTyConSort (..), IfaceTyLit (..))
import GHC.Unit.Types (Module, moduleName)
import GHC.Unit.Module (moduleStableString)
import GHC.Unit (moduleUnit, toUnitId, UnitId, unitIdString)
import GHC.Unit.Module.Name (ModuleName, moduleNameString)
import GHC.Types.Name (Name, isExternalName, nameModule, nameOccName, nameStableString)
import GHC.Types.Name.Occurrence (isSymOcc, occNameString)
import GHC.Types.SrcLoc (RealSrcSpan, srcSpanEndCol, srcSpanEndLine, srcSpanFile, srcSpanStartCol,
srcSpanStartLine, mkRealSrcSpan, mkRealSrcLoc)
import GHC.Types.Var (ArgFlag (..))

import qualified Data.Text as T

moduleUnitId :: Module -> UnitId
moduleUnitId = toUnitId . moduleUnit

showTUnitId :: UnitId -> Text
showTUnitId = T.pack . unitIdString
#else
() where
#endif
74 changes: 74 additions & 0 deletions src/Stan/Ghc/Compat902.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{-# LANGUAGE CPP #-}

module Stan.Ghc.Compat902
#if __GLASGOW_HASKELL__ == 902 || __GLASGOW_HASKELL__ == 904
( -- * Modules
Module
, ModuleName
, moduleNameString
, moduleName
, moduleStableString
, moduleUnitId

-- * Names
, Name
, isExternalName
, isSymOcc
, nameModule
, nameOccName
, nameStableString
, occNameString

-- * Source locations
, RealSrcSpan
, srcSpanEndCol
, srcSpanStartCol
, srcSpanStartLine
, srcSpanEndLine
, srcSpanFile
, mkRealSrcLoc
, mkRealSrcSpan

-- * Other common types (for debugging and not only)
, ArgFlag (..)
, AvailInfo (..)
, FastString
, mkFastString
, FieldLbl
, FieldLabel (..)
, IfaceTyCon (..)
, IfaceTyConInfo (..)
, IfaceTyConSort (..)
, IfaceTyLit (..)
, PromotionFlag (..)
, TupleSort (..)
, showTUnitId
) where

import GHC.Types.Avail (AvailInfo (..))
import GHC.Types.Basic (PromotionFlag (..), TupleSort (..))
import GHC.Data.FastString (FastString, mkFastString)
import GHC.Types.FieldLabel (FieldLabel (..))
import GHC.Iface.Type (IfaceTyCon (..), IfaceTyConInfo (..), IfaceTyConSort (..), IfaceTyLit (..))
import GHC.Unit.Types (Module, moduleName)
import GHC.Unit.Module (moduleStableString)
import GHC.Unit (moduleUnit, toUnitId, UnitId, unitIdString)
import GHC.Unit.Module.Name (ModuleName, moduleNameString)
import GHC.Types.Name (Name, isExternalName, nameModule, nameOccName, nameStableString)
import GHC.Types.Name.Occurrence (isSymOcc, occNameString)
import GHC.Types.SrcLoc (RealSrcSpan, srcSpanEndCol, srcSpanEndLine, srcSpanFile, srcSpanStartCol,
srcSpanStartLine, mkRealSrcSpan, mkRealSrcLoc)
import GHC.Types.Var (ArgFlag (..))

import qualified Data.Text as T

moduleUnitId :: Module -> UnitId
moduleUnitId = toUnitId . moduleUnit

showTUnitId :: UnitId -> Text
showTUnitId = T.pack . unitIdString

type FieldLbl = FieldLabel
#else
() where
#endif
Loading

0 comments on commit 3843f7f

Please sign in to comment.