Push this further along, and fix build problems in the first patch.
* 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); \
#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 )
-----------------------------------------------------------------
--
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
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 ->
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
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
-- -----------------------------------------------------------------------------
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
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 )
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:
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
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
import SrcLoc
import Outputable
import Panic ( GhcException(..) )
-import EXCEPTION ( throwDyn )
+import Control.Exception ( throwDyn )
}
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 )
-----------------------------------------------------------------------------
#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.
-- 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 )
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
#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
import FastString
import Constants ( wORD_SIZE )
-import GLAEXTS
+import GHC.Exts
-- -----------------------------------------------------------------------------
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
-- -----------------------------------------------------------------------------
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
#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
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 )
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 (
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
--
import Panic
import UniqFM
import FastMutInt
-import PackageConfig ( PackageId, packageIdFS, fsToPackageId )
+import PackageConfig
import Foreign
import Data.Array.IO
--
-- 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
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(
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
#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}
#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
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
--
#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}
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,
#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}
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.
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.
import BufWrite
import FastString
-import GLAEXTS
+import GHC.Exts
import Numeric (fromRat)
-import IO
-
-import System.IO ( hPutBuf )
+import System.IO
import GHC.Base ( unpackCString# )
import GHC.Ptr ( Ptr(..) )
%
+% (c) The University of Glasgow 2006
% (c) The University of Glasgow, 1997-2006
%
-\section{String buffers}
Buffers for scanning string input stored in external arrays.
-%ilter
+%
+% (c) The University of Glasgow 2006
% (c) The AQUA Project, Glasgow University, 1994-1998
%
-\section[UniqFM]{Specialised finite maps, for things with @Uniques@}
+
+UniqFM: Specialised finite maps, for things with @Uniques@
Based on @FiniteMaps@ (as you would expect).
import FastTypes
import Outputable
-import GLAEXTS -- Lots of Int# operations
+import GHC.Exts -- Lots of Int# operations
\end{code}
%************************************************************************
%
+% (c) The University of Glasgow 2006
% (c) The AQUA Project, Glasgow University, 1994-1998
%
\section[UniqSet]{Specialised sets, for things with @Uniques@}
%
+% (c) The University of Glasgow 2006
% (c) The University of Glasgow 1992-2002
%
\section[Util]{Highly random utility functions}
import Panic ( panic, trace )
import FastTypes
-import EXCEPTION ( Exception(..), finally, throwDyn, catchDyn, throw )
-import qualified EXCEPTION as Exception
-import DYNAMIC ( Typeable )
-import DATA_IOREF ( IORef, newIORef )
-import UNSAFE_IO ( unsafePerformIO )
-import DATA_IOREF ( readIORef, writeIORef )
+import Control.Exception ( Exception(..), finally, catchDyn, throw )
+import qualified Control.Exception as Exception
+import Data.Dynamic ( Typeable )
+import Data.IORef ( IORef, newIORef )
+import System.IO.Unsafe ( unsafePerformIO )
+import Data.IORef ( readIORef, writeIORef )
-import qualified List ( elem, notElem )
+import qualified Data.List as List ( elem, notElem )
#ifndef DEBUG
-import List ( zipWith4 )
+import Data.List ( zipWith4 )
#endif
-import Monad ( when )
-import IO ( catch, isDoesNotExistError )
-import Directory ( doesDirectoryExist, createDirectory )
-import Char ( isUpper, isAlphaNum, isSpace, ord, isDigit )
-import Ratio ( (%) )
-import Time ( ClockTime )
-import Directory ( getModificationTime )
+import Control.Monad ( when )
+import SYSTEM_IO_ERROR as IO ( catch, isDoesNotExistError )
+import System.Directory ( doesDirectoryExist, createDirectory,
+ getModificationTime )
+import Data.Char ( isUpper, isAlphaNum, isSpace, ord, isDigit )
+import Data.Ratio ( (%) )
+import System.Time ( ClockTime )
infixr 9 `thenCmp`
\end{code}