Making cabalDependPackages pure.
This commit is contained in:
parent
14ea5a6d71
commit
431e3fa904
2
Cabal.hs
2
Cabal.hs
@ -47,7 +47,7 @@ fromCabal ghcOptions = do
|
|||||||
idirs = case hsSourceDirs of
|
idirs = case hsSourceDirs of
|
||||||
[] -> [cdir,owdir]
|
[] -> [cdir,owdir]
|
||||||
dirs -> map (cdir </>) dirs ++ [owdir]
|
dirs -> map (cdir </>) dirs ++ [owdir]
|
||||||
depPkgs <- removeMe cfile <$> cabalDependPackages cabal
|
let depPkgs = removeMe cfile $ cabalDependPackages cabal
|
||||||
return (gopts,idirs,depPkgs)
|
return (gopts,idirs,depPkgs)
|
||||||
|
|
||||||
removeMe :: FilePath -> [String] -> [String]
|
removeMe :: FilePath -> [String] -> [String]
|
||||||
|
@ -48,8 +48,8 @@ allDependsOfDescription pd =
|
|||||||
getDependencyPackageName :: Dependency -> String
|
getDependencyPackageName :: Dependency -> String
|
||||||
getDependencyPackageName (Dependency (PackageName n) _) = n
|
getDependencyPackageName (Dependency (PackageName n) _) = n
|
||||||
|
|
||||||
cabalDependPackages :: GenericPackageDescription -> IO [String]
|
cabalDependPackages :: GenericPackageDescription -> [String]
|
||||||
cabalDependPackages =
|
cabalDependPackages =
|
||||||
return . toList . fromList
|
toList . fromList
|
||||||
. map getDependencyPackageName
|
. map getDependencyPackageName
|
||||||
. allDependsOfDescription
|
. allDependsOfDescription
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module CabalApiSpec where
|
module CabalApiSpec where
|
||||||
|
|
||||||
|
import Control.Applicative
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import CabalApi
|
import CabalApi
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ spec :: Spec
|
|||||||
spec = do
|
spec = do
|
||||||
describe "cabalDependPackages" $ do
|
describe "cabalDependPackages" $ do
|
||||||
it "extracts dependent packages" $ do
|
it "extracts dependent packages" $ do
|
||||||
pkgs <- cabalParseFile "test/data/cabalapi.cabal" >>= cabalDependPackages
|
pkgs <- cabalDependPackages <$> cabalParseFile "test/data/cabalapi.cabal"
|
||||||
pkgs `shouldBe` ["Cabal","base","containers","convertible","directory","filepath","ghc","ghc-paths","ghc-syb-utils","hlint","hspec","io-choice","old-time","process","regex-posix","syb","time","transformers"]
|
pkgs `shouldBe` ["Cabal","base","containers","convertible","directory","filepath","ghc","ghc-paths","ghc-syb-utils","hlint","hspec","io-choice","old-time","process","regex-posix","syb","time","transformers"]
|
||||||
|
|
||||||
describe "cabalBuildInfo" $ do
|
describe "cabalBuildInfo" $ do
|
||||||
|
Loading…
Reference in New Issue
Block a user