Commit 046ee54f authored by Simon Marlow's avatar Simon Marlow

Module header tidyup #2

Push this further along, and fix build problems in the first patch.
parent 5199290f
......@@ -22,6 +22,12 @@ you will screw up the layout where they are used in case expressions!
* settings for the target plat instead). */
#include "../includes/ghcautoconf.h"
#if __GLASGOW_HASKELL__ >= 602
#define SYSTEM_IO_ERROR System.IO.Error
#else
#define SYSTEM_IO_ERROR System.IO
#endif
#ifdef __GLASGOW_HASKELL__
#define GLOBAL_VAR(name,value,ty) \
name = Util.global (value) :: IORef (ty); \
......
......@@ -34,14 +34,14 @@ import Panic ( catchJust, ioErrors )
#endif
import ErrUtils ( debugTraceMsg, printErrorsAndWarnings )
import DATA_IOREF ( IORef, readIORef, writeIORef )
import EXCEPTION
import System ( ExitCode(..), exitWith )
import Directory
import IO
import Monad ( when )
import Maybe ( isJust )
import Data.IORef ( IORef, readIORef, writeIORef )
import Control.Exception
import System.Exit ( ExitCode(..), exitWith )
import System.Directory
import System.IO
import SYSTEM_IO_ERROR ( isEOFError )
import Control.Monad ( when )
import Data.Maybe ( isJust )
-----------------------------------------------------------------
--
......
......@@ -50,17 +50,18 @@ import ParserCoreUtils ( getCoreModuleName )
import SrcLoc ( unLoc )
import SrcLoc ( Located(..) )
import EXCEPTION
import DATA_IOREF ( readIORef, writeIORef, IORef )
import GLAEXTS ( Int(..) )
import Directory
import System
import IO
import Monad
import Control.Exception as Exception
import Data.IORef ( readIORef, writeIORef, IORef )
import GHC.Exts ( Int(..) )
import System.Directory
import System.IO
import SYSTEM_IO_ERROR as IO
import Control.Monad
import Data.List ( isSuffixOf )
import Maybe
import Data.Maybe
import System.Exit
import System.Cmd
import System.Environment
-- ---------------------------------------------------------------------------
-- Pre-process
......@@ -1133,7 +1134,7 @@ checkProcessArgsResult flags filename
getHCFilePackages :: FilePath -> IO [PackageId]
getHCFilePackages filename =
EXCEPTION.bracket (openFile filename ReadMode) hClose $ \h -> do
Exception.bracket (openFile filename ReadMode) hClose $ \h -> do
l <- hGetLine h
case l of
'/':'*':' ':'G':'H':'C':'_':'P':'A':'C':'K':'A':'G':'E':'S':rest ->
......
......@@ -69,20 +69,20 @@ import UniqFM ( UniqFM )
import Util ( notNull, splitLongestPrefix, normalisePath )
import Maybes ( fromJust, orElse )
import SrcLoc ( SrcSpan )
import Outputable
import {-# SOURCE #-} ErrUtils ( Severity(..), Message, mkLocMessage )
import DATA_IOREF ( readIORef )
import EXCEPTION ( throwDyn )
import Monad ( when )
import Data.IORef ( readIORef )
import Control.Exception ( throwDyn )
import Control.Monad ( when )
#ifdef mingw32_TARGET_OS
import Data.List ( isPrefixOf )
#else
import Util ( split )
#endif
import Char ( isDigit, isUpper )
import Outputable
import Data.Char ( isDigit, isUpper )
import System.IO ( hPutStrLn, stderr )
import {-# SOURCE #-} ErrUtils ( Severity(..), Message, mkLocMessage )
-- -----------------------------------------------------------------------------
-- DynFlags
......
......@@ -37,9 +37,10 @@ import qualified Pretty
import SrcLoc ( srcSpanStart, noSrcSpan )
import DynFlags ( DynFlags(..), DynFlag(..), dopt )
import StaticFlags ( opt_ErrorSpans )
import System ( ExitCode(..), exitWith )
import IO ( hPutStrLn, stderr )
import DYNAMIC
import System.Exit ( ExitCode(..), exitWith )
import System.IO ( hPutStrLn, stderr )
import Data.Dynamic
-- -----------------------------------------------------------------------------
......
......@@ -37,13 +37,12 @@ import FiniteMap
import UniqFM
import Maybes ( expectJust )
import DATA_IOREF ( IORef, writeIORef, readIORef, modifyIORef )
import Data.IORef ( IORef, writeIORef, readIORef, modifyIORef )
import Data.List
import System.Directory
import System.IO
import Control.Monad
import Time ( ClockTime )
import System.Time ( ClockTime )
type FileExt = String -- Filename extension
......
......@@ -35,9 +35,9 @@ import Bag ( emptyBag, listToBag )
import Distribution.Compiler
import EXCEPTION ( throwDyn )
import IO
import List
import Control.Exception
import System.IO
import Data.List
#if __GLASGOW_HASKELL__ >= 601
import System.IO ( openBinaryFile )
......
......@@ -41,13 +41,14 @@ import Util
import Panic
-- Standard Haskell libraries
import EXCEPTION ( throwDyn )
import IO
import Directory ( doesDirectoryExist )
import System ( getArgs, exitWith, ExitCode(..) )
import Monad
import List
import Maybe
import Control.Exception ( throwDyn )
import System.IO
import System.Directory ( doesDirectoryExist )
import System.Environment
import System.Exit
import Control.Monad
import Data.List
import Data.Maybe
-----------------------------------------------------------------------------
-- ToDo:
......
......@@ -42,15 +42,12 @@ import Config ( cProjectVersion )
import Name ( Name, nameModule_maybe )
import UniqFM
import Module
import UniqSet
import Util
import Maybes ( expectJust, MaybeErr(..) )
import Panic
import Outputable
#if __GLASGOW_HASKELL__ >= 603
import System.Directory ( getAppUserDataDirectory )
#else
#if __GLASGOW_HASKELL__ < 603
import Compat.Directory ( getAppUserDataDirectory )
#endif
......@@ -58,15 +55,15 @@ import System.Environment ( getEnv )
import Distribution.InstalledPackageInfo
import Distribution.Package
import Distribution.Version
import System.Directory ( doesFileExist, doesDirectoryExist,
getDirectoryContents )
import Data.Maybe ( catMaybes )
import Control.Monad ( foldM )
import Data.List ( nub, partition, sortBy, isSuffixOf )
import FastString
import EXCEPTION ( throwDyn )
import ErrUtils ( debugTraceMsg, putMsg, Message )
import System.Directory
import Data.Maybe
import Control.Monad
import Data.List
import Control.Exception ( throwDyn )
-- ---------------------------------------------------------------------------
-- The Package state
......
......@@ -12,7 +12,7 @@ import ErrUtils ( mkLocMessage )
import SrcLoc
import Outputable
import Panic ( GhcException(..) )
import EXCEPTION ( throwDyn )
import Control.Exception ( throwDyn )
}
......
......@@ -76,11 +76,11 @@ import Util
import Maybes ( firstJust )
import Panic ( GhcException(..), ghcError )
import EXCEPTION ( throwDyn )
import DATA_IOREF
import UNSAFE_IO ( unsafePerformIO )
import Monad ( when )
import Char ( isDigit )
import Control.Exception ( throwDyn )
import Data.IORef
import System.IO.Unsafe ( unsafePerformIO )
import Control.Monad ( when )
import Data.Char ( isDigit )
import Data.List ( sort, intersperse, nub )
-----------------------------------------------------------------------------
......
......@@ -37,31 +37,27 @@ module SysTools (
#include "HsVersions.h"
import DriverPhases ( isHaskellUserSrcFilename )
import DriverPhases
import Config
import Outputable
import ErrUtils ( putMsg, debugTraceMsg, showPass, Severity(..), Messages )
import Panic ( GhcException(..) )
import Util ( Suffix, global, notNull, consIORef, joinFileName,
normalisePath, pgmPath, platformPath, joinFileExt )
import DynFlags ( DynFlags(..), DynFlag(..), dopt, Option(..),
setTmpDir, defaultDynFlags )
import EXCEPTION ( throwDyn, finally )
import DATA_IOREF ( IORef, readIORef, writeIORef )
import DATA_INT
import Monad ( when, unless )
import System ( ExitCode(..), getEnv, system )
import IO ( try, catch, hGetContents,
openFile, hPutStr, hClose, hFlush, IOMode(..),
stderr, ioError, isDoesNotExistError,
isAlreadyExistsError )
import Directory ( doesFileExist, removeFile,
createDirectory, removeDirectory )
import Maybe ( isJust )
import List ( partition )
import FiniteMap ( FiniteMap, emptyFM, lookupFM, addToFM, eltsFM )
import ErrUtils
import Panic
import Util
import DynFlags
import FiniteMap
import Control.Exception
import Data.IORef
import Data.Int
import Control.Monad
import System.Exit
import System.Cmd
import System.Environment
import System.IO
import SYSTEM_IO_ERROR as IO
import System.Directory
import Data.Maybe
import Data.List
-- GHC <= 4.08 didn't have rawSystem, and runs into problems with long command
-- lines on mingw32, so we disallow it now.
......@@ -88,10 +84,8 @@ import Text.Regex
-- rawSystem comes from libghccompat.a in stage1
import Compat.RawSystem ( rawSystem )
import GHC.IOBase ( IOErrorType(..) )
import System.IO.Error ( ioeGetErrorType )
#else
import System.Process ( runInteractiveProcess, getProcessExitCode )
import System.IO ( hSetBuffering, hGetLine, BufferMode(..) )
import Control.Concurrent( forkIO, newChan, readChan, writeChan )
import Data.Char ( isSpace )
import FastString ( mkFastString )
......
......@@ -53,10 +53,10 @@ import FastString
import List ( intersperse )
#endif
import DATA_INT
import DATA_WORD
import DATA_BITS
import GLAEXTS
import Data.Int
import Data.Word
import Data.Bits
import GHC.Exts
{-
The native-code generator has machine-independent and
......
......@@ -42,13 +42,13 @@ import Constants ( wORD_SIZE )
#ifdef DEBUG
import Outputable ( assertPanic )
import TRACE ( trace )
import Debug.Trace ( trace )
#endif
import Control.Monad ( mapAndUnzipM )
import Maybe ( fromJust )
import DATA_BITS
import DATA_WORD
import Data.Maybe ( fromJust )
import Data.Bits
import Data.Word
-- -----------------------------------------------------------------------------
-- Top-level of the instruction selector
......
......@@ -43,7 +43,7 @@ import Outputable
import FastString
import Constants ( wORD_SIZE )
import GLAEXTS
import GHC.Exts
-- -----------------------------------------------------------------------------
......
......@@ -39,20 +39,15 @@ import qualified Outputable
import StaticFlags ( opt_PIC, opt_Static )
#if __GLASGOW_HASKELL__ >= 504
import Data.Array.ST
import Data.Word ( Word8 )
#else
import MutableArray
#endif
import MONAD_ST
import Char ( chr, ord )
import Maybe ( isJust )
import Control.Monad.ST
import Data.Char ( chr, ord )
import Data.Maybe ( isJust )
#if powerpc_TARGET_ARCH || darwin_TARGET_OS
import DATA_WORD(Word32)
import DATA_BITS
import Data.Word(Word32)
import Data.Bits
#endif
-- -----------------------------------------------------------------------------
......
......@@ -100,13 +100,13 @@ import UniqSupply
import Outputable
#ifndef DEBUG
import Maybe ( fromJust )
import Data.Maybe ( fromJust )
#endif
import Maybe ( fromMaybe )
import List ( nub, partition, mapAccumL, groupBy )
import Monad ( when )
import DATA_WORD
import DATA_BITS
import Data.Maybe ( fromMaybe )
import Data.List ( nub, partition, mapAccumL, groupBy )
import Control.Monad ( when )
import Data.Word
import Data.Bits
-- -----------------------------------------------------------------------------
-- Some useful types
......
......@@ -17,9 +17,9 @@ module Ctype
#include "HsVersions.h"
import DATA_INT ( Int32 )
import DATA_BITS ( Bits((.&.)) )
import Char ( ord, chr )
import Data.Int ( Int32 )
import Data.Bits ( Bits((.&.)) )
import Data.Char ( ord, chr )
\end{code}
Bit masks
......
......@@ -43,10 +43,10 @@ import DynFlags
import Ctype
import Util ( maybePrefixMatch, readRational )
import DATA_BITS
import Data.Bits
import Data.Char ( chr, isSpace )
import Ratio
import TRACE
import Data.Ratio
import Debug.Trace
#if __GLASGOW_HASKELL__ >= 605
import Data.Char ( GeneralCategory(..), generalCategory, isPrint, isUpper )
......
......@@ -42,10 +42,10 @@ import HaddockUtils
import FastString
import Maybes ( orElse )
import Monad ( when )
import Outputable
import GLAEXTS
import Control.Monad ( when )
import GHC.Exts
import Data.Char
import Control.Monad ( mplus )
}
......
%
% (c) The University of Glasgow 2006
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[Bags]{@Bag@: an unordered collection with duplicates}
Bag: an unordered collection with duplicates
\begin{code}
module Bag (
......@@ -20,7 +22,8 @@ module Bag (
import Outputable
import Util ( isSingleton )
import List ( partition )
import Data.List ( partition )
\end{code}
......
{-# OPTIONS -cpp #-}
--
-- (c) The University of Glasgow 2002
-- (c) The University of Glasgow 2002-2006
--
-- Binary I/O library, with special tweaks for GHC
--
......@@ -59,7 +59,7 @@ import Unique
import Panic
import UniqFM
import FastMutInt
import PackageConfig ( PackageId, packageIdFS, fsToPackageId )
import PackageConfig
import Foreign
import Data.Array.IO
......
......@@ -2,7 +2,7 @@
--
-- Fast write-buffered Handles
--
-- (c) The University of Glasgow 2005
-- (c) The University of Glasgow 2005-2006
--
-- This is a simple abstraction over Handles that offers very fast write
-- buffering, but without the thread safety that Handles provide. It's used
......@@ -26,16 +26,16 @@ import FastString
import FastMutInt
import Panic ( panic )
import Monad ( when )
import Char ( ord )
import Control.Monad ( when )
import Data.Char ( ord )
import Foreign
import IO
import System.IO
import GHC.IOBase ( IO(..) )
import System.IO ( hPutBuf )
import GHC.Ptr ( Ptr(..) )
import GLAEXTS ( Int(..), Int#, Addr# )
import GHC.Exts ( Int(..), Int#, Addr# )
-- -----------------------------------------------------------------------------
......
%
% (c) The University of Glasgow 2006
%
\begin{code}
module Digraph(
......@@ -34,22 +38,20 @@ module Digraph(
import Util ( sortLe )
import Outputable
-- Extensions
import MONAD_ST
import Control.Monad.ST
-- std interfaces
import Maybe
import Array
import List
import Outputable
import Data.Maybe
import Data.Array
import Data.List
#if __GLASGOW_HASKELL__ > 604
import Data.Array.ST
#elif __GLASGOW_HASKELL__ >= 504
import Data.Array.ST hiding ( indices, bounds )
#else
import ST
import Data.Array.ST hiding ( indices, bounds )
#endif
\end{code}
......
{-# OPTIONS -cpp #-}
--
-- (c) The University of Glasgow 2002
-- (c) The University of Glasgow 2002-2006
--
-- Unboxed mutable Ints
......@@ -17,13 +17,8 @@ module FastMutInt(
#endif
#if __GLASGOW_HASKELL__ < 503
import GlaExts
import PrelIOBase
#else
import GHC.Base
import GHC.IOBase
#endif
#if __GLASGOW_HASKELL__ < 411
newByteArray# = newCharArray#
......
%
% (c) The University of Glasgow, 2000
% (c) The University of Glasgow, 2000-2006
%
\section{Fast integers and booleans}
......@@ -17,7 +17,7 @@ module FastTypes (
#if defined(__GLASGOW_HASKELL__)
-- Import the beggars
import GLAEXTS
import GHC.Exts
( Int(..), Int#, (+#), (-#), (*#),
quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
)
......
%
% (c) The University of Glasgow 2006
% (c) The AQUA Project, Glasgow University, 1994-1998
%
\section[FiniteMap]{An implementation of finite maps}
``Finite maps'' are the heart of the compiler's
lookup-tables/environments and its implementation of sets. Important
......@@ -62,7 +62,7 @@ import Bag ( Bag, foldrBag )
import Util
import Outputable
import GLAEXTS
import GHC.Exts
#if ! OMIT_NATIVE_CODEGEN
# define IF_NCG(a) a
......
-- (c) The University of Glasgow 2002
--
-- (c) The University of Glasgow 2002-2006
--
-- The IO Monad with an environment
--
......@@ -26,9 +27,10 @@ module IOEnv (
#include "HsVersions.h"
import Panic ( try, tryUser, tryMost, Exception(..) )
import DATA_IOREF ( IORef, newIORef, readIORef, writeIORef )
import UNSAFE_IO ( unsafeInterleaveIO )
import FIX_IO ( fixIO )
import Data.IORef ( IORef, newIORef, readIORef, writeIORef )
import System.IO.Unsafe ( unsafeInterleaveIO )
import System.IO ( fixIO )
----------------------------------------------------------------------
......
%
% (c) The University of Glasgow 2006
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[ListSetOps]{Set-like operations on lists}
......@@ -24,7 +25,8 @@ import Outputable
import Unique ( Unique )
import UniqFM ( eltsUFM, emptyUFM, addToUFM_C )
import Util ( isn'tIn, isIn, mapAccumR, sortLe )
import List ( partition )
import Data.List ( partition )
\end{code}
......
%
% (c) The University of Glasgow 2006
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[Maybes]{The `Maybe' types and associated utility functions}
\begin{code}
module Maybes (
module Maybe, -- Re-export all of Maybe
module Data.Maybe, -- Re-export all of Maybe
MaybeErr(..), -- Instance of Monad
failME, isSuccess,
......@@ -22,8 +22,7 @@ module Maybes (
#include "HsVersions.h"
import Maybe
import Data.Maybe
infixr 4 `orElse`
\end{code}
......
%
% (c) The University of Glasgow 2006
% (c) The AQUA Project, Glasgow University, 1993-1998
%
......
%
% (c) The University of Glasgow 2006
% (c) The GRASP Project, Glasgow University, 1992-1998
%
\section[Outputable]{Classes for pretty-printing}
Defines classes for pretty-printing and forcing, both forms of
``output.''
Outputable: defines classes for pretty-printing and forcing, both
forms of ``output.''
\begin{code}
......@@ -62,10 +62,9 @@ import qualified Pretty
import Pretty ( Doc, Mode(..) )
import Panic
import DATA_WORD ( Word32 )
import IO ( Handle, stderr, stdout, hFlush )
import Char ( ord )
import Data.Word ( Word32 )
import System.IO ( Handle, stderr, stdout, hFlush )
import Data.Char ( ord )
\end{code}
......
%
% (c) The University of Glasgow 2006
% (c) The GRASP Project, Glasgow University, 1992-2000
%
\section{Panic error messages}
Defines basic funtions for printing error messages.
......@@ -39,24 +39,15 @@ import Posix ( Handler(Catch), installHandler, sigINT, sigQUIT )
import GHC.ConsoleHandler
#endif
# if __GLASGOW_HASKELL__ < 500
import EXCEPTION ( raiseInThread )
# else
import EXCEPTION ( throwTo )
# endif /* GHC < 500 */
#if __GLASGOW_HASKELL__ > 408
import EXCEPTION ( catchJust, tryJust, ioErrors )
#endif
import CONCURRENT ( myThreadId, MVar, ThreadId, withMVar, newEmptyMVar )
import DYNAMIC
import qualified EXCEPTION as Exception
import TRACE ( trace )
import UNSAFE_IO ( unsafePerformIO )
import IO ( isUserError )
import System
import Control.Exception hiding (try)
import Control.Concurrent ( myThreadId, MVar, ThreadId, withMVar, newEmptyMVar )
import Data.Dynamic
import qualified Control.Exception as Exception
import Debug.Trace ( trace )
import System.IO.Unsafe ( unsafePerformIO )
import System.IO.Error ( isUserError )
import System.Exit
import System.Environment
\end{code}
GHC's own exception type.
......
......@@ -180,12 +180,10 @@ module Pretty (
import BufWrite
import FastString
import GLAEXTS
import GHC.Exts