Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions PyF.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand Down Expand Up @@ -53,9 +53,6 @@
rec {
checks = {
inherit (packages)
pyf_810
pyf_90
pyf_92
pyf_94
pyf_96
pyf_98
Expand All @@ -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;
};
Expand Down
18 changes: 15 additions & 3 deletions src/PyF/Internal/Meta.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion src/PyF/Internal/ParserEx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions src/PyF/Internal/QQ.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 $
Expand Down
Loading