Commit c4c73a51 authored by ijones's avatar ijones
Browse files

cleanup

* Cleaned up lots of warnings
* Qualified imports
* Type sigs
parent c2f73685
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.ModuleTest
-- Copyright : Isaac Jones 2003-2004
......
......@@ -140,9 +140,9 @@ parseArgs args
parseInstall _ _
= commandSyntaxError "install"
noFlags str cmd [] unkFlags
noFlags _ cmd [] unkFlags
= Right (cmd, unkFlags)
noFlags str cmd _ unkFlags
noFlags str _ _ _
= commandSyntaxError str
commandSyntaxError c = Left ["Syntax error for command: " ++ c]
......@@ -151,7 +151,7 @@ parseArgs args
isInstallPrefix (InstPrefix _) = True
isInstallPrefix _ = False
-- Converts the abstract "flag" type to a more concrete type.
-- |Converts the abstract "flag" type to a more concrete type.
getConfigFlags :: [Flag] -> Either String ConfigFlags
getConfigFlags flags
= do flavor <- getOneOpt [f | Just f <- map convert flags]
......
......@@ -65,7 +65,6 @@ import Distribution.Misc (License(..))
import Distribution.Version (Version(..))
import System.IO
import Control.Monad ( when )
import Data.List ( intersperse )
-- |Reads local build info, executes function
......@@ -92,7 +91,7 @@ defaultMain pkg_descr
localbuildinfo <- getPersistBuildConfig
build pkg_descr localbuildinfo
Right (InstallCmd maybe_install_prefix, extra_flags) -> do
Right (InstallCmd _, extra_flags) -> do
no_extra_flags extra_flags
localbuildinfo <- getPersistBuildConfig
install pkg_descr localbuildinfo
......@@ -117,6 +116,7 @@ defaultMain pkg_descr
hPutStr stderr (optionHelpString helpprefix)
return ()
no_extra_flags :: [String] -> IO ()
no_extra_flags [] = return ()
no_extra_flags extra_flags =
die ("Unrecognised flags: " ++ concat (intersperse "," (extra_flags)))
......
......@@ -44,15 +44,14 @@ module Distribution.Simple.Build (
build
) where
import Distribution.Setup
import Distribution.Package
import Distribution.Simple.Configure
import Distribution.Simple.Utils
import Distribution.Misc (Extension)
import Distribution.Setup (CompilerFlavor(..), compilerFlavor, compilerPath)
import Distribution.Package (PackageDescription(..), showPackageId)
import Distribution.Simple.Configure (LocalBuildInfo, compiler)
import Distribution.Simple.Utils (rawSystemExit, setupMessage,
die, rawSystemPathExit)
import System.IO
import System.Exit
import System.Cmd (rawSystem)
import Control.Monad
import Control.Monad (when)
-- -----------------------------------------------------------------------------
-- Build the library
......@@ -78,7 +77,7 @@ build pkg_descr lbi = do
rawSystemPathExit "ar" (["q", lib] ++ objs)
constructGHCCmdLine :: PackageDescription -> LocalBuildInfo -> [String]
constructGHCCmdLine pkg_descr lbi =
constructGHCCmdLine pkg_descr _ =
[
"--make",
"-package-name", showPackageId (package pkg_descr)
......@@ -87,6 +86,7 @@ constructGHCCmdLine pkg_descr lbi =
++ [ opt | (GHC,opts) <- options pkg_descr, opt <- opts ]
++ allModules pkg_descr
extensionsToGHCFlag :: [ Extension ] -> [String]
extensionsToGHCFlag _ = [] -- ToDo
#ifdef mingw32_TARGET_OS
......@@ -95,6 +95,7 @@ objsuffix = ".obj"
objsuffix = ".o"
#endif
mkLibName :: String -> String
mkLibName lib = "libHS" ++ lib ++ ".a"
-- ToDo: includes, includeDirs
......@@ -56,7 +56,6 @@ import Distribution.Package ( PackageIdentifier )
import System.IO hiding (catch)
import System.Exit
import System.Directory
import System.Environment ( getEnv )
import Control.Monad ( when )
import Control.Exception ( catch, evaluate )
import Prelude hiding (catch)
......@@ -88,7 +87,7 @@ getPersistBuildConfig :: IO LocalBuildInfo
getPersistBuildConfig = do
str <- readFile localBuildInfoFile
let bi = read str
evaluate bi `catch` \e ->
evaluate bi `catch` \_ ->
die "error reading .setup-config; run ./Setup.lhs configure?\n"
return bi
......@@ -119,6 +118,7 @@ configure pkg_descr (maybe_hc_flavor, maybe_hc_path, maybe_prefix)
message $ "Using package tool: " ++ pkg
return LocalBuildInfo{prefix=prefix, compiler=compiler, packageDeps=[]}
system_default_prefix :: PackageDescription -> String
system_default_prefix PackageDescription{package=package} =
#ifdef mingw32_TARGET_OS
"C:\Program Files\" ++ pkgName package
......@@ -132,13 +132,13 @@ system_default_prefix PackageDescription{package=package} =
configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> PackageDescription
-> IO Compiler
configCompiler (Just flavor) (Just path) pkg_descr
configCompiler (Just flavor) (Just path) _
= do pkgtool <- guessPkgToolFromHCPath flavor path
return (Compiler{compilerFlavor=flavor,
compilerPath=path,
compilerPkgTool=pkgtool})
configCompiler (Just flavor) Nothing pkg_descr
configCompiler (Just flavor) Nothing _
= do path <- findCompiler flavor
pkgtool <- guessPkgToolFromHCPath flavor path
return (Compiler{compilerFlavor=flavor,
......@@ -168,10 +168,12 @@ findCompiler flavor = do
return path
-- ToDo: check that compiler works? check compiler version?
compilerBinaryName :: CompilerFlavor -> String
compilerBinaryName GHC = "ghc"
compilerBinaryName NHC = "nhc98"
compilerBinaryName Hugs = "hugs"
compilerPkgToolName :: CompilerFlavor -> String
compilerPkgToolName GHC = "ghc-pkg"
compilerPkgToolName NHC = "nhc98-pkg"
compilerPkgToolName Hugs = "hugs-package"
......@@ -188,6 +190,7 @@ guessPkgToolFromHCPath flavor path
message $ "found package tool in " ++ pkgtool
return pkgtool
message :: String -> IO ()
message s = putStrLn $ "configure: " ++ s
-- -----------------------------------------------------------------------------
......
......@@ -63,6 +63,7 @@ data GHCPackageConfig
extra_frameworks:: [String] -- ignored everywhere but on Darwin/MacOS X
}
defaultGHCPackageConfig :: GHCPackageConfig
defaultGHCPackageConfig
= GHCPackage {
name = error "defaultPackage",
......@@ -107,7 +108,7 @@ showGHCPackageConfig pkg = render $
])))
dumpField :: String -> [String] -> Doc
dumpField name val = hang (text name <+> equals) 2 (dumpFieldContents val)
dumpField name' val = hang (text name' <+> equals) 2 (dumpFieldContents val)
dumpFieldContents :: [String] -> Doc
dumpFieldContents val = brackets (sep (punctuate comma (map (text . show) val)))
......@@ -54,7 +54,7 @@ import Distribution.Simple.Utils(setupMessage)
import System.Exit
install :: PackageDescription -> LocalBuildInfo -> IO ()
install pkg_descr localbuildinfo = do
install pkg_descr _ = do
setupMessage "Installing" pkg_descr
exitWith (ExitFailure 1)
......
......@@ -46,17 +46,13 @@ module Distribution.Simple.Register (
unregister,
) where
import Distribution.Simple.Configure
import Distribution.Setup
import Distribution.Package
import Distribution.InstalledPackageInfo(InstalledPackageInfo)
import Distribution.Simple.Utils
import Distribution.Simple.GHCPackageConfig
import Distribution.Simple.Configure (LocalBuildInfo, compiler)
import Distribution.Setup (CompilerFlavor(..), Compiler(..))
import Distribution.Package (PackageDescription, package, showPackageId)
import Distribution.Simple.Utils (setupMessage, rawSystemExit, die)
import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageConfig)
import System.IO
import System.Exit
import Control.Monad
import Control.Monad (when)
-- -----------------------------------------------------------------------------
-- Registration
......
......@@ -51,6 +51,6 @@ import System.IO
import System.Exit
sdist :: PackageDescription -> LocalBuildInfo -> IO ()
sdist pkg_descr lbi = do
sdist pkg_descr _ = do
setupMessage "Building source dist for" pkg_descr
exitWith (ExitFailure 1)
......@@ -80,11 +80,11 @@ split c s = case rest of
where (chunk, rest) = break (==c) s
split_longest_prefix :: String -> (Char -> Bool) -> (String,String)
split_longest_prefix s pred
split_longest_prefix s pred'
= case pre of
[] -> ([], reverse suf)
(_:pre) -> (reverse pre, reverse suf)
where (suf,pre) = break pred (reverse s)
(_:pre') -> (reverse pre', reverse suf)
where (suf,pre) = break pred' (reverse s)
isPathSeparator :: Char -> Bool
isPathSeparator ch =
......
......@@ -59,7 +59,6 @@ module Distribution.Version (
import Data.List ( intersperse )
import Time (Month(..))
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Language
import qualified Text.ParserCombinators.Parsec.Token as P
......@@ -148,13 +147,21 @@ data VersionRange
| IntersectVersionRanges VersionRange VersionRange
deriving (Show,Read,Eq)
orLaterVersion :: Version -> VersionRange
orLaterVersion v = UnionVersionRanges (ThisVersion v) (LaterVersion v)
orEarlierVersion :: Version -> VersionRange
orEarlierVersion v = UnionVersionRanges (ThisVersion v) (EarlierVersion v)
betweenVersionsInclusive :: Version -> Version -> VersionRange
betweenVersionsInclusive v1 v2 =
IntersectVersionRanges (orLaterVersion v1) (orEarlierVersion v2)
laterVersion :: Version -> Version -> Bool
v1 `laterVersion` v2 = versionBranch v1 > versionBranch v2
earlierVersion :: Version -> Version -> Bool
v1 `earlierVersion` v2 = versionBranch v1 < versionBranch v2
-- |Does this version fall within the given range?
......@@ -348,15 +355,28 @@ doVersionRangeParse input
in case x of
Left err -> Left (show err)
Right y -> Right y
branch1 :: [Int]
branch1 = [1]
branch2 :: [Int]
branch2 = [1,2]
branch3 :: [Int]
branch3 = [1,2,3]
branch4 :: [Int]
branch4 = [1,2,3,4]
release1 :: Version
release1 = Version{versionBranch=branch1, versionTags=[]}
release2 :: Version
release2 = Version{versionBranch=branch2, versionTags=[]}
release3 :: Version
release3 = Version{versionBranch=branch3, versionTags=[]}
release4 :: Version
release4 = Version{versionBranch=branch4, versionTags=[]}
hunitTests :: [Test]
......
module A where
module Main where
a = 42 :: Int
main = print a
Markdown is supported
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