summaryrefslogtreecommitdiff
path: root/ghc/lib/std/PrelIOBase.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2002-02-12 15:17:13 by simonmar]simonmar2002-02-121-633/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 :-(
* [project @ 2002-01-29 17:12:53 by simonmar]simonmar2002-01-291-1/+20
| | | | Add instance Eq Exception (and hence instance Eq IOError).
* [project @ 2002-01-22 13:54:22 by simonmar]simonmar2002-01-221-2/+4
| | | | | | | | | | | | | | | | | | 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).
* [project @ 2001-11-26 20:04:00 by sof]sof2001-11-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* [project @ 2001-11-14 11:39:29 by simonmar]simonmar2001-11-141-15/+18
| | | | | | | | | | | | | | | | | | | 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.
* [project @ 2001-10-11 22:27:04 by sof]sof2001-10-111-12/+9
| | | | | | | | | | | | | | | | - 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.
* [project @ 2001-06-01 13:06:01 by sewardj]sewardj2001-06-011-1/+3
| | | | | | | | | | | 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.
* [project @ 2001-05-31 10:03:35 by simonmar]simonmar2001-05-311-1/+11
| | | | | | | | - 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.
* [project @ 2001-05-22 19:25:49 by qrczak]qrczak2001-05-221-4/+3
| | | | | | Remove module dependency loop: don't import PrelIOBase in PrelRead. readIO is in PrelIO, remove it from PrelRead. Derive instance Read BufferMode automatically.
* [project @ 2001-05-22 15:06:47 by simonmar]simonmar2001-05-221-4/+22
| | | | | | | | - 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
* [project @ 2001-05-18 16:54:04 by simonmar]simonmar2001-05-181-352/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2001-02-27 13:38:58 by simonmar]simonmar2001-02-271-2/+5
| | | | changes for commandline do-bindings: define failIO.
* [project @ 2001-02-27 13:38:15 by simonmar]simonmar2001-02-271-3/+1
| | | | remove PutFullMVar
* [project @ 2001-02-22 13:17:57 by simonpj]simonpj2001-02-221-4/+10
| | | | | | | | | | | | | | 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.
* [project @ 2001-02-20 18:40:54 by qrczak]qrczak2001-02-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* [project @ 2001-02-06 11:42:30 by simonmar]simonmar2001-02-061-4/+5
| | | | | | | | | | | | 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.
* [project @ 2001-01-11 17:25:56 by simonmar]simonmar2001-01-111-20/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2001-01-11 07:04:16 by qrczak]qrczak2001-01-111-38/+39
| | | | Change the representation of IOException: add optional filename.
* [project @ 2001-01-10 16:28:15 by qrczak]qrczak2001-01-101-5/+5
| | | | | | | | | | | | | | | | 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).
* [project @ 2000-11-07 10:42:55 by simonmar]simonmar2000-11-071-8/+12
| | | | | merge before-ghci -> before-ghci-branch-merged into the ghc (non-compiler) parts of the tree.
* [project @ 2000-09-25 12:58:39 by simonpj]simonpj2000-09-251-1/+2
| | | | | | | | | | | | -------------------------------------------------- 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.
* [project @ 2000-07-08 18:17:40 by panne]panne2000-07-081-2/+3
| | | | Fixed Show instance for Exception
* [project @ 2000-07-07 11:03:57 by simonmar]simonmar2000-07-071-243/+343
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2000-05-30 14:28:13 by simonmar]simonmar2000-05-301-2/+2
| | | | don't need to import PrelPack.hi-boot
* [project @ 2000-05-30 12:50:04 by sewardj]sewardj2000-05-301-2/+2
| | | | Fix cyclic dependency problem when compiling the Prelude.
* [project @ 2000-04-14 15:28:24 by rrt]rrt2000-04-141-2/+2
| | | | Removed -fcompiling-prelude flag (now removed from compiler)
* [project @ 2000-04-12 17:33:16 by simonmar]simonmar2000-04-121-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2000-04-10 16:02:58 by simonpj]simonpj2000-04-101-2/+2
| | | | | | | | | | 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.
* [project @ 2000-04-07 13:45:46 by simonpj]simonpj2000-04-071-2/+4
| | | | | | | | | | * 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.
* [project @ 2000-03-28 08:51:09 by simonmar]simonmar2000-03-281-3/+2
| | | | remove redundant import.
* [project @ 2000-03-14 01:52:25 by sof]sof2000-03-141-3/+4
| | | | Misc Win32 bitrot
* [project @ 2000-01-30 10:11:32 by simonmar]simonmar2000-01-301-1/+18
| | | | | 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.
* [project @ 1999-12-03 16:17:42 by simonmar]simonmar1999-12-031-5/+1
| | | | Move fixST and fixIO out of the prelude.
* [project @ 1999-11-26 16:26:32 by simonmar]simonmar1999-11-261-2/+2
| | | | rename error.h to stgerror.h
* [project @ 1999-11-22 15:55:49 by simonmar]simonmar1999-11-221-2/+21
| | | | | | 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.
* [project @ 1999-09-19 19:12:39 by sof]sof1999-09-191-11/+22
| | | | | Drop the use of _ccall_, _casm_ and lit-lits in std/, "foreign import" is the future.
* [project @ 1999-08-23 12:53:23 by keithw]keithw1999-08-231-2/+2
| | | | | | 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.
* [project @ 1999-06-12 16:17:23 by keithw]keithw1999-06-121-2/+2
| | | | K&R -> ANSI token pasting (ie, x##y for x/**/y)
* [project @ 1999-05-18 14:59:04 by simonpj]simonpj1999-05-181-1/+2
| | | | ../compiler/msg_prel
* [project @ 1999-04-27 17:41:17 by sof]sof1999-04-271-2/+4
| | | | | | | | | | | | * 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.
* [project @ 1999-03-31 09:52:05 by sof]sof1999-03-311-26/+13
| | | | | On Win32 platforms, provide a (IOError.ComError Int) constructor for handling HRESULTs conveniently.
* [project @ 1999-01-14 18:12:47 by sof]sof1999-01-141-8/+22
| | | | | | | 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..)
* [project @ 1998-12-02 13:17:09 by simonm]simonm1998-12-021-154/+130
| | | | Move 4.01 onto the main trunk.
* [project @ 1998-08-27 12:55:57 by sof]sof1998-08-271-1/+8
| | | | FilePath moved from PrelHandle to PrelIOBase
* [project @ 1998-08-14 12:49:51 by sof]sof1998-08-141-96/+225
| | | | New Handle repr;better IOErrors;moved trace+performGC to IOExts;removed fputs(yes!)
* [project @ 1998-05-22 15:57:05 by simonm]simonm1998-05-221-0/+34
| | | | | | - Add NOINLINE pragmas to the unsafe things (unsafe*IO, unsafe*ST, runST etc.) - Move unsafe function back into the proper modules - Remove PrelUnsafe*.lhs
* [project @ 1998-05-05 10:31:14 by sof]sof1998-05-051-9/+15
| | | | constructErrorAndFailWithInfo: new function for including files/paths that caused IO op to fail
* [project @ 1998-02-02 17:27:26 by simonm]simonm1998-02-021-0/+389
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