Commit 77aace39 authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Some -Wall policing.

parent 163267f5
......@@ -15,7 +15,7 @@ module Network.Hackage.CabalInstall.Clean
) where
import Network.Hackage.CabalInstall.Types (ConfigFlags)
import Network.Hackage.CabalInstall.Fetch (packagesDirectory)
import Network.Hackage.CabalInstall.Config (packagesDirectory)
import System.Directory (removeDirectoryRecursive)
......
......@@ -25,20 +25,17 @@ module Network.Hackage.CabalInstall.Config
) where
import Prelude hiding (catch)
import Control.Exception (catch, Exception(IOException),evaluate)
import Control.Exception (catch, Exception(IOException))
import Control.Monad (when)
import Control.Monad.Error (mplus, filterM) -- Using Control.Monad.Error to get the Error instance for IO.
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.ByteString.Lazy.Char8 (ByteString)
import Data.Char (isAlphaNum, toLower)
import Data.List (intersperse)
import Data.Maybe (mapMaybe, fromMaybe)
import System.Directory (Permissions (..), getPermissions, createDirectoryIfMissing
,getTemporaryDirectory)
import System.FilePath (takeDirectory)
import Data.Maybe (fromMaybe)
import System.Directory (createDirectoryIfMissing, getAppUserDataDirectory)
import System.FilePath ((</>), takeDirectory, takeExtension, (<.>))
import System.IO.Error (isDoesNotExistError)
import System.IO (hPutStrLn, stderr)
import System.IO.Unsafe
import Text.PrettyPrint.HughesPJ (text)
import Distribution.Compat.ReadP (ReadP, char, munch1, readS_to_P)
......@@ -53,9 +50,7 @@ import qualified Distribution.Simple.Configure as Configure (configCompiler)
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), PathTemplate, defaultInstallDirs)
import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration)
import Distribution.Version (Dependency, showVersion)
import Distribution.Verbosity
import System.FilePath ((</>), takeExtension, (<.>))
import System.Directory
import Distribution.Verbosity (Verbosity, normal)
import Network.Hackage.CabalInstall.Tar (readTarArchive, tarFileName)
import Network.Hackage.CabalInstall.Types (ConfigFlags (..), PkgInfo (..), Repo(..))
......
......@@ -29,18 +29,15 @@ module Network.Hackage.CabalInstall.Dependency
import Distribution.Version (Version, Dependency(..), withinRange)
import Distribution.Package (PackageIdentifier(..))
import Distribution.PackageDescription
(PackageDescription(package, buildDepends, pkgUrl, synopsis)
(PackageDescription(package, buildDepends)
, GenericPackageDescription(packageDescription)
, finalizePackageDescription)
import Distribution.ParseUtils (showDependency)
import Distribution.Simple.Configure (getInstalledPackages)
import Distribution.Simple.Compiler (PackageDB(..), Compiler, showCompilerId, compilerVersion)
import Distribution.Simple.Program (defaultProgramConfiguration)
import Data.Char (toLower)
import Data.List (nub, maximumBy, isPrefixOf)
import Data.Maybe (mapMaybe)
import Control.Monad (guard)
import qualified System.Info (arch,os)
import Network.Hackage.CabalInstall.Config (getKnownPackages, findCompiler)
......
......@@ -17,7 +17,6 @@ module Network.Hackage.CabalInstall.Fetch
, -- * Utilities
fetchPackage
, packageFile
, packagesDirectory
, isFetched
, readURI
, downloadIndex
......@@ -29,8 +28,6 @@ import Network.HTTP (ConnError(..), Request (..), simpleHTTP
import Control.Exception (bracket)
import Control.Monad (filterM)
import Data.List (intersperse)
import Data.Version
import Text.Printf (printf)
import System.Directory (doesFileExist, createDirectoryIfMissing)
......
......@@ -16,12 +16,15 @@ module Network.Hackage.CabalInstall.Install
, installPkg -- :: ConfigFlags -> (PackageIdentifier,[String],String) -> IO ()
) where
import Data.List (elemIndex)
import Data.Maybe (fromJust)
import Debug.Trace
import Control.Exception (bracket_)
import System.Directory (getTemporaryDirectory, createDirectoryIfMissing
,removeDirectoryRecursive)
import System.FilePath ((</>))
import Text.Printf (printf)
import Network.Hackage.CabalInstall.Config (programConfiguration, findCompiler, message)
import Network.Hackage.CabalInstall.Config (findCompiler, message)
import Network.Hackage.CabalInstall.Dependency (getPackages, resolveDependencies
, listInstalledPackages)
import Network.Hackage.CabalInstall.Fetch (isFetched, packageFile, fetchPackage)
......@@ -36,16 +39,8 @@ import Distribution.Simple.Setup (CopyDest(..))
import Distribution.Package (showPackageId, PackageIdentifier)
import Distribution.Verbosity
import System.FilePath ((</>), splitFileName)
import Data.Maybe (fromMaybe, maybeToList)
import Text.Printf (printf, PrintfType)
import System.Directory (getTemporaryDirectory, createDirectoryIfMissing
,removeDirectoryRecursive, copyFile)
import System.IO (hPutStrLn, stderr)
import System.Process (runProcess, waitForProcess, terminateProcess)
import System.Exit (ExitCode(..))
import System.Posix.Signals
-- |Installs the packages needed to satisfy a list of dependencies.
install :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
......@@ -77,7 +72,6 @@ mkPkgOps cfg comp pkgId cmd ops = verbosity ++
where verbosity = ["--verbose=" ++ showForCabal (configVerbose cfg)]
user = if configUserInstall cfg then ["--user"] else []
installDirs = absoluteInstallDirs pkgId (compilerId comp) NoCopyDest (configInstallDirs cfg)
showForCabal v = show$ fromJust$ elemIndex v [silent,normal,verbose,deafening]
installDirFlags :: InstallDirs FilePath -> [String]
installDirFlags dirs =
......
......@@ -15,14 +15,13 @@ module Network.Hackage.CabalInstall.List
) where
import Text.Regex
import Data.Maybe (catMaybes, isJust)
import Data.List (find, nubBy, sortBy)
import Data.Maybe (isJust)
import Data.List (nubBy, sortBy)
import Data.Char as Char (toLower)
import Data.Ord (comparing)
import Distribution.Package
import Distribution.PackageDescription
import Network.Hackage.CabalInstall.Config (getKnownPackages)
import Network.Hackage.CabalInstall.Dependency (finalizePackage, listInstalledPackages)
import Network.Hackage.CabalInstall.Types (PkgInfo(..), ConfigFlags(..), UnresolvedDependency(..))
-- |Show information about packages
......
......@@ -17,9 +17,8 @@ module Network.Hackage.CabalInstall.Setup
) where
import Control.Monad (when)
import Data.Maybe (fromMaybe)
import Distribution.ParseUtils (parseDependency)
import Distribution.Compiler (defaultCompilerFlavor, CompilerFlavor(..))
import Distribution.Compiler (CompilerFlavor(..))
import Distribution.Simple.InstallDirs (InstallDirTemplates(..))
import Distribution.Verbosity
import Data.List (find)
......
......@@ -19,8 +19,6 @@ import Distribution.PackageDescription (GenericPackageDescription)
import Distribution.Version (Dependency)
import Distribution.Verbosity
import System.IO (Handle)
-- | We re-use @GenericPackageDescription@ and use the @package-url@
-- field to store the tarball URL.
data PkgInfo = PkgInfo {
......
......@@ -15,20 +15,12 @@ module Network.Hackage.CabalInstall.Update
) where
import Network.Hackage.CabalInstall.Types (ConfigFlags (..), PkgInfo(..), Repo(..))
import Network.Hackage.CabalInstall.Utils (isVerbose)
import Network.Hackage.CabalInstall.Fetch (downloadIndex, packagesDirectory)
import Network.Hackage.CabalInstall.Fetch (downloadIndex)
import Network.Hackage.CabalInstall.Tar (gunzip)
import Distribution.Package (PackageIdentifier(..), pkgName, showPackageId)
import Distribution.PackageDescription (PackageDescription(..), readPackageDescription, GenericPackageDescription(..))
import Distribution.Verbosity
import System.FilePath ((</>), joinPath, addExtension, takeExtension, dropExtension)
import Control.Monad (liftM, when)
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.ByteString.Lazy.Char8 (ByteString)
import Data.Version (showVersion)
import System.FilePath (dropExtension)
import Text.Printf
-- | 'update' downloads the package list from all known servers
......
module Network.Hackage.CabalInstall.Utils where
import Distribution.Compat.ReadP (ReadP, readP_to_S, readS_to_P, pfail, get, look, choice)
import Distribution.Compat.ReadP (ReadP, readP_to_S, pfail, get, look, choice)
import Distribution.ParseUtils
import Distribution.Verbosity
import Network.Hackage.CabalInstall.Types
import Control.Exception
import Control.Monad (foldM, guard)
import Data.Char (isSpace, isAlphaNum, toLower)
import Data.Char (isSpace, toLower)
import Data.Maybe (listToMaybe)
import System.IO.Error (isDoesNotExistError)
import Text.PrettyPrint.HughesPJ (Doc, render, vcat, text, (<>), (<+>))
isVerbose cfg = configVerbose cfg >= verbose
readFileIfExists :: FilePath -> IO (Maybe String)
readFileIfExists path =
catchJust fileNotFoundExceptions
......@@ -62,7 +57,7 @@ lookupFieldDescr :: [FieldDescr a] -> String -> Maybe (FieldDescr a)
lookupFieldDescr fs n = listToMaybe [f | f@(FieldDescr name _ _) <- fs, name == n]
boolField :: String -> (a -> Bool) -> (Bool -> a -> a) -> FieldDescr a
boolField name get set = liftField get set $ field name showBool readBool
boolField name g s = liftField g s $ field name showBool readBool
where
showBool :: Bool -> Doc
showBool True = text "true"
......@@ -75,7 +70,7 @@ boolField name get set = liftField get set $ field name showBool readBool
, stringNoCase "no" >> return False]
showFields :: [FieldDescr a] -> a -> String
showFields fs x = render $ vcat [ text name <> text ":" <+> get x | FieldDescr name get _ <- fs]
showFields fs x = render $ vcat [ text name <> text ":" <+> g x | FieldDescr name g _ <- fs]
stringNoCase :: String -> ReadP r String
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment