Skip to content

Commit

Permalink
fix: support for GHC 9.10 api
Browse files Browse the repository at this point in the history
Tested with GHC 9.10 alpha 3.

Close #137.
  • Loading branch information
guibou committed Apr 23, 2024
1 parent 8beb2d4 commit 15c99fa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for PyF

##

- Support for GHC 9.10.

## 0.11.2.1 -- 2023-10-25

- Final version for GHC 9.8
Expand Down
4 changes: 2 additions & 2 deletions PyF.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ library
PyF.Internal.ParserEx
PyF.Internal.Parser

build-depends: base >= 4.12 && < 4.20
build-depends: base >= 4.12 && < 4.22
, bytestring >= 0.10.8 && < 0.13
, template-haskell >= 2.14.0 && < 2.22
, template-haskell >= 2.14.0 && < 2.24
, text >= 1.2.3 && < 2.2
, time >= 1.8.0 && < 1.14
, parsec >= 3.1.13 && < 3.2
Expand Down
13 changes: 10 additions & 3 deletions src/PyF/Internal/Meta.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ 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)
toExp d (Expr.HsApp _ e1 e2) = TH.AppE (toExp d . unLoc $ e1) (toExp d . unLoc $ e2)
#if MIN_VERSION_ghc(9,6,0)
#if MIN_VERSION_ghc(9,8,0)
toExp d (Expr.HsAppType _ e HsWC{hswc_body}) = TH.AppTypeE (toExp d . unLoc $ e) (toType . unLoc $ hswc_body)
toExp d (Expr.ExprWithTySig _ e HsWC{hswc_body=unLoc -> HsSig{sig_body}}) = TH.SigE (toExp d . unLoc $ e) (toType . unLoc $ sig_body)
#elif MIN_VERSION_ghc(9,6,0)
toExp d (Expr.HsAppType _ e _ HsWC{hswc_body}) = TH.AppTypeE (toExp d . unLoc $ e) (toType . unLoc $ hswc_body)
toExp d (Expr.ExprWithTySig _ e HsWC{hswc_body=unLoc -> HsSig{sig_body}}) = TH.SigE (toExp d . unLoc $ e) (toType . unLoc $ sig_body)
#elif MIN_VERSION_ghc(9,2,0)
Expand All @@ -177,7 +180,9 @@ toExp d (Expr.ExprWithTySig HsWC{hswc_body=HsIB{hsib_body}} e) = TH.SigE (toExp
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)
-- NOTE: for lambda, there is only one match
#if MIN_VERSION_ghc(9,6,0)
#if MIN_VERSION_ghc(9,8,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)
#elif MIN_VERSION_ghc(9,6,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)
#else
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 Expand Up @@ -213,7 +218,9 @@ toExp d (Expr.ExplicitTuple _ (map unLoc -> args) boxity) = ctor tupArgs
{- ORMOLU_ENABLE -}

-- toExp (Expr.List _ xs) = TH.ListE (fmap toExp xs)
#if MIN_VERSION_ghc(9,3,0)
#if MIN_VERSION_ghc(9,8,0)
toExp d (Expr.HsPar _ e) = TH.ParensE (toExp d . unLoc $ e)
#elif MIN_VERSION_ghc(9,3,0)
toExp d (Expr.HsPar _ _ e _) = TH.ParensE (toExp d . unLoc $ e)
#else
toExp d (Expr.HsPar _ e) = TH.ParensE (toExp d . unLoc $ e)
Expand Down
4 changes: 3 additions & 1 deletion src/PyF/Internal/QQ.hs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ findFreeVariables item = allNames
Just (HsVar _ l) -> [l]
#endif

#if MIN_VERSION_ghc(9,6,0)
#if MIN_VERSION_ghc(9,8,0)
Just (HsLam _ _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])))) -> filter keepVar subVars
#elif MIN_VERSION_ghc(9,6,0)
Just (HsLam _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])))) -> filter keepVar subVars
#else
Just (HsLam _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])) _)) -> filter keepVar subVars
Expand Down

0 comments on commit 15c99fa

Please sign in to comment.