packages feed

ghc-hs-meta 0.1.1.0 → 0.1.2.0

raw patch · 5 files changed

+56/−19 lines, 5 filesdep ~basedep ~bytestringdep ~ghcnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, bytestring, ghc, ghc-boot, template-haskell

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+# 0.1.2.0++ * Support GHC 9.6++# 0.1.1.0++ * Support GHC 9.4+ # 0.1.0.0  Initial release.
README.md view
@@ -1,7 +1,7 @@-# ghc-meta+# ghc-hs-meta  Generate Template Haskell expressions from Haskell source code using the GHC parser.-This package runs on GHC versions 8.10.7, 9.0.2, and 9.2.1.+This package runs on GHC versions 8.10, 9.0, 9.2, 9.4 and 9.6.  ## Usage @@ -18,7 +18,7 @@  ## Thank you, PyF -This code originated from the excellent parser included in the [`PyF`](https://github.com/guibou/PyF) package. +This code originated from the excellent parser included in the [`PyF`](https://github.com/guibou/PyF) package. I extracted the relevant code and refactored/renamed things to be usable in a more general context. Without PyF, this could wouldn't have been possible. Thank you! 
ghc-hs-meta.cabal view
@@ -1,16 +1,16 @@ cabal-version:  2.4  name:           ghc-hs-meta-version:        0.1.1.0+version:        0.1.2.0 build-type:     Simple author:         Zachary Wood-maintainer:     zac.wood@hey.com+maintainer:     amesgen@amesgen.de license:        BSD-3-Clause license-files:  LICENSE LICENSE-PyF synopsis:       Translate Haskell source to Template Haskell expression description:    Translate from Haskell source code to Template Haskell expressions using the GHC parser category:       ghc,template-haskell-tested-with:    GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.4, GHC == 9.4.1+tested-with:    GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.5, GHC == 9.6.2  extra-source-files: CHANGELOG.md README.md @@ -26,10 +26,10 @@       LambdaCase   ghc-options: -Wall   build-depends:-      base >= 4.14 && <4.18-    , ghc >= 8.10.7 && < 9.5-    , ghc-boot >= 8.10.7 && < 9.5-    , template-haskell >= 2.16.0 && < 2.20+      base >= 4.14 && <4.19+    , ghc >= 8.10.7 && < 9.7+    , ghc-boot >= 8.10.7 && < 9.7+    , template-haskell >= 2.16.0 && < 2.21     , bytestring >= 0.10 && < 0.12   default-language: Haskell2010 
src/Language/Haskell/Meta/Settings.hs view
@@ -169,15 +169,18 @@       PlatformConstants{pc_DYNAMIC_BY_DEFAULT=False,pc_WORD_SIZE=8} #endif -#if MIN_VERSION_ghc(8, 10, 0)-fakeLlvmConfig :: LlvmConfig-fakeLlvmConfig = LlvmConfig [] []+#if MIN_VERSION_ghc(9, 6, 0)+applyFakeLlvmConfig :: a -> a+applyFakeLlvmConfig = id+#elif MIN_VERSION_ghc(8, 10, 0)+applyFakeLlvmConfig :: (LlvmConfig -> a) -> a+applyFakeLlvmConfig f = f $ LlvmConfig [] [] #else-fakeLlvmConfig :: (LlvmTargets, LlvmPasses)-fakeLlvmConfig = ([], [])+applyFakeLlvmConfig :: (LlvmTargets, LlvmPasses)+applyFakeLlvmConfig f = f ([], []) #endif  baseDynFlags :: [GhcTH.Extension] -> DynFlags baseDynFlags exts =   let enable = GhcTH.TemplateHaskellQuotes : exts-   in foldl xopt_set (defaultDynFlags fakeSettings fakeLlvmConfig) enable+   in foldl xopt_set (applyFakeLlvmConfig $ defaultDynFlags fakeSettings) enable
src/Language/Haskell/Meta/Translate.hs view
@@ -16,6 +16,10 @@ import HsTypes (HsWildCardBndrs (..), HsType (..), HsImplicitBndrs (HsIB), hsib_body) #endif +#if MIN_VERSION_ghc(9,6,0)+import Language.Haskell.Syntax.Basic (FieldLabelString (..))+#endif+ #if MIN_VERSION_ghc(8,10,0) import GHC.Hs.Expr as Expr import GHC.Hs.Extension as Ext@@ -128,7 +132,7 @@         else TH.VarE (toName n')  #if MIN_VERSION_ghc(9,0,0)-toExp _ (Expr.HsUnboundVar _ n)              = TH.UnboundVarE (TH.mkName . occNameString $ n)+toExp _ (Expr.HsUnboundVar _ n)              = TH.UnboundVarE (TH.mkName . occNameString . occName $ n) #else toExp _ (Expr.HsUnboundVar _ n)              = TH.UnboundVarE (TH.mkName . occNameString . Expr.unboundVarOcc $ n) #endif@@ -146,7 +150,11 @@   = TH.AppE (toExp d . unLoc $ e1) (toExp d . unLoc $ e2)  #if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,6,0)+toExp d (Expr.HsAppType _ e _ HsWC {hswc_body}) = TH.AppTypeE (toExp d . unLoc $ e) (toType . unLoc $ hswc_body)+#else toExp d (Expr.HsAppType _ e HsWC {hswc_body}) = TH.AppTypeE (toExp d . unLoc $ e) (toType . unLoc $ hswc_body)+#endif 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(8,8,0) toExp d (Expr.HsAppType _ e HsWC {hswc_body}) = TH.AppTypeE (toExp d . unLoc $ e) (toType . unLoc $ hswc_body)@@ -162,7 +170,11 @@   = TH.AppE (TH.VarE 'negate) (toExp d . unLoc $ e)  -- NOTE: for lambda, there is only one match+#if 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)] _)]))))+#else toExp d (Expr.HsLam _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])) _))+#endif   = TH.LamE (fmap (toPat d) ps) (toExp d e)  -- toExp (Expr.Let _ bs e)                       = TH.LetE (toDecs bs) (toExp e)@@ -237,9 +249,23 @@     (FromTo a b) -> TH.FromToR (toExp d $ unLoc a) (toExp d $ unLoc b)     (FromThenTo a b c) -> TH.FromThenToR (toExp d $ unLoc a) (toExp d $ unLoc b) (toExp d $ unLoc c) -#if MIN_VERSION_ghc(9, 4, 0)+#if MIN_VERSION_ghc(9, 6, 0) toExp _ (Expr.HsProjection _ locatedFields) =   let+    extractFieldLabel (DotFieldOcc _ locatedStr) = field_label <$> locatedStr+    extractFieldLabel _ = error "Don't know how to handle XHsFieldLabel constructor..."+  in+    TH.ProjectionE (NonEmpty.map (unpackFS . unLoc . extractFieldLabel . unLoc) locatedFields)++toExp d (Expr.HsGetField _ expr locatedField) =+  let+    extractFieldLabel (DotFieldOcc _ locatedStr) = field_label <$> locatedStr+    extractFieldLabel _ = error "Don't know how to handle XHsFieldLabel constructor..."+  in+    TH.GetFieldE (toExp d (unLoc expr)) (unpackFS . unLoc . extractFieldLabel . unLoc $ locatedField)+#elif MIN_VERSION_ghc(9, 4, 0)+toExp _ (Expr.HsProjection _ locatedFields) =+  let     extractFieldLabel (DotFieldOcc _ locatedStr) = locatedStr     extractFieldLabel _ = error "Don't know how to handle XHsFieldLabel constructor..."   in@@ -268,7 +294,7 @@ #endif  -#if MIN_VERSION_ghc(9, 2, 0)+#if MIN_VERSION_ghc(9, 2, 0) && !MIN_VERSION_ghc(9, 6, 0) toExp _ (Expr.HsOverLabel _ fastString) = TH.LabelE (unpackFS fastString) #else toExp _ (Expr.HsOverLabel _ _ fastString) = TH.LabelE (unpackFS fastString)