packages feed

cabal-sort 0.1.1 → 0.1.1.1

raw patch · 2 files changed

+19/−21 lines, 2 files

Files

cabal-sort.cabal view
@@ -1,6 +1,6 @@ Cabal-Version:    2.2 Name:             cabal-sort-Version:          0.1.1+Version:          0.1.1.1 License:          BSD-3-Clause License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -90,7 +90,7 @@ Source-Repository this   type:     darcs   location: http://code.haskell.org/~thielema/cabal-sort/-  tag:      0.1.1+  tag:      0.1.1.1   Executable cabal-sort
src/CabalSort.hs view
@@ -24,6 +24,7 @@ import qualified Control.Monad.Trans.Class as Trans import Control.Arrow ((***)) import Control.Monad (guard, when)+import Control.Applicative (pure, (<*>), (<|>))  import qualified Data.List as List import qualified Data.Map as Map@@ -43,8 +44,7 @@    Flags {       optVerbosity :: Verbosity.Verbosity,       optInfo :: SourcePackage -> String,-      optParallel :: Bool,-      optMakefile :: Bool,+      optOutputFormat :: Format,       optBuilddir :: FilePath,       optInstall  :: String    }@@ -67,6 +67,9 @@       ("dir", FilePath.takeDirectory . location) :       [] +data Format = Serial | Parallel | Makefile+   deriving (Eq, Ord, Show, Enum)+ options :: OP.Parser Flags options =    pure Flags@@ -89,15 +92,15 @@           OP.help ("kind of output: " ++                      List.intercalate ", " (Map.keys infoMap)))    <*>-      OP.switch-         (OP.short 'p' <>-          OP.long "parallel" <>-          OP.help "Display independently buildable groups of packages")-   <*>-      OP.switch+      (OP.flag' Makefile          (OP.short 'm' <>           OP.long "makefile" <>           OP.help "Generate a makefile of package dependencies")+       <|>+       OP.flag Serial Parallel+         (OP.short 'p' <>+          OP.long "parallel" <>+          OP.help "Display independently buildable groups of packages"))    <*>       OP.strOption          (OP.long "builddir" <>@@ -141,15 +144,13 @@           graph = getBuildGraph pkgs       checkForCycles graph       Trans.lift $-         if optMakefile flags-           then printMakefile flags $ getDeps graph-           else if optParallel flags-              then+         case optOutputFormat flags of+            Makefile -> printMakefile flags $ getDeps graph+            Serial -> mapM_ (putStrLn . optInfo flags) $ topsort' graph+            Parallel ->                  mapM_ (putStrLn . unwords . map (optInfo flags)) $                  map (topsort' . subgraph graph) $                  components graph-              else-                 mapM_ (putStrLn . optInfo flags) $ topsort' graph   printMakefile :: Flags -> [(SourcePackage, [SourcePackage])] -> IO ()@@ -181,9 +182,7 @@                   (Graph.pre gr . Graph.node' $ ctx))     in  Graph.ufold (\ctx ds -> c2dep ctx : ds) [] gr -getBuildGraph ::-   [SourcePackage] ->-   Gr SourcePackage ()+getBuildGraph :: [SourcePackage] -> Gr SourcePackage () getBuildGraph srcPkgs =    let nodes = zip [0..] srcPkgs        nodeDict =@@ -216,8 +215,7 @@  nodeLabels :: Gr a b -> [Graph.Node] -> [a] nodeLabels graph =-   map (fromMaybe (error "node not found in graph") .-        Graph.lab graph)+   map (fromMaybe (error "node not found in graph") . Graph.lab graph)  subgraph :: Gr a b -> [Graph.Node] -> Gr a b subgraph graph nodes =