66
77module PyF.Internal.Meta (toExp , baseDynFlags , toName ) where
88
9+ import qualified Data.List.NonEmpty as NE
10+
911#if MIN_VERSION_ghc(9,2,0)
1012import GHC.Hs.Type (HsWildCardBndrs (.. ), HsType (.. ), HsSigType (HsSig ), sig_body )
1113#elif MIN_VERSION_ghc(9,0,0)
@@ -95,8 +97,13 @@ toLit (HsIntPrim _ i) = TH.IntPrimL i
9597toLit (HsWordPrim _ i) = TH. WordPrimL i
9698toLit (HsInt64Prim _ i) = TH. IntegerL i
9799toLit (HsWord64Prim _ i) = TH. WordPrimL i
98- toLit (HsInteger _ i _) = TH. IntegerL i
100+ #if MIN_VERSION_ghc(9,13,0)
101+ -- toLit (HsRat _ f _) = TH.FloatPrimL (fl_value f)
102+ -- toLit (HsInteger _ i _) = TH.IntegerL i
103+ #else
99104toLit (HsRat _ f _) = TH. FloatPrimL (fl_value f)
105+ toLit (HsInteger _ i _) = TH. IntegerL i
106+ #endif
100107toLit (HsFloatPrim _ f) = TH. FloatPrimL (fl_value f)
101108toLit (HsDoublePrim _ f) = TH. DoublePrimL (fl_value f)
102109#if MIN_VERSION_ghc(9,7,0)
@@ -150,13 +157,16 @@ toExp _ (Expr.HsVar _ n) =
150157 in if isRdrDataCon n'
151158 then TH. ConE (toName n')
152159 else TH. VarE (toName n')
153- #if MIN_VERSION_ghc(9,6,0)
160+ #if MIN_VERSION_ghc(9, 13, 0)
161+
162+ #elif MIN_VERSION_ghc(9,6,0)
154163toExp _ (Expr. HsUnboundVar _ n) = TH. UnboundVarE (TH. mkName . occNameString . rdrNameOcc $ n)
155164#elif MIN_VERSION_ghc(9,0,0)
156165toExp _ (Expr. HsUnboundVar _ n) = TH. UnboundVarE (TH. mkName . occNameString $ n)
157166#else
158167toExp _ (Expr. HsUnboundVar _ n) = TH. UnboundVarE (TH. mkName . occNameString . Expr. unboundVarOcc $ n)
159168#endif
169+
160170toExp _ Expr. HsIPVar {} = noTH " toExp" " HsIPVar"
161171toExp _ (Expr. HsLit _ l) = TH. LitE (toLit l)
162172toExp _ (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
179189#endif
180190toExp d (Expr. OpApp _ e1 o e2) = TH. UInfixE (toExp d . unLoc $ e1) (toExp d . unLoc $ o) (toExp d . unLoc $ e2)
181191toExp d (Expr. NegApp _ e _) = TH. AppE (TH. VarE 'negate) (toExp d . unLoc $ e)
192+ #if MIN_VERSION_ghc(9,13,0)
193+ 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)
194+ #elif MIN_VERSION_ghc(9,12,0)
182195-- NOTE: for lambda, there is only one match
183- #if MIN_VERSION_ghc(9,12,0)
184196toExp 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)
185197#elif MIN_VERSION_ghc(9,10,0)
186198toExp 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)
0 commit comments