Commit f4e1e67a authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Whitespace changes, convert tabs to spaces

parent a2d79b94
......@@ -3,13 +3,13 @@
-- Module : Distribution.Compat.ReadP
-- Copyright : (c) The University of Glasgow 2002
-- License : BSD-style (see the file libraries/base/LICENSE)
--
--
-- Maintainer : libraries@haskell.org
-- Stability : provisional
-- Portability : portable
--
-- This is a library of parser combinators, originally written by Koen Claessen.
-- It parses all alternatives in parallel, so it never keeps hold of
-- It parses all alternatives in parallel, so it never keeps hold of
-- the beginning of the input string, a common source of space leaks with
-- other parsers. The '(+++)' choice combinator is genuinely commutative;
-- it makes no difference which branch is \"shorter\".
......@@ -23,17 +23,17 @@
-----------------------------------------------------------------------------
module Distribution.Compat.ReadP
(
(
-- * The 'ReadP' type
ReadP, -- :: * -> *; instance Functor, Monad, MonadPlus
-- * Primitive operations
get, -- :: ReadP Char
look, -- :: ReadP String
(+++), -- :: ReadP a -> ReadP a -> ReadP a
(<++), -- :: ReadP a -> ReadP a -> ReadP a
gather, -- :: ReadP a -> ReadP (String, a)
-- * Other operations
pfail, -- :: ReadP a
satisfy, -- :: (Char -> Bool) -> ReadP Char
......@@ -60,12 +60,12 @@ module Distribution.Compat.ReadP
chainl1, -- :: ReadP a -> ReadP (a -> a -> a) -> ReadP a
chainr1, -- :: ReadP a -> ReadP (a -> a -> a) -> ReadP a
manyTill, -- :: ReadP a -> ReadP end -> ReadP [a]
-- * Running a parser
ReadS, -- :: *; = String -> [(a,String)]
readP_to_S, -- :: ReadP a -> ReadS a
readS_to_P -- :: ReadS a -> ReadP a
-- * Properties
-- $properties
)
......@@ -105,7 +105,7 @@ instance MonadPlus (P s) where
-- most common case: two gets are combined
Get f1 `mplus` Get f2 = Get (\c -> f1 c `mplus` f2 c)
-- results are delivered as soon as possible
Result x p `mplus` q = Result x (p `mplus` q)
p `mplus` Result x q = Result x (p `mplus` q)
......@@ -206,9 +206,9 @@ gather :: ReadP (String -> P Char r) a -> ReadP r (String, a)
-- ^ Transforms a parser into one that does the same, but
-- in addition returns the exact characters read.
-- IMPORTANT NOTE: 'gather' gives a runtime error if its first argument
-- is built using any occurrences of readS_to_P.
-- is built using any occurrences of readS_to_P.
gather (R m) =
R (\k -> gath id (m (\a -> return (\s -> k (s,a)))))
R (\k -> gath id (m (\a -> return (\s -> k (s,a)))))
where
gath l (Get f) = Get (\c -> gath (l.(c:)) (f c))
gath _ Fail = Fail
......@@ -437,7 +437,7 @@ Here follow the properties:
> xs +<+ _ = xs
>
> prop_Gather s =
> forAll readPWithoutReadS $ \p ->
> forAll readPWithoutReadS $ \p ->
> readP_to_S (gather p) s =~
> [ ((pre,x::Int),s')
> | (x,s') <- readP_to_S p s
......
......@@ -2,7 +2,7 @@
-- |
-- Module : Distribution.Compiler
-- Copyright : Isaac Jones 2003-2004
--
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
-- Stability : alpha
-- Portability : portable
......
......@@ -3,13 +3,13 @@
-- Module : Distribution.GetOpt
-- Copyright : (c) Sven Panne 2002-2005
-- License : BSD-style (see the file libraries/base/LICENSE)
--
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
-- Portability : portable
--
-- This library provides facilities for parsing the command-line options
-- in a standalone program. It is essentially a Haskell port of the GNU
-- in a standalone program. It is essentially a Haskell port of the GNU
-- @getopt@ library.
--
-----------------------------------------------------------------------------
......@@ -33,7 +33,7 @@ Other differences between GNU's getopt and this implementation:
compliant... :-(
And a final Haskell advertisement: The GNU C implementation uses well
over 1100 lines, we need only 195 here, including a 46 line example!
over 1100 lines, we need only 195 here, including a 46 line example!
:-)
-}
......@@ -93,7 +93,7 @@ data OptKind a -- kind of cmd line arg (internal use only):
| OptErr String -- something went wrong...
-- | Return a string describing the usage of a command, derived from
-- the header (first argument) and the options described by the
-- the header (first argument) and the options described by the
-- second argument.
usageInfo :: String -- header
-> [OptDescr a] -- option descriptors
......@@ -104,15 +104,15 @@ usageInfo header optDescr = unlines (header:table)
,d)
| Option sos los ad d <- optDescr ]
ssWidth = (maximum . map length) ss
lsWidth = (maximum . map length) ls
dsWidth = 30 `max` (80 - (ssWidth + lsWidth + 3))
lsWidth = (maximum . map length) ls
dsWidth = 30 `max` (80 - (ssWidth + lsWidth + 3))
table = [ " " ++ padTo ssWidth so' ++
" " ++ padTo lsWidth lo' ++
" " ++ d'
| (so,lo,d) <- zip3 ss ls ds
, (so',lo',d') <- fmtOpt dsWidth so lo d ]
padTo n x = take n (x ++ repeat ' ')
sepBy s = concat . intersperse s
sepBy s = concat . intersperse s
fmtOpt :: Int -> String -> String -> String -> [(String, String, String)]
fmtOpt descrWidth so lo descr =
......@@ -153,7 +153,7 @@ Process the command-line, and return the list of values that matched
* The option descriptions (see 'OptDescr')
* The actual command line arguments (presumably got from
* The actual command line arguments (presumably got from
'System.Environment.getArgs').
'getOpt' returns a triple consisting of the option arguments, a list
......@@ -288,11 +288,11 @@ test order cmdline = case getOpt order options cmdline of
-- putStr (test Permute ["--ver","foo"])
-- ==> option `--ver' is ambiguous; could be one of:
-- -v --verbose verbosely list files
-- -V, -? --version, --release show version info
-- -V, -? --version, --release show version info
-- Usage: foobar [OPTION...] files...
-- -v --verbose verbosely list files
-- -V, -? --version, --release show version info
-- -o[FILE] --output[=FILE] use FILE for dump
-- -v --verbose verbosely list files
-- -V, -? --version, --release show version info
-- -o[FILE] --output[=FILE] use FILE for dump
-- -n USER --name=USER only dump USER's files
-----------------------------------------------------------------------------------------
-}
......@@ -304,15 +304,15 @@ structures, here\'s the command-line options for a (very simple)
compiler:
> module Opts where
>
>
> import Distribution.GetOpt
> import Data.Maybe ( fromMaybe )
>
> data Flag
> = Verbose | Version
>
> data Flag
> = Verbose | Version
> | Input String | Output String | LibDir String
> deriving Show
>
>
> options :: [OptDescr Flag]
> options =
> [ Option ['v'] ["verbose"] (NoArg Verbose) "chatty output on stderr"
......@@ -321,13 +321,13 @@ compiler:
> , Option ['c'] [] (OptArg inp "FILE") "input FILE"
> , Option ['L'] ["libdir"] (ReqArg LibDir "DIR") "library directory"
> ]
>
>
> inp,outp :: Maybe String -> Flag
> outp = Output . fromMaybe "stdout"
> inp = Input . fromMaybe "stdin"
>
>
> compilerOpts :: [String] -> IO ([Flag], [String])
> compilerOpts argv =
> compilerOpts argv =
> case getOpt Permute options argv of
> (o,n,[] ) -> return (o,n)
> (_,_,errs) -> ioError (userError (concat errs ++ usageInfo header options))
......
......@@ -2,7 +2,7 @@
-- |
-- Module : Distribution.InstalledPackageInfo
-- Copyright : (c) The University of Glasgow 2004
--
--
-- Maintainer : libraries@haskell.org
-- Stability : alpha
-- Portability : portable
......@@ -46,21 +46,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
-- This module is meant to be local-only to Distribution...
module Distribution.InstalledPackageInfo (
InstalledPackageInfo_(..), InstalledPackageInfo,
ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
parseInstalledPackageInfo,
showInstalledPackageInfo,
showInstalledPackageInfoField,
InstalledPackageInfo_(..), InstalledPackageInfo,
ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
parseInstalledPackageInfo,
showInstalledPackageInfo,
showInstalledPackageInfoField,
) where
import Distribution.ParseUtils (
FieldDescr(..), readFields, ParseResult(..), PError(..), PWarning,
Field(F), simpleField, listField, parseLicenseQ, ppField, ppFields,
parseFilePathQ, parseTokenQ, parseModuleNameQ, parsePackageNameQ,
showFilePath, showToken, boolField, parseOptVersion, parseQuoted,
showFreeText)
import Distribution.License ( License(..) )
FieldDescr(..), readFields, ParseResult(..), PError(..), PWarning,
Field(F), simpleField, listField, parseLicenseQ, ppField, ppFields,
parseFilePathQ, parseTokenQ, parseModuleNameQ, parsePackageNameQ,
showFilePath, showToken, boolField, parseOptVersion, parseQuoted,
showFreeText)
import Distribution.License ( License(..) )
import Distribution.Package
( PackageName(..), PackageIdentifier(..)
, packageName, packageVersion )
......@@ -74,7 +74,7 @@ import Distribution.Text
( Text(disp, parse) )
import qualified Distribution.Compat.ReadP as ReadP
import Control.Monad ( foldM )
import Control.Monad ( foldM )
import Text.PrettyPrint
-- -----------------------------------------------------------------------------
......@@ -82,36 +82,36 @@ import Text.PrettyPrint
data InstalledPackageInfo_ m
= InstalledPackageInfo {
-- these parts are exactly the same as PackageDescription
package :: PackageIdentifier,
-- these parts are exactly the same as PackageDescription
package :: PackageIdentifier,
license :: License,
copyright :: String,
maintainer :: String,
author :: String,
author :: String,
stability :: String,
homepage :: String,
pkgUrl :: String,
description :: String,
category :: String,
-- these parts are required by an installed package only:
homepage :: String,
pkgUrl :: String,
description :: String,
category :: String,
-- these parts are required by an installed package only:
exposed :: Bool,
exposedModules :: [m],
hiddenModules :: [m],
exposedModules :: [m],
hiddenModules :: [m],
importDirs :: [FilePath], -- contain sources in case of Hugs
libraryDirs :: [FilePath],
hsLibraries :: [String],
extraLibraries :: [String],
extraGHCiLibraries:: [String], -- overrides extraLibraries for GHCi
extraGHCiLibraries:: [String], -- overrides extraLibraries for GHCi
includeDirs :: [FilePath],
includes :: [String],
depends :: [PackageIdentifier],
hugsOptions :: [String],
ccOptions :: [String],
ldOptions :: [String],
hugsOptions :: [String],
ccOptions :: [String],
ldOptions :: [String],
frameworkDirs :: [FilePath],
frameworks :: [String],
haddockInterfaces :: [FilePath],
haddockHTMLs :: [FilePath]
frameworks :: [String],
haddockInterfaces :: [FilePath],
haddockHTMLs :: [FilePath]
}
deriving (Read, Show)
......@@ -129,30 +129,30 @@ emptyInstalledPackageInfo
license = AllRightsReserved,
copyright = "",
maintainer = "",
author = "",
author = "",
stability = "",
homepage = "",
pkgUrl = "",
description = "",
category = "",
homepage = "",
pkgUrl = "",
description = "",
category = "",
exposed = False,
exposedModules = [],
hiddenModules = [],
exposedModules = [],
hiddenModules = [],
importDirs = [],
libraryDirs = [],
hsLibraries = [],
extraLibraries = [],
extraGHCiLibraries= [],
includeDirs = [],
includes = [],
includes = [],
depends = [],
hugsOptions = [],
ccOptions = [],
ldOptions = [],
frameworkDirs = [],
frameworks = [],
haddockInterfaces = [],
haddockHTMLs = []
haddockInterfaces = [],
haddockHTMLs = []
}
noVersion :: Version
......@@ -164,19 +164,19 @@ noVersion = Version{ versionBranch=[], versionTags=[] }
parseInstalledPackageInfo :: String -> ParseResult InstalledPackageInfo
parseInstalledPackageInfo inp = do
stLines <- readFields inp
-- not interested in stanzas, so just allow blank lines in
-- the package info.
-- not interested in stanzas, so just allow blank lines in
-- the package info.
foldM (parseBasicStanza all_fields) emptyInstalledPackageInfo stLines
parseBasicStanza :: [FieldDescr a]
-> a
-> Field
-> ParseResult a
-> a
-> Field
-> ParseResult a
parseBasicStanza ((FieldDescr name _ set):fields) pkg (F lineNo f val)
| name == f = set lineNo val pkg
| otherwise = parseBasicStanza fields pkg (F lineNo f val)
parseBasicStanza [] pkg _ = return pkg
parseBasicStanza _ _ _ =
parseBasicStanza _ _ _ =
error "parseBasicStanza must be called with a simple field."
-- -----------------------------------------------------------------------------
......@@ -186,12 +186,12 @@ showInstalledPackageInfo :: InstalledPackageInfo -> String
showInstalledPackageInfo pkg = render (ppFields pkg all_fields)
showInstalledPackageInfoField
:: String
-> Maybe (InstalledPackageInfo -> String)
:: String
-> Maybe (InstalledPackageInfo -> String)
showInstalledPackageInfoField field
= case [ (f,get') | (FieldDescr f get' _) <- all_fields, f == field ] of
[] -> Nothing
((f,get'):_) -> Just (render . ppField f . get')
[] -> Nothing
((f,get'):_) -> Just (render . ppField f . get')
-- -----------------------------------------------------------------------------
-- Description of the fields, for parsing/printing
......@@ -242,58 +242,58 @@ parseFreeText = ReadP.munch (const True)
installedFieldDescrs :: [FieldDescr InstalledPackageInfo]
installedFieldDescrs = [
boolField "exposed"
exposed (\val pkg -> pkg{exposed=val})
exposed (\val pkg -> pkg{exposed=val})
, listField "exposed-modules"
disp parseModuleNameQ
exposedModules (\xs pkg -> pkg{exposedModules=xs})
disp parseModuleNameQ
exposedModules (\xs pkg -> pkg{exposedModules=xs})
, listField "hidden-modules"
disp parseModuleNameQ
hiddenModules (\xs pkg -> pkg{hiddenModules=xs})
disp parseModuleNameQ
hiddenModules (\xs pkg -> pkg{hiddenModules=xs})
, listField "import-dirs"
showFilePath parseFilePathQ
importDirs (\xs pkg -> pkg{importDirs=xs})
showFilePath parseFilePathQ
importDirs (\xs pkg -> pkg{importDirs=xs})
, listField "library-dirs"
showFilePath parseFilePathQ
libraryDirs (\xs pkg -> pkg{libraryDirs=xs})
showFilePath parseFilePathQ
libraryDirs (\xs pkg -> pkg{libraryDirs=xs})
, listField "hs-libraries"
showFilePath parseTokenQ
hsLibraries (\xs pkg -> pkg{hsLibraries=xs})
showFilePath parseTokenQ
hsLibraries (\xs pkg -> pkg{hsLibraries=xs})
, listField "extra-libraries"
showToken parseTokenQ
extraLibraries (\xs pkg -> pkg{extraLibraries=xs})
showToken parseTokenQ
extraLibraries (\xs pkg -> pkg{extraLibraries=xs})
, listField "extra-ghci-libraries"
showToken parseTokenQ
extraGHCiLibraries (\xs pkg -> pkg{extraGHCiLibraries=xs})
showToken parseTokenQ
extraGHCiLibraries (\xs pkg -> pkg{extraGHCiLibraries=xs})
, listField "include-dirs"
showFilePath parseFilePathQ
includeDirs (\xs pkg -> pkg{includeDirs=xs})
showFilePath parseFilePathQ
includeDirs (\xs pkg -> pkg{includeDirs=xs})
, listField "includes"
showFilePath parseFilePathQ
includes (\xs pkg -> pkg{includes=xs})
showFilePath parseFilePathQ
includes (\xs pkg -> pkg{includes=xs})
, listField "depends"
disp parsePackageId'
depends (\xs pkg -> pkg{depends=xs})
disp parsePackageId'
depends (\xs pkg -> pkg{depends=xs})
, listField "hugs-options"
showToken parseTokenQ
hugsOptions (\path pkg -> pkg{hugsOptions=path})
showToken parseTokenQ
hugsOptions (\path pkg -> pkg{hugsOptions=path})
, listField "cc-options"
showToken parseTokenQ
ccOptions (\path pkg -> pkg{ccOptions=path})
showToken parseTokenQ
ccOptions (\path pkg -> pkg{ccOptions=path})
, listField "ld-options"
showToken parseTokenQ
ldOptions (\path pkg -> pkg{ldOptions=path})
showToken parseTokenQ
ldOptions (\path pkg -> pkg{ldOptions=path})
, listField "framework-dirs"
showFilePath parseFilePathQ
frameworkDirs (\xs pkg -> pkg{frameworkDirs=xs})
showFilePath parseFilePathQ
frameworkDirs (\xs pkg -> pkg{frameworkDirs=xs})
, listField "frameworks"
showToken parseTokenQ
frameworks (\xs pkg -> pkg{frameworks=xs})
showToken parseTokenQ
frameworks (\xs pkg -> pkg{frameworks=xs})
, listField "haddock-interfaces"
showFilePath parseFilePathQ
haddockInterfaces (\xs pkg -> pkg{haddockInterfaces=xs})
showFilePath parseFilePathQ
haddockInterfaces (\xs pkg -> pkg{haddockInterfaces=xs})
, listField "haddock-html"
showFilePath parseFilePathQ
haddockHTMLs (\xs pkg -> pkg{haddockHTMLs=xs})
showFilePath parseFilePathQ
haddockHTMLs (\xs pkg -> pkg{haddockHTMLs=xs})
]
parsePackageId' :: ReadP.ReadP [PackageIdentifier] PackageIdentifier
......
......@@ -2,7 +2,7 @@
-- |
-- Module : Distribution.License
-- Copyright : Isaac Jones 2003-2005
--
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
-- Stability : alpha
-- Portability : portable
......@@ -46,7 +46,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.License (
License(..)
License(..)
) where
import Distribution.Version (Version)
......
......@@ -2,7 +2,7 @@
-- |
-- Module : Distribution.Make
-- Copyright : Martin Sj&#xF6;gren 2004
--
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
-- Stability : alpha
-- Portability : portable
......@@ -11,39 +11,39 @@
-- Haskell tools using a backend build system based on make. Obviously we
-- assume that there is a configure script, and that after the ConfigCmd has
-- been run, there is a Makefile. Further assumptions:
--
--
-- [ConfigCmd] We assume the configure script accepts
-- @--with-hc@,
-- @--with-hc-pkg@,
-- @--prefix@,
-- @--bindir@,
-- @--libdir@,
-- @--libexecdir@,
-- @--datadir@.
--
-- @--with-hc@,
-- @--with-hc-pkg@,
-- @--prefix@,
-- @--bindir@,
-- @--libdir@,
-- @--libexecdir@,
-- @--datadir@.
--
-- [BuildCmd] We assume that the default Makefile target will build everything.
--
--
-- [InstallCmd] We assume there is an @install@ target. Note that we assume that
-- this does *not* register the package!
--
-- [CopyCmd] We assume there is a @copy@ target, and a variable @$(destdir)@.
-- The @copy@ target should probably just invoke @make install@
-- recursively (e.g. @$(MAKE) install prefix=$(destdir)\/$(prefix)
-- bindir=$(destdir)\/$(bindir)@. The reason we can\'t invoke @make
-- install@ directly here is that we don\'t know the value of @$(prefix)@.
--
--
-- [CopyCmd] We assume there is a @copy@ target, and a variable @$(destdir)@.
-- The @copy@ target should probably just invoke @make install@
-- recursively (e.g. @$(MAKE) install prefix=$(destdir)\/$(prefix)
-- bindir=$(destdir)\/$(bindir)@. The reason we can\'t invoke @make
-- install@ directly here is that we don\'t know the value of @$(prefix)@.
--
-- [SDistCmd] We assume there is a @dist@ target.
--
--
-- [RegisterCmd] We assume there is a @register@ target and a variable @$(user)@.
--
--
-- [UnregisterCmd] We assume there is an @unregister@ target.
--
--
-- [HaddockCmd] We assume there is a @docs@ or @doc@ target.
-- copy :
-- $(MAKE) install prefix=$(destdir)/$(prefix) \
-- bindir=$(destdir)/$(bindir) \
-- copy :
-- $(MAKE) install prefix=$(destdir)/$(prefix) \
-- bindir=$(destdir)/$(bindir) \
{- All rights reserved.
......@@ -76,9 +76,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Make (
module Distribution.Package,
License(..), Version(..),
defaultMain, defaultMainArgs, defaultMainNoRead
module Distribution.Package,
License(..), Version(..),
defaultMain, defaultMainArgs, defaultMainNoRead
) where
-- local
......@@ -121,7 +121,7 @@ defaultMainHelper args =
_ | fromFlag (globalVersion flags) -> printVersion
| fromFlag (globalNumericVersion flags) -> printNumericVersion
CommandHelp help -> printHelp help
CommandList opts -> printOptionsList opts
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
CommandReadyToGo action -> action
......@@ -160,11 +160,11 @@ configureAction flags args = do
copyAction :: CopyFlags -> [String] -> IO ()
copyAction flags args = do
noExtraFlags args
let destArgs = case fromFlag $ copyDest flags of
let destArgs = case fromFlag $ copyDest flags of
NoCopyDest -> ["install"]
CopyTo path -> ["copy", "destdir=" ++ path]
CopyPrefix path -> ["install", "prefix=" ++ path]
-- CopyPrefix is backwards compat, DEPRECATED
-- CopyPrefix is backwards compat, DEPRECATED
rawSystemExit (fromFlag $ copyVerbosity flags) "make" destArgs
installAction :: InstallFlags -> [String] -> IO ()
......@@ -174,7 +174,7 @@ installAction flags args = do
rawSystemExit (fromFlag $ installVerbosity flags) "make" ["register"]
haddockAction :: HaddockFlags -> [String] -> IO ()
haddockAction flags args = do
haddockAction flags args = do
noExtraFlags args