packages feed

cabal-cargs 0.9.1 → 1.0.0

raw patch · 4 files changed

+45/−43 lines, 4 filesdep −eitherdep ~cabal-lensesPVP ok

version bump matches the API change (PVP)

Dependencies removed: either

Dependency ranges changed: cabal-lenses

API changes (from Hackage documentation)

Files

CHANGELOG view
@@ -1,3 +1,7 @@+1.0.0+-----+* Migrate from EitherT to ExceptT+ 0.9.1 ----- * Support Cabal 2.2
cabal-cargs.cabal view
@@ -1,17 +1,17 @@-name: cabal-cargs-version: 0.9.1 cabal-version: >=1.9.2-build-type: Simple+name: cabal-cargs+version: 1.0.0 license: BSD3 license-file: LICENSE maintainer: daniel.trstenjak@gmail.com+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 ghc ==8.2.1 ghc ==8.4.2 synopsis: A command line program for extracting compiler arguments from a cabal file. description:     For further details please consult the <https://github.com/dan-t/cabal-cargs README>. 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 GHC ==8.2.1 GHC ==8.4.2+build-type: Simple extra-source-files:     README.md     CHANGELOG@@ -44,43 +44,42 @@         CabalCargs.Format         CabalCargs.Spec         CabalCargs.CompilerArgs+    cpp-options: -DCABAL+    hs-source-dirs: lib+    other-modules:+        CabalCargs.BuildInfo+        Paths_cabal_cargs+    ghc-options: -W     build-depends:         base >=3 && <5,         cmdargs >=0.10.5 && <0.11,         lens >=4.0.1 && <4.17,         directory >=1.0 && <1.4,         transformers >=0.3.0.0 && <0.6,-        either >=4.1.1 && <4.6,         text >=1.1.0.1 && <1.3,         system-filepath >=0.4.9 && <0.5,         system-fileio >=0.3.12 && <0.4,         unordered-containers >=0.2.3.3 && <0.3,-        cabal-lenses >=0.6.0 && <0.8,+        cabal-lenses >=0.8.0 && <0.9,         Cabal >=2.2.0.0 && <2.3,         bytestring >=0.9 && <0.11-    cpp-options: -DCABAL-    hs-source-dirs: lib-    other-modules:-        CabalCargs.BuildInfo-        Paths_cabal_cargs-    ghc-options: -W  executable cabal-cargs     main-is: Main.hs+    hs-source-dirs: exe+    ghc-options: -W     build-depends:         base >=3 && <5,         cabal-cargs -any-    hs-source-dirs: exe-    ghc-options: -W  test-suite tests     type: exitcode-stdio-1.0     main-is: Main.hs+    hs-source-dirs: tests+    ghc-options: -W     build-depends:         base >=3 && <5,         tasty >=0.9.0.1 && <1.2,         tasty-golden >=2.2.0.2 && <2.4,         filepath >=1.3.0.1 && <1.5,         cabal-cargs -any-    hs-source-dirs: tests-    ghc-options: -W
lib/CabalCargs/CompilerArgs.hs view
@@ -16,7 +16,6 @@ import Data.Maybe (maybeToList, listToMaybe) import Control.Lens import qualified Filesystem.Path.CurrentOS as FP-import Filesystem.Path ((</>))  #if __GLASGOW_HASKELL__ < 710 import Control.Applicative ((<$>))
lib/CabalCargs/Spec.hs view
@@ -6,14 +6,14 @@    ) where  import Distribution.PackageDescription (GenericPackageDescription)-import Distribution.PackageDescription.Parsec (parseGenericPackageDescription, runParseResult, ParseResult(..))+import Distribution.PackageDescription.Parsec (parseGenericPackageDescription, runParseResult) import Distribution.Parsec.Common (PWarning) import qualified Distribution.System as Sys import CabalCargs.Args (Args) import qualified CabalCargs.Args as A import qualified CabalCargs.Fields as F import qualified CabalLenses as CL-import Control.Monad.Trans.Either (EitherT, left, right, runEitherT)+import Control.Monad.Trans.Except (ExceptT, throwE, runExceptT) import Control.Monad.IO.Class import Control.Lens import System.Directory (getCurrentDirectory)@@ -57,32 +57,32 @@ --   and a source file have been given. fromCmdArgs :: Args -> IO (Either Error Spec) fromCmdArgs args-   | Just cabalFile <- A.cabalFile args = runEitherT $ do+   | Just cabalFile <- A.cabalFile args = runExceptT $ do       spec        <- fromCabalFile cabalFile       srcSections <- io $ case A.sourceFile args of                                Just srcFile -> findSections srcFile cabalFile (pkgDescrp spec)                                _            -> return [] -      right $ applyCondVars $ spec { sections      = combineSections (args, pkgDescrp spec) srcSections-                                   , fields        = fields_ args-                                   , relativePaths = A.relative args-                                   }+      return $ applyCondVars $ spec { sections      = combineSections (args, pkgDescrp spec) srcSections+                                    , fields        = fields_ args+                                    , relativePaths = A.relative args+                                    } -   | Just sourceFile <- A.sourceFile args = runEitherT $ do+   | Just sourceFile <- A.sourceFile args = runExceptT $ do       spec <- fromSourceFile sourceFile-      right $ applyCondVars $ spec { sections      = combineSections (args, pkgDescrp spec) (sections spec)-                                   , fields        = fields_ args-                                   , relativePaths = A.relative args-                                   }+      return $ applyCondVars $ spec { sections      = combineSections (args, pkgDescrp spec) (sections spec)+                                    , fields        = fields_ args+                                    , relativePaths = A.relative args+                                    } -   | otherwise = runEitherT $ do+   | otherwise = runExceptT $ do       curDir    <- io getCurrentDirectory       cabalFile <- CL.findCabalFile curDir       spec      <- fromCabalFile cabalFile-      right $ applyCondVars $ spec { sections      = sections_ args (pkgDescrp spec)-                                   , fields        = fields_ args-                                   , relativePaths = A.relative args-                                   }+      return $ applyCondVars $ spec { sections      = sections_ args (pkgDescrp spec)+                                    , fields        = fields_ args+                                    , relativePaths = A.relative args+                                    }     where       applyCondVars = applyFlags args . applyOS args . applyArch args@@ -93,13 +93,13 @@ -- --   If a cabal sandbox is present in the directory of the cabal file, then --   the path to its package database is also returned.-fromCabalFile :: FilePath -> EitherT Error IO Spec+fromCabalFile :: FilePath -> ExceptT Error IO Spec fromCabalFile file = do    pkgDescrp <- packageDescription file    pkgDB     <- CL.findPackageDB file    distDir   <- io $ CL.findDistDir file    absFile   <- FP.encodeString <$> io (absoluteFile file)-   right $ Spec+   return $ Spec       { sections      = CL.allSections pkgDescrp       , fields        = F.allFields       , condVars      = CL.fromDefaults pkgDescrp@@ -121,14 +121,14 @@ -- --   If a cabal sandbox is present in the directory of the cabal file, then --   the path to its package database is also returned.-fromSourceFile :: FilePath -> EitherT Error IO Spec+fromSourceFile :: FilePath -> ExceptT Error IO Spec fromSourceFile file = do    cabalFile   <- CL.findCabalFile file    pkgDB       <- CL.findPackageDB cabalFile    distDir     <- io $ CL.findDistDir cabalFile    pkgDescrp   <- packageDescription cabalFile    srcSections <- io $ findSections file cabalFile pkgDescrp-   right $ Spec+   return $ Spec       { sections      = srcSections       , fields        = F.allFields       , condVars      = CL.fromDefaults pkgDescrp@@ -180,14 +180,14 @@       setArch name = spec { condVars = (condVars spec) { CL.arch = name } }  -packageDescription :: FilePath -> EitherT Error IO GenericPackageDescription+packageDescription :: FilePath -> ExceptT Error IO GenericPackageDescription packageDescription file = do    contents <- io $ BS.readFile file    let (warnings, result) = runParseResult $ parseGenericPackageDescription contents    io $ showWarnings warnings    case result of-        Left (_, errors) -> left $ show errors-        Right pkgDescrp  -> right pkgDescrp+        Left (_, errors) -> throwE $ show errors+        Right pkgDescrp  -> return pkgDescrp     where       showWarnings :: [PWarning] -> IO ()