| 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 instance Eq Exception (and hence instance Eq IOError).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Deadlock is now an exception instead of a return status from
rts_evalIO().
The current behaviour is as follows, and can be changed if necessary:
in the event of a deadlock, the top main thread is taken from the main
thread queue, and if it is blocked on an MVar or an Exception (for
throwTo), then it receives a Deadlock exception. If it is blocked on
a BLACKHOLE, we instead send it the NonTermination exception. Note
that only the main thread gets the exception: it is the responsibility
of the main thread to unblock other threads if necessary.
There's a slight difference in the SMP build: *all* the main threads
get an exception, because clearly none of them may make progress
(compared to the non-SMP situation, where all but the top main thread
are usually blocked).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make the IO implementation work with WinSock once again.
When creating sockets with WinSock, you don't get back
a file descriptor, but a SOCKET (which just so happens
to map to the same type as a 'normal' file descriptor).
This SOCKET value cannot be used with the CRT ops
read(), write(), close(), but you have to use the
socket-specific operations (recv(), send(), and closesocket(),
respectively) instead.
To keep track of this distinction between file and
socket file descriptors, the following changes were
made:
* a Handle__ has got a new field, haIsStream, which is True
for sockets / streams.
(this field is essentially unused in non-Win32 settings,
but I decided not to conditionalise its presence).
* PrelHandle.openFd now takes an extra (Maybe FDType) argument,
which lets you force what type of FD we're converting into
a Handle (this is crucial for WinSock SOCKETs, since we don't
want to attempt fstat()ing them).
Fixes breakage that was introduced with May 2001 (or earlier)
rewrite of the IO layer. This commit build upon recent IO changes
to HEAD, so merging it to STABLE will require importing those
changes too (I'll let others be the judge whether this should
be done or not).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the way we do finalization for duplex handles. Previously, we
arranged that the read side pointed to the right side via a special
handle type (ReadSideHandle _), and the finalizer points to the write
side. This turned out to interact badly with hGetContents, which
likes to explicitly close the read side of the handle after it reads
EOF or gets an error, which resulted in double-closes for duplex
handles.
Now we store the pointer from the read side to the write side in the
Handle structure itself, so it doesn't get lost when hGetContents
changes the handle type to SemiClosedHandle. Furthermore, in hClose
we no longer close the file descriptor associated with the read side
of a duplex handle - the actual close will have to wait until the
finalizer runs, because someone might still be using the write side.
Thanks to Volker Stolz for pointing out the problem.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- removed Win32-only IOErrorType.ComError
- added IOErrorType.(DynIOError Dynamic.Dynamic)
Propagating dynamically-typed exceptions as Exception.DynException
isn't always the right thing to do
[ why? You cannot catch them with IO.catch & you don't get the
'infrastructure' that IOError offers, so you're forced to
reinvent that wheel for each dynamic exception.
]
- removed IOExts.isComError :: IOError -> Bool
- added IOExts.isDynIOError :: IOError -> Bool
- added IOExts.getDynIOError :: IOError -> Dynamic.Dynamic
- documented IOExts changes.
|
|
|
|
|
|
|
|
|
|
|
| |
More fixups to make the new IO lib work on mingw.
* Outlaw changing the file position on a text-mode file. After
consideration of the mingw translation semantics I cannot see
how to make a correct implementation.
* Add a field to Handle__ to say whether or not the handle is in
binary mode.
* Restrict seek operations on Handles to those in binary mode.
* Export hSetBinaryMode from IO.lhs.
|
|
|
|
|
|
|
|
| |
- don't put a TTY into RAW mode if the handle is an output-only handle (so
if you set stdout to NoBuffering and leave stdin as it is, you don't
lose TTY processing on stdin).
- some cleanups.
|
|
|
|
|
|
| |
Remove module dependency loop: don't import PrelIOBase in PrelRead.
readIO is in PrelIO, remove it from PrelRead. Derive instance Read
BufferMode automatically.
|
|
|
|
|
|
|
|
| |
- System.exitWith now raises a (new) exception,
ExitException ExitCode.
- While I was there I cleaned up System.getArgs and
System.getProgName, using foriegn label and removing progargs.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I/O library rewrite
-------------------
This commit replaces the old C/Haskell I/O implementation with a new
Haskell-only one using the new FFI & hsc2hs.
main points:
- lots of code deleted: we're about 3000 lines of C lighter,
but the amount of Haskell code is about the same.
- performance is ok: some operations are faster, others are
slower. There's still some tuning to do, though.
- the new library is designed to handle read/write streams
much better: a read/write stream gets a special kind of
handle internally called a "DuplexHandle", which actually
contains two separate handles, one for writing and one for
reading. The upshot is that you can do simultaneous reading
and writing to/from a socket or FIFO without any locking
problems. The effect is similar to calling socketToHandle
twice, except that finalization works properly (creating
two separate Handles could lead to the socket being closed
too early when one of the Handles is GC'd).
- hConnectTo and withHandleFor are gone (no one responded to
my mail on GHC users, but we can always bring 'em back if
necessary).
- I made a half-hearted attempt at keeping the system-specific
code in one place: see PrelPosix.hsc.
- I've rearranged the I/O tests and added lots more.
ghc/tests/lib/IO now contains Haskell 98-only IO tests,
ghc/test/lib/{IOExts, Directory, Time} now contain tests for
the relevant libraries. I haven't quite finished in here yet,
the IO tests work but the others don't yet.
- I haven't done anything about Unicode yet, but now we can
start to discuss what needs doing here. The new library
is using MutableByteArrays for its buffers because that
turned out to be a *lot* easier (and quicker) than malloc'd
buffers - I hope this won't cause trouble for unicode
translations though.
WARNING: Windows users refrain from updating until we've had a chance
to fix any issues that arise.
Testing: the basic H98 stuff has been pretty thoroughly tested, but
the new duplex handle stuff is still a little green.
|
|
|
|
| |
changes for commandline do-bindings: define failIO.
|
|
|
|
| |
remove PutFullMVar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Apply tweaks needed to let this compile: remove syn_map argument from
typecheckExpr in HscMain, import PrelNum.fromInt to modules which
use integer literals with -fno-implicit-prelude flag.
It crashes later, on Directory.hs:
ghc: panic! (the `impossible' happened):
srtExpr
I'm not sure if resolving numeric literals to top-level definitions
of fromInt/fromInteger with -fno-implicit-prelude is a good idea.
Using names from whatever module is called Prelude would be IMHO
better, probably when -fglasgow-exts is given. Prel* modules themselves
would import PrelNum as Prelude.
Both schemes break for fromInt, which is non-standard and by default
it's visible neither at the top level nor in the Prelude module. My
proposal for dealing with it is as follows (assuming that fromInteger
is taken from the module locally called Prelude instead of the top
level): when the standard Prelude is used, take fromInt from PrelNum;
when a Prelude replacement is used, use fromInt from it if available,
otherwise use its fromInteger instead. That way Prelude replacements
can ignore this non-standard extension and get the expected behavior,
or they can also choose to use this extension (in a way compatible
with Haskell implementations which allow to replace Prelude but don't
have fromInt).
|
|
|
|
|
|
|
|
|
|
|
|
| |
urk! when showing a handle, we don't replace the MVar. For example,
the following test causes a deadlock:
main = do
getContents
catch getChar (\e -> print e >> return 'x')
catch getChar (\e -> print e >> return 'x')
To be merged into 4.08.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Re-organisation of ghc/lib/std and hslibs/lang
----------------------------------------------
In brief: move deprecated features out of ghc/lib/std and into
hslibs/lang, move new FFI libraries into ghc/lib/std and start
using them.
- foreign import may now return an unboxed type (this was
advertised to work before, but in fact didn't). Subsequent
cleanups in PrelInt/PrelWord.
- Ptr is now defined in ghc/lib/std/PrelPtr.lhs. Ptr is no
longer a newtype of Addr, it is defined directly in terms of
Addr#.
- PrelAddr has disappeared from ghc/lib/std, all uses of Addr in
ghc/lib/std have been replaced with Ptr. The definitions of
Addr has been moved to hslibs/lang/Addr.lhs, as has
lots of other Addr-related stuff.
- ForeignObj has been removed from ghc/lib/std, and replaced with
ForeignPtr. The definition of ForeignObj has been moved to
hslibs/lang/ForeignObj.lhs.
- Most of the new FFI has been moved into ghc/lib/std in the form
of modules PrelMarshalAlloc, PrelCString, PrelCError,
PrelMarshalError, PrelMarshalArray, PrelMarshalUtils,
PrelCTypes, PrelCTypesISO, and PrelStorable. The corresponding
modules in hslibs/lang simply re-export the contents of these
modules.
- PrelPosixTypes defines a few POSIX types (CMode == mode_t,
etc.)
- PrelCError changed to access errno using foreign label and peek
(the POSIX book I have says that errno is guaranteed to be an
extern int, so this should be OK until I get around to making
errno thread-safe).
- Hacked the macros that generate the code for CTypes and
CTypesISO to generate much less code
(ghc/lib/std/cbits/CTypes.h).
- RtsAPI is now a bit more honest when it comes to building heap
objects (it uses the correct constructors).
- the Bits class and related stuff has been moved to ghc/lib/std
(it was simpler this way).
- Directory and System have been converted to use the new FFI.
|
|
|
|
| |
Change the representation of IOException: add optional filename.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove CError.throwCError. Export the new function errnoToIOError.
Add a missing colon in a string inside IOException formed from
the error-specific part and optional filename. The IOException
representation has not changed yet, but IMHO the filename should
be kept separate.
Correctly handle user errors in IO.ioeGet* functions like other
IO errors.
Let fail :: String -> IO a throw a user error instead of invoking error
(Haskell98 is ambiguous about that and IMHO it should be this way;
this is also what nhc does).
|
|
|
|
|
| |
merge before-ghci -> before-ghci-branch-merged into the ghc
(non-compiler) parts of the tree.
|
|
|
|
|
|
|
|
|
|
|
|
| |
--------------------------------------------------
Tidying up HsLit, and making it possible to define
your own numeric library
Simon PJ 22 Sept 00
--------------------------------------------------
I forgot to commit changes to the libraries! The main thing
is to define monomorphic plusInteger, timesInteger etc, in PrelNum.
|
|
|
|
| |
Fixed Show instance for Exception
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rearrange exception stuff, as per my message on glasgow-haskell-users
recently.
The main change is the IOError type is now a synonym for Exception.
IO.ioError can therefore be used for throwing exceptions. IO.catch
still catches only IO exceptions, for backwards compatibility.
The interface exported by Exception has changed somewhat:
try :: IO a -> IO (Either Exception a)
tryJust :: (Exception -> Maybe b) -> a -> IO (Either b a)
catch :: IO a -> (Exception -> IO a) -> IO a
catchJust :: (Exception -> Maybe b) -> IO a -> (b -> IO a) -> IO a
ioErrors :: Exception -> Maybe IOError
arithExceptions :: Exception -> Maybe ArithException
errorCalls :: Exception -> Maybe String
dynExceptions :: Exception -> Maybe Dynamic
assertions :: Exception -> Maybe String
asyncExceptions :: Exception -> Maybe AsyncException
raiseInThread is now called throwTo.
Where possible, the old functions have been left around, but marked
deprecated.
|
|
|
|
| |
don't need to import PrelPack.hi-boot
|
|
|
|
| |
Fix cyclic dependency problem when compiling the Prelude.
|
|
|
|
| |
Removed -fcompiling-prelude flag (now removed from compiler)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes the trace/stderr problem, and also fixes some other
problems with the I/O library.
- handles now contain a list of free buffers, which are
guaranteed to be the same size as the primary handle buffer.
- hPutStr now doesn't evaluate any part of the input string with
the handle locked. Instead, it acquires a buffer from the handle
copies characters into it, then commits the buffer. This is
better for concurrency too, because the handle is only locked
while we're actually reading/writing, not while evaluating.
- there were an even number of off-by-one errors in the I/O system
which compensated for each other. This has been fixed.
- made the I/O subsystem a little more exception-safe. It still
isn't totally exception-safe, but I can't face doing that
without a complete rewrite of this thing in Haskell.
- add hPutBufFull and hGetBufFull. The compiler probably needs to
be updated to use these too.
|
|
|
|
|
|
|
|
|
|
| |
Make it so that -fcompiling-prelude applies only
for Prelude modules (i.e. ones called Prelxxx).
I've done this with an {-# OPTIONS #-} line in each
such module (they all has -fno-implicit-prelude anyway)
but a less repetitive approach in the Makefile would
be welcome.
|
|
|
|
|
|
|
|
|
|
| |
* Fix 'foreign export' and 'foreign export dynamic' so
that we can export pure (non-IO) functions as well as IO-ish ones
NB: There's a change to PrelIOBase, so you'll
need to recompile the Prelude
* Add Type.mkDictTys and call it in various places.
|
|
|
|
| |
remove redundant import.
|
|
|
|
| |
Misc Win32 bitrot
|
|
|
|
|
| |
Add notes about where the IO representation is wired in to various
parts of the source tree, since I'm about to add some more.
|
|
|
|
| |
Move fixST and fixIO out of the prelude.
|
|
|
|
| |
rename error.h to stgerror.h
|
|
|
|
|
|
| |
Reduce the number of orphan-instance modules. There are a few left,
but these can't be removed without significant reorganisation due to
recursive dependencies.
|
|
|
|
|
| |
Drop the use of _ccall_, _casm_ and lit-lits in std/, "foreign import" is
the future.
|
|
|
|
|
|
| |
Revert commit of 1999/06/12 16:17:28. We use -traditional for CPP,
and so x##y and #x don't work and we must use x/**/y (ugh) and "x"
(urk!!) instead. Ah well.
|
|
|
|
| |
K&R -> ANSI token pasting (ie, x##y for x/**/y)
|
|
|
|
| |
../compiler/msg_prel
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Added toplevel exception handler:
topHandler :: Bool -- bomb on exception caught
-> Exception
-> IO ()
for PrelMain.mainIO and Concurrent.forkIO to use
* moved forkIO out of PrelConc and into Concurrent.
|
|
|
|
|
| |
On Win32 platforms, provide a (IOError.ComError Int) constructor for
handling HRESULTs conveniently.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
FilePath moved from PrelHandle to PrelIOBase
|
|
|
|
| |
New Handle repr;better IOErrors;moved trace+performGC to IOExts;removed fputs(yes!)
|
|
|
|
|
|
| |
- Add NOINLINE pragmas to the unsafe things (unsafe*IO, unsafe*ST, runST etc.)
- Move unsafe function back into the proper modules
- Remove PrelUnsafe*.lhs
|
|
|
|
| |
constructErrorAndFailWithInfo: new function for including files/paths that caused IO op to fail
|
|
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
|