| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Switch over to the new hierarchical libraries
---------------------------------------------
This commit reorganises our libraries to use the new hierarchical
module namespace extension.
The basic story is this:
- fptools/libraries contains the new hierarchical libraries.
Everything in here is "clean", i.e. most deprecated stuff has
been removed.
- fptools/libraries/base is the new base package
(replacing "std") and contains roughly what was previously
in std, lang, and concurrent, minus deprecated stuff.
Things that are *not allowed* in libraries/base include:
Addr, ForeignObj, ByteArray, MutableByteArray,
_casm_, _ccall_, ``'', PrimIO
For ByteArrays and MutableByteArrays we use UArray and
STUArray/IOUArray respectively now.
Modules previously called PrelFoo are now under
fptools/libraries/GHC. eg. PrelBase is now GHC.Base.
- fptools/libraries/haskell98 provides the Haskell 98 std.
libraries (Char, IO, Numeric etc.) as a package. This
package is enabled by default.
- fptools/libraries/network is a rearranged version of
the existing net package (the old package net is still
available; see below).
- Other packages will migrate to fptools/libraries in
due course.
NB. you need to checkout fptools/libraries as well as
fptools/hslibs now. The nightly build scripts will need to be
tweaked.
- fptools/hslibs still contains (almost) the same stuff as before.
Where libraries have moved into the new hierarchy, the hslibs
version contains a "stub" that just re-exports the new version.
The idea is that code will gradually migrate from fptools/hslibs
into fptools/libraries as it gets cleaned up, and in a version or
two we can remove the old packages altogether.
- I've taken the opportunity to make some changes to the build
system, ripping out the old hslibs Makefile stuff from
mk/target.mk; the new package building Makefile code is in
mk/package.mk (auto-included from mk/target.mk).
The main improvement is that packages now register themselves at
make boot time using ghc-pkg, and the monolithic package.conf
in ghc/driver is gone.
I've updated the standard packages but haven't tested win32,
graphics, xlib, object-io, or OpenGL yet. The Makefiles in
these packages may need some further tweaks, and they'll need
pkg.conf.in files added.
- Unfortunately all this rearrangement meant I had to bump the
interface-file version and create a bunch of .hi-boot-6 files :-(
|
|
|
|
|
| |
Add genRange method to class RandomGen, as per the revised Haskell 98
library report.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add {intToInt,wordToWord}{8,16,32}# primops. WARNING: Not implemented
in ncg for Alpha and Sparc. But -O -fasm is not going to go far anyway
because of other omissions.
* Have full repertoire of 8,16,32-bit signed and unsigned MachMisc.Size
values. Again only x86 is fully supported. They are used for
{index,read,write}{Int,Word}{8,16,32}{OffAddr,Array}# and
{intToInt,wordToWord}{8,16,32}# primops.
* Have full repertoire of
{index,read,write}\
{Char,WideChar,Int,Word,Addr,Float,Double,StablePtr,\
{Int,Word}{8,16,32,64}}\
{OffAddr,Array} primops and appropriate instances.
There were various omissions in various places.
* Add {plus,minus,times}Word# primops to avoid so many Word# <-> Int#
coercions.
* Rewrite modules PrelWord and PrelInt almost from scratch.
* Simplify fromInteger and realToFrac rules. For each of
{Int,Word}{8,16,32} there is just a pair of fromInteger rules
replacing the source or target type with Int or Word. For
{Int,Word,Int64,Word64} there are rules from any to any.
Don't include rules which are derivable from inlining anyway,
e.g. those mentioning Integer. Old explicit coercions are simply
defined as appropriately typed fromInteger.
* Various old coercion functions marked as deprecated.
* Add instance Bits Int, and
instance {Show,Num,Real,Enum,Integral,Bounded,Ix,Read,Bits} Word.
* Coercions to sized integer types consistently behave as cutting the
right amount of bits from the infinite two-complement representation.
For example (fromIntegral (-1 :: Int8) :: Word64) == maxBound.
* ghc/tests/numeric/should_run/arith011 tests {Int,Word}64 and instance
Bits Int, and does not try to use overflowing toEnum. arith011.stdout
is not updated yet because of a problem I will tell about soon.
* Move fromInteger and realToFrac from Prelude to PrelReal.
Move fromInt from PrelNum to PrelReal and define as fromInteger.
Define toInt as fromInteger. fromInteger is the place to write
integer conversion rules for.
* Remove ArrayBase.newInitialisedArray, use default definition of
newArray instead.
* Bugs fixed:
- {quot,rem}Word# primop attributes.
- integerToInt64# for small negative values.
- {min,max}Bound::Int on 64-bit platforms.
- iShiftRL64#.
- Various Bits instances.
* Polishing:
- Use 'ppr' instead of 'pprPrimOp' and 'text . showPrimRep'.
- PrimRep.{primRepString,showPrimRepToUser} removed.
- MachMisc.sizeOf returns Int instead of Integer.
- Some eta reduction, parens, spacing, and reordering cleanups -
sorry, couldn't resist.
* Questions:
- Should iShiftRL and iShiftRL64 be removed? IMHO they should,
s/iShiftRA/iShiftR/, s/shiftRL/shiftR/. The behaviour on shifting
is a property of the signedness of the type, not the operation!
I haven't done this change.
|
|
|
|
| |
Since fromInt was degraded to a function, do the same with toInt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fromInt
Remove fromInt from class Num, though it is retained
as an overloaded operation (with unchanged type) in PrelNum.
There are quite a few consequential changes in the Prelude.
I hope I got them all correct!
Also fix a bug that meant Integer (and its instances)
wasn't getting slurped in by the renamer, even though it
was needed for defaulting.
|
|
|
|
|
|
| |
- fix copyrights
- remove some unused imports
- comment formatting fixes
|
|
|
|
| |
Changing PrimPrel to PrelPrim
|
|
|
|
| |
Using the new Prelude structure to handle prims.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Simplfy the mutable array story:
- rename MutableArray to STArray (and similarly
for all operations on MutableArray, eg newArray
is now newSTArray).
- remove the extra level of indirection between
STArrays and MutableArrays.
- remove the MutableArray interface from
hslibs/lang/MutableArray. This module will go
away soon - Andy, don't bother porting it to Hugs.
|
|
|
|
| |
Wibble: rm needless import Prelude used by Hugs.
|
|
|
|
| |
Changed an #ifdef so that the Prelude can be builit again by GHC.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
improving the synatax and semantics of the privileged import
Typical use might be:
import Prelude
import privileged Prelude ( IORef , unsafePerformIO )
Which means please ignore the export that comes with Prelude,
and let me at compiler internal magic operations, IORef and
unsafePerformIO (both are later exported by IOExt)
I've also updated the stdlib files to use this (hugs only :-).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
GHC now uses the "Hugs" split function, which is believed to have
better behaviour: it is not unsafe, is deterministic, and works
better with QuickCheck, a major client.
Rational for the Record, quoted from Mark Jones mail on the Hugs list:
[Mark Jones]
A couple of months ago, John Hughes sent me mail about a problem that
he had uncovered with the implementation of the Random library in Hugs.
He had been using the "split" function in an attempt to generate a
stream of random number generators, each of which he hoped would be
different from the others. But instead he found that he actually
ended with many different copies of the *same* random number generator.
A disappointing, and frustratingly non-random result.
If you don't happen to recall, split is a member of the RandomGen class,
with type RandomGen g => g -> (g,g); it takes a single random number
generator as its argument, and returns a pair of two new generators as
its result. The only thing that the specification requires is that the
two generators returned are (a) distinct and (b) `independently robust'
from a statistical point of view. To the best of my knowledge, the
implementation in Hugs meets this modest specification. Sadly, assuming
only this specification, you cannot write the function that John was
looking for and be sure that it will generate more than two different
generators.
For example, the specification allows even the following trivial
implementation for split: split _ = (g1, g2), where g1 and g2 are some
arbitrary but constant pair of distinct, and independently robust
generators. With this implementation, you can split as often as you
want and you'll never get more that two generators.
Hugs and GHC (as far as I can tell) both use definitions of the form:
split g = (g, f g)
for some function f. (My understanding of the code in GHC is that it
uses an unsafe function for f, breaking referential transparency; I hope
the optimizer knows about this.) Note that this definition returns the
argument as a result; the specification doesn't prohibit that; all it
requires is that the two results returned be distinct. But if you try
to generate a list of n different generators using:
take n (iterate (fst . split) g)
then you will be sorely disappointed; you might as well have written
replicate n g. (On the other hand, if you were lucky enough to have
used (snd . split), instead of (fst . split), then you wouldn't have
noticed the problem ...)
I know very little about the mathematics or pragmatics of random
number generators, so I'm not sure that I know how to fix this
problem. However, starting from this position of ignorance, I have
hacked up a new version of "split" for the standard "StdGen" that
will appear in the next release of Hugs (real soon now!). Judging
from the tests that I've tried so far, it seems to work much
better than the old version. That said:
- Take care if you use Random.split in your programs, because it
may not do what you expect.
- There should probably be an errata about this for the Haskell 98
library report ... if somebody can figure out what it should say.
- If you use Hugs, be aware that the implementation of Random.split
was hacked up by someone who has no way of justifying that
implementation, beyond some simple experiments.
- If you know something about the mechanics of random number
generators, here's an area where Haskell specifications and
implementations could benefit from your knowledge!
All the best,
Mark
[end quote]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Implement Random.setStdGen and Random.getStdGen for Hugs.
|
|
|
|
|
|
|
| |
Adding in the modified versions of the Standard Haskell 98 libraries.
These should compile under both Hugs and GHC.
use the flags -D__HUGS__ -DUSE_REPORT_PRELUDE to extract the Hugs src.
|
|
|
|
| |
Adjust library imports to get fromInt/toInt from PrelNum
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All Simon's recent tuning changes. Rough summary follows:
* Fix Kevin Atkinson's cant-find-instance bug. Turns out that Rename.slurpSourceRefs
needs to repeatedly call getImportedInstDecls, and then go back to slurping
source-refs. Comments with Rename.slurpSourceRefs.
* Add a case to Simplify.mkDupableAlt for the quite-common case where there's
a very simple alternative, in which case there's no point in creating a
join-point binding.
* Fix CoreUtils.exprOkForSpeculation so that it returns True of (==# a# b#).
This lack meant that
case ==# a# b# of { True -> x; False -> x }
was not simplifying
* Make float-out dump bindings at the top of a function argument, as
at the top of a let(rec) rhs. See notes with FloatOut.floatRhs
* Make the ArgOf case of mkDupableAlt generate a OneShot lambda.
This gave a noticeable boost to spectral/boyer2
* Reduce the number of coerces, using worker/wrapper stuff.
The main idea is in WwLib.mkWWcoerce. The gloss is that we must do
the w/w split even for small non-recursive things. See notes with
WorkWrap.tryWw.
* This further complicated getWorkerId, so I finally bit the bullet and
make the workerInfo field of the IdInfo work properly, including
under substitutions. Death to getWorkerId. Kevin Glynn will be happy.
* Make all lambdas over realWorldStatePrimTy
into one-shot lambdas. This is a GROSS HACK.
* Also make the occurrence analyser aware of one-shot lambdas.
* Make various Prelude things into INLINE, so that foldr doesn't
get inlined in their body, so that the caller gets the benefit
of fusion. Notably in PrelArr.lhs.
|
|
|
|
| |
../compiler/msg_prel
|
|
|
|
|
|
| |
randomIvalInteger: The difference between '1' and 'l' is rather slight
at the level of pixels. At the level of Haskell programs however, the
difference is rather more pronounced :)
|
|
|
|
| |
couple of fixes (courtesy of MPJ)
|
|
|
|
| |
Improved the splitting of the std. generator
|
|
|
|
| |
The bugfix that time forgot
|
|
|
|
|
|
|
| |
Changes to make the Prelude comply with Haskell 98.
I claim that this completes GHC's implementation of Haskell 98 (at
least feature-wise, but there's bound to be some bugs lurking..)
|
|
|
|
| |
Move 4.01 onto the main trunk.
|
|
Library re-organisation:
All libraries now live under ghc/lib, which has the following structure:
ghc/lib/std -- all prelude files (libHS.a)
ghc/lib/std/cbits
ghc/lib/exts -- standard Hugs/GHC extensions (libHSexts.a)
-- available with '-fglasgow-exts'
ghc/lib/posix -- POSIX library (libHSposix.a)
ghc/lib/posix/cbits -- available with '-syslib posix'
ghc/lib/misc -- used to be hslibs/ghc (libHSmisc.a)
ghc/lib/misc/cbits -- available with '-syslib misc'
ghc/lib/concurrent -- Concurrent libraries (libHSconc.a)
-- available with '-concurrent'
Also, several non-standard prelude modules had their names changed to begin
with 'Prel' to reduce namespace pollution.
Addr ==> PrelAddr (Addr interface available in 'exts')
ArrBase ==> PrelArr
CCall ==> PrelCCall (CCall interface available in 'exts')
ConcBase ==> PrelConc
GHCerr ==> PrelErr
Foreign ==> PrelForeign (Foreign interface available in 'exts')
GHC ==> PrelGHC
IOHandle ==> PrelHandle
IOBase ==> PrelIOBase
GHCmain ==> PrelMain
STBase ==> PrelST
Unsafe ==> PrelUnsafe
UnsafeST ==> PrelUnsafeST
|