diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d61d81f..bb502cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v21 - - uses: cachix/cachix-action@v12 + - uses: cachix/install-nix-action@v31 + - uses: cachix/cachix-action@v15 with: name: guibou authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 840f948..acbbc4c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -8,12 +8,12 @@ jobs: nix_matrix: strategy: matrix: - ghc: [90, 92, 94, 96, 98, 910, 912] + ghc: [94, 96, 98, 910, 912, 914] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v21 - - uses: cachix/cachix-action@v12 + - uses: cachix/install-nix-action@v31 + - uses: cachix/cachix-action@v15 with: name: guibou authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' @@ -23,7 +23,8 @@ jobs: stack_build: strategy: matrix: - resolver: [lts-14.27, # 8.6 + resolver: [ + lts-14.27, # 8.6 lts-16.31, # 8.8 lts-17.1, # 8.10 lts-19.1, # 9.0 diff --git a/PyF.cabal b/PyF.cabal index 6b90c4c..b163b42 100644 --- a/PyF.cabal +++ b/PyF.cabal @@ -31,14 +31,14 @@ library PyF.Internal.QQ build-depends: - , base >=4.12 && <4.22 + , base >=4.12 && <4.23 , bytestring >=0.10.8 && <0.13 , ghc >=8.6.1 , mtl >=2.2.2 && <2.4 , parsec >=3.1.13 && <3.2 - , template-haskell >=2.14.0 && <2.24 + , template-haskell >=2.14.0 && <2.25 , text >=1.2.3 && <2.2 - , time >=1.8.0 && <1.15 + , time >=1.8.0 && <1.16 if impl(ghc <9.2.1) build-depends: ghc-boot >=8.6.1 && <9.7 diff --git a/flake.lock b/flake.lock index cf8678d..221e75a 100644 --- a/flake.lock +++ b/flake.lock @@ -20,27 +20,27 @@ }, "nixpkgs": { "locked": { - "lastModified": 1735863392, - "narHash": "sha256-jdyYQ7GquKhseXmwG6lyx9ebCLo9lMX9iJ1htpbpOF8=", - "owner": "nixos", + "lastModified": 1763811872, + "narHash": "sha256-qN03zMKGAJsCzwS8zmhFG+2SQuF1Sdk+KVGuJ4V/3Ko=", + "owner": "guibou", "repo": "nixpkgs", - "rev": "f371cdec06dbc42781824c5324657294e7ac581b", + "rev": "10f4fa4b05cae48dee180d5dbd80e8fba0fc7227", "type": "github" }, "original": { - "owner": "nixos", - "ref": "haskell-updates", + "owner": "guibou", + "ref": "ghc-914", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1735554305, - "narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=", + "lastModified": 1754340878, + "narHash": "sha256-lgmUyVQL9tSnvvIvBp7x1euhkkCho7n3TMzgjdvgPoU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd", + "rev": "cab778239e705082fe97bb4990e0d24c50924c04", "type": "github" }, "original": { @@ -77,11 +77,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1735905407, - "narHash": "sha256-1hKMRIT+QZNWX46e4gIovoQ7H8QRb7803ZH4qSKI45o=", + "lastModified": 1760120816, + "narHash": "sha256-gq9rdocpmRZCwLS5vsHozwB6b5nrOBDNc2kkEaTXHfg=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "29806abab803e498df96d82dd6f34b32eb8dd2c8", + "rev": "761ae7aff00907b607125b2f57338b74177697ed", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9408a3a..bc3ff42 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "PyF"; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.nixpkgs.url = "github:nixos/nixpkgs/haskell-updates"; + inputs.nixpkgs.url = "github:guibou/nixpkgs/ghc-914"; inputs.treefmt-nix.url = "github:numtide/treefmt-nix"; nixConfig.extra-substituters = [ "https://guibou.cachix.org" ]; @@ -53,9 +53,6 @@ rec { checks = { inherit (packages) - pyf_810 - pyf_90 - pyf_92 pyf_94 pyf_96 pyf_98 @@ -68,17 +65,15 @@ packages = { # GHC 8.6 is tested with stack, I'm stopping the testing with nix. - # GHC 8.8 is not in nixpkgs anymore. + # GHC 8.6..9.2 are not in nixpkgs anymore. - pyf_810 = pyfBuilder haskell.packages.ghc810; - pyf_90 = pyfBuilder haskell.packages.ghc90; - pyf_92 = pyfBuilder haskell.packages.ghc92; pyf_94 = pyfBuilder haskell.packages.ghc94; pyf_96 = pyfBuilder haskell.packages.ghc96; pyf_98 = pkgs.haskell.lib.dontCheck (pyfBuilder haskell.packages.ghc98); pyf_910 = pyfBuilder haskell.packages.ghc910; pyf_912 = pyfBuilder haskell.packages.ghc912; + pyf_914 = pyfBuilder haskell.packages.ghc914; default = pyfBuilder haskellPackages; }; diff --git a/src/PyF/Internal/Meta.hs b/src/PyF/Internal/Meta.hs index 0f4c329..17e8843 100644 --- a/src/PyF/Internal/Meta.hs +++ b/src/PyF/Internal/Meta.hs @@ -6,6 +6,8 @@ module PyF.Internal.Meta (toExp, baseDynFlags, toName) where +import qualified Data.List.NonEmpty as NE + #if MIN_VERSION_ghc(9,2,0) import GHC.Hs.Type (HsWildCardBndrs (..), HsType (..), HsSigType(HsSig), sig_body) #elif MIN_VERSION_ghc(9,0,0) @@ -95,8 +97,13 @@ toLit (HsIntPrim _ i) = TH.IntPrimL i toLit (HsWordPrim _ i) = TH.WordPrimL i toLit (HsInt64Prim _ i) = TH.IntegerL i toLit (HsWord64Prim _ i) = TH.WordPrimL i -toLit (HsInteger _ i _) = TH.IntegerL i +#if MIN_VERSION_ghc(9,13,0) +-- toLit (HsRat _ f _) = TH.FloatPrimL (fl_value f) +-- toLit (HsInteger _ i _) = TH.IntegerL i +#else toLit (HsRat _ f _) = TH.FloatPrimL (fl_value f) +toLit (HsInteger _ i _) = TH.IntegerL i +#endif toLit (HsFloatPrim _ f) = TH.FloatPrimL (fl_value f) toLit (HsDoublePrim _ f) = TH.DoublePrimL (fl_value f) #if MIN_VERSION_ghc(9,7,0) @@ -150,13 +157,16 @@ toExp _ (Expr.HsVar _ n) = in if isRdrDataCon n' then TH.ConE (toName n') else TH.VarE (toName n') -#if MIN_VERSION_ghc(9,6,0) +#if MIN_VERSION_ghc(9, 13, 0) + +#elif MIN_VERSION_ghc(9,6,0) toExp _ (Expr.HsUnboundVar _ n) = TH.UnboundVarE (TH.mkName . occNameString . rdrNameOcc $ n) #elif MIN_VERSION_ghc(9,0,0) toExp _ (Expr.HsUnboundVar _ n) = TH.UnboundVarE (TH.mkName . occNameString $ n) #else toExp _ (Expr.HsUnboundVar _ n) = TH.UnboundVarE (TH.mkName . occNameString . Expr.unboundVarOcc $ n) #endif + toExp _ Expr.HsIPVar {} = noTH "toExp" "HsIPVar" toExp _ (Expr.HsLit _ l) = TH.LitE (toLit l) toExp _ (Expr.HsOverLit _ OverLit {ol_val}) = TH.LitE (toLit' ol_val) @@ -179,8 +189,10 @@ toExp d (Expr.ExprWithTySig HsWC{hswc_body=HsIB{hsib_body}} e) = TH.SigE (toExp #endif toExp d (Expr.OpApp _ e1 o e2) = TH.UInfixE (toExp d . unLoc $ e1) (toExp d . unLoc $ o) (toExp d . unLoc $ e2) toExp d (Expr.NegApp _ e _) = TH.AppE (TH.VarE 'negate) (toExp d . unLoc $ e) +#if MIN_VERSION_ghc(9,13,0) +toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (Expr.GRHSs _ (NE.toList -> [unLoc -> Expr.GRHS _ _ (unLoc -> e)]) _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e) +#elif MIN_VERSION_ghc(9,12,0) -- NOTE: for lambda, there is only one match -#if MIN_VERSION_ghc(9,12,0) toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e) #elif MIN_VERSION_ghc(9,10,0) toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e) diff --git a/src/PyF/Internal/ParserEx.hs b/src/PyF/Internal/ParserEx.hs index 7e5802c..90ca6db 100644 --- a/src/PyF/Internal/ParserEx.hs +++ b/src/PyF/Internal/ParserEx.hs @@ -96,16 +96,28 @@ import OccName import GHC.Driver.Config.Parser (initParserOpts) #endif +#if MIN_VERSION_ghc(9,13,0) +import GHC.Unit.Types (UnitId(..)) +#endif + import Data.Maybe fakeSettings :: Settings fakeSettings = Settings -#if MIN_VERSION_ghc(9, 2, 0) +#if MIN_VERSION_ghc(9, 13, 0) { sGhcNameVersion=ghcNameVersion , sFileSettings=fileSettings , sTargetPlatform=platform + , sToolSettings=toolSettings , sPlatformMisc=platformMisc + , sUnitSettings = UnitSettings (UnitId $ fsLit "pyf-preprocessor") + } +#elif MIN_VERSION_ghc(9, 2, 0) + { sGhcNameVersion=ghcNameVersion + , sFileSettings=fileSettings + , sTargetPlatform=platform , sToolSettings=toolSettings + , sPlatformMisc=platformMisc } #elif MIN_VERSION_ghc(8, 10, 0) { sGhcNameVersion=ghcNameVersion diff --git a/src/PyF/Internal/QQ.hs b/src/PyF/Internal/QQ.hs index 88c90f9..7f2afe1 100644 --- a/src/PyF/Internal/QQ.hs +++ b/src/PyF/Internal/QQ.hs @@ -27,6 +27,8 @@ module PyF.Internal.QQ ) where +import qualified Data.List.NonEmpty as NE + import Control.Monad.Reader import Data.Data (Data (gmapQ), Typeable, cast) import Data.Kind @@ -196,7 +198,13 @@ findFreeVariables item = allNames Just (HsVar _ l) -> [l] #endif -#if MIN_VERSION_ghc(9,12,0) +#if MIN_VERSION_ghc(9,13,0) + Just (HsLam _ _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (GRHSs _ (NE.toList -> [unLoc -> GRHS _ _ (unLoc -> e)]) _)])))) -> filter keepVar subVars + where + keepVar (L _ n) = n `notElem` subPats + subVars = concat $ gmapQ f [e] + subPats = concat $ gmapQ findPats ps +#elif MIN_VERSION_ghc(9,12,0) Just (HsLam _ _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])))) -> filter keepVar subVars where keepVar (L _ n) = n `notElem` subPats @@ -273,7 +281,10 @@ unsafeRunTcM m = Q (unsafeCoerce m) reportErrorAt :: SrcSpan -> String -> Q () reportErrorAt loc msg = unsafeRunTcM $ addErrAt loc msg' where -#if MIN_VERSION_ghc(9,7,0) +#if MIN_VERSION_ghc(9,13,0) + -- TODO: maybe leverage the "hint" logic to add additionnal hints here? + msg' = TcRnUnknownMessage (UnknownDiagnostic (const NoDiagnosticOpts) (\x -> x) (mkPlainError noHints (text msg))) +#elif MIN_VERSION_ghc(9,7,0) msg' = TcRnUnknownMessage (UnknownDiagnostic (const NoDiagnosticOpts) (mkPlainError noHints (text msg))) #elif MIN_VERSION_ghc(9,6,0) msg' = TcRnUnknownMessage (UnknownDiagnostic $ mkPlainError noHints $