extract-dependencies (empty) → 0.1.0.0
raw patch · 5 files changed
+96/−0 lines, 5 filesdep +Cabaldep +asyncdep +basesetup-changed
Dependencies added: Cabal, async, base, containers, package-description-remote
Files
- LICENSE +22/−0
- Setup.hs +2/−0
- extract-dependencies.cabal +34/−0
- src/Development/ExtractDependencies.hs +18/−0
- src/Main.hs +20/−0
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2015 André Barnabá+++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:+++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.+++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ extract-dependencies.cabal view
@@ -0,0 +1,34 @@+name: extract-dependencies+version: 0.1.0.0+synopsis: Given a hackage package outputs the list of its dependencies.+homepage: https://github.com/yamadapc/stack-run-auto/extract-dependencies+license: MIT+license-file: LICENSE+author: André Barnabá+maintainer: asakeron@gmail.com+copyright: 2015 André Barnabá+category: Development+build-type: Simple+cabal-version: >=1.10++executable extract-dependencies+ hs-source-dirs: src+ main-is: Main.hs+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends: base >= 4.8 && < 5+ , async+ , containers+ , Cabal >= 1.22 && < 2+ , package-description-remote+ default-language: Haskell2010++library+ hs-source-dirs: src+ exposed-modules: Development.ExtractDependencies+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends: base >= 4.8 && < 5+ , async+ , containers+ , Cabal >= 1.22 && < 2+ , package-description-remote+ default-language: Haskell2010
+ src/Development/ExtractDependencies.hs view
@@ -0,0 +1,18 @@+module Development.ExtractDependencies where++import Distribution.Package+import Distribution.PackageDescription+import Distribution.PackageDescription.Parse+import Distribution.PackageDescription.Remote++extractDependencies :: String -> IO [String]+extractDependencies npkg = do+ ppkg <- getPackageLatest npkg+ case ppkg of+ ParseOk _ info ->+ case condLibrary info of+ Just lib -> return $ dependencyName <$> condTreeConstraints lib+ Nothing -> error "Package is not a library"+ _ -> error "Failed to parse package description"+ where+ dependencyName (Dependency name _) = unPackageName name
+ src/Main.hs view
@@ -0,0 +1,20 @@+module Main where++import Control.Concurrent.Async+import Control.Monad+import qualified Data.Set as Set+import Development.ExtractDependencies+import System.Environment++main :: IO ()+main = do+ npkgs <- getArgs+ deps <- mapConcurrently extractDependencies npkgs+ forM_ (uniq (concat deps)) putStrLn+ where+ uniq = uniq' Set.empty+ where+ uniq' _ [] = []+ uniq' x (y:ys) = if Set.member y x+ then uniq' x ys+ else y : uniq' (Set.insert y x) ys