summaryrefslogtreecommitdiff
path: root/ghc/lib/std/IO.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2002-02-12 15:17:13 by simonmar]simonmar2002-02-121-94/+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 @ 2001-06-09 07:06:05 by qrczak]qrczak2001-06-091-3/+3
| | | | Fix hSetPosn type in the export comment.
* [project @ 2001-06-07 10:44:47 by sewardj]sewardj2001-06-071-2/+1
| | | | | | | | Try to improve matters in the text-mode-seek swamp. Only disallow text-mode-seeks on Win32, rather than on all platforms. That means that seeks in text mode on Unix platforms should work as originally (which was the correct H98 behaviour), whilst Win32 generates exceptions if you do seeks in text mode.
* [project @ 2001-06-01 13:06:01 by sewardj]sewardj2001-06-011-1/+2
| | | | | | | | | | | 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-18 16:54:04 by simonmar]simonmar2001-05-181-415/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 @ 2000-06-30 13:39:35 by simonmar]simonmar2000-06-301-1/+4
| | | | | | - fix copyrights - remove some unused imports - comment formatting fixes
* [project @ 2000-04-10 13:18:13 by simonpj]simonpj2000-04-101-537/+11
| | | | | | | | | Complete the previous commit. I think things should be OK now; but the Hugs versioning may well need adjusting. NOTE: I've added PrelIO.lhs; it contains all the GHC parts of what was IO.lhs.
* [project @ 2000-04-10 12:12:27 by simonpj]simonpj2000-04-101-57/+5
| | | | | | | | | | | | | | | | | | | | Make it so that (A) All modules imported by Prelude are PrelXXX modules, not library modules (notably Ix, Monad were culprits). This lines up with the Hugs story, and is more intuitive. (B) All things needed implicitly by syntax (e.g. do-notation needs Monad) come from PrelXXX modules, even if they aren't visible when you say 'import Prelude'. These changes simplify the story, and fix the 'looking for [boot] interface for Ix' problem. This change is not quite complete. I'm committing it so Simon can finish it off.
* [project @ 2000-04-06 00:04:01 by andy]andy2000-04-061-1/+1
| | | | Changing PrimPrel to PrelPrim
* [project @ 2000-04-04 02:20:30 by andy]andy2000-04-041-26/+23
| | | | Using the new Prelude structure to handle prims.
* [project @ 2000-03-30 09:04:34 by andy]andy2000-03-301-0/+1
| | | | Wibble One.
* [project @ 2000-03-17 15:00:25 by simonmar]simonmar2000-03-171-7/+0
| | | | don't export non-std stuff.
* [project @ 2000-03-09 21:16:49 by andy]andy2000-03-091-1/+0
| | | | Wibble: rm needless import Prelude used by Hugs.
* [project @ 2000-03-09 13:28:08 by panne]panne2000-03-091-1/+1
| | | | Removed a typo, i.e. ]\begin{code} => \begin{code}
* [project @ 2000-03-09 06:14:38 by andy]andy2000-03-091-8/+34
| | | | | | | | | | | | | | | 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 :-).
* [project @ 2000-03-06 08:01:01 by andy]andy2000-03-061-1/+0
| | | | Removing debugging printf code from hClose.
* [project @ 2000-01-18 12:44:37 by simonmar]simonmar2000-01-181-15/+7
| | | | | | Don't hold the lock on the Handle while we block waiting for data on a read. This is a partial solution to the general problem of holding a lock on the Handle while in mayBlock.
* [project @ 1999-12-20 10:34:27 by simonpj]simonpj1999-12-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 1999-11-23 15:26:56 by andy]andy1999-11-231-1/+1
| | | | Fixing incorrect definition of BlockBuffering in Hugs.
* [project @ 1999-11-22 16:00:21 by sewardj]sewardj1999-11-221-10/+99
| | | | Enforce multiple reader, single writer semantics for Handles.
* [project @ 1999-11-22 15:55:49 by simonmar]simonmar1999-11-221-29/+0
| | | | | | 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-11-22 10:53:11 by simonmar]simonmar1999-11-221-12/+0
| | | | remove some irrelevant code
* [project @ 1999-11-19 16:43:52 by sewardj]sewardj1999-11-191-71/+144
| | | | | | Implement more of IO std library. Buffering settings, seekery and some error-handling stuff is still missing, but the rest is done.
* [project @ 1999-11-01 02:04:31 by andy]andy1999-11-011-7/+8
| | | | | Changing to use the new IO primitives. Addr is no longer a synonym of Int.
* [project @ 1999-10-29 01:16:48 by andy]andy1999-10-291-17/+220
| | | | | | | 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.
* [project @ 1999-09-19 19:12:39 by sof]sof1999-09-191-38/+31
| | | | | 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-1/+1
| | | | | | 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-25 14:10:03 by simonmar]simonmar1999-06-251-28/+40
| | | | Fix some race holes in the handle locking code, and clean it up a little.
* [project @ 1999-06-12 16:17:23 by keithw]keithw1999-06-121-1/+1
| | | | K&R -> ANSI token pasting (ie, x##y for x/**/y)
* [project @ 1999-06-01 16:15:42 by simonmar]simonmar1999-06-011-1/+1
| | | | Remove illegal use of layout.
* [project @ 1999-05-18 14:59:04 by simonpj]simonpj1999-05-181-3/+2
| | | | ../compiler/msg_prel
* [project @ 1999-05-10 16:55:43 by sof]sof1999-05-101-4/+24
| | | | | | The implementation of hGetLine, as given in the report, doesn't handle partial lines on unbuffered handles that well (not at all, as it turns out). Fixed.
* [project @ 1999-01-15 17:54:20 by sof]sof1999-01-151-0/+2
| | | | | | | | | | | | | | | | | | | | Re-integrated mod. that seems to have been dropped on the floor when new-rts moved back onto the main trunk. Here's the commit msg. that was originally used: Extend hConnectTo to also allow output handles to be connected, i.e., h1 <- openFile "foo" WriteMode h2 <- openFile "bar" WriteMode hConnectTo h1 h2 will cause h1's buffer to be flushed when h2's buffer overflows (and it is just about to be flushed.) The implementation is currently not as lazy as that, it flushes h1's buffer regardless of whether a write to h2 causes h2's buffer to overflow or not. This is used to connect 'stderr' and 'stdout', i.e., output on 'stderr' will now cause 'stdout' output to (first) be flushed.
* [project @ 1999-01-14 18:12:47 by sof]sof1999-01-141-27/+27
| | | | | | | 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-47/+173
| | | | Move 4.01 onto the main trunk.
* [project @ 1998-11-23 15:44:21 by sof]sof1998-11-231-0/+2
| | | | | | | | | | | | | | | | Extend hConnectTo to also allow output handles to be connected, i.e., h1 <- openFile "foo" WriteMode h2 <- openFile "bar" WriteMode hConnectTo h1 h2 will cause h1's buffer to be flushed when h2's buffer overflows (and it is just about to be flushed.) The implementation is currently not as lazy as that, it flushes h1's buffer regardless of whether h2's buffer overflows or not. This is used to connect 'stderr' and 'stdout', i.e., output on 'stderr' will now cause 'stdout' output to (first) be flushed.
* [project @ 1998-11-11 17:40:07 by sof]sof1998-11-111-2/+2
| | | | Fixed endian bug that struck when outputting on non-buffered handles
* [project @ 1998-08-27 13:07:56 by sof]sof1998-08-271-3/+87
| | | | | | [non-standard]: Have IO also export the standard IO functions that only the Prelude (in 1.4) provides.
* [project @ 1998-08-14 12:58:30 by sof]sof1998-08-141-378/+290
| | | | Completely rewritten IO implementation
* [project @ 1998-07-22 20:40:26 by sof]sof1998-07-221-3/+3
| | | | IO.hInputReady: interval arg is millisecs, not secs
* [project @ 1998-06-29 14:50:31 by sof]sof1998-06-291-1/+1
| | | | Wrong t. signature for ioeGetErrorString
* [project @ 1998-06-19 10:06:21 by simonm]simonm1998-06-191-2/+2
| | | | | Use BUFSIZ sized blocks for Haskell-side buffering, not (BUFSIZ+1), which probably interacts very badly with the C-side buffering.
* [project @ 1998-05-22 15:57:05 by simonm]simonm1998-05-221-1/+0
| | | | | | - 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-04-07 08:22:03 by sof]sof1998-04-071-284/+216
| | | | Misc code cleanup
* [project @ 1998-02-02 17:27:26 by simonm]simonm1998-02-021-0/+669
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