ghc-compat-plugin 0.0.1.0 → 0.0.2.0
raw patch · 6 files changed
+39/−38 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ GhcCompat: Error :: ReportLevel
+ GhcCompat: Opts :: Version -> Maybe ReportLevel -> Opts
+ GhcCompat: Warn :: ReportLevel
+ GhcCompat: [minVersion] :: Opts -> Version
+ GhcCompat: [reportIncompatibleExtensions] :: Opts -> Maybe ReportLevel
+ GhcCompat: data ReportLevel
Files
- CHANGELOG.md +12/−2
- README.md +5/−7
- ghc-compat-plugin.cabal +2/−2
- supported/GhcCompat.hs +9/−6
- supported/GhcCompat/GhcRelease.hs +9/−14
- supported/GhcCompat/Opts.hs +2/−7
CHANGELOG.md view
@@ -5,10 +5,20 @@ The format is based on [Keep a Changelog 1.1](https://keepachangelog.com/en/1.1.0/), and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). -## [0.0.1.0] -+## [0.0.2.0] – 2026-02-03 +### Fixed++- `NamedFieldPuns` had erroneously been reported as unsupported before GHC 9.4.1. Now it correctly only reports before 6.10.1 (#4)+- improved some documentation (#2)++## [0.0.1.0] - 2026-02-01+ ### Added - initial release of this package -[0.0.1.0]: https://github.com/sellout/ghc-compat-plugin/releases/tag/v0.0.1.0+<!-- NB: The version on the left is the Haskell package version (PVP), the version on the right is the repo (tag) version (SemVer). Their only relationship is that a change of any severity on the left implies a change of at least that severity on the right. -->++[0.0.2.0]: https://github.com/sellout/ghc-compat-plugin/compare/v0.1.0...v0.2.0+[0.0.1.0]: https://github.com/sellout/ghc-compat-plugin/releases/tag/v0.1.0
README.md view
@@ -1,6 +1,6 @@ # `GhcCompat` plugin -[](https://hackage.haskell.org/package/)+[](https://hackage.haskell.org/package/ghc-compat-plugin) [](https://repology.org/project/haskell:ghc-compat-plugin/versions) [](https://repology.org/project/haskell:ghc-compat-plugin/versions) @@ -37,11 +37,10 @@ Add the following to any stanzas[^2] in your Cabal package files. -[^2]: I like to put it in a `common` section that’s imported by all my stanzas.+[^2]: I like to put it in a `common` section (provided you’re using at least Cabal 2.2) that’s imported by all my stanzas. ```cabal-library- build-depends: ghc-compat-plugin >=0.0.1 && <0.1,+ build-depends: ghc-compat-plugin >=0.0.2 && <0.1 ghc-options: -fplugin=GhcCompat -fplugin-opt=GhcCompat:minVersion=8.8.1@@ -52,7 +51,7 @@ You can also add ```cabal- -fplugin-opt GhcCompat:reportIncompatibleExtensions=error+ -fplugin-opt=GhcCompat:reportIncompatibleExtensions=error ``` (where `error` can also be `warn` (the default) or `no`) in order to control how the plugin informs you of enabled extensions that aren’t compatible with all of your supported GHC versions.@@ -60,9 +59,8 @@ **NB**: This plugin should load from GHC 7.2 (the first version of GHC to support plugins[^3]). However, it currently won’t _do_ anything before GHC 7.10.1. If you do need to support a GHC prior to 7.2, you can use the plugin conditionally, like ```cabal-library if impl(ghc >= 7.2.1)- build-depends: ghc-compat-plugin >=0.0.1 && <0.1,+ build-depends: ghc-compat-plugin >=0.0.2 && <0.1 ghc-options: -fplugin=GhcCompat -fplugin-opt=GhcCompat:minVersion=6.8.1
ghc-compat-plugin.cabal view
@@ -5,7 +5,7 @@ -- https://cabal.readthedocs.io/en/stable/file-format-changelog.html name: ghc-compat-plugin-version: 0.0.1.0+version: 0.0.2.0 synopsis: Eases support for multiple GHC versions description: Controls various GHC options and extensions to make compilation across multiple versions easier, and to alert you to@@ -54,7 +54,7 @@ location: https://github.com/sellout/ghc-compat-plugin.git subdir: core -- NB: This is the repo version, which is distinct from the package version.- tag: v0.1.0+ tag: v0.2.0 flag noisy-deprecations description:
supported/GhcCompat.hs view
@@ -13,9 +13,9 @@ -- currently. module GhcCompat ( plugin,-- -- * exported purely for documentation- Opts,+ -- exported purely for documentation+ Opts (..),+ ReportLevel (..), ) where @@ -40,7 +40,7 @@ import safe "base" Text.Show (show) import safe "this" GhcCompat.GhcRelease (GhcRelease) import safe qualified "this" GhcCompat.GhcRelease as GhcRelease-import safe "this" GhcCompat.Opts (Opts)+import safe "this" GhcCompat.Opts (Opts (Opts), ReportLevel (Error, Warn)) import safe qualified "this" GhcCompat.Opts as Opts #if MIN_VERSION_ghc(9, 0, 0) import "ghc" GHC.Plugins (Plugin, defaultPlugin)@@ -50,6 +50,9 @@ import qualified "ghc" GhcPlugins as Plugins #endif +-- | The entry-point for the GHC plugin. This is used by passing+-- [@-fplugin=GhcCompat@](https://downloads.haskell.org/ghc/latest/docs/users_guide/extending_ghc.html#ghc-flag-fplugin-module)+-- to GHC. plugin :: Plugin plugin = defaultPlugin@@ -108,7 +111,7 @@ -- extensions. identifyProblematicFlags :: Version -> Plugins.DynFlags -> [Plugins.WarningFlag] identifyProblematicFlags minVersion dflags =- List.filter (flip Plugins.wopt dflags) . warningFlags minVersion $+ List.filter (`Plugins.wopt` dflags) . warningFlags minVersion $ List.filter ((< GhcRelease.version GhcRelease.ghc_8_10_1) . GhcRelease.version) GhcRelease.all@@ -233,7 +236,7 @@ Plugins.On a -> a #else usedIncompatibleExtensions minVersion dflags =- List.filter (flip Plugins.xopt dflags) $ incompatibleExtensions minVersion+ List.filter (`Plugins.xopt` dflags) $ incompatibleExtensions minVersion #endif -- | A list of /all/ extensions that are incompatible with the provided version.
supported/GhcCompat/GhcRelease.hs view
@@ -38,7 +38,6 @@ ghc_9_0_1, ghc_9_2_1, ghc_9_2_4,- ghc_9_4_1, ghc_9_6_1, ghc_9_8_1, ghc_9_10_1,@@ -204,7 +203,14 @@ [ Extension.PackageImports, Extension.QuasiQuotes, Extension.TransformListComp,- Extension.ViewPatterns+ Extension.ViewPatterns,+-- NB: `NamedFieldPuns` is documented as being added in 6.10.1, but it was+-- called `RecordPuns` in `Extension` until 9.4.1.+#if MIN_VERSION_GLASGOW_HASKELL(9, 4, 1, 0)+ Extension.NamedFieldPuns+#else+ Extension.RecordPuns+#endif ], newWarnings = [] }@@ -212,6 +218,7 @@ { newExtensions = [ Extension.Opt_PackageImports, Extension.Opt_QuasiQuotes,+ Extension.Opt_RecordPuns, Extension.Opt_TransformListComp, Extension.Opt_ViewPatterns ],@@ -557,17 +564,6 @@ } #endif -ghc_9_4_1 :: GhcRelease-ghc_9_4_1 =- (ghcRelease [9, 4, 1])-#if MIN_VERSION_GLASGOW_HASKELL(9, 4, 1, 0)- { -- NB: `NamedFieldPuns` is documented as being added in 6.10.1, but- -- doesn’t appear in `Extension` until 9.4.1.- newExtensions = [Extension.NamedFieldPuns],- newWarnings = []- }-#endif- ghc_9_8_1 :: GhcRelease ghc_9_8_1 = (ghcRelease [9, 8, 1])@@ -642,7 +638,6 @@ ghc_9_0_1, ghc_9_2_1, ghc_9_2_4,- ghc_9_4_1, ghc_9_6_1, ghc_9_8_1, ghc_9_10_1,
supported/GhcCompat/Opts.hs view
@@ -6,7 +6,7 @@ -- -- Option handling for "GhcCompat". module GhcCompat.Opts- ( Opts,+ ( Opts (Opts), ReportLevel (Error, Warn), minVersion, parse,@@ -18,26 +18,22 @@ import "base" Control.Category ((.)) import "base" Data.Bifunctor (second) import "base" Data.Either (Either (Left))-import "base" Data.Eq (Eq, (==))+import "base" Data.Eq ((==)) import "base" Data.Foldable (foldrM) import "base" Data.Function (flip, ($)) import "base" Data.Functor (fmap, (<$>)) import "base" Data.List (break, drop, lookup, reverse, uncons) import "base" Data.Maybe (Maybe (Nothing), maybe) import "base" Data.Monoid ((<>))-import "base" Data.Ord (Ord) import "base" Data.String (String) import "base" Data.Tuple (fst, uncurry) import "base" Data.Version (Version, parseVersion) import "base" Text.ParserCombinators.ReadP (readP_to_S)-import "base" Text.Read (Read)-import "base" Text.Show (Show) -- | This mirrors the levels provided by GHC’s warning flags. Correspondingly, -- we use the lowercase forms for the plugin opts instead of the capitalized -- ones. data ReportLevel = Warn | Error- deriving (Eq, Ord, Read, Show) defaultOpts :: Version -> Opts defaultOpts minVersion =@@ -58,7 +54,6 @@ -- | This can be “no”, “warn” (the default), or “error”. reportIncompatibleExtensions :: Maybe ReportLevel }- deriving (Eq, Ord, Read, Show) parseOpt :: Opts -> String -> String -> Either String Opts parseOpt opts name value = case (name, value) of