extensions 0.1.0.3 → 0.1.1.0
raw patch · 6 files changed
+40/−24 lines, 6 filesdep +Cabal-syntaxdep −Cabaldep ~basedep ~ghc-boot-thdep ~hedgehogPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: Cabal-syntax
Dependencies removed: Cabal
Dependency ranges changed: base, ghc-boot-th, hedgehog, optparse-applicative
API changes (from Hackage documentation)
- Extensions.Module: commentP :: Parser [a]
+ Extensions.Module: commentP :: Parser String
Files
- CHANGELOG.md +12/−0
- extensions.cabal +9/−9
- src/Extensions/Cabal.hs +2/−5
- src/Extensions/Module.hs +10/−10
- src/Extensions/Types.hs +1/−0
- test/Test/Extensions/Module.hs +6/−0
CHANGELOG.md view
@@ -3,6 +3,18 @@ `extensions` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.1.1.0 — Sep 27, 2025++* Support `PolymorphicComponents`++* Parse nested comments++* Support GHC 9.12++* Depend on `Cabal-syntax`, not `Cabal`++* Add support for `Cabal-syntax` `3.16`+ ## 0.1.0.3 — Sep 28, 2024 * Support `Cabal` `3.14` (only)
extensions.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: extensions-version: 0.1.0.3+version: 0.1.1.0 synopsis: Parse Haskell Language Extensions description: Parse Haskell Language Extensions. See [README.md](https://github.com/kowainik/extensions#extensions) for more details.@@ -34,7 +34,7 @@ location: https://github.com/kowainik/extensions.git common common-options- build-depends: base >= 4.13.0.0 && < 4.21+ build-depends: base >= 4.13.0.0 && < 4.22 ghc-options: -Wall -Wcompat@@ -86,19 +86,19 @@ build-depends: bytestring >= 0.10 && < 0.13 -- We need to pin a single major version of- -- Cabal here because the main reason we use- -- Cabal is for its list of extensions. Later+ -- Cabal-syntax here because the main reason we use+ -- Cabal-syntax is for its list of extensions. Later -- versions have strictly more extensions, and -- we'll have missing patterns if we try to -- support more than one major version. If -- this causes problems in practice let's -- revisit this decision and come up with -- another approach.- , Cabal ^>= 3.14- , containers >= 0.6 && < 0.8+ , Cabal-syntax >= 3.14 && < 3.18+ , containers >= 0.6 && < 0.9 , directory ^>= 1.3 , filepath >= 1.4 && < 1.6- , ghc-boot-th >= 8.8.1 && < 9.11+ , ghc-boot-th >= 8.8.1 && < 9.13 , parsec ^>= 3.1 , text >= 1.2.3 && < 2.2 @@ -131,9 +131,9 @@ , bytestring , containers , ghc-boot-th- , hedgehog >= 1.0 && < 1.5+ , hedgehog >= 1.0 && < 1.6 , hspec- , hspec-hedgehog >= 0.0.1 && < 0.2+ , hspec-hedgehog >= 0.0.1 && < 0.4 , text ghc-options: -threaded -rtsopts
src/Extensions/Cabal.hs view
@@ -41,7 +41,7 @@ import Distribution.Types.Library (Library (..)) import Distribution.Types.TestSuite (TestSuite (..)) import Distribution.Types.TestSuiteInterface (TestSuiteInterface (..))-#if MIN_VERSION_Cabal(3,6,0)+#if MIN_VERSION_Cabal_syntax(3,6,0) import Distribution.Utils.Path (getSymbolicPath) #endif import GHC.LanguageExtensions.Type (Extension (..))@@ -147,7 +147,7 @@ condTreeToExtensions extractModules extractBuildInfo condTree = do let comp = condTreeData condTree let buildInfo = extractBuildInfo comp-#if MIN_VERSION_Cabal(3,6,0)+#if MIN_VERSION_Cabal_syntax(3,6,0) let srcDirs = getSymbolicPath <$> hsSourceDirs buildInfo #else let srcDirs = hsSourceDirs buildInfo@@ -408,9 +408,6 @@ Cabal.ListTuplePuns -> Nothing #endif #if __GLASGOW_HASKELL__ >= 912- -- This branch cannot be satisfied yet but we're including it so- -- we don't forget to enable RequiredTypeArguments when it- -- becomes available. Cabal.NamedDefaults -> Just NamedDefaults Cabal.MultilineStrings -> Just MultilineStrings Cabal.OrPatterns -> Just OrPatterns
src/Extensions/Module.hs view
@@ -26,7 +26,7 @@ import Data.Char (toLower, toUpper) import Data.Either (partitionEithers) import Data.Foldable (traverse_)-import Data.Functor ((<&>))+import Data.Functor ((<&>), void) import Data.List (nub) import Data.List.NonEmpty (NonEmpty (..)) import System.Directory (doesFileExist)@@ -109,8 +109,8 @@ extensionsP = concat <$> ( newLines *> manyTill- (try singleExtensionsP <|> try optionsGhcP <|> try commentP <|> try cppP)- (eof <|> (() <$ manyTill endOfLine letter))+ (try singleExtensionsP <|> try optionsGhcP <|> [] <$ try commentP <|> try cppP)+ (eof <|> void (manyTill endOfLine letter)) ) {- | Single LANGUAGE pragma parser.@@ -186,16 +186,16 @@ \-\} @ -}-commentP :: Parser [a]+commentP :: Parser String commentP = newLines *> (try singleLineCommentP <|> try multiLineCommentP) <* newLines where- singleLineCommentP :: Parser [a]- singleLineCommentP = [] <$- (string "--" *> manyTill anyChar (try (() <$ endOfLine) <|> eof))+ singleLineCommentP :: Parser String+ singleLineCommentP =+ string "--" *> manyTill anyChar (try (void endOfLine) <|> eof) - multiLineCommentP :: Parser [a]- multiLineCommentP = [] <$- (string "{-" *> manyTill anyChar (try $ string "-}"))+ multiLineCommentP :: Parser String+ multiLineCommentP =+ concat <$> (string "{-" *> manyTill (try multiLineCommentP <|> (: []) <$> anyChar) (try (string "-}"))) {- | CPP syntax parser.
src/Extensions/Types.hs view
@@ -200,6 +200,7 @@ "RecordPuns" -> Nothing #endif "Rank2Types" -> Just RankNTypes+ "PolymorphicComponents" -> Just RankNTypes "CPP" -> Just Cpp "Cpp" -> Nothing s -> readMaybe s
test/Test/Extensions/Module.hs view
@@ -69,6 +69,9 @@ itShouldParseOnOff "{-# LANGUAGE NondecreasingIndentation #-}" [On NondecreasingIndentation]+ itShouldParseOnOff+ "{-# LANGUAGE PolymorphicComponents #-}"+ [On RankNTypes] itShouldParse "{-#language TypeApplications#-}" [TypeApplications] itShouldParse "{-# LANGUAGE TypeApplications, LambdaCase#-}" [TypeApplications, LambdaCase] itShouldParse "{-# LANGUAGE TypeApplications , LambdaCase #-}" [TypeApplications, LambdaCase]@@ -420,6 +423,9 @@ { parsedExtensionsAll = [On Cpp] , parsedExtensionsSafe = Just Trustworthy }+ itShouldParse "{- {- -} -}" []+ itShouldParse "{- {-# LANGUAGE LambdaCase #-} -}" []+ itShouldParse "{-# LANGUAGE LambdaCase {- -} #-}" [LambdaCase] itShouldParse :: String -> [Extension] -> SpecWith (Arg Expectation) itShouldParse s = itShouldParseOnOff s . map On