cabal-lenses 0.4.9 → 0.5.0
raw patch · 3 files changed
+23/−18 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ CabalLenses.Utils: findNewDistDir :: FilePath -> IO (Maybe FilePath)
- CabalLenses.PackageDescription: condTreeComponentsL :: forall v_aoBq c_aoBr a_aoBs v_apVs. Lens (CondTree v_aoBq c_aoBr a_aoBs) (CondTree v_apVs c_aoBr a_aoBs) [(Condition v_aoBq, CondTree v_aoBq c_aoBr a_aoBs, Maybe (CondTree v_aoBq c_aoBr a_aoBs))] [(Condition v_apVs, CondTree v_apVs c_aoBr a_aoBs, Maybe (CondTree v_apVs c_aoBr a_aoBs))]
+ CabalLenses.PackageDescription: condTreeComponentsL :: forall v_aeUv c_aeUw a_aeUx v_am5v. Lens (CondTree v_aeUv c_aeUw a_aeUx) (CondTree v_am5v c_aeUw a_aeUx) [(Condition v_aeUv, CondTree v_aeUv c_aeUw a_aeUx, Maybe (CondTree v_aeUv c_aeUw a_aeUx))] [(Condition v_am5v, CondTree v_am5v c_aeUw a_aeUx, Maybe (CondTree v_am5v c_aeUw a_aeUx))]
- CabalLenses.PackageDescription: condTreeConstraintsL :: forall v_aoBq c_aoBr a_aoBs. Lens' (CondTree v_aoBq c_aoBr a_aoBs) c_aoBr
+ CabalLenses.PackageDescription: condTreeConstraintsL :: forall v_aeUv c_aeUw a_aeUx. Lens' (CondTree v_aeUv c_aeUw a_aeUx) c_aeUw
- CabalLenses.PackageDescription: condTreeDataL :: forall v_aoBq c_aoBr a_aoBs. Lens' (CondTree v_aoBq c_aoBr a_aoBs) a_aoBs
+ CabalLenses.PackageDescription: condTreeDataL :: forall v_aeUv c_aeUw a_aeUx. Lens' (CondTree v_aeUv c_aeUw a_aeUx) a_aeUx
Files
- CHANGELOG +4/−0
- cabal-lenses.cabal +3/−2
- lib/CabalLenses/Utils.hs +16/−16
CHANGELOG view
@@ -1,3 +1,7 @@+0.5.0+-----+* Add 'findNewDistDir', 'findDistDir' and 'findPackageDB' now return absolute paths+ 0.4.7 ----- * Raise upper bounds of dependencies
cabal-lenses.cabal view
@@ -1,5 +1,5 @@ name: cabal-lenses-version: 0.4.9+version: 0.5.0 cabal-version: >=1.9.2 build-type: Simple license: BSD3@@ -11,7 +11,8 @@ the <https://hackage.haskell.org/package/Cabal Cabal> library. category: Utils, Development author: Daniel Trstenjak-tested-with: GHC ==7.6.2 GHC ==7.6.3 GHC ==7.8.3 GHC ==7.10.1 GHC ==8.0.1+tested-with: GHC ==7.6.2 GHC ==7.6.3 GHC ==7.8.3 GHC ==7.10.1+ GHC ==8.0.1 GHC ==8.2.1 extra-source-files: README.md CHANGELOG
lib/CabalLenses/Utils.hs view
@@ -4,6 +4,7 @@ ( findCabalFile , findPackageDB , findDistDir+ , findNewDistDir ) where import Control.Monad.Trans.Either (EitherT, left, right, runEitherT)@@ -59,7 +60,7 @@ -- | Find the package database of the cabal sandbox from the given cabal file.--- The returned file path is relative to the directory of the cabal file.+-- The returned file path is absolute. findPackageDB :: FilePath -> EitherT Error IO (Maybe FilePath) findPackageDB cabalFile = do cabalDir <- io $ absoluteDirectory cabalFile@@ -69,20 +70,19 @@ then do packageDB <- io $ readPackageDB sandboxConfig case packageDB of- Just db -> right . Just $ stripPrefix cabalDir db+ Just db -> right . Just $ db _ -> left $ "Couldn't find field 'package-db: ' in " ++ (show sandboxConfig) else right Nothing where -- | reads the 'package-db: ' field from the sandbox config file and returns the value of the field- readPackageDB :: FP.FilePath -> IO (Maybe FP.FilePath)+ readPackageDB :: FP.FilePath -> IO (Maybe FilePath) readPackageDB sandboxConfig = do lines <- lines <$> Strict.readFile (FP.encodeString sandboxConfig) return $ do- line <- L.find (package_db `L.isPrefixOf`) lines- packageDB <- L.stripPrefix package_db line- return $ FP.decodeString packageDB+ line <- L.find (package_db `L.isPrefixOf`) lines+ L.stripPrefix package_db line sandbox_config = FP.decodeString "cabal.sandbox.config" package_db = "package-db: "@@ -90,8 +90,7 @@ -- | Find the dist directory of the cabal build from the given cabal file. For a non sandboxed -- build it's just the directory 'dist' in the cabal build directory. For a sandboxed build--- it's the directory 'dist/dist-sandbox-*'. The returned file path is relative to the--- directory of the cabal file.+-- it's the directory 'dist/dist-sandbox-*'. The returned file path is absolute. findDistDir :: FilePath -> IO (Maybe FilePath) findDistDir cabalFile = do cabalDir <- absoluteDirectory cabalFile@@ -100,7 +99,7 @@ if hasDistDir then do files <- filterM FS.isDirectory =<< (FS.listDirectory distDir)- return $ (stripPrefix cabalDir) <$> maybe (Just distDir) Just (L.find isSandboxDistDir files)+ return $ FP.encodeString <$> maybe (Just distDir) Just (L.find isSandboxDistDir files) else return Nothing where@@ -108,13 +107,14 @@ "dist-sandbox-" `L.isPrefixOf` (FP.encodeString . FP.filename $ file) -stripPrefix :: FP.FilePath -> FP.FilePath -> FilePath-stripPrefix prefix file- | Just stripped <- FP.stripPrefix prefix file- = FP.encodeString stripped-- | otherwise- = FP.encodeString file+-- | Find the new style dist directory of the cabal build from the given cabal file.+-- The returned file path is absolute.+findNewDistDir :: FilePath -> IO (Maybe FilePath)+findNewDistDir cabalFile = do+ cabalDir <- absoluteDirectory cabalFile+ let distDir = cabalDir </> FP.decodeString "dist-newstyle"+ hasDistDir <- FS.isDirectory distDir+ return $ if hasDistDir then Just . FP.encodeString $ distDir else Nothing absoluteDirectory :: FilePath -> IO FP.FilePath