From be33dbc967b4915cfdb0307ae1b7ae3cee651b8c Mon Sep 17 00:00:00 2001
From: simonm <unknown>
Date: Tue, 3 Feb 1998 17:16:13 +0000
Subject: [PATCH] [project @ 1998-02-03 17:13:54 by simonm] - Fixes for
 bootstrapping with 3.01.   - Use 'official' extension interfaces rather than
 internal prelude     modules (such as ArrBase) where possible.   - Remove
 some cruft.   - Delete some unused imports found by '-fwarn-unused-imports'.

---
 ghc/compiler/HsVersions.h              |  39 +++---
 ghc/compiler/basicTypes/Id.lhs         |  15 +--
 ghc/compiler/basicTypes/IdInfo.lhs     |  12 +-
 ghc/compiler/basicTypes/IdUtils.lhs    |   7 +-
 ghc/compiler/basicTypes/Name.lhs       |   6 +-
 ghc/compiler/basicTypes/UniqSupply.lhs |   8 +-
 ghc/compiler/basicTypes/Unique.lhs     |   1 -
 ghc/compiler/coreSyn/CoreSyn.lhs       |   4 +-
 ghc/compiler/coreSyn/CoreUnfold.lhs    |  22 +--
 ghc/compiler/coreSyn/CoreUtils.lhs     |   4 +-
 ghc/compiler/coreSyn/PprCore.lhs       |   6 +-
 ghc/compiler/hsSyn/HsBinds.lhs         |   3 +-
 ghc/compiler/hsSyn/HsCore.lhs          |   2 -
 ghc/compiler/hsSyn/HsDecls.lhs         |   4 +-
 ghc/compiler/hsSyn/HsPat.lhs           |   2 -
 ghc/compiler/hsSyn/HsPragmas.lhs       | 180 -------------------------
 ghc/compiler/hsSyn/HsTypes.lhs         |   3 +-
 ghc/compiler/main/CmdLineOpts.lhs      |  18 +--
 ghc/compiler/parser/UgenUtil.lhs       |   2 -
 ghc/compiler/prelude/PrelInfo.lhs      |  12 --
 ghc/compiler/prelude/PrelVals.lhs      |   9 +-
 ghc/compiler/prelude/StdIdInfo.lhs     |   2 +-
 ghc/compiler/prelude/TysPrim.lhs       |   2 +-
 ghc/compiler/profiling/CostCentre.lhs  |   5 +-
 ghc/compiler/reader/Lex.lhs            |   2 +-
 ghc/compiler/reader/RdrHsSyn.lhs       |   7 +-
 ghc/compiler/rename/Rename.lhs         |  13 +-
 ghc/compiler/rename/RnBinds.lhs        |   4 +-
 ghc/compiler/rename/RnEnv.lhs          |  12 +-
 ghc/compiler/rename/RnExpr.lhs         |   7 +-
 ghc/compiler/rename/RnIfaces.lhs       |  15 +--
 ghc/compiler/rename/RnNames.lhs        |   5 +-
 ghc/compiler/rename/RnSource.lhs       |  20 +--
 ghc/compiler/simplCore/OccurAnal.lhs   |  11 +-
 ghc/compiler/simplCore/SimplEnv.lhs    |  23 ++--
 ghc/compiler/specialise/SpecEnv.lhs    |   2 +-
 ghc/compiler/stranal/WwLib.lhs         |  11 +-
 ghc/compiler/types/Class.lhs           |   3 +-
 ghc/compiler/types/TyCon.lhs           |   9 +-
 ghc/compiler/types/Type.lhs            |   3 +-
 ghc/compiler/utils/Argv.lhs            |   4 +-
 ghc/compiler/utils/Digraph.lhs         |  12 +-
 ghc/compiler/utils/FastString.lhs      |  53 +++++---
 ghc/compiler/utils/ListSetOps.lhs      |  25 +---
 ghc/compiler/utils/OrdList.lhs         |   2 -
 ghc/compiler/utils/Outputable.lhs      |   2 +-
 ghc/compiler/utils/PrimPacked.lhs      |  29 ++--
 ghc/compiler/utils/SST.lhs             |  14 +-
 ghc/compiler/utils/StringBuffer.lhs    |  21 ++-
 ghc/compiler/utils/UniqFM.lhs          |   2 -
 ghc/compiler/utils/UniqSet.lhs         |   2 -
 51 files changed, 201 insertions(+), 480 deletions(-)

diff --git a/ghc/compiler/HsVersions.h b/ghc/compiler/HsVersions.h
index 2e1b15404495..cd5c2207b5b9 100644
--- a/ghc/compiler/HsVersions.h
+++ b/ghc/compiler/HsVersions.h
@@ -43,9 +43,6 @@ you will screw up the layout where they are used in case expressions!
 # define seqStrictlyST seqST
 # define thenStrictlyST thenST
 # define returnStrictlyST return
-# define _readHandle IOHandle.readHandle
-# define _writeHandle IOHandle.writeHandle
-# define _newHandle   IOHandle.newdHandle
 # define MkST ST
 # if __GLASGOW_HASKELL__ >= 209
 #  define STATE_TOK(x)    x
@@ -61,7 +58,6 @@ you will screw up the layout where they are used in case expressions!
 # define failWith fail
 # define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
 # define CCALL_THEN thenIO_Prim
-# define _filePtr IOHandle.filePtr
 # define Text Show
 # define IMP_FASTSTRING() import FastString
 # if __GLASGOW_HASKELL__ >= 209
@@ -93,9 +89,10 @@ you will screw up the layout where they are used in case expressions!
 #if defined(__GLASGOW_HASKELL__)
 
 -- Import the beggars
-import GlaExts	( Int(..), Int#, (+#), (-#), (*#), 
-		  quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
-		)
+import GlaExts
+	( Int(..), Int#, (+#), (-#), (*#), 
+	  quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
+	)
 
 #define FAST_INT Int#
 #define ILIT(x) (x#)
@@ -146,24 +143,22 @@ import GlaExts	( Int(..), Int#, (+#), (-#), (*#),
 -- when compiling FastString itself
 #ifndef COMPILING_FAST_STRING
 -- 
-import FastString	( FastString, mkFastString, mkFastCharString#, nullFastString, 
-			  consFS, headFS, tailFS, lengthFS, unpackFS, appendFS, concatFS
-			)
+import qualified FastString 
 #endif
 
 # define USE_FAST_STRINGS 1
-# define FAST_STRING	FastString
-# define SLIT(x)	(mkFastCharString# (x#))
-# define _NULL_		nullFastString
-# define _NIL_		(mkFastString "")
-# define _CONS_		consFS
-# define _HEAD_		headFS
-# define _TAIL_		tailFS
-# define _LENGTH_	lengthFS
-# define _PK_		mkFastString
-# define _UNPK_		unpackFS
-# define _APPEND_	`appendFS`
-# define _CONCAT_	concatFS
+# define FAST_STRING	FastString.FastString
+# define SLIT(x)	(FastString.mkFastCharString# (x#))
+# define _NULL_		FastString.nullFastString
+# define _NIL_		(FastString.mkFastString "")
+# define _CONS_		FastString.consFS
+# define _HEAD_		FastString.headFS
+# define _TAIL_		FastString.tailFS
+# define _LENGTH_	FastString.lengthFS
+# define _PK_		FastString.mkFastString
+# define _UNPK_		FastString.unpackFS
+# define _APPEND_	`FastString.appendFS`
+# define _CONCAT_	FastString.concatFS
 #else
 # define FAST_STRING String
 # define SLIT(x)      (x)
diff --git a/ghc/compiler/basicTypes/Id.lhs b/ghc/compiler/basicTypes/Id.lhs
index dc1cca8b5571..51133408677b 100644
--- a/ghc/compiler/basicTypes/Id.lhs
+++ b/ghc/compiler/basicTypes/Id.lhs
@@ -148,23 +148,20 @@ import BasicTypes	( Arity )
 import IdInfo
 import Maybes		( maybeToBool )
 import Name	 	( nameUnique, mkLocalName, mkSysLocalName, isLocalName,
-			  mkCompoundName,
-			  isLocallyDefinedName, occNameString, modAndOcc,
-			  isLocallyDefined, changeUnique, isWiredInName,
-			  nameString, getOccString, setNameVisibility,
-			  isExported, ExportFlag(..), Provenance,
+			  mkCompoundName, occNameString, modAndOcc,
+			  changeUnique, isWiredInName, setNameVisibility,
+			  ExportFlag(..), Provenance,
 			  OccName(..), Name, Module,
 			  NamedThing(..)
 			) 
 import PrimOp		( PrimOp )
 import PrelMods		( pREL_TUP, pREL_BASE )
-import Lex		( mkTupNameStr )
 import FieldLabel	( fieldLabelName, FieldLabel(..){-instances-} )
 import PragmaInfo	( PragmaInfo(..) )
 import SrcLoc		( mkBuiltinSrcLoc )
 import TysWiredIn	( tupleTyCon )
 import TyCon		( TyCon, tyConDataCons, isDataTyCon, isNewTyCon, mkSpecTyCon )
-import Type		( mkSigmaTy, mkTyVarTys, mkFunTys, splitSigmaTy,
+import Type		( mkSigmaTy, mkTyVarTys, mkFunTys,
 			  mkTyConApp, instantiateTy, mkForAllTys,
 			  tyVarsOfType, instantiateTy, typePrimRep,
 			  instantiateTauTy,
@@ -175,10 +172,10 @@ import TyVar		( TyVar, alphaTyVars, isEmptyTyVarSet,
 			)
 import UniqFM
 import UniqSet		-- practically all of it
-import Unique		( getBuiltinUniques, pprUnique, Unique, Uniquable(..) )
+import Unique		( getBuiltinUniques, Unique, Uniquable(..) )
 import Outputable
 import SrcLoc		( SrcLoc )
-import Util		( mapAccumL, nOfThem, zipEqual, assoc )
+import Util		( nOfThem, assoc )
 import GlaExts		( Int# )
 \end{code}
 
diff --git a/ghc/compiler/basicTypes/IdInfo.lhs b/ghc/compiler/basicTypes/IdInfo.lhs
index 8539d005e9b2..d50a60edc139 100644
--- a/ghc/compiler/basicTypes/IdInfo.lhs
+++ b/ghc/compiler/basicTypes/IdInfo.lhs
@@ -54,13 +54,9 @@ import SpecEnv	        ( SpecEnv, emptySpecEnv, isEmptySpecEnv )
 import BasicTypes	( NewOrData )
 
 import Demand
-import Maybes		( firstJust )
 import Outputable	
-import Unique		( pprUnique )
-import Util		( mapAccumL )
 
-ord = fromEnum :: Char -> Int
-showTypeCategory = panic "IdInfo.showTypeCategory"
+import Char 		( ord )
 \end{code}
 
 An @IdInfo@ gives {\em optional} information about an @Id@.  If
@@ -376,11 +372,7 @@ updateInfoMaybe (SomeUpdateInfo	 u) = Just u
 Text instance so that the update annotations can be read in.
 
 \begin{code}
-#ifdef REALLY_HASKELL_1_3
 instance Read UpdateInfo where
-#else
-instance Text UpdateInfo where
-#endif
     readsPrec p s | null s    = panic "IdInfo: empty update pragma?!"
 		  | otherwise = [(SomeUpdateInfo (map ok_digit s),"")]
       where
@@ -429,8 +421,10 @@ argUsageInfo (IdInfo _ _ _ _ _ _ au _) = au
 addArgUsageInfo id_info			   NoArgUsageInfo = id_info
 addArgUsageInfo (IdInfo a b d e f g _ h) au_info	  = IdInfo a b d e f g au_info h
 
+{- UNUSED:
 ppArgUsageInfo NoArgUsageInfo	  = empty
 ppArgUsageInfo (SomeArgUsageInfo aut) = (<>) (ptext SLIT("_L_ ")) (ppArgUsageType aut)
+-}
 
 ppArgUsage (ArgUsage n)      = int n
 ppArgUsage (UnknownArgUsage) = char '-'
diff --git a/ghc/compiler/basicTypes/IdUtils.lhs b/ghc/compiler/basicTypes/IdUtils.lhs
index 7307caa5cb1d..fe04abfd7ba6 100644
--- a/ghc/compiler/basicTypes/IdUtils.lhs
+++ b/ghc/compiler/basicTypes/IdUtils.lhs
@@ -9,15 +9,14 @@ module IdUtils ( primOpName ) where
 #include "HsVersions.h"
 
 import CoreSyn
-import CoreUnfold	( UnfoldingGuidance(..), Unfolding, mkUnfolding )
+import CoreUnfold	( Unfolding )
 import Id		( mkPrimitiveId )
 import IdInfo		-- quite a few things
 import StdIdInfo
 import Name		( mkWiredInIdName, Name )
-import PrimOp		( primOpInfo, tagOf_PrimOp, primOp_str,
-			  PrimOpInfo(..), PrimOpResultInfo(..), PrimOp )
+import PrimOp		( primOpInfo, tagOf_PrimOp, PrimOpInfo(..), PrimOp )
 import PrelMods		( pREL_GHC )
-import Type		( mkForAllTys, mkFunTy, mkFunTys, mkTyVarTy, mkTyConApp )
+import Type		( mkForAllTys, mkFunTy, mkFunTys, mkTyConApp )
 import TysWiredIn	( boolTy )
 import Unique		( mkPrimOpIdUnique )
 import Util		( panic )
diff --git a/ghc/compiler/basicTypes/Name.lhs b/ghc/compiler/basicTypes/Name.lhs
index 9951f988f510..ac4738729034 100644
--- a/ghc/compiler/basicTypes/Name.lhs
+++ b/ghc/compiler/basicTypes/Name.lhs
@@ -57,11 +57,11 @@ module Name (
 import {-# SOURCE #-} Id    ( Id )
 import {-# SOURCE #-} TyCon ( TyCon )
 
-import CStrings		( identToC, modnameToC, cSEP )
+import CStrings		( identToC )
 import CmdLineOpts	( opt_PprStyle_All, opt_OmitInterfacePragmas, opt_EnsureSplittableC )
 import BasicTypes	( Module, IfaceFlavour(..), moduleString, pprModule )
 
-import Lex		( isLexSym, isLexConId )
+import Lex		( isLexConId )
 import SrcLoc		( noSrcLoc, mkBuiltinSrcLoc, SrcLoc )
 import Unique		( pprUnique, showUnique, Unique, Uniquable(..) )
 import UniqSet		( UniqSet(..), emptyUniqSet, unitUniqSet, unionUniqSets, uniqSetToList, 
@@ -558,14 +558,12 @@ class NamedThing a where
 
 \begin{code}
 modAndOcc	    :: NamedThing a => a -> (Module, OccName)
-getModule	    :: NamedThing a => a -> Module
 getSrcLoc	    :: NamedThing a => a -> SrcLoc
 isLocallyDefined    :: NamedThing a => a -> Bool
 isExported	    :: NamedThing a => a -> Bool
 getOccString	    :: NamedThing a => a -> String
 
 modAndOcc	    = nameModAndOcc	   . getName
-getModule	    = nameModule	   . getName
 isExported	    = isExportedName 	   . getName
 getSrcLoc	    = nameSrcLoc	   . getName
 isLocallyDefined    = isLocallyDefinedName . getName
diff --git a/ghc/compiler/basicTypes/UniqSupply.lhs b/ghc/compiler/basicTypes/UniqSupply.lhs
index 23bd2c051e9e..4b83b52a610b 100644
--- a/ghc/compiler/basicTypes/UniqSupply.lhs
+++ b/ghc/compiler/basicTypes/UniqSupply.lhs
@@ -24,10 +24,12 @@ module UniqSupply (
 import Unique
 import Util
 
-
 import GlaExts
-import IOBase	( IO(..), IOResult(..) )
-import PrelBase ( Char(..) )
+
+#if __GLASGOW_HASKELL__ < 301
+import IOBase		( IO(..), IOResult(..) )
+#else
+#endif
 
 w2i x = word2Int# x
 i2w x = int2Word# x
diff --git a/ghc/compiler/basicTypes/Unique.lhs b/ghc/compiler/basicTypes/Unique.lhs
index c6b6f0a11b3a..44a06129de8d 100644
--- a/ghc/compiler/basicTypes/Unique.lhs
+++ b/ghc/compiler/basicTypes/Unique.lhs
@@ -638,7 +638,6 @@ errorIdKey		      = mkPreludeMiscIdUnique  7
 foldlIdKey		      = mkPreludeMiscIdUnique  8
 foldrIdKey		      = mkPreludeMiscIdUnique  9
 forkIdKey   	    	      = mkPreludeMiscIdUnique 10
-int2IntegerIdKey	      = mkPreludeMiscIdUnique 11
 integerMinusOneIdKey	      = mkPreludeMiscIdUnique 12
 integerPlusOneIdKey	      = mkPreludeMiscIdUnique 13
 integerPlusTwoIdKey	      = mkPreludeMiscIdUnique 14
diff --git a/ghc/compiler/coreSyn/CoreSyn.lhs b/ghc/compiler/coreSyn/CoreSyn.lhs
index 596a7c2a69a0..a6fe32dce1a1 100644
--- a/ghc/compiler/coreSyn/CoreSyn.lhs
+++ b/ghc/compiler/coreSyn/CoreSyn.lhs
@@ -53,11 +53,11 @@ module CoreSyn (
 
 #include "HsVersions.h"
 
-import CostCentre	( showCostCentre, CostCentre )
+import CostCentre	( CostCentre )
 import Id		( idType, GenId{-instance Eq-}, Id )
 import Type		( isUnboxedType,GenType, Type )
 import TyVar		( GenTyVar, TyVar )
-import Util		( panic, assertPanic {-pprTrace:ToDo:rm-} )
+import Util		( panic, assertPanic )
 import BinderInfo       ( BinderInfo )
 import BasicTypes	( Unused )
 import Literal          ( Literal )
diff --git a/ghc/compiler/coreSyn/CoreUnfold.lhs b/ghc/compiler/coreSyn/CoreUnfold.lhs
index c92ffe6bdf65..31276b697e15 100644
--- a/ghc/compiler/coreSyn/CoreUnfold.lhs
+++ b/ghc/compiler/coreSyn/CoreUnfold.lhs
@@ -15,14 +15,14 @@ find, unsurprisingly, a Core expression.
 \begin{code}
 module CoreUnfold (
 	SimpleUnfolding(..), Unfolding(..), UnfoldingGuidance(..), -- types
-	UfExpr,	RdrName, -- For closure (delete in 1.3)
 
-	FormSummary(..), mkFormSummary, whnfOrBottom, exprSmallEnoughToDup, exprIsTrivial,
+	FormSummary(..), mkFormSummary, whnfOrBottom, exprSmallEnoughToDup, 
+	exprIsTrivial,
 
 	noUnfolding, mkMagicUnfolding, mkUnfolding, getUnfoldingTemplate,
 
-	smallEnoughToInline, couldBeSmallEnoughToInline, certainlySmallEnoughToInline,
-	inlineUnconditionally,
+	smallEnoughToInline, couldBeSmallEnoughToInline, 
+	certainlySmallEnoughToInline, inlineUnconditionally,
 
 	calcUnfoldingGuidance,
 
@@ -33,8 +33,6 @@ module CoreUnfold (
 
 import {-# SOURCE #-} MagicUFs	( MagicUnfoldingFun, mkMagicUnfoldingFun )
 
-import Bag		( emptyBag, unitBag, unionBags, Bag )
-
 import CmdLineOpts	( opt_UnfoldingCreationThreshold,
 			  opt_UnfoldingUseThreshold,
 			  opt_UnfoldingConDiscount,
@@ -49,23 +47,17 @@ import BinderInfo	( BinderInfo, isOneFunOcc, isOneSafeFunOcc
 import PragmaInfo	( PragmaInfo(..) )
 import CoreSyn
 import CoreUtils	( unTagBinders )
-import HsCore		( UfExpr )
-import RdrHsSyn		( RdrName )
 import OccurAnal	( occurAnalyseGlobalExpr )
 import CoreUtils	( coreExprType )
 import Id		( Id, idType, getIdArity,  isBottomingId, isDataCon,
 			  idWantsToBeINLINEd, idMustBeINLINEd, idMustNotBeINLINEd,
 			  IdSet, GenId{-instances-} )
-import PrimOp		( primOpCanTriggerGC, fragilePrimOp, PrimOp(..) )
-import IdInfo		( ArityInfo(..), bottomIsGuaranteed )
-import Literal		( isNoRepLit, isLitLitLit )
+import PrimOp		( fragilePrimOp, primOpCanTriggerGC )
+import IdInfo		( ArityInfo(..) )
+import Literal		( isNoRepLit )
 import TyCon		( tyConFamilySize )
 import Type		( splitAlgTyConApp_maybe )
 import Unique           ( Unique )
-import UniqSet		( emptyUniqSet, unitUniqSet, mkUniqSet,
-			  addOneToUniqSet, unionUniqSets
-			)
-import Maybes		( maybeToBool )
 import Util		( isIn, panic, assertPanic )
 import Outputable
 \end{code}
diff --git a/ghc/compiler/coreSyn/CoreUtils.lhs b/ghc/compiler/coreSyn/CoreUtils.lhs
index bfc21df7426c..1ecaadf61e61 100644
--- a/ghc/compiler/coreSyn/CoreUtils.lhs
+++ b/ghc/compiler/coreSyn/CoreUtils.lhs
@@ -29,7 +29,7 @@ import Id		( idType, mkSysLocal, isBottomingId,
 			  addOneToIdEnv, growIdEnvList, lookupIdEnv,
 			  isNullIdEnv, IdEnv, Id
 			)
-import Literal		( literalType, isNoRepLit, Literal(..) )
+import Literal		( literalType, Literal(..) )
 import Maybes		( catMaybes, maybeToBool )
 import PprCore
 import PrimOp		( primOpType, PrimOp(..) )
@@ -46,7 +46,7 @@ import Type		( mkFunTy, mkForAllTy, mkTyVarTy,
 import TysWiredIn	( trueDataCon, falseDataCon )
 import Unique		( Unique )
 import BasicTypes	( Unused )
-import UniqSupply	( initUs, returnUs, thenUs,
+import UniqSupply	( returnUs, thenUs,
 			  mapUs, mapAndUnzipUs, getUnique,
 			  UniqSM, UniqSupply
 			)
diff --git a/ghc/compiler/coreSyn/PprCore.lhs b/ghc/compiler/coreSyn/PprCore.lhs
index 0c29fa035140..9eeadaf96a37 100644
--- a/ghc/compiler/coreSyn/PprCore.lhs
+++ b/ghc/compiler/coreSyn/PprCore.lhs
@@ -17,13 +17,11 @@ module PprCore (
 
 import CoreSyn
 import CostCentre	( showCostCentre )
-import Id		( idType, getIdInfo, getIdStrictness, isTupleCon,
-			  nullIdEnv, DataCon, GenId{-instances-},
-			  Id
+import Id		( idType, getIdInfo, isTupleCon,
+			  DataCon, GenId{-instances-}, Id
 			) 
 import IdInfo		( ppIdInfo, ppStrictnessInfo )
 import Literal		( Literal{-instances-} )
-import Name		( OccName )
 import Outputable	-- quite a few things
 import PprEnv
 import PprType		( pprParendGenType, pprTyVarBndr, GenType{-instances-}, GenTyVar{-instance-} )
diff --git a/ghc/compiler/hsSyn/HsBinds.lhs b/ghc/compiler/hsSyn/HsBinds.lhs
index d020b76baff0..b5578034d0a2 100644
--- a/ghc/compiler/hsSyn/HsBinds.lhs
+++ b/ghc/compiler/hsSyn/HsBinds.lhs
@@ -14,13 +14,12 @@ import {-# SOURCE #-} HsExpr    ( pprExpr, HsExpr )
 import {-# SOURCE #-} HsMatches ( pprMatches, Match, pprGRHSsAndBinds, GRHSsAndBinds )
 
 -- friends:
-import HsPragmas	( GenPragmas, ClassOpPragmas )
 import HsTypes		( HsType )
 import CoreSyn		( CoreExpr )
 import PprCore		()	   -- Instances for Outputable
 
 --others:
-import Id		( DictVar, Id, GenId )
+import Id		( Id, GenId )
 import Name		( OccName, NamedThing(..) )
 import BasicTypes	( RecFlag(..) )
 import Outputable	
diff --git a/ghc/compiler/hsSyn/HsCore.lhs b/ghc/compiler/hsSyn/HsCore.lhs
index 05226a126e2f..53d16be95590 100644
--- a/ghc/compiler/hsSyn/HsCore.lhs
+++ b/ghc/compiler/hsSyn/HsCore.lhs
@@ -21,9 +21,7 @@ module HsCore (
 
 -- friends:
 import HsTypes		( HsType, pprParendHsType )
-import PrimOp		( PrimOp, tagOf_PrimOp )
 import Kind		( Kind {- instance Outputable -} )
-import Type		( GenType {- instance Outputable -} )
 
 -- others:
 import Literal		( Literal )
diff --git a/ghc/compiler/hsSyn/HsDecls.lhs b/ghc/compiler/hsSyn/HsDecls.lhs
index f466d590028f..ce68cefce86f 100644
--- a/ghc/compiler/hsSyn/HsDecls.lhs
+++ b/ghc/compiler/hsSyn/HsDecls.lhs
@@ -13,9 +13,7 @@ module HsDecls where
 
 -- friends:
 import HsBinds		( HsBinds, MonoBinds, Sig, nullMonoBinds )
-import HsPragmas	( DataPragmas, ClassPragmas,
-			  InstancePragmas, ClassOpPragmas
-			)
+import HsPragmas	( DataPragmas, ClassPragmas )
 import HsTypes
 import HsCore		( UfExpr )
 import BasicTypes	( Fixity, NewOrData(..) )
diff --git a/ghc/compiler/hsSyn/HsPat.lhs b/ghc/compiler/hsSyn/HsPat.lhs
index 8e89bb2f3dad..ffbd373b16eb 100644
--- a/ghc/compiler/hsSyn/HsPat.lhs
+++ b/ghc/compiler/hsSyn/HsPat.lhs
@@ -214,8 +214,6 @@ pprOutPat (DictPat dicts methods)
 		  brackets (interpp'SP dicts),
 		  brackets (interpp'SP methods)])
 
-pprConPatTy ty
- = parens (ppr ty)
 \end{code}
 
 %************************************************************************
diff --git a/ghc/compiler/hsSyn/HsPragmas.lhs b/ghc/compiler/hsSyn/HsPragmas.lhs
index 418c1507830c..c2aed3620c10 100644
--- a/ghc/compiler/hsSyn/HsPragmas.lhs
+++ b/ghc/compiler/hsSyn/HsPragmas.lhs
@@ -16,10 +16,6 @@ module HsPragmas where
 
 #include "HsVersions.h"
 
--- friends:
-import HsTypes		( HsType )
-
--- others:
 import IdInfo
 import Outputable
 \end{code}
@@ -60,179 +56,3 @@ instance Outputable name => Outputable (InstancePragmas name) where
 instance Outputable name => Outputable (GenPragmas name) where
     ppr NoGenPragmas = empty
 \end{code}
-
-========================= OLD CODE SCEDULED FOR DELETION SLPJ Nov 96 ==============
-
-\begin{code}
-{-		COMMENTED OUT 
-
-Certain pragmas expect to be pinned onto certain constructs.
-
-Pragma types may be parameterised, just as with any other
-abstract-syntax type.
-
-For a @data@ declaration---indicates which specialisations exist.
-\begin{code}
-data DataPragmas name
-  = NoDataPragmas
-  | DataPragmas	[[Maybe (HsType name)]]  -- types to which specialised
-
-noDataPragmas = NoDataPragmas
-isNoDataPragmas NoDataPragmas = True
-\end{code}
-
-These are {\em general} things you can know about any value:
-\begin{code}
-data GenPragmas name
-  = NoGenPragmas
-  | GenPragmas	(Maybe Int)		-- arity (maybe)
-		(Maybe UpdateInfo)	-- update info (maybe)
-		(ImpStrictness name)	-- strictness, worker-wrapper
-		(ImpUnfolding name)	-- unfolding (maybe)
-		[([Maybe (HsType name)], -- Specialisations: types to which spec'd;
-		  Int,			   -- # dicts to ignore
-		  GenPragmas name)] 	   -- Gen info about the spec'd version
-
-noGenPragmas = NoGenPragmas
-
-isNoGenPragmas NoGenPragmas = True
-isNoGenPragmas _            = False
-
-data ImpUnfolding name
-  = NoImpUnfolding
-  | ImpMagicUnfolding FAST_STRING	-- magic "unfolding"
-					-- known to the compiler by "String"
-  | ImpUnfolding UnfoldingGuidance	-- always, if you like, etc.
-		 (UnfoldingCoreExpr name)
-
-data ImpStrictness name
-  = NoImpStrictness
-  | ImpStrictness Bool			-- True <=> bottoming Id
-		  [Demand]		-- demand info
-		  (GenPragmas name)	-- about the *worker*
-\end{code}
-
-For an ordinary imported function: it can have general pragmas (only).
-
-For a class's super-class dictionary selectors:
-\begin{code}
-data ClassPragmas name
-  = NoClassPragmas
-  | SuperDictPragmas [GenPragmas name]	-- list mustn't be empty
-
-noClassPragmas = NoClassPragmas
-
-isNoClassPragmas NoClassPragmas = True
-isNoClassPragmas _              = False
-\end{code}
-
-For a class's method selectors:
-\begin{code}
-data ClassOpPragmas name
-  = NoClassOpPragmas
-  | ClassOpPragmas  (GenPragmas name) -- for method selector
-		    (GenPragmas name) -- for default method
-
-
-noClassOpPragmas = NoClassOpPragmas
-
-isNoClassOpPragmas NoClassOpPragmas = True
-isNoClassOpPragmas _                = False
-\end{code}
-
-\begin{code}
-data InstancePragmas name
-  = NoInstancePragmas
-
-  | SimpleInstancePragma	   -- nothing but for the dfun itself...
-	(GenPragmas name)
-
-  | ConstantInstancePragma
-	(GenPragmas name)	   -- for the "dfun" itself
-	[(name, GenPragmas name)]  -- one per class op
-
-  | SpecialisedInstancePragma
-	(GenPragmas name)	   -- for its "dfun"
-	[([Maybe (HsType name)], -- specialised instance; type...
-	  Int,			   -- #dicts to ignore
-	  InstancePragmas name)]   -- (no SpecialisedInstancePragma please!)
-
-noInstancePragmas = NoInstancePragmas
-
-isNoInstancePragmas NoInstancePragmas = True
-isNoInstancePragmas _                 = False
-\end{code}
-
-Some instances for printing (just for debugging, really)
-\begin{code}
-instance Outputable name => Outputable (ClassPragmas name) where
-    ppr NoClassPragmas = empty
-    ppr (SuperDictPragmas sdsel_prags)
-      = ($$) (ptext SLIT("{-superdict pragmas-}"))
-		(ppr sdsel_prags)
-
-instance Outputable name => Outputable (ClassOpPragmas name) where
-    ppr NoClassOpPragmas = empty
-    ppr (ClassOpPragmas op_prags defm_prags)
-      = ($$) (hsep [ptext SLIT("{-meth-}"), ppr op_prags])
-		(hsep [ptext SLIT("{-defm-}"), ppr defm_prags])
-
-instance Outputable name => Outputable (InstancePragmas name) where
-    ppr NoInstancePragmas = empty
-    ppr (SimpleInstancePragma dfun_pragmas)
-      = hsep [ptext SLIT("{-dfun-}"), ppr dfun_pragmas]
-    ppr (ConstantInstancePragma dfun_pragmas name_pragma_pairs)
-      = ($$) (hsep [ptext SLIT("{-constm-}"), ppr dfun_pragmas])
-	    	(vcat (map pp_pair name_pragma_pairs))
-      where
-	pp_pair (n, prags)
-	  = hsep [ppr n, equals, ppr prags]
-
-    ppr (SpecialisedInstancePragma dfun_pragmas spec_pragma_info)
-      = ($$) (hsep [ptext SLIT("{-spec'd-}"), ppr dfun_pragmas])
-	    	(vcat (map pp_info spec_pragma_info))
-      where
-	pp_info (ty_maybes, num_dicts, prags)
-	  = hcat [brackets (hsep (map pp_ty ty_maybes)),
-		       parens (int num_dicts), equals, ppr prags]
-	pp_ty Nothing = ptext SLIT("_N_")
-	pp_ty (Just t)= ppr t
-
-instance Outputable name => Outputable (GenPragmas name) where
-    ppr NoGenPragmas = empty
-    ppr (GenPragmas arity_maybe upd_maybe def strictness unfolding specs)
-      = hsep [pp_arity arity_maybe, pp_upd upd_maybe, -- ToDo: print def?
-	       pp_str strictness, pp_unf unfolding,
-	       pp_specs specs]
-      where
-    	pp_arity Nothing  = empty
-	pp_arity (Just i) = (<>) (ptext SLIT("ARITY=")) (int i)
-
-	pp_upd Nothing  = empty
-	pp_upd (Just u) = ppUpdateInfo u
-
-	pp_str NoImpStrictness = empty
-	pp_str (ImpStrictness is_bot demands wrkr_prags)
-	  = hcat [ptext SLIT("IS_BOT="), ppr is_bot,
-		       ptext SLIT("STRICTNESS="), text (showList demands ""),
-		       ptext SLIT(" {"), ppr wrkr_prags, char '}']
-
-	pp_unf NoImpUnfolding = ptext SLIT("NO_UNFOLDING")
-	pp_unf (ImpMagicUnfolding m) = (<>) (ptext SLIT("MAGIC=")) (ptext m)
-	pp_unf (ImpUnfolding g core) = (<>) (ptext SLIT("UNFOLD=")) (ppr core)
-
-	pp_specs [] = empty
-	pp_specs specs
-	  = hcat [ptext SLIT("SPECS=["), hsep (map pp_spec specs), char ']']
-	  where
-	    pp_spec (ty_maybes, num_dicts, gprags)
-	      = hsep [brackets (hsep (map pp_MaB ty_maybes)), int num_dicts, ppr gprags]
-
-	    pp_MaB Nothing  = ptext SLIT("_N_")
-	    pp_MaB (Just x) = ppr x
-\end{code}
-
-
-\begin{code}
--}
-\end{code}
diff --git a/ghc/compiler/hsSyn/HsTypes.lhs b/ghc/compiler/hsSyn/HsTypes.lhs
index 759251b5fc15..e2b1354df660 100644
--- a/ghc/compiler/hsSyn/HsTypes.lhs
+++ b/ghc/compiler/hsSyn/HsTypes.lhs
@@ -23,8 +23,7 @@ module HsTypes (
 
 import Outputable
 import Kind		( Kind {- instance Outputable -} )
-import Name		( nameOccName )
-import Util		( thenCmp, cmpList, isIn, panic )
+import Util		( thenCmp, cmpList, panic )
 import GlaExts		( Int#, (<#) )
 \end{code}
 
diff --git a/ghc/compiler/main/CmdLineOpts.lhs b/ghc/compiler/main/CmdLineOpts.lhs
index 7b1a71d3336a..c9278fe78b87 100644
--- a/ghc/compiler/main/CmdLineOpts.lhs
+++ b/ghc/compiler/main/CmdLineOpts.lhs
@@ -105,12 +105,17 @@ module CmdLineOpts (
 
 import Array	( array, (//) )
 import GlaExts
-import ArrBase
 import Argv
 import Constants	-- Default values for some flags
 
 import Maybes		( assocMaybe, firstJust, maybeToBool )
-import Util		( startsWith, panic, panic#, assertPanic )
+import Util		( startsWith, panic, panic# )
+
+#if __GLASGOW_HASKELL__ < 301
+import ArrBase	( Array(..) )
+#else
+import PrelArr  ( Array(..) )
+#endif
 \end{code}
 
 A command-line {\em switch} is (generally) either on or off; e.g., the
@@ -588,15 +593,6 @@ switchIsOn lookup_fn switch
       SwBool False -> False
       _	    	   -> True
 
-stringSwitchSet :: (switch -> SwitchResult)
-		-> (FAST_STRING -> switch)
-		-> Maybe FAST_STRING
-
-stringSwitchSet lookup_fn switch
-  = case (lookup_fn (switch (panic "stringSwitchSet"))) of
-      SwString str -> Just str
-      _	    	   -> Nothing
-
 intSwitchSet :: (switch -> SwitchResult)
 	     -> (Int -> switch)
 	     -> Maybe Int
diff --git a/ghc/compiler/parser/UgenUtil.lhs b/ghc/compiler/parser/UgenUtil.lhs
index 10bcca358b3e..c73b6cefa9fe 100644
--- a/ghc/compiler/parser/UgenUtil.lhs
+++ b/ghc/compiler/parser/UgenUtil.lhs
@@ -12,8 +12,6 @@ module UgenUtil (
 
 import GlaExts
 import Name
-import RdrHsSyn		( RdrName(..) )
-import BasicTypes	( IfaceFlavour )
 import SrcLoc		( mkSrcLoc, noSrcLoc, SrcLoc )
 import FastString	( FastString, mkFastCharString, mkFastCharString2 )
 \end{code}
diff --git a/ghc/compiler/prelude/PrelInfo.lhs b/ghc/compiler/prelude/PrelInfo.lhs
index f4f3cabf1856..de1a41e57ce3 100644
--- a/ghc/compiler/prelude/PrelInfo.lhs
+++ b/ghc/compiler/prelude/PrelInfo.lhs
@@ -171,18 +171,6 @@ data_tycons
     , voidTyCon
     , wordTyCon
     ]
-
-min_nonprim_tycon_list 	-- used w/ HideMostBuiltinNames
-  = [ boolTyCon
-    , charTyCon
-    , intTyCon
-    , floatTyCon
-    , doubleTyCon
-    , integerTyCon
-    , liftTyCon
-    , return2GMPsTyCon	-- ADR asked for these last two (WDP 94/11)
-    , returnIntAndGMPTyCon
-    ]
 \end{code}
 
 %************************************************************************
diff --git a/ghc/compiler/prelude/PrelVals.lhs b/ghc/compiler/prelude/PrelVals.lhs
index 9f6930b269c9..4d3660488aee 100644
--- a/ghc/compiler/prelude/PrelVals.lhs
+++ b/ghc/compiler/prelude/PrelVals.lhs
@@ -8,9 +8,9 @@ module PrelVals where
 
 #include "HsVersions.h"
 
-import {-# SOURCE #-} CoreUnfold ( UnfoldingGuidance(..), mkUnfolding )
+import {-# SOURCE #-} CoreUnfold ( mkUnfolding )
 
-import Id		( Id, mkImported, mkTemplateLocals )
+import Id		( Id, mkImported )
 import SpecEnv		( SpecEnv, emptySpecEnv )
 
 -- friends:
@@ -19,15 +19,12 @@ import TysPrim
 import TysWiredIn
 
 -- others:
-import CmdLineOpts	( maybe_CompilingGhcInternals )
 import CoreSyn		-- quite a bit
 import IdInfo		-- quite a bit
-import Literal		( mkMachInt )
 import Name		( mkWiredInIdName, Module )
 import PragmaInfo
-import PrimOp		( PrimOp(..) )
 import Type		
-import TyVar		( openAlphaTyVar, alphaTyVar, betaTyVar, gammaTyVar, TyVar )
+import TyVar		( openAlphaTyVar, alphaTyVar, betaTyVar, TyVar )
 import Unique		-- lots of *Keys
 import Util		( panic )
 \end{code}
diff --git a/ghc/compiler/prelude/StdIdInfo.lhs b/ghc/compiler/prelude/StdIdInfo.lhs
index 58c281186190..f9fe24846076 100644
--- a/ghc/compiler/prelude/StdIdInfo.lhs
+++ b/ghc/compiler/prelude/StdIdInfo.lhs
@@ -35,7 +35,7 @@ import Id		( GenId, mkTemplateLocals, idType,
 			)
 import IdInfo		( ArityInfo, exactArity )
 import Class		( classBigSig, classTyCon )
-import TyCon		( isNewTyCon, isDataTyCon, isAlgTyCon, tyConDataCons )
+import TyCon		( isNewTyCon, tyConDataCons )
 import FieldLabel	( FieldLabel )
 import PrelVals		( pAT_ERROR_ID )
 import Maybes
diff --git a/ghc/compiler/prelude/TysPrim.lhs b/ghc/compiler/prelude/TysPrim.lhs
index 37ad832f881d..7a8796a216c4 100644
--- a/ghc/compiler/prelude/TysPrim.lhs
+++ b/ghc/compiler/prelude/TysPrim.lhs
@@ -11,7 +11,7 @@ module TysPrim where
 
 #include "HsVersions.h"
 
-import Kind		( mkUnboxedTypeKind, mkBoxedTypeKind, mkTypeKind, mkArrowKind )
+import Kind		( mkBoxedTypeKind )
 import Name		( mkWiredInTyConName )
 import PrimRep		( PrimRep(..) )	-- getPrimRepInfo uses PrimRep repn
 import TyCon		( mkPrimTyCon, mkDataTyCon, TyCon )
diff --git a/ghc/compiler/profiling/CostCentre.lhs b/ghc/compiler/profiling/CostCentre.lhs
index 4d1cfcddc83c..a1478da21f69 100644
--- a/ghc/compiler/profiling/CostCentre.lhs
+++ b/ghc/compiler/profiling/CostCentre.lhs
@@ -28,9 +28,9 @@ module CostCentre (
 
 #include "HsVersions.h"
 
-import Id		( externallyVisibleId, GenId, showId, Id )
+import Id		( externallyVisibleId, GenId, Id )
 import CStrings		( identToC, stringToC )
-import Name		( OccName, getOccString, moduleString, nameString )
+import Name		( OccName, getOccString, moduleString )
 import Outputable	
 import Util	        ( panic, panic#, assertPanic, thenCmp )
 
@@ -497,7 +497,6 @@ uppCostCentreDecl is_local cc
       where
 	cc_IS_CAF      = "CC_IS_CAF"
 	cc_IS_DICT     = "CC_IS_DICT"
-	cc_IS_SUBSUMED = "CC_IS_SUBSUMED"
 	cc_IS_BORING   = "CC_IS_BORING"
 
 	do_caf IsCafCC	     = cc_IS_CAF
diff --git a/ghc/compiler/reader/Lex.lhs b/ghc/compiler/reader/Lex.lhs
index b3126559dcc6..5ce4cc793d32 100644
--- a/ghc/compiler/reader/Lex.lhs
+++ b/ghc/compiler/reader/Lex.lhs
@@ -32,7 +32,7 @@ module Lex (
 
 #include "HsVersions.h"
 
-import Char 		(isDigit, isAlpha, isAlphanum, isUpper,isLower, isSpace, ord )
+import Char 		(isDigit, isAlphanum, isUpper,isLower, isSpace, ord )
 
 import {-# SOURCE #-} CostCentre
 
diff --git a/ghc/compiler/reader/RdrHsSyn.lhs b/ghc/compiler/reader/RdrHsSyn.lhs
index 5cd65ddca1d2..922fe48ffae5 100644
--- a/ghc/compiler/reader/RdrHsSyn.lhs
+++ b/ghc/compiler/reader/RdrHsSyn.lhs
@@ -56,13 +56,10 @@ module RdrHsSyn (
 
 import HsSyn
 import Lex
-import PrelMods		( pRELUDE )
-import BasicTypes	( Module(..), NewOrData, IfaceFlavour(..), Unused )
-import Name		( ExportFlag(..), pprModule,
-			  OccName(..), pprOccName, 
+import BasicTypes	( Module(..), IfaceFlavour(..), Unused )
+import Name		( pprModule, OccName(..), pprOccName, 
 			  prefixOccName, NamedThing )
 import Util		( thenCmp )
-import CoreSyn		( GenCoreExpr )
 import HsPragmas	( GenPragmas, ClassPragmas, DataPragmas, ClassOpPragmas, InstancePragmas )
 import List		( nub )
 import Outputable
diff --git a/ghc/compiler/rename/Rename.lhs b/ghc/compiler/rename/Rename.lhs
index 0cb23f06dd4c..e221088e3333 100644
--- a/ghc/compiler/rename/Rename.lhs
+++ b/ghc/compiler/rename/Rename.lhs
@@ -9,10 +9,10 @@ module Rename ( renameModule ) where
 #include "HsVersions.h"
 
 import HsSyn
-import RdrHsSyn		( RdrName(..), RdrNameHsModule, RdrNameImportDecl )
+import RdrHsSyn		( RdrName(..), RdrNameHsModule )
 import RnHsSyn		( RenamedHsModule, RenamedHsDecl, extractHsTyNames )
 
-import CmdLineOpts	( opt_HiMap, opt_WarnNameShadowing, opt_D_show_rn_trace,
+import CmdLineOpts	( opt_HiMap, opt_D_show_rn_trace,
 			  opt_D_dump_rn, opt_D_show_rn_stats,
 			  opt_WarnUnusedBinds, opt_WarnUnusedImports
 		        )
@@ -23,11 +23,9 @@ import RnIfaces		( getImportedInstDecls, importDecl, getImportVersions, getSpeci
 			  getDeferredDataDecls,
 			  mkSearchPath, getSlurpedNames, getRnStats
 			)
-import RnEnv		( availsToNameSet, addAvailToNameSet,
-			  addImplicitOccsRn, lookupImplicitOccRn )
-import Name		( Name, PrintUnqualified, Provenance, ExportFlag(..), 
-			  isLocallyDefined,
-			  NameSet(..), elemNameSet, mkNameSet, unionNameSets, 
+import RnEnv		( addImplicitOccsRn )
+import Name		( Name, PrintUnqualified, Provenance, isLocallyDefined,
+			  NameSet(..),
 			  nameSetToList, minusNameSet, NamedThing(..),
 			  nameModule, pprModule, pprOccName, nameOccName
 			)
@@ -38,7 +36,6 @@ import PrelInfo		( ioTyCon_NAME )
 import ErrUtils		( pprBagOfErrors, pprBagOfWarnings,
 			  doIfSet, dumpIfSet, ghcExit
 			)
-import FiniteMap	( emptyFM, eltsFM, fmToList, addToFM, FiniteMap )
 import Bag		( isEmptyBag )
 import UniqSupply	( UniqSupply )
 import Util		( equivClasses )
diff --git a/ghc/compiler/rename/RnBinds.lhs b/ghc/compiler/rename/RnBinds.lhs
index 4a7bd54ee353..92e221e2c683 100644
--- a/ghc/compiler/rename/RnBinds.lhs
+++ b/ghc/compiler/rename/RnBinds.lhs
@@ -20,7 +20,6 @@ module RnBinds (
 import {-# SOURCE #-} RnSource ( rnHsSigType )
 
 import HsSyn
-import HsPragmas	( isNoGenPragmas, noGenPragmas )
 import RdrHsSyn
 import RnHsSyn
 import RnMonad
@@ -36,8 +35,7 @@ import Name		( OccName(..), Provenance,
 		 	  minusNameSet, unionManyNameSets, elemNameSet, unitNameSet, nameSetToList
 			)
 import BasicTypes	( RecFlag(..), TopLevelFlag(..) )
-import Maybes		( catMaybes )
-import Util		( thenCmp, isIn, removeDups, panic, panic#, assertPanic, assocDefault )
+import Util		( thenCmp, removeDups, panic, panic#, assertPanic )
 import UniqSet		( UniqSet )
 import ListSetOps	( minusList )
 import Bag		( bagToList )
diff --git a/ghc/compiler/rename/RnEnv.lhs b/ghc/compiler/rename/RnEnv.lhs
index 664fa7002263..c41b0bd7a708 100644
--- a/ghc/compiler/rename/RnEnv.lhs
+++ b/ghc/compiler/rename/RnEnv.lhs
@@ -12,25 +12,23 @@ import CmdLineOpts	( opt_WarnNameShadowing, opt_WarnUnusedMatches,
 			  opt_WarnUnusedBinds, opt_WarnUnusedImports )
 import HsSyn
 import RdrHsSyn		( RdrName(..), RdrNameIE,
-			  rdrNameOcc, ieOcc, isQual, qual
+			  rdrNameOcc, isQual, qual
 			)
 import HsTypes		( getTyVarName, replaceTyVarName )
-import BasicTypes	( Fixity(..), FixityDirection(..), IfaceFlavour(..), pprModule )
+import BasicTypes	( Fixity(..), FixityDirection(..), IfaceFlavour(..) )
 import RnMonad
 import Name		( Name, OccName(..), Provenance(..), ExportFlag(..), NamedThing(..),
-			  occNameString, occNameFlavour, getSrcLoc,
+			  occNameFlavour, getSrcLoc,
 			  NameSet, emptyNameSet, addListToNameSet, nameSetToList,
 			  mkLocalName, mkGlobalName, modAndOcc,
 			  nameOccName, setNameProvenance, isVarOcc, getNameProvenance,
-			  pprProvenance, pprOccName, pprModule, pprNameProvenance,
-			  isLocalName
+			  pprOccName, isLocalName
 			)
 import TyCon		( TyCon )
-import TysWiredIn	( tupleTyCon, listTyCon, charTyCon, intTyCon )
+import TysWiredIn	( tupleTyCon, listTyCon, charTyCon )
 import FiniteMap
 import Unique		( Unique, Uniquable(..), unboundKey )
 import UniqFM           ( listToUFM, plusUFM_C )
-import Maybes		( maybeToBool )
 import UniqSupply
 import SrcLoc		( SrcLoc, noSrcLoc )
 import Outputable
diff --git a/ghc/compiler/rename/RnExpr.lhs b/ghc/compiler/rename/RnExpr.lhs
index 165555e1ad8f..4a7bd2283b18 100644
--- a/ghc/compiler/rename/RnExpr.lhs
+++ b/ghc/compiler/rename/RnExpr.lhs
@@ -37,11 +37,8 @@ import TysPrim		( charPrimTyCon, addrPrimTyCon, intPrimTyCon,
 			  floatPrimTyCon, doublePrimTyCon
 			)
 import Name
-import UniqFM		( lookupUFM, {- ToDo:rm-} isNullUFM )
-import UniqSet		( emptyUniqSet, unitUniqSet,
-			  unionUniqSets, unionManyUniqSets,
-			  UniqSet
-			)
+import UniqFM		( isNullUFM )
+import UniqSet		( emptyUniqSet, unionManyUniqSets, UniqSet )
 import Util		( removeDups )
 import Outputable
 \end{code}
diff --git a/ghc/compiler/rename/RnIfaces.lhs b/ghc/compiler/rename/RnIfaces.lhs
index f5e5e7783b3f..fc92acabb9a0 100644
--- a/ghc/compiler/rename/RnIfaces.lhs
+++ b/ghc/compiler/rename/RnIfaces.lhs
@@ -26,25 +26,24 @@ import HsSyn		( HsDecl(..), TyDecl(..), ClassDecl(..), InstDecl(..), IfaceSig(..
 			  HsType(..), ConDecl(..), IE(..), ConDetails(..), Sig(..),
 			  hsDeclName
 			)
-import HsPragmas	( noGenPragmas )
 import BasicTypes	( Version, NewOrData(..), IfaceFlavour(..) )
 import RdrHsSyn		( RdrNameHsDecl, RdrNameInstDecl, RdrNameTyDecl,
 			  RdrName(..), rdrNameOcc
 			)
-import RnEnv		( newImportedGlobalName, addImplicitOccsRn, ifaceFlavour,
-			  availName, availNames, addAvailToNameSet, pprAvail
+import RnEnv		( newImportedGlobalName, addImplicitOccsRn,
+			  ifaceFlavour, availName, availNames, addAvailToNameSet
 			)
 import RnSource		( rnHsSigType )
 import RnMonad
 import RnHsSyn          ( RenamedHsDecl )
 import ParseIface	( parseIface, IfaceStuff(..) )
 
-import FiniteMap	( FiniteMap, sizeFM, emptyFM, unitFM,  delFromFM,
+import FiniteMap	( FiniteMap, sizeFM, emptyFM, delFromFM,
 			  lookupFM, addToFM, addToFM_C, addListToFM, 
-			  fmToList, eltsFM 
+			  fmToList
 			)
 import Name		( Name {-instance NamedThing-}, Provenance, OccName(..),
-			  nameModule, occNameString, moduleString, pprModule, isLocallyDefined,
+			  nameModule, moduleString, pprModule, isLocallyDefined,
 			  NameSet(..), emptyNameSet, unionNameSets, nameSetToList,
 			  minusNameSet, mkNameSet, elemNameSet, nameUnique, addOneToNameSet,
 			  isWiredInName, maybeWiredInTyConName, maybeWiredInIdName,
@@ -58,11 +57,11 @@ import SrcLoc		( mkSrcLoc, SrcLoc )
 import PrelMods		( pREL_GHC )
 import PrelInfo		( cCallishTyKeys )
 import Bag
-import Maybes		( MaybeErr(..), expectJust, maybeToBool )
+import Maybes		( MaybeErr(..), maybeToBool )
 import ListSetOps	( unionLists )
 import Outputable
 import Unique		( Unique )
-import StringBuffer     ( StringBuffer, hGetStringBuffer, freeStringBuffer )
+import StringBuffer     ( StringBuffer, hGetStringBuffer )
 import FastString	( mkFastString )
 import Outputable
 
diff --git a/ghc/compiler/rename/RnNames.lhs b/ghc/compiler/rename/RnNames.lhs
index f8cf4b11f828..f69ebb329cab 100644
--- a/ghc/compiler/rename/RnNames.lhs
+++ b/ghc/compiler/rename/RnNames.lhs
@@ -23,7 +23,6 @@ import RdrHsSyn	( RdrNameHsDecl(..), RdrName(..), RdrNameIE(..), RdrNameImportDe
 		  RdrNameHsModule, RdrNameFixityDecl,
 		  rdrNameOcc, ieOcc
 		)
-import RnHsSyn	( RenamedHsModule(..), RenamedFixityDecl(..) )
 import RnIfaces	( getInterfaceExports, getDeclBinders, recordSlurp, checkUpToDate )
 import BasicTypes ( IfaceFlavour(..) )
 import RnEnv
@@ -31,9 +30,9 @@ import RnMonad
 
 import FiniteMap
 import PrelMods
-import UniqFM	( UniqFM, emptyUFM, addListToUFM_C, lookupUFM )
+import UniqFM	( UniqFM, addListToUFM_C, lookupUFM )
 import Bag	( Bag, bagToList )
-import Maybes	( maybeToBool, expectJust )
+import Maybes	( maybeToBool )
 import Name
 import Outputable
 import Util	( removeDups )
diff --git a/ghc/compiler/rename/RnSource.lhs b/ghc/compiler/rename/RnSource.lhs
index 4a6456909241..cb5abf3e434b 100644
--- a/ghc/compiler/rename/RnSource.lhs
+++ b/ghc/compiler/rename/RnSource.lhs
@@ -25,23 +25,17 @@ import RnEnv		( bindTyVarsRn, lookupBndrRn, lookupOccRn, lookupImplicitOccRn, bi
 			  listType_RDR, tupleType_RDR )
 import RnMonad
 
-import Name		( Name, isLocallyDefined, 
-			  OccName(..), occNameString, prefixOccName,
-			  ExportFlag(..),
-			  Provenance(..), getNameProvenance,
-			  NameSet, unionNameSets, emptyNameSet, mkNameSet, unitNameSet,
-			  elemNameSet, nameSetToList
+import Name		( Name, OccName(..), occNameString, prefixOccName,
+			  ExportFlag(..), Provenance(..), NameSet,
+			  elemNameSet
 			)
-import FiniteMap	( emptyFM, lookupFM, addListToFM_C )
+import FiniteMap	( lookupFM )
 import Id		( GenId{-instance NamedThing-} )
-import IdInfo		( IdInfo, StrictnessInfo(..), FBTypeInfo, DemandInfo, ArgUsageInfo )
+import IdInfo		( FBTypeInfo, ArgUsageInfo )
 import Lex		( isLexCon )
-import CoreUnfold	( Unfolding(..), SimpleUnfolding )
-import MagicUFs		( MagicUnfoldingFun )
 import PrelInfo		( derivingOccurrences, evalClass_RDR, numClass_RDR, allClass_NAME )
-import ListSetOps	( unionLists, minusList )
-import Maybes		( maybeToBool, catMaybes )
-import Bag		( emptyBag, unitBag, consBag, unionManyBags, unionBags, listToBag, bagToList )
+import Maybes		( maybeToBool )
+import Bag		( bagToList )
 import Outputable
 import SrcLoc		( SrcLoc )
 import Unique		( Unique )
diff --git a/ghc/compiler/simplCore/OccurAnal.lhs b/ghc/compiler/simplCore/OccurAnal.lhs
index 61ade109a8a4..7a4ca18995bd 100644
--- a/ghc/compiler/simplCore/OccurAnal.lhs
+++ b/ghc/compiler/simplCore/OccurAnal.lhs
@@ -20,11 +20,11 @@ module OccurAnal (
 import BinderInfo
 import CmdLineOpts	( opt_D_dump_occur_anal, SimplifierSwitch(..) )
 import CoreSyn
-import Digraph		( stronglyConnComp, stronglyConnCompR, SCC(..) )
+import Digraph		( stronglyConnCompR, SCC(..) )
 import Id		( idWantsToBeINLINEd, addNoInlinePragma, nukeNoInlinePragma,
 			  idType, idUnique, Id,
 			  emptyIdSet, unionIdSets, mkIdSet,
-			  unitIdSet, elementOfIdSet,
+			  elementOfIdSet,
 			  addOneToIdSet, IdSet,
 			  nullIdEnv, unitIdEnv, combineIdEnvs,
 			  delOneFromIdEnv, delManyFromIdEnv, isNullIdEnv, 
@@ -39,9 +39,8 @@ import PprType		( GenType{-instance Outputable-}, GenTyVar{-ditto-} )
 import TyVar		( GenTyVar{-instance Eq-} )
 import Unique		( Unique{-instance Eq-}, u2i )
 import UniqFM		( keysUFM )  
-import Util		( assoc, zipEqual, zipWithEqual )
+import Util		( zipWithEqual )
 import Outputable
-import List		( partition )
 
 isSpecPragmaId_maybe x = Nothing -- ToDo:!trace "OccurAnal.isSpecPragmaId_maybe"
 \end{code}
@@ -101,10 +100,12 @@ keepUnusedBinding :: OccEnv -> Id -> Bool
 keepUnusedBinding (OccEnv keep_dead keep_spec keep_conjurable _ _ _) binder
   = keep_dead || (keep_spec && maybeToBool (isSpecPragmaId_maybe binder))
 
+{- UNUSED:
 keepBecauseConjurable :: OccEnv -> Id -> Bool
 keepBecauseConjurable (OccEnv _ _ keep_conjurable _ _ _) binder
   = False
     {- keep_conjurable && isConstMethodId binder -}
+-}
 
 type UsageDetails = IdEnv BinderInfo	-- A finite map from ids to their usage
 
@@ -330,8 +331,6 @@ It isn't easy to do a perfect job in one blow.  Consider
 occAnalBind env (Rec pairs) body_usage
   = foldr (_scc_ "occAnalBind.dofinal" do_final_bind) (body_usage, []) sccs
   where
-    pp_scc (CyclicSCC cycle) = hcat [text "Cyclic ", hcat (punctuate comma (map pp_item cycle))]
-    pp_scc (AcyclicSCC item) = hcat [text "Acyclic ", pp_item item]
     pp_item (_, bndr, _)     = ppr bndr
 
     binders = map fst pairs
diff --git a/ghc/compiler/simplCore/SimplEnv.lhs b/ghc/compiler/simplCore/SimplEnv.lhs
index fb5d225dcdcf..24872996eb8b 100644
--- a/ghc/compiler/simplCore/SimplEnv.lhs
+++ b/ghc/compiler/simplCore/SimplEnv.lhs
@@ -53,21 +53,17 @@ import CmdLineOpts	( switchIsOn, intSwitchSet, opt_UnfoldingCreationThreshold,
 			)
 import CoreSyn
 import CoreUnfold	( mkFormSummary, couldBeSmallEnoughToInline, whnfOrBottom,
-			  Unfolding(..), UfExpr, RdrName,
-			  SimpleUnfolding(..), FormSummary(..),
-			  calcUnfoldingGuidance, UnfoldingGuidance(..)
-			)
-import CoreUtils	( coreExprCc, unTagBinders )
+			  Unfolding(..), SimpleUnfolding(..), FormSummary(..),
+			  calcUnfoldingGuidance	)
+import CoreUtils	( coreExprCc )
 import CostCentre	( CostCentre, subsumedCosts, noCostCentreAttached )
 import FiniteMap	-- lots of things
-import Id		( idType, getIdUnfolding, getIdStrictness, idWantsToBeINLINEd,
-			  applyTypeEnvToId, getInlinePragma,
-			  nullIdEnv, growIdEnvList, rngIdEnv, lookupIdEnv,
-			  addOneToIdEnv, modifyIdEnv, mkIdSet, modifyIdEnv_Directly,
+import Id		( applyTypeEnvToId, getInlinePragma,
+			  nullIdEnv, growIdEnvList, lookupIdEnv,
+			  addOneToIdEnv, modifyIdEnv, modifyIdEnv_Directly,
 			  IdEnv, IdSet, GenId, Id )
-import Literal		( isNoRepLit, Literal{-instances-} )
-import Maybes		( maybeToBool, expectJust )
-import Name		( isLocallyDefined )
+import Literal		( Literal{-instances-} )
+import Maybes		( expectJust )
 import OccurAnal	( occurAnalyseExpr )
 import PprCore		-- various instances
 import PprType		( GenType, GenTyVar )
@@ -78,8 +74,7 @@ import TyVar		( emptyTyVarEnv, plusTyVarEnv, addToTyVarEnv, growTyVarEnvList,
 			)
 import Unique		( Unique{-instance Outputable-}, Uniquable(..) )
 import UniqFM		( addToUFM, addToUFM_C, ufmToList )
-import Util		( Eager, appEager, returnEager, runEager,
-			  zipEqual, thenCmp, cmpList )
+import Util		( Eager, returnEager, zipEqual, thenCmp, cmpList )
 import Outputable
 \end{code}
 
diff --git a/ghc/compiler/specialise/SpecEnv.lhs b/ghc/compiler/specialise/SpecEnv.lhs
index 168e46795384..194acef471a7 100644
--- a/ghc/compiler/specialise/SpecEnv.lhs
+++ b/ghc/compiler/specialise/SpecEnv.lhs
@@ -13,7 +13,7 @@ module SpecEnv (
 #include "HsVersions.h"
 
 import Type		( Type, GenType, matchTys, tyVarsOfTypes )
-import TyVar		( TyVar, TyVarEnv, lookupTyVarEnv, tyVarSetToList )
+import TyVar		( TyVarEnv, lookupTyVarEnv, tyVarSetToList )
 import Unify		( Subst, unifyTyListsX )
 import Maybes
 import Util		( assertPanic )
diff --git a/ghc/compiler/stranal/WwLib.lhs b/ghc/compiler/stranal/WwLib.lhs
index bd2ebe513c8a..8ef584acc913 100644
--- a/ghc/compiler/stranal/WwLib.lhs
+++ b/ghc/compiler/stranal/WwLib.lhs
@@ -15,11 +15,11 @@ module WwLib (
 
 import CoreSyn
 import Id		( GenId, idType, mkSysLocal, dataConArgTys, isDataCon, isNewCon, Id )
-import IdInfo		( mkStrictnessInfo, {-??nonAbsentArgs,-} Demand(..) )
+import IdInfo		( Demand(..) )
 import PrelVals		( aBSENT_ERROR_ID, voidId )
 import TysPrim		( voidTy )
 import SrcLoc		( noSrcLoc )
-import Type		( isUnpointedType, mkTyVarTys, mkForAllTys, mkFunTys,
+import Type		( isUnpointedType, mkTyVarTys, mkFunTys,
 			  splitForAllTys, splitFunTys,
 			  splitAlgTyConApp_maybe, 
 			  Type
@@ -28,12 +28,9 @@ import TyCon		( isNewTyCon, isDataTyCon )
 import BasicTypes	( NewOrData(..) )
 import TyVar            ( TyVar )
 import PprType		( GenType, GenTyVar )
-import UniqSupply	( returnUs, thenUs, thenMaybeUs,
-			  getUniques, getUnique, UniqSM
-			)
-import Util		( zipWithEqual, zipEqual )
+import UniqSupply	( returnUs, thenUs, getUniques, getUnique, UniqSM )
+import Util		( zipEqual )
 import Outputable
-import List		( nub )
 \end{code}
 
 %************************************************************************
diff --git a/ghc/compiler/types/Class.lhs b/ghc/compiler/types/Class.lhs
index 6845415e8f1a..9827cabb731e 100644
--- a/ghc/compiler/types/Class.lhs
+++ b/ghc/compiler/types/Class.lhs
@@ -17,14 +17,13 @@ module Class (
 
 #include "HsVersions.h"
 
-import {-# SOURCE #-} Id	( Id, idType, idName )
+import {-# SOURCE #-} Id	( Id )
 import {-# SOURCE #-} TyCon	( TyCon )
 import {-# SOURCE #-} Type	( Type )
 import {-# SOURCE #-} SpecEnv	( SpecEnv )
 
 import TyCon		( TyCon )
 import TyVar		( TyVar )
-import Maybes		( assocMaybe )
 import Name		( NamedThing(..), Name, getOccName )
 import Unique		( Unique, Uniquable(..) )
 import BasicTypes	( Unused )
diff --git a/ghc/compiler/types/TyCon.lhs b/ghc/compiler/types/TyCon.lhs
index a2048a5ab905..0ce00b16a0e4 100644
--- a/ghc/compiler/types/TyCon.lhs
+++ b/ghc/compiler/types/TyCon.lhs
@@ -40,7 +40,7 @@ module TyCon(
 
 import {-# SOURCE #-} Type  ( Type )
 import {-# SOURCE #-} Class ( Class )
-import {-# SOURCE #-} Id    ( Id, isNullaryDataCon, idType )
+import {-# SOURCE #-} Id    ( Id, isNullaryDataCon )
 import {-# SOURCE #-} TysWiredIn ( tupleCon )
 
 
@@ -53,11 +53,8 @@ import Maybes
 import Name		( Name, nameUnique, mkWiredInTyConName, NamedThing(getName) )
 import Unique		( Unique, funTyConKey, Uniquable(..) )
 import PrimRep		( PrimRep(..), isFollowableRep )
-import PrelMods		( pREL_GHC, pREL_TUP, pREL_BASE )
-import Lex		( mkTupNameStr )
-import SrcLoc		( SrcLoc, mkBuiltinSrcLoc )
-import Util		( nOfThem, isIn )
-import Outputable
+import PrelMods		( pREL_GHC )
+import Util		( panic )
 \end{code}
 
 \begin{code}
diff --git a/ghc/compiler/types/Type.lhs b/ghc/compiler/types/Type.lhs
index d84f41a5c9bd..0b9b29423fdd 100644
--- a/ghc/compiler/types/Type.lhs
+++ b/ghc/compiler/types/Type.lhs
@@ -56,8 +56,7 @@ import BasicTypes ( Unused )
 import Maybes	( maybeToBool, assocMaybe )
 import PrimRep	( PrimRep(..) )
 import Unique	-- quite a few *Keys
-import Util	( thenCmp, zipEqual, zipWithEqual, assoc )
-import Outputable
+import Util	( thenCmp, panic )
 \end{code}
 
 
diff --git a/ghc/compiler/utils/Argv.lhs b/ghc/compiler/utils/Argv.lhs
index 4793b127dc02..6d406a83ff22 100644
--- a/ghc/compiler/utils/Argv.lhs
+++ b/ghc/compiler/utils/Argv.lhs
@@ -10,8 +10,8 @@ module Argv ( argv ) where
 
 import FastString
 
-import GlaExts	( Addr )
-import ArrBase	( indexAddrOffAddr )
+import GlaExts		( Addr )
+import ByteArray 	( indexAddrOffAddr )
 
 argv :: [FAST_STRING]
 argv = unpackArgv ``prog_argv'' (``prog_argc''::Int)
diff --git a/ghc/compiler/utils/Digraph.lhs b/ghc/compiler/utils/Digraph.lhs
index 15df0baa1432..b904fff79373 100644
--- a/ghc/compiler/utils/Digraph.lhs
+++ b/ghc/compiler/utils/Digraph.lhs
@@ -34,12 +34,16 @@ module Digraph(
 
 #define ARR_ELT		(COMMA)
 
-import Array
-import List
+import Util	( sortLt )
+
+-- GHC extensions
 import ST
-import ArrBase
+import MutableArray
+
+-- std interfaces
 import Maybe
-import Util	( sortLt )
+import Array
+import List
 \end{code}
 
 
diff --git a/ghc/compiler/utils/FastString.lhs b/ghc/compiler/utils/FastString.lhs
index 1635997c99ae..8a2d89af6d7d 100644
--- a/ghc/compiler/utils/FastString.lhs
+++ b/ghc/compiler/utils/FastString.lhs
@@ -48,22 +48,31 @@ module FastString
 #define COMPILING_FAST_STRING
 #include "HsVersions.h"
 
+#if __GLASGOW_HASKELL__ < 301
 import PackBase
+import STBase		( StateAndPtr#(..) )
+import IOHandle		( filePtr, readHandle, writeHandle )
+import IOBase		( Handle__(..), IOError(..), IOErrorType(..),
+		  	  IOResult(..), IO(..),
+		  	  constructError
+			)
+#else
+import PrelPack
+import PrelST		( StateAndPtr#(..) )
+import PrelHandle	( filePtr, readHandle, writeHandle )
+import PrelIOBase	( Handle__(..), IOError(..), IOErrorType(..),
+		  	  IOResult(..), IO(..),
+		  	  constructError
+			)
+#endif
+
 import PrimPacked
 import GlaExts
-import Addr	( Addr(..) )
-import STBase	( StateAndPtr#(..) )
-import ArrBase	( MutableArray(..) )
-import Foreign	( ForeignObj(..) )
-import IOExts	( IOArray(..), newIOArray,
-		  IORef, newIORef, readIORef, writeIORef
-		)
+import Addr		( Addr(..) )
+import MutableArray	( MutableArray(..) )
+import Foreign		( ForeignObj(..) )
+import IOExts		( IORef, newIORef, readIORef, writeIORef )
 import IO
-import IOHandle	( filePtr, readHandle, writeHandle )
-import IOBase	( Handle__(..), IOError(..), IOErrorType(..),
-		  IOResult(..), IO(..),
-		  constructError
-		)
 
 #define hASH_TBL_SIZE 993
 \end{code} 
@@ -458,19 +467,19 @@ hPutFS handle (FastString _ l# ba#) =
  if l# ==# 0# then
     return ()
  else
-    _readHandle handle				    >>= \ htype ->
+    readHandle handle				    >>= \ htype ->
     case htype of 
       ErrorHandle ioError ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
           fail ioError
       ClosedHandle ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
 	  fail MkIOError(handle,IllegalOperation,"handle is closed")
       SemiClosedHandle _ _ ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
 	  fail MkIOError(handle,IllegalOperation,"handle is closed")
       ReadHandle _ _ _ ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
 	  fail MkIOError(handle,IllegalOperation,"handle is not open for writing")
       other -> 
           let fp = filePtr htype in
@@ -485,19 +494,19 @@ hPutFS handle (CharStr a# l#) =
  if l# ==# 0# then
     return ()
  else
-    _readHandle handle				    >>= \ htype ->
+    readHandle handle				    >>= \ htype ->
     case htype of 
       ErrorHandle ioError ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
           fail ioError
       ClosedHandle ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
 	  fail MkIOError(handle,IllegalOperation,"handle is closed")
       SemiClosedHandle _ _ ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
 	  fail MkIOError(handle,IllegalOperation,"handle is closed")
       ReadHandle _ _ _ ->
-	  _writeHandle handle htype		    >>
+	  writeHandle handle htype		    >>
 	  fail MkIOError(handle,IllegalOperation,"handle is not open for writing")
       other -> 
           let fp = filePtr htype in
diff --git a/ghc/compiler/utils/ListSetOps.lhs b/ghc/compiler/utils/ListSetOps.lhs
index dfa2cd023f67..92cbfc56e80f 100644
--- a/ghc/compiler/utils/ListSetOps.lhs
+++ b/ghc/compiler/utils/ListSetOps.lhs
@@ -13,36 +13,13 @@ module ListSetOps (
 
 #include "HsVersions.h"
 
-import Util	( isIn, isn'tIn )
+import Util	( isn'tIn )
 import List	( union )
 \end{code}
 
 \begin{code}
 unionLists :: (Eq a) => [a] -> [a] -> [a]
-#ifdef REALLY_HASKELL_1_3
 unionLists = union
-#else
-unionLists []     []		= []
-unionLists []     b		= b
-unionLists a	   []		= a
-unionLists (a:as) b
-  | a `is_elem` b = unionLists as b
-  | otherwise     = a : unionLists as b
-  where
-    is_elem = isIn "unionLists"
-#endif
-
-{- UNUSED
-intersectLists :: (Eq a) => [a] -> [a] -> [a]
-intersectLists []     []		= []
-intersectLists []     b			= []
-intersectLists a      []		= []
-intersectLists (a:as) b
-  | a `is_elem` b = a : intersectLists as b
-  | otherwise	  = intersectLists as b
-  where
-    is_elem = isIn "intersectLists"
--}
 \end{code}
 
 Everything in the first list that is not in the second list:
diff --git a/ghc/compiler/utils/OrdList.lhs b/ghc/compiler/utils/OrdList.lhs
index 223ff8842276..ab683cdb5862 100644
--- a/ghc/compiler/utils/OrdList.lhs
+++ b/ghc/compiler/utils/OrdList.lhs
@@ -12,8 +12,6 @@ module OrdList (
 
     	flattenOrdList
     ) where
-
-import Util	( mapAccumB, mapAccumL, mapAccumR )
 \end{code}
 
 This section provides an ordering list that allows fine grain
diff --git a/ghc/compiler/utils/Outputable.lhs b/ghc/compiler/utils/Outputable.lhs
index 861f4b5f09e3..e09d59da1744 100644
--- a/ghc/compiler/utils/Outputable.lhs
+++ b/ghc/compiler/utils/Outputable.lhs
@@ -42,7 +42,7 @@ module Outputable (
 #include "HsVersions.h"
 
 import IO		( Handle, hPutChar, hPutStr, stderr, stdout )
-import CmdLineOpts	( opt_PprStyle_All, opt_PprStyle_Debug, opt_PprStyle_User, opt_PprUserLength )
+import CmdLineOpts	( opt_PprStyle_All, opt_PprStyle_Debug, opt_PprUserLength )
 import FastString
 import qualified Pretty
 import Pretty		( Doc, Mode(..), TextDetails(..), fullRender )
diff --git a/ghc/compiler/utils/PrimPacked.lhs b/ghc/compiler/utils/PrimPacked.lhs
index 455bf9fd2956..cf36882936ba 100644
--- a/ghc/compiler/utils/PrimPacked.lhs
+++ b/ghc/compiler/utils/PrimPacked.lhs
@@ -32,12 +32,19 @@ module PrimPacked
 
 import GlaExts
 import Addr	( Addr(..) )
-import GHC
-import ArrBase
 import ST
+import Foreign
+
+#if __GLASGOW_HASKELL__ < 301
+import ArrBase  	( StateAndMutableByteArray#(..), 
+			  StateAndByteArray#(..) )
 import STBase
-import IOBase	( ForeignObj(..) )
-import PackBase ( unpackCStringBA, packString )
+#else
+import PrelArr  	( StateAndMutableByteArray#(..), 
+			  StateAndByteArray#(..) )
+import PrelST
+#endif
+
 \end{code} 
 
 Return the length of a @\\NUL@ terminated character string:
@@ -198,9 +205,6 @@ eqCharStrPrefix a1# a2# len# =
   unsafePerformIO (
    _ccall_ strncmp (A# a1#) (A# a2#) (I# len#) >>= \ (I# x#) ->
    return (x# ==# 0#))
-  where
-   bottom :: (Int,Int)
-   bottom = error "eqStrPrefix"
 
 eqStrPrefixBA :: ByteArray# -> ByteArray# -> Int# -> Int# -> Bool
 eqStrPrefixBA b1# b2# start# len# = 
@@ -241,14 +245,3 @@ eqStrPrefixFO fo# barr# start# len# =
    bottom :: (Int,Int)
    bottom = error "eqStrPrefixFO"
 \end{code}
-
-\begin{code}
-byteArrayToString :: ByteArray Int -> String
-byteArrayToString = unpackCStringBA
-\end{code}
-
-
-\begin{code}
-stringToByteArray :: String -> (ByteArray Int)
-stringToByteArray = packString
-\end{code}
diff --git a/ghc/compiler/utils/SST.lhs b/ghc/compiler/utils/SST.lhs
index ac147dc920d9..45a8174a5051 100644
--- a/ghc/compiler/utils/SST.lhs
+++ b/ghc/compiler/utils/SST.lhs
@@ -18,10 +18,18 @@ module SST(
 #include "HsVersions.h"
 
 import GlaExts
-import STBase
-import IOBase	( IO(..), IOResult(..) )
-import ArrBase
 import ST
+
+#if __GLASGOW_HASKELL__ < 301
+import STBase		( ST(..), STret(..), StateAndPtr#(..) )
+import ArrBase		( StateAndMutableArray#(..) )
+import IOBase		( IO(..), IOResult(..) )
+#else
+import PrelST		( ST(..), STret(..), StateAndPtr#(..) )
+import PrelArr		( StateAndMutableArray#(..) )
+import PrelIOBase	( IO(..), IOResult(..) )
+#endif
+
 \end{code}
 
 @SST@ is very like the standard @ST@ monad, but it comes with its
diff --git a/ghc/compiler/utils/StringBuffer.lhs b/ghc/compiler/utils/StringBuffer.lhs
index 6fac2356ab2f..0fe695bf4332 100644
--- a/ghc/compiler/utils/StringBuffer.lhs
+++ b/ghc/compiler/utils/StringBuffer.lhs
@@ -69,15 +69,22 @@ module StringBuffer
 import GlaExts
 import Addr 		( Addr(..) )
 import Foreign
-import IOBase
-import IOHandle
 import ST
-import STBase
-import Char 		(isDigit)
-import PackBase 
+import IO		( openFile, hFileSize, hClose, IOMode(..) )
+
+#if __GLASGOW_HASKELL__ < 301
+import IOBase		( IOError(..), IOErrorType(..) )
+import IOHandle		( readHandle, writeHandle, filePtr )
+import PackBase 	( unpackCStringBA )
+#else
+import PrelIOBase	( IOError(..), IOErrorType(..) )
+import PrelHandle	( readHandle, writeHandle, filePtr )
+import PrelPack		( unpackCStringBA )
+#endif
+
 import PrimPacked
 import FastString
-
+import Char 		(isDigit)
 \end{code} 
 
 \begin{code}
@@ -114,7 +121,7 @@ hGetStringBuffer fname =
 --    makeForeignObj arr free_p		                     >>= \ fo@(_ForeignObj fo#) ->
      readHandle hndl        >>= \ hndl_ ->
      writeHandle hndl hndl_ >>
-     let ptr = _filePtr hndl_ in
+     let ptr = filePtr hndl_ in
      _ccall_ fread arr (1::Int) len_i ptr                     >>= \  (I# read#) ->
 --     trace ("DEBUG: opened " ++ fname ++ show (I# read#)) $
      hClose hndl		     >>
diff --git a/ghc/compiler/utils/UniqFM.lhs b/ghc/compiler/utils/UniqFM.lhs
index 2fec976bc326..08830111b743 100644
--- a/ghc/compiler/utils/UniqFM.lhs
+++ b/ghc/compiler/utils/UniqFM.lhs
@@ -49,8 +49,6 @@ import {-# SOURCE #-} Name	( Name )
 
 import Unique		( Uniquable(..), Unique, u2i, mkUniqueGrimily )
 import Util
-import Outputable	( Outputable(..) )
-import SrcLoc		( SrcLoc )
 import GlaExts		-- Lots of Int# operations
 
 #if ! OMIT_NATIVE_CODEGEN
diff --git a/ghc/compiler/utils/UniqSet.lhs b/ghc/compiler/utils/UniqSet.lhs
index 13b3eae53fa5..508969400419 100644
--- a/ghc/compiler/utils/UniqSet.lhs
+++ b/ghc/compiler/utils/UniqSet.lhs
@@ -25,8 +25,6 @@ import {-# SOURCE #-} Name
 import Maybes		( maybeToBool )
 import UniqFM
 import Unique		( Unique, Uniquable(..) )
-import SrcLoc		( SrcLoc )
-import Outputable	( Outputable(..) )
 
 #if ! OMIT_NATIVE_CODEGEN
 #define IF_NCG(a) a
-- 
GitLab