From 11a18a8cbf2b620b72928509770c506d3b2b7c6d Mon Sep 17 00:00:00 2001 From: Hiroki Tokunaga Date: Thu, 10 Nov 2022 15:21:46 +0900 Subject: [PATCH 1/3] Fix a compile error with recent Cabal --- src/Language/Haskell/Source/Enumerator.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Language/Haskell/Source/Enumerator.hs b/src/Language/Haskell/Source/Enumerator.hs index 2e3c229..f9f853e 100644 --- a/src/Language/Haskell/Source/Enumerator.hs +++ b/src/Language/Haskell/Source/Enumerator.hs @@ -12,7 +12,10 @@ import Distribution.PackageDescription import qualified Distribution.Verbosity as Verbosity import System.Directory import System.FilePath -#if MIN_VERSION_Cabal(2,2,0) +#if MIN_VERSION_Cabal(3,6,0) +import Distribution.Utils.Path +import Distribution.PackageDescription.Parsec (readGenericPackageDescription) +#elif MIN_VERSION_Cabal(2,2,0) import Distribution.PackageDescription.Parsec (readGenericPackageDescription) #elif MIN_VERSION_Cabal(2,0,0) import Distribution.PackageDescription.Parse (readGenericPackageDescription) @@ -71,7 +74,11 @@ hasHaskellExtension :: FilePath -> Bool hasHaskellExtension path = ".hs" `isSuffixOf` path || ".lhs" `isSuffixOf` path sourcePaths :: GenericPackageDescription -> [FilePath] +#if MIN_VERSION_Cabal(3,6,0) +sourcePaths pkg = nub $ concatMap ($ pkg) $ fmap (fmap getSymbolicPath .) pathExtractors +#else sourcePaths pkg = nub $ concatMap ($ pkg) pathExtractors +#endif where pathExtractors = [ maybe [] (hsSourceDirs . libBuildInfo . condTreeData) . condLibrary From c63f5e37e12e7efcc27e9d20e2a011ea627bc8e5 Mon Sep 17 00:00:00 2001 From: Hiroki Tokunaga Date: Fri, 11 Nov 2022 05:34:18 +0900 Subject: [PATCH 2/3] Fix the file format --- src/Language/Haskell/Source/Enumerator.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Language/Haskell/Source/Enumerator.hs b/src/Language/Haskell/Source/Enumerator.hs index f9f853e..221e475 100644 --- a/src/Language/Haskell/Source/Enumerator.hs +++ b/src/Language/Haskell/Source/Enumerator.hs @@ -79,8 +79,13 @@ sourcePaths pkg = nub $ concatMap ($ pkg) $ fmap (fmap getSymbolicPath .) pathEx #else sourcePaths pkg = nub $ concatMap ($ pkg) pathExtractors #endif - where - pathExtractors = + +#if MIN_VERSION_Cabal (3,6,0) +pathExtractors :: [GenericPackageDescription -> [SymbolicPath PackageDir SourceDir]] +#else +pathExtractors :: [GenericPackageDescription -> [FilePath]] +#endif +pathExtractors = [ maybe [] (hsSourceDirs . libBuildInfo . condTreeData) . condLibrary , concatMap (hsSourceDirs . buildInfo . condTreeData . snd) . condExecutables From 9fd571e6ce881d658e94f774f2443a55fef1b93e Mon Sep 17 00:00:00 2001 From: Hiroki Tokunaga Date: Fri, 11 Nov 2022 05:45:55 +0900 Subject: [PATCH 3/3] Apply the formatter --- src/Language/Haskell/Source/Enumerator.hs | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Language/Haskell/Source/Enumerator.hs b/src/Language/Haskell/Source/Enumerator.hs index 221e475..1959555 100644 --- a/src/Language/Haskell/Source/Enumerator.hs +++ b/src/Language/Haskell/Source/Enumerator.hs @@ -13,8 +13,8 @@ import qualified Distribution.Verbosity as Verbosity import System.Directory import System.FilePath #if MIN_VERSION_Cabal(3,6,0) -import Distribution.Utils.Path import Distribution.PackageDescription.Parsec (readGenericPackageDescription) +import Distribution.Utils.Path #elif MIN_VERSION_Cabal(2,2,0) import Distribution.PackageDescription.Parsec (readGenericPackageDescription) #elif MIN_VERSION_Cabal(2,0,0) @@ -74,26 +74,27 @@ hasHaskellExtension :: FilePath -> Bool hasHaskellExtension path = ".hs" `isSuffixOf` path || ".lhs" `isSuffixOf` path sourcePaths :: GenericPackageDescription -> [FilePath] -#if MIN_VERSION_Cabal(3,6,0) -sourcePaths pkg = nub $ concatMap ($ pkg) $ fmap (fmap getSymbolicPath .) pathExtractors +#if MIN_VERSION_Cabal(3,6,0) +sourcePaths pkg = + nub $ concatMap ($ pkg) $ fmap (fmap getSymbolicPath .) pathExtractors #else sourcePaths pkg = nub $ concatMap ($ pkg) pathExtractors #endif #if MIN_VERSION_Cabal (3,6,0) -pathExtractors :: [GenericPackageDescription -> [SymbolicPath PackageDir SourceDir]] +pathExtractors :: + [GenericPackageDescription -> [SymbolicPath PackageDir SourceDir]] #else pathExtractors :: [GenericPackageDescription -> [FilePath]] #endif pathExtractors = - [ maybe [] (hsSourceDirs . libBuildInfo . condTreeData) . condLibrary - , concatMap (hsSourceDirs . buildInfo . condTreeData . snd) . - condExecutables - , concatMap (hsSourceDirs . testBuildInfo . condTreeData . snd) . - condTestSuites - , concatMap (hsSourceDirs . benchmarkBuildInfo . condTreeData . snd) . - condBenchmarks - ] + [ maybe [] (hsSourceDirs . libBuildInfo . condTreeData) . condLibrary + , concatMap (hsSourceDirs . buildInfo . condTreeData . snd) . condExecutables + , concatMap (hsSourceDirs . testBuildInfo . condTreeData . snd) . + condTestSuites + , concatMap (hsSourceDirs . benchmarkBuildInfo . condTreeData . snd) . + condBenchmarks + ] (<&&>) :: Applicative f => f Bool -> f Bool -> f Bool (<&&>) = liftA2 (&&)