[project @ 1999-12-20 10:34:27 by simonpj]
authorsimonpj <unknown>
Mon, 20 Dec 1999 10:34:37 +0000 (10:34 +0000)
committersimonpj <unknown>
Mon, 20 Dec 1999 10:34:37 +0000 (10:34 +0000)
commite921b2e307532e0f30eefa88b11a124be592bde4
tree4512ea94bc7aff13ccbd13f513ee40bf5beedf88
parentf7989a6dea8c43352f363117d9bb07439953ccdc
[project @ 1999-12-20 10:34:27 by simonpj]
This commit implements a substantial re-organisation of the Prelude
It also fixes a couple of small renamer bugs that were reported recently
(notably, Sven pointed out that we weren't reporting
unused imports properly)

My original goal was to get rid of all "orphan" modules (i.e. ones
with instance decls that don't belong either to a tycon or a class
defined in the same module).  This should reduce the number of
interface files that have to be read when compiling small Haskell
modules.

But like most expeditions into the Prelude Swamp, it spiraled out
of control.  The result is quite satisfactory, though.

GONE AWAY: PrelCCall, PrelNumExtra

NEW: PrelReal, PrelFloat, PrelByteArr, PrelNum.hi-boot

(The extra PrelNum.hi-boot is because of a tiresome thin-air Id, addr2Integer,
which used to be in PrelBase.)

Quite a lot of types have moved from one module to another,
which entails some changes to part of the compiler (PrelInfo, PrelMods) etc,
and there are a few places in the RTS includes and even in the driver
that know about these home modules (alas).

So the rough structure is as follows, in (linearised) dependency order
[this list now appears in PrelBase.lhs]

PrelGHC Has no implementation.  It defines built-in things, and
by importing it you bring them into scope.
The source file is PrelGHC.hi-boot, which is just
copied to make PrelGHC.hi

Classes: CCallable, CReturnable

PrelBase Classes: Eq, Ord, Functor, Monad
Types:   list, (), Int, Bool, Ordering, Char, String

PrelTup Types: tuples, plus instances for PrelBase classes

PrelShow Class: Show, plus instances for PrelBase/PrelTup types

PrelEnum Class: Enum,  plus instances for PrelBase/PrelTup types

PrelMaybe Type: Maybe, plus instances for PrelBase classes

PrelNum Class: Num, plus instances for Int
Type:  Integer, plus instances for all classes so far (Eq, Ord, Num, Show)

Integer is needed here because it is mentioned in the signature
of 'fromInteger' in class Num

PrelReal Classes: Real, Integral, Fractional, RealFrac
 plus instances for Int, Integer
Types:  Ratio, Rational
plus intances for classes so far

Rational is needed here because it is mentioned in the signature
of 'toRational' in class Real

Ix Classes: Ix, plus instances for Int, Bool, Char, Integer, Ordering, tuples

PrelArr Types: Array, MutableArray, MutableVar

Does *not* contain any ByteArray stuff (see PrelByteArr)
Arrays are used by a function in PrelFloat

PrelFloat Classes: Floating, RealFloat
Types:   Float, Double, plus instances of all classes so far

This module contains everything to do with floating point.
It is a big module (900 lines)
With a bit of luck, many modules can be compiled without ever reading PrelFloat.hi

PrelByteArr Types: ByteArray, MutableByteArray

We want this one to be after PrelFloat, because it defines arrays
of unboxed floats.

Other Prelude modules are much easier with fewer complex dependencies.
50 files changed:
ghc/compiler/basicTypes/Name.lhs
ghc/compiler/main/MkIface.lhs
ghc/compiler/prelude/PrelInfo.lhs
ghc/compiler/prelude/PrelMods.lhs
ghc/compiler/prelude/ThinAir.lhs
ghc/compiler/prelude/TysWiredIn.lhs
ghc/compiler/rename/Rename.lhs
ghc/compiler/rename/RnEnv.lhs
ghc/compiler/rename/RnIfaces.lhs
ghc/compiler/rename/RnNames.lhs
ghc/compiler/typecheck/TcDefaults.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcInstDcls.lhs
ghc/docs/users_guide/debugging.vsgml
ghc/docs/users_guide/using.vsgml
ghc/driver/ghc.lprl
ghc/includes/Prelude.h
ghc/lib/std/Array.lhs
ghc/lib/std/CPUTime.lhs
ghc/lib/std/Directory.lhs
ghc/lib/std/IO.lhs
ghc/lib/std/Ix.lhs
ghc/lib/std/Numeric.lhs
ghc/lib/std/PrelAddr.lhs
ghc/lib/std/PrelArr.lhs
ghc/lib/std/PrelArrExtra.lhs
ghc/lib/std/PrelBase.lhs
ghc/lib/std/PrelByteArr.lhs [new file with mode: 0644]
ghc/lib/std/PrelCCall.lhs [deleted file]
ghc/lib/std/PrelConc.lhs
ghc/lib/std/PrelEnum.lhs
ghc/lib/std/PrelFloat.lhs [new file with mode: 0644]
ghc/lib/std/PrelForeign.lhs
ghc/lib/std/PrelGHC.hi-boot
ghc/lib/std/PrelHandle.lhs
ghc/lib/std/PrelNum.hi-boot [new file with mode: 0644]
ghc/lib/std/PrelNum.lhs
ghc/lib/std/PrelPack.lhs
ghc/lib/std/PrelRead.lhs
ghc/lib/std/PrelReal.lhs [new file with mode: 0644]
ghc/lib/std/PrelST.lhs
ghc/lib/std/PrelStable.lhs
ghc/lib/std/PrelTup.lhs
ghc/lib/std/Prelude.lhs
ghc/lib/std/Random.lhs
ghc/lib/std/Ratio.lhs
ghc/lib/std/System.lhs
ghc/lib/std/Time.lhs
ghc/rts/HSprel.def
ghc/rts/RtsStartup.c