Skip to content

Commit

Permalink
Support GHC 9.8
Browse files Browse the repository at this point in the history
Bump dependencies

Add Debug908.hs

Fix renaming of `(,)` to `Tuple2` from `GHC.Tuple.Prim`

https://hackage.haskell.org/package/ghc-prim-0.11.0/docs/GHC-Tuple-Prim.html#t:Tuple2

Set conditional `--allow-newer' for ci
  • Loading branch information
0rphee authored and tomjaguarpaw committed Oct 22, 2023
1 parent 3306c3b commit aff7e69
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 9 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
- "9.4.6"
- "9.4.7"
- "9.6.3"
- "9.8.1"

exclude:
- os: macOS-latest
ghc: 8.8.4
Expand All @@ -50,14 +52,21 @@ jobs:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: Set envvar EXTRA_FLAGS
shell: bash
if: ${{ matrix.ghc == '9.8.1' }}
run: |
echo "EXTRA_FLAGS=--allow-newer" >> "$GITHUB_ENV"
# Tom says: I'm not sure whether it's correct to configure before
# freezing because it might defeat the point of caching. However,
# configuring *after* freezing seemed to mean that the cache got
# stuck in some bad state where it couldn't find a build plan. We
# should revisit this decision later.
- name: Configure
shell: bash
run: |
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct $EXTRA_FLAGS
- name: Freeze
run: |
Expand Down
2 changes: 2 additions & 0 deletions src/Stan/Ghc/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ import Stan.Ghc.Compat902 as Compat
import Stan.Ghc.Compat902 as Compat
#elif __GLASGOW_HASKELL__ == 906
import Stan.Ghc.Compat906 as Compat
#elif __GLASGOW_HASKELL__ == 908
import Stan.Ghc.Compat906 as Compat
#endif
2 changes: 1 addition & 1 deletion src/Stan/Ghc/Compat906.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Stan.Ghc.Compat906
#if __GLASGOW_HASKELL__ == 906
#if __GLASGOW_HASKELL__ == 906 || __GLASGOW_HASKELL__ == 908
( -- * Modules
Module
, ModuleName
Expand Down
2 changes: 2 additions & 0 deletions src/Stan/Hie/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ import Stan.Hie.Compat902 as Compat
import Stan.Hie.Compat904 as Compat
#elif __GLASGOW_HASKELL__ == 906
import Stan.Hie.Compat904 as Compat
#elif __GLASGOW_HASKELL__ == 908
import Stan.Hie.Compat904 as Compat
#endif
2 changes: 1 addition & 1 deletion src/Stan/Hie/Compat904.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE CPP #-}

module Stan.Hie.Compat904
#if __GLASGOW_HASKELL__ == 904 || __GLASGOW_HASKELL__ == 906
#if __GLASGOW_HASKELL__ == 904 || __GLASGOW_HASKELL__ == 906 || __GLASGOW_HASKELL__ == 908
( -- * Main HIE types
ContextInfo (..)
, HieArgs (..)
Expand Down
2 changes: 2 additions & 0 deletions src/Stan/Hie/Debug.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ import Stan.Hie.Debug902 as Compat
import Stan.Hie.Debug902 as Compat
#elif __GLASGOW_HASKELL__ == 906
import Stan.Hie.Debug902 as Compat
#elif __GLASGOW_HASKELL__ == 908
import Stan.Hie.Debug908 as Compat
#endif
99 changes: 99 additions & 0 deletions src/Stan/Hie/Debug908.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{-# LANGUAGE CPP #-}

{-# OPTIONS_GHC -fno-warn-orphans #-}

{-# LANGUAGE FlexibleInstances #-}

{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Maintainer: Kowainik <[email protected]>
Useful debugging and printing utilities for HIE types. They are
implemented in two ways:
1. Using derived 'Show' instances.
2. Using @ghc@ pretty-printing.
To make full use of derived 'Show' instances, add the @pretty-simple@
package to dependencies and use the @pPrint@ function from the
@Text.Pretty.Simple@ module.
-}

module Stan.Hie.Debug908
#if __GLASGOW_HASKELL__ == 908
( debugHieFile
) where

import Text.Pretty.Simple (pPrint)

import Stan.Core.ModuleName (fromGhcModule)
import Stan.Ghc.Compat (AvailInfo (..), FieldLabel (..), IfaceTyCon (..),
IfaceTyConInfo (..), IfaceTyConSort (..), IfaceTyLit (..), Module,
Name, PromotionFlag (..), TupleSort (..), isExternalName,
moduleStableString, moduleUnitId, nameModule, nameOccName,
nameStableString, occNameString, showTUnitId)
import Stan.Hie.Compat (HieAST (..), HieASTs (..), HieArgs (..), HieFile (..), HieType (..),
IdentifierDetails (..), NodeInfo (..))
import Stan.NameMeta (NameMeta (..))

import qualified Text.Show

import GHC.Iface.Ext.Types (SourcedNodeInfo(..), NodeOrigin(..), ContextInfo(..), IEType(..), BindType(..), Scope(..), DeclType(..), TyVarScope(..), RecFieldContext(..), EvVarSource(..), EvBindDeps(..), DeclType(..), NodeAnnotation (..))
import GHC.Types.Var (Specificity(..))

debugHieFile :: FilePath -> [HieFile] -> IO ()
debugHieFile path hieFiles = do
let mHieFile = find (\HieFile{..} -> hie_hs_file == path) hieFiles
whenJust mHieFile pPrint

deriving stock instance Show a => Show (SourcedNodeInfo a)
deriving stock instance Show NodeOrigin
deriving stock instance Show ContextInfo
deriving stock instance Show IEType
deriving stock instance Show BindType
deriving stock instance Show Scope
deriving stock instance Show DeclType
deriving stock instance Show TyVarScope
deriving stock instance Show EvBindDeps
deriving stock instance Show EvVarSource
deriving stock instance Show RecFieldContext

deriving stock instance Show Specificity

-- orphan intances
deriving stock instance Show HieFile
deriving stock instance Show a => Show (HieType a)
deriving stock instance Show a => Show (HieAST a)
deriving newtype instance Show a => Show (HieASTs a)
deriving newtype instance Show a => Show (HieArgs a)
deriving stock instance Show a => Show (NodeInfo a)
deriving stock instance Show a => Show (IdentifierDetails a)
deriving stock instance Show IfaceTyCon
deriving stock instance Show IfaceTyConInfo
deriving stock instance Show IfaceTyConSort
deriving stock instance Show IfaceTyLit
deriving stock instance Show PromotionFlag
deriving stock instance Show TupleSort
deriving stock instance Show AvailInfo
deriving stock instance Show FieldLabel
deriving stock instance Show NodeAnnotation

instance Show Module where
show = moduleStableString

instance Show Name where
show nm =
if isExternalName nm
then show $ toNameMeta nm
else nameStableString nm
where
toNameMeta :: Name -> NameMeta
toNameMeta name =
let nameMetaName = toText $ occNameString $ nameOccName name
nameMetaModuleName = fromGhcModule $ nameModule name
nameMetaPackage = showTUnitId $ moduleUnitId $ nameModule name
in NameMeta{..}
#else
() where
#endif
4 changes: 4 additions & 0 deletions src/Stan/Pattern/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ eitherPattern = "Either" `baseNameFrom` "Data.Either" |:: [ (?), (?) ]

-- | 'PatternType' for pair @(,)@.
pairPattern :: PatternType
#if __GLASGOW_HASKELL__ < 908
pairPattern = "(,)" `ghcPrimNameFrom` ghcTuple |:: [ (?), (?) ]
#elif __GLASGOW_HASKELL__ >= 908
pairPattern = "Tuple2" `ghcPrimNameFrom` ghcTuple |:: [ (?), (?) ]
#endif
where
#if __GLASGOW_HASKELL__ < 906
ghcTuple = "GHC.Tuple"
Expand Down
13 changes: 7 additions & 6 deletions stan.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ source-repository head
location: https://github.com/kowainik/stan.git

common common-options
build-depends: base >= 4.13 && < 4.19 && (< 4.16.3.0 || >= 4.17)
build-depends: base >= 4.13 && < 4.20 && (< 4.16.3.0 || >= 4.17)
-- ^^ .hie files don't contain enough type
-- information on ghc-9.2.[4-8] (base >=
-- 4.16.3.0 && < 4.17)
Expand Down Expand Up @@ -130,23 +130,24 @@ library
Stan.Hie.Debug810
Stan.Hie.Debug900
Stan.Hie.Debug902
Stan.Hie.Debug908

build-depends: array ^>= 0.5
, base64 ^>= 0.4.1
, blaze-html ^>= 0.9.1
, bytestring >= 0.10 && < 0.12
, bytestring >= 0.10 && < 0.13
, clay ^>= 0.14
, colourista >= 0.1 && < 0.3
, cryptohash-sha1 ^>= 0.11
, dir-traverse ^>= 0.2.2.2
, directory ^>= 1.3
, extensions ^>= 0.0.0.1 || ^>= 0.1.0.0
, filepath ^>= 1.4
, ghc >= 8.8 && < 9.7
, ghc-boot-th >= 8.8 && < 9.7
, ghc >= 8.8 && < 9.9
, ghc-boot-th >= 8.8 && < 9.9
, gitrev ^>= 1.3.1
, microaeson ^>= 0.1.0.0
, optparse-applicative >= 0.15 && < 0.17
, optparse-applicative >= 0.15 && < 0.19
, pretty-simple ^>= 4.0
, process ^>= 1.6.8.0
, slist >= 0.1 && < 0.3
Expand Down Expand Up @@ -201,7 +202,7 @@ test-suite stan-test
, containers
, filepath ^>= 1.4
, ghc
, hedgehog >= 1.0 && < 1.4
, hedgehog >= 1.0 && < 1.5
, hspec >= 2.7 && < 2.12
, hspec-hedgehog >= 0.0.1.2
, optparse-applicative
Expand Down

0 comments on commit aff7e69

Please sign in to comment.