Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a compile error with recent Cabal #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/Language/Haskell/Source/Enumerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.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)
import Distribution.PackageDescription.Parse (readGenericPackageDescription)
Expand Down Expand Up @@ -71,17 +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
#else
sourcePaths pkg = nub $ concatMap ($ pkg) pathExtractors
where
pathExtractors =
[ maybe [] (hsSourceDirs . libBuildInfo . condTreeData) . condLibrary
, concatMap (hsSourceDirs . buildInfo . condTreeData . snd) .
condExecutables
, concatMap (hsSourceDirs . testBuildInfo . condTreeData . snd) .
condTestSuites
, concatMap (hsSourceDirs . benchmarkBuildInfo . condTreeData . snd) .
condBenchmarks
]
#endif

#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
, concatMap (hsSourceDirs . testBuildInfo . condTreeData . snd) .
condTestSuites
, concatMap (hsSourceDirs . benchmarkBuildInfo . condTreeData . snd) .
condBenchmarks
]

(<&&>) :: Applicative f => f Bool -> f Bool -> f Bool
(<&&>) = liftA2 (&&)
Expand Down