diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e6a2f51..47e8c0d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @chshersh @vrom911 +* @vrom911 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5961392..4c28269 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - cabal: ["3.4"] + cabal: ["3.8"] ghc: - "8.8.4" - "8.10.7" - "9.0.2" + - "9.2.4" + - "9.4.2" steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 907b78e..47b86e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,14 @@ `extensions` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. -## Unreleased +## 0.1.0.0 — Oct 14, 2022 + +* [#74](https://github.com/kowainik/extensions/issues/74): + Support GHC-9.2. +* [#83](https://github.com/kowainik/extensions/issues/83): + Support GHC-9.4. +* Support `Cabal` `3.4`, `3.6` and `3.8`. * [#70](https://github.com/kowainik/extensions/issues/70): Parse empty lines and spaces in before comments and pragmas in the beginning of the file. diff --git a/extensions.cabal b/extensions.cabal index d645932..77b7711 100644 --- a/extensions.cabal +++ b/extensions.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: extensions -version: 0.0.0.1 +version: 0.1.0.0 synopsis: Parse Haskell Language Extensions description: Parse Haskell Language Extensions. See [README.md](https://github.com/kowainik/extensions#extensions) for more details. @@ -10,7 +10,7 @@ license: MPL-2.0 license-file: LICENSE author: Veronika Romashkina, Dmitrii Kovanikov maintainer: Kowainik -copyright: 2020 Kowainik +copyright: 2020-2022 Kowainik category: GHC, Parsing, Haskell build-type: Simple extra-doc-files: README.md @@ -18,6 +18,8 @@ extra-doc-files: README.md tested-with: GHC == 8.8.4 GHC == 8.10.7 GHC == 9.0.2 + GHC == 9.2.4 + GHC == 9.4.2 flag executable description: Build the extensions executable @@ -29,7 +31,7 @@ source-repository head location: https://github.com/kowainik/extensions.git common common-options - build-depends: base >= 4.13.0.0 && < 4.16 + build-depends: base >= 4.13.0.0 && < 4.18 ghc-options: -Wall -Wcompat @@ -47,6 +49,11 @@ common common-options ghc-options: -Wmissing-deriving-strategies if impl(ghc >= 8.10.1) ghc-options: -Wunused-packages + if impl(ghc >= 9.0) + ghc-options: -Winvalid-haddock + if impl(ghc >= 9.2) + ghc-options: -Woperator-whitespace + -Wredundant-bang-patterns default-language: Haskell2010 default-extensions: ConstraintKinds @@ -73,14 +80,14 @@ library Extensions.Package Extensions.Types - build-depends: bytestring ^>= 0.10 - , Cabal >= 3.0 && < 3.5 + build-depends: bytestring >= 0.10 && < 0.12 + , Cabal >= 3.0 && < 3.9 , containers ^>= 0.6 , directory ^>= 1.3 , filepath ^>= 1.4 - , ghc-boot-th >= 8.8.1 && < 9.1 + , ghc-boot-th >= 8.8.1 && < 9.5 , parsec ^>= 3.1 - , text ^>= 1.2.3 + , text >= 1.2.3 && < 2.1 executable extensions import: common-options @@ -95,7 +102,7 @@ executable extensions , containers , directory , filepath - , optparse-applicative >= 0.15 && < 0.17 + , optparse-applicative >= 0.15 && < 0.18 , text test-suite extensions-test @@ -111,10 +118,10 @@ test-suite extensions-test , bytestring , containers , ghc-boot-th - , hedgehog ^>= 1.0 + , hedgehog >= 1.0 && < 1.3 , hspec , hspec-hedgehog ^>= 0.0.1 - , text ^>= 1.2 + , text ghc-options: -threaded -rtsopts -with-rtsopts=-N diff --git a/src/Extensions.hs b/src/Extensions.hs index 864d01a..e293a11 100644 --- a/src/Extensions.hs +++ b/src/Extensions.hs @@ -1,5 +1,5 @@ {- | -Copyright: (c) 2020 Kowainik +Copyright: (c) 2020-2022 Kowainik SPDX-License-Identifier: MPL-2.0 Maintainer: Kowainik diff --git a/src/Extensions/Cabal.hs b/src/Extensions/Cabal.hs index bd9d5c9..dd35abf 100644 --- a/src/Extensions/Cabal.hs +++ b/src/Extensions/Cabal.hs @@ -1,7 +1,7 @@ {-# LANGUAGE CPP #-} {- | -Copyright: (c) 2020 Kowainik +Copyright: (c) 2020-2022 Kowainik SPDX-License-Identifier: MPL-2.0 Maintainer: Kowainik @@ -41,6 +41,9 @@ import Distribution.Types.GenericPackageDescription (GenericPackageDescription ( import Distribution.Types.Library (Library (..)) import Distribution.Types.TestSuite (TestSuite (..)) import Distribution.Types.TestSuiteInterface (TestSuiteInterface (..)) +#if MIN_VERSION_Cabal(3,6,0) +import Distribution.Utils.Path (getSymbolicPath) +#endif import GHC.LanguageExtensions.Type (Extension (..)) import System.Directory (doesFileExist) import System.FilePath ((<.>), ()) @@ -144,7 +147,11 @@ condTreeToExtensions condTreeToExtensions extractModules extractBuildInfo condTree = do let comp = condTreeData condTree let buildInfo = extractBuildInfo comp +#if MIN_VERSION_Cabal(3,6,0) + let srcDirs = getSymbolicPath <$> hsSourceDirs buildInfo +#else let srcDirs = hsSourceDirs buildInfo +#endif let modules = extractModules comp ++ map toModulePath (otherModules buildInfo ++ autogenModules buildInfo) let (safeExts, parsedExtensionsAll) = partitionEithers $ mapMaybe cabalToGhcExtension $ defaultExtensions buildInfo @@ -213,148 +220,168 @@ cabalToGhcExtension = \case -- | Convert 'Cabal.KnownExtension' to 'OnOffExtension'. toGhcExtension :: Cabal.KnownExtension -> Maybe Extension toGhcExtension = \case - Cabal.OverlappingInstances -> Just OverlappingInstances - Cabal.UndecidableInstances -> Just UndecidableInstances - Cabal.IncoherentInstances -> Just IncoherentInstances - Cabal.DoRec -> Just RecursiveDo - Cabal.RecursiveDo -> Just RecursiveDo - Cabal.ParallelListComp -> Just ParallelListComp - Cabal.MultiParamTypeClasses -> Just MultiParamTypeClasses - Cabal.MonomorphismRestriction -> Just MonomorphismRestriction - Cabal.FunctionalDependencies -> Just FunctionalDependencies - Cabal.Rank2Types -> Just RankNTypes - Cabal.RankNTypes -> Just RankNTypes - Cabal.PolymorphicComponents -> Just RankNTypes - Cabal.ExistentialQuantification -> Just ExistentialQuantification - Cabal.ScopedTypeVariables -> Just ScopedTypeVariables - Cabal.PatternSignatures -> Just ScopedTypeVariables - Cabal.ImplicitParams -> Just ImplicitParams - Cabal.FlexibleContexts -> Just FlexibleContexts - Cabal.FlexibleInstances -> Just FlexibleInstances - Cabal.EmptyDataDecls -> Just EmptyDataDecls - Cabal.CPP -> Just Cpp - Cabal.KindSignatures -> Just KindSignatures - Cabal.BangPatterns -> Just BangPatterns - Cabal.TypeSynonymInstances -> Just TypeSynonymInstances - Cabal.TemplateHaskell -> Just TemplateHaskell - Cabal.ForeignFunctionInterface -> Just ForeignFunctionInterface - Cabal.Arrows -> Just Arrows - Cabal.ImplicitPrelude -> Just ImplicitPrelude - Cabal.PatternGuards -> Just PatternGuards - Cabal.GeneralizedNewtypeDeriving -> Just GeneralizedNewtypeDeriving - Cabal.GeneralisedNewtypeDeriving -> Just GeneralizedNewtypeDeriving - Cabal.MagicHash -> Just MagicHash - Cabal.TypeFamilies -> Just TypeFamilies - Cabal.StandaloneDeriving -> Just StandaloneDeriving - Cabal.UnicodeSyntax -> Just UnicodeSyntax - Cabal.UnliftedFFITypes -> Just UnliftedFFITypes - Cabal.InterruptibleFFI -> Just InterruptibleFFI - Cabal.CApiFFI -> Just CApiFFI - Cabal.LiberalTypeSynonyms -> Just LiberalTypeSynonyms - Cabal.TypeOperators -> Just TypeOperators - Cabal.RecordWildCards -> Just RecordWildCards - Cabal.RecordPuns -> Just RecordPuns - Cabal.NamedFieldPuns -> Just RecordPuns - Cabal.DisambiguateRecordFields -> Just DisambiguateRecordFields - Cabal.TraditionalRecordSyntax -> Just TraditionalRecordSyntax - Cabal.OverloadedStrings -> Just OverloadedStrings - Cabal.GADTs -> Just GADTs - Cabal.GADTSyntax -> Just GADTSyntax - Cabal.RelaxedPolyRec -> Just RelaxedPolyRec - Cabal.ExtendedDefaultRules -> Just ExtendedDefaultRules - Cabal.UnboxedTuples -> Just UnboxedTuples - Cabal.DeriveDataTypeable -> Just DeriveDataTypeable - Cabal.AutoDeriveTypeable -> Just DeriveDataTypeable - Cabal.DeriveGeneric -> Just DeriveGeneric - Cabal.DefaultSignatures -> Just DefaultSignatures - Cabal.InstanceSigs -> Just InstanceSigs - Cabal.ConstrainedClassMethods -> Just ConstrainedClassMethods - Cabal.PackageImports -> Just PackageImports - Cabal.ImpredicativeTypes -> Just ImpredicativeTypes - Cabal.PostfixOperators -> Just PostfixOperators - Cabal.QuasiQuotes -> Just QuasiQuotes - Cabal.TransformListComp -> Just TransformListComp - Cabal.MonadComprehensions -> Just MonadComprehensions - Cabal.ViewPatterns -> Just ViewPatterns - Cabal.TupleSections -> Just TupleSections - Cabal.GHCForeignImportPrim -> Just GHCForeignImportPrim - Cabal.NPlusKPatterns -> Just NPlusKPatterns - Cabal.DoAndIfThenElse -> Just DoAndIfThenElse - Cabal.MultiWayIf -> Just MultiWayIf - Cabal.LambdaCase -> Just LambdaCase - Cabal.RebindableSyntax -> Just RebindableSyntax - Cabal.ExplicitForAll -> Just ExplicitForAll - Cabal.DatatypeContexts -> Just DatatypeContexts - Cabal.MonoLocalBinds -> Just MonoLocalBinds - Cabal.DeriveFunctor -> Just DeriveFunctor - Cabal.DeriveTraversable -> Just DeriveTraversable - Cabal.DeriveFoldable -> Just DeriveFoldable - Cabal.NondecreasingIndentation -> Just NondecreasingIndentation - Cabal.ConstraintKinds -> Just ConstraintKinds - Cabal.PolyKinds -> Just PolyKinds - Cabal.DataKinds -> Just DataKinds - Cabal.ParallelArrays -> Just ParallelArrays - Cabal.RoleAnnotations -> Just RoleAnnotations - Cabal.OverloadedLists -> Just OverloadedLists - Cabal.EmptyCase -> Just EmptyCase - Cabal.NegativeLiterals -> Just NegativeLiterals - Cabal.BinaryLiterals -> Just BinaryLiterals - Cabal.NumDecimals -> Just NumDecimals - Cabal.NullaryTypeClasses -> Just NullaryTypeClasses - Cabal.ExplicitNamespaces -> Just ExplicitNamespaces - Cabal.AllowAmbiguousTypes -> Just AllowAmbiguousTypes - Cabal.JavaScriptFFI -> Just JavaScriptFFI - Cabal.PatternSynonyms -> Just PatternSynonyms - Cabal.PartialTypeSignatures -> Just PartialTypeSignatures - Cabal.NamedWildCards -> Just NamedWildCards - Cabal.DeriveAnyClass -> Just DeriveAnyClass - Cabal.DeriveLift -> Just DeriveLift - Cabal.StaticPointers -> Just StaticPointers - Cabal.StrictData -> Just StrictData - Cabal.Strict -> Just Strict - Cabal.ApplicativeDo -> Just ApplicativeDo - Cabal.DuplicateRecordFields -> Just DuplicateRecordFields - Cabal.TypeApplications -> Just TypeApplications - Cabal.TypeInType -> Just TypeInType - Cabal.UndecidableSuperClasses -> Just UndecidableSuperClasses - Cabal.MonadFailDesugaring -> Just MonadFailDesugaring - Cabal.TemplateHaskellQuotes -> Just TemplateHaskellQuotes - Cabal.OverloadedLabels -> Just OverloadedLabels - Cabal.TypeFamilyDependencies -> Just TypeFamilyDependencies - Cabal.DerivingStrategies -> Just DerivingStrategies - Cabal.DerivingVia -> Just DerivingVia - Cabal.UnboxedSums -> Just UnboxedSums - Cabal.HexFloatLiterals -> Just HexFloatLiterals - Cabal.BlockArguments -> Just BlockArguments - Cabal.NumericUnderscores -> Just NumericUnderscores - Cabal.QuantifiedConstraints -> Just QuantifiedConstraints - Cabal.StarIsType -> Just StarIsType - Cabal.EmptyDataDeriving -> Just EmptyDataDeriving + Cabal.OverlappingInstances -> Just OverlappingInstances + Cabal.UndecidableInstances -> Just UndecidableInstances + Cabal.IncoherentInstances -> Just IncoherentInstances + Cabal.DoRec -> Just RecursiveDo + Cabal.RecursiveDo -> Just RecursiveDo + Cabal.ParallelListComp -> Just ParallelListComp + Cabal.MultiParamTypeClasses -> Just MultiParamTypeClasses + Cabal.MonomorphismRestriction -> Just MonomorphismRestriction + Cabal.FunctionalDependencies -> Just FunctionalDependencies + Cabal.Rank2Types -> Just RankNTypes + Cabal.RankNTypes -> Just RankNTypes + Cabal.PolymorphicComponents -> Just RankNTypes + Cabal.ExistentialQuantification -> Just ExistentialQuantification + Cabal.ScopedTypeVariables -> Just ScopedTypeVariables + Cabal.PatternSignatures -> Just ScopedTypeVariables + Cabal.ImplicitParams -> Just ImplicitParams + Cabal.FlexibleContexts -> Just FlexibleContexts + Cabal.FlexibleInstances -> Just FlexibleInstances + Cabal.EmptyDataDecls -> Just EmptyDataDecls + Cabal.CPP -> Just Cpp + Cabal.KindSignatures -> Just KindSignatures + Cabal.BangPatterns -> Just BangPatterns + Cabal.TypeSynonymInstances -> Just TypeSynonymInstances + Cabal.TemplateHaskell -> Just TemplateHaskell + Cabal.ForeignFunctionInterface -> Just ForeignFunctionInterface + Cabal.Arrows -> Just Arrows + Cabal.ImplicitPrelude -> Just ImplicitPrelude + Cabal.PatternGuards -> Just PatternGuards + Cabal.GeneralizedNewtypeDeriving -> Just GeneralizedNewtypeDeriving + Cabal.GeneralisedNewtypeDeriving -> Just GeneralizedNewtypeDeriving + Cabal.MagicHash -> Just MagicHash + Cabal.TypeFamilies -> Just TypeFamilies + Cabal.StandaloneDeriving -> Just StandaloneDeriving + Cabal.UnicodeSyntax -> Just UnicodeSyntax + Cabal.UnliftedFFITypes -> Just UnliftedFFITypes + Cabal.InterruptibleFFI -> Just InterruptibleFFI + Cabal.CApiFFI -> Just CApiFFI + Cabal.LiberalTypeSynonyms -> Just LiberalTypeSynonyms + Cabal.TypeOperators -> Just TypeOperators + Cabal.RecordWildCards -> Just RecordWildCards +#if MIN_VERSION_ghc_boot_th(9,4,1) + Cabal.RecordPuns -> Just NamedFieldPuns + Cabal.NamedFieldPuns -> Just NamedFieldPuns +#else + Cabal.RecordPuns -> Just RecordPuns + Cabal.NamedFieldPuns -> Just RecordPuns +#endif + Cabal.DisambiguateRecordFields -> Just DisambiguateRecordFields + Cabal.TraditionalRecordSyntax -> Just TraditionalRecordSyntax + Cabal.OverloadedStrings -> Just OverloadedStrings + Cabal.GADTs -> Just GADTs + Cabal.GADTSyntax -> Just GADTSyntax + Cabal.RelaxedPolyRec -> Just RelaxedPolyRec + Cabal.ExtendedDefaultRules -> Just ExtendedDefaultRules + Cabal.UnboxedTuples -> Just UnboxedTuples + Cabal.DeriveDataTypeable -> Just DeriveDataTypeable + Cabal.AutoDeriveTypeable -> Just DeriveDataTypeable + Cabal.DeriveGeneric -> Just DeriveGeneric + Cabal.DefaultSignatures -> Just DefaultSignatures + Cabal.InstanceSigs -> Just InstanceSigs + Cabal.ConstrainedClassMethods -> Just ConstrainedClassMethods + Cabal.PackageImports -> Just PackageImports + Cabal.ImpredicativeTypes -> Just ImpredicativeTypes + Cabal.PostfixOperators -> Just PostfixOperators + Cabal.QuasiQuotes -> Just QuasiQuotes + Cabal.TransformListComp -> Just TransformListComp + Cabal.MonadComprehensions -> Just MonadComprehensions + Cabal.ViewPatterns -> Just ViewPatterns + Cabal.TupleSections -> Just TupleSections + Cabal.GHCForeignImportPrim -> Just GHCForeignImportPrim + Cabal.NPlusKPatterns -> Just NPlusKPatterns + Cabal.DoAndIfThenElse -> Just DoAndIfThenElse + Cabal.MultiWayIf -> Just MultiWayIf + Cabal.LambdaCase -> Just LambdaCase + Cabal.RebindableSyntax -> Just RebindableSyntax + Cabal.ExplicitForAll -> Just ExplicitForAll + Cabal.DatatypeContexts -> Just DatatypeContexts + Cabal.MonoLocalBinds -> Just MonoLocalBinds + Cabal.DeriveFunctor -> Just DeriveFunctor + Cabal.DeriveTraversable -> Just DeriveTraversable + Cabal.DeriveFoldable -> Just DeriveFoldable + Cabal.NondecreasingIndentation -> Just NondecreasingIndentation + Cabal.ConstraintKinds -> Just ConstraintKinds + Cabal.PolyKinds -> Just PolyKinds + Cabal.DataKinds -> Just DataKinds + Cabal.ParallelArrays -> Just ParallelArrays + Cabal.RoleAnnotations -> Just RoleAnnotations + Cabal.OverloadedLists -> Just OverloadedLists + Cabal.EmptyCase -> Just EmptyCase + Cabal.NegativeLiterals -> Just NegativeLiterals + Cabal.BinaryLiterals -> Just BinaryLiterals + Cabal.NumDecimals -> Just NumDecimals + Cabal.NullaryTypeClasses -> Just NullaryTypeClasses + Cabal.ExplicitNamespaces -> Just ExplicitNamespaces + Cabal.AllowAmbiguousTypes -> Just AllowAmbiguousTypes + Cabal.JavaScriptFFI -> Just JavaScriptFFI + Cabal.PatternSynonyms -> Just PatternSynonyms + Cabal.PartialTypeSignatures -> Just PartialTypeSignatures + Cabal.NamedWildCards -> Just NamedWildCards + Cabal.DeriveAnyClass -> Just DeriveAnyClass + Cabal.DeriveLift -> Just DeriveLift + Cabal.StaticPointers -> Just StaticPointers + Cabal.StrictData -> Just StrictData + Cabal.Strict -> Just Strict + Cabal.ApplicativeDo -> Just ApplicativeDo + Cabal.DuplicateRecordFields -> Just DuplicateRecordFields + Cabal.TypeApplications -> Just TypeApplications + Cabal.TypeInType -> Just TypeInType + Cabal.UndecidableSuperClasses -> Just UndecidableSuperClasses +#if MIN_VERSION_ghc_boot_th(9,2,1) + Cabal.MonadFailDesugaring -> Nothing +#else + Cabal.MonadFailDesugaring -> Just MonadFailDesugaring +#endif + Cabal.TemplateHaskellQuotes -> Just TemplateHaskellQuotes + Cabal.OverloadedLabels -> Just OverloadedLabels + Cabal.TypeFamilyDependencies -> Just TypeFamilyDependencies + Cabal.DerivingStrategies -> Just DerivingStrategies + Cabal.DerivingVia -> Just DerivingVia + Cabal.UnboxedSums -> Just UnboxedSums + Cabal.HexFloatLiterals -> Just HexFloatLiterals + Cabal.BlockArguments -> Just BlockArguments + Cabal.NumericUnderscores -> Just NumericUnderscores + Cabal.QuantifiedConstraints -> Just QuantifiedConstraints + Cabal.StarIsType -> Just StarIsType + Cabal.EmptyDataDeriving -> Just EmptyDataDeriving #if __GLASGOW_HASKELL__ >= 810 - Cabal.CUSKs -> Just CUSKs - Cabal.ImportQualifiedPost -> Just ImportQualifiedPost - Cabal.StandaloneKindSignatures -> Just StandaloneKindSignatures - Cabal.UnliftedNewtypes -> Just UnliftedNewtypes + Cabal.CUSKs -> Just CUSKs + Cabal.ImportQualifiedPost -> Just ImportQualifiedPost + Cabal.StandaloneKindSignatures -> Just StandaloneKindSignatures + Cabal.UnliftedNewtypes -> Just UnliftedNewtypes #endif #if __GLASGOW_HASKELL__ >= 900 - Cabal.LexicalNegation -> Just LexicalNegation - Cabal.QualifiedDo -> Just QualifiedDo - Cabal.LinearTypes -> Just LinearTypes + Cabal.LexicalNegation -> Just LexicalNegation + Cabal.QualifiedDo -> Just QualifiedDo + Cabal.LinearTypes -> Just LinearTypes +#endif +#if __GLASGOW_HASKELL__ >= 902 + Cabal.FieldSelectors -> Just FieldSelectors + Cabal.OverloadedRecordDot -> Just OverloadedRecordDot + Cabal.UnliftedDatatypes -> Just UnliftedDatatypes +#endif +#if __GLASGOW_HASKELL__ >= 904 + Cabal.OverloadedRecordUpdate -> Just OverloadedRecordUpdate + Cabal.AlternativeLayoutRule -> Just AlternativeLayoutRule + Cabal.AlternativeLayoutRuleTransitional -> Just AlternativeLayoutRuleTransitional + Cabal.RelaxedLayout -> Just RelaxedLayout #endif -- GHC extensions, parsed by both Cabal and GHC, but don't have an Extension constructor - Cabal.Safe -> Nothing - Cabal.Trustworthy -> Nothing - Cabal.Unsafe -> Nothing + Cabal.Safe -> Nothing + Cabal.Trustworthy -> Nothing + Cabal.Unsafe -> Nothing -- non-GHC extensions - Cabal.Generics -> Nothing - Cabal.ExtensibleRecords -> Nothing - Cabal.RestrictedTypeSynonyms -> Nothing - Cabal.HereDocuments -> Nothing - Cabal.MonoPatBinds -> Nothing - Cabal.XmlSyntax -> Nothing - Cabal.RegularPatterns -> Nothing - Cabal.SafeImports -> Nothing - Cabal.NewQualifiedOperators -> Nothing + Cabal.Generics -> Nothing + Cabal.ExtensibleRecords -> Nothing + Cabal.RestrictedTypeSynonyms -> Nothing + Cabal.HereDocuments -> Nothing + Cabal.MonoPatBinds -> Nothing + Cabal.XmlSyntax -> Nothing + Cabal.RegularPatterns -> Nothing + Cabal.SafeImports -> Nothing + Cabal.NewQualifiedOperators -> Nothing -- | Convert 'Cabal.KnownExtension' to 'SafeHaskellExtension'. toSafeExtensions :: Cabal.KnownExtension -> Maybe SafeHaskellExtension diff --git a/src/Extensions/Module.hs b/src/Extensions/Module.hs index f1475fd..709f565 100644 --- a/src/Extensions/Module.hs +++ b/src/Extensions/Module.hs @@ -1,5 +1,5 @@ {- | -Copyright: (c) 2020 Kowainik +Copyright: (c) 2020-2022 Kowainik SPDX-License-Identifier: MPL-2.0 Maintainer: Kowainik diff --git a/src/Extensions/Package.hs b/src/Extensions/Package.hs index 7e7415a..417141e 100644 --- a/src/Extensions/Package.hs +++ b/src/Extensions/Package.hs @@ -1,5 +1,5 @@ {- | -Copyright: (c) 2020 Kowainik +Copyright: (c) 2020-2022 Kowainik SPDX-License-Identifier: MPL-2.0 Maintainer: Kowainik diff --git a/src/Extensions/Types.hs b/src/Extensions/Types.hs index 042eec3..e3b26e6 100644 --- a/src/Extensions/Types.hs +++ b/src/Extensions/Types.hs @@ -1,10 +1,10 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE CPP #-} {- | -Copyright: (c) 2020 Kowainik +Copyright: (c) 2020-2022 Kowainik SPDX-License-Identifier: MPL-2.0 Maintainer: Kowainik @@ -173,7 +173,9 @@ showOnOffExtension = \case showExtension :: Extension -> Text showExtension = \case Cpp -> "CPP" +#if !MIN_VERSION_ghc_boot_th(9,4,1) RecordPuns -> "NamedFieldPuns" +#endif ext -> Text.pack $ show ext {- | Parse 'OnOffExtension' from a string that specifies extension. @@ -193,12 +195,14 @@ doesn't always work since some extensions are named differently. readExtension :: String -> Maybe Extension readExtension = \case "GeneralisedNewtypeDeriving" -> Just GeneralizedNewtypeDeriving - "NamedFieldPuns" -> Just RecordPuns - "RecordPuns" -> Nothing - "Rank2Types" -> Just RankNTypes - "CPP" -> Just Cpp - "Cpp" -> Nothing - s -> readMaybe s +#if !MIN_VERSION_ghc_boot_th(9,4,1) + "NamedFieldPuns" -> Just RecordPuns + "RecordPuns" -> Nothing +#endif + "Rank2Types" -> Just RankNTypes + "CPP" -> Just Cpp + "Cpp" -> Nothing + s -> readMaybe s {- | Take accumulated 'OnOffExtension's, and merge them into one 'Set', excluding enabling of 'default2010Extensions'.