summaryrefslogtreecommitdiff
path: root/ghc/lib/std/PrelConc.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2002-02-12 15:17:13 by simonmar]simonmar2002-02-121-205/+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-09-14 15:49:56 by simonpj]simonpj2001-09-141-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ----------------- Make seq built in ----------------- DO NOT merge with stable Until this commit 'seq' used a cunning hack so that it seems to be *non-strict* in its second argument: seq x y = case seq# x of { 0 -> y; other -> error "urk" } The reason for this is to make sure that x is evaluated before y, which is what you want in a parallel setting. But in a *sequential* settting, this simply destroys strictness information about y. Now that people are starting to use seq more, this is becoming painful. People sometimes use seq to make their function strict, and are surprised when it becomes non-strict in other arguments! So this commit changes seq so that it does what you would naively expect: seq x y = case x of { any -> y } This is done by making seq built-in, defined along with unsafeCoerce getTag in MkId.lhs. (I considered giving their unfoldings in PrelGHC.hi-boot.pp, but then there is the matter of making sure they are unfolded, since these fns don't have top-level curried defns, so I held off and did seq the same way as the other two.) I renamed PrelConc.seq as PrelConc.pseq; maybe its name will change to `then` or `before` or something else. That's up to the GPH folk.
* [project @ 2001-05-18 16:54:04 by simonmar]simonmar2001-05-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-15 10:02:43 by simonmar]simonmar2001-02-151-2/+9
| | | | changes to support tryPutMVar which I forgot in the main commit.
* [project @ 2001-02-13 15:23:33 by rrt]rrt2001-02-131-2/+2
| | | | | Remove typos, and NO_LARGE_TUPLES, which was the wrong way round anyway (so we never had large tuples).
* [project @ 2000-10-02 11:06:19 by simonmar]simonmar2000-10-021-15/+1
| | | | | | | | | | | | | | - move readMVar and swapMVar from PrelConc to concurrent - add the following exception-safe MVar operations: withMVar :: MVar a -> (a -> IO b) -> IO b modifyMVar :: MVar a -> (a -> IO (a,b)) -> IO b modifyMVar_ :: MVar a -> (a -> IO a) -> IO () - re-implement readMVar and swapMVar in an exception-safe way. - re-implement the Chan operations using withMVar et al.
* [project @ 2000-07-07 11:03:57 by simonmar]simonmar2000-07-071-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10 11:02:00 by simonmar]simonmar2000-05-101-6/+6
| | | | rename takeMaybeMVar to tryTakeMVar
* [project @ 2000-04-14 15:28:24 by rrt]rrt2000-04-141-1/+1
| | | | Removed -fcompiling-prelude flag (now removed from compiler)
* [project @ 2000-04-12 17:08:15 by simonmar]simonmar2000-04-121-7/+12
| | | | add takeMaybeMVar
* [project @ 2000-04-10 16:02:58 by simonpj]simonpj2000-04-101-1/+1
| | | | | | | | | | 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-01-14 12:27:50 by simonmar]simonmar2000-01-141-6/+1
| | | | | expose 'par' now that we have an implementation for both sequential and SMP ways.
* [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-22 15:55:49 by simonmar]simonmar1999-11-221-3/+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-08-27 08:20:34 by simonmar]simonmar1999-08-271-1/+4
| | | | oops, export threadWaitRead etc.
* [project @ 1999-08-26 13:34:36 by simonmar]simonmar1999-08-261-13/+3
| | | | threadDelay etc. should be defined in PrelConc.
* [project @ 1999-05-18 14:59:04 by simonpj]simonpj1999-05-181-2/+1
| | | | ../compiler/msg_prel
* [project @ 1999-05-14 19:49:22 by sof]sof1999-05-141-0/+6
| | | | Added (yield :: IO ()) - the underlying bits were already there, really.
* [project @ 1999-04-27 17:41:17 by sof]sof1999-04-271-13/+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-16 13:20:07 by simonm]simonm1999-03-161-22/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improvements to the threading model. - asynchronous exceptions supported. - killThread# can now raise an exception in the specified thread. It's new type is killThread# :: ThreadId# -> Exception -> IO () High-level versions: killThread :: ThreadId -> IO () raiseInThread :: ThreadId -> Exception -> IO () (killThread raises a 'ThreadKilled' exception in the specified thread). If the thread has no exception handler, it is killed as before. Otherwise, the exception is passed to the innermost CATCH_FRAME and the thread is woken up if it was blocked. The current computation is suspended, instead of being replaced by the exception (as is the case with throw). Sending an exception to the current thread works too. - new primitive: myThreadId# :: IO ThreadId# and corresponding high-level version myThreadId :: IO ThreadId. - new primitive: yield# :: IO (), and yield :: IO (). - the TSO now contains a pointer to the resource currently blocked on (MVAR or BLACKHOLE_BQ). - Add a giant comment to TSO.h about what the various link fields are supposed to do, and invariants etc.
* [project @ 1999-01-28 11:32:11 by simonpj]simonpj1999-01-281-1/+1
| | | | Wibble
* [project @ 1999-01-14 18:12:47 by sof]sof1999-01-141-11/+34
| | | | | | | 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-53/+56
| | | | Move 4.01 onto the main trunk.
* [project @ 1998-08-14 12:53:10 by sof]sof1998-08-141-1/+1
| | | | Import PrelErr using {-# SOURCE #-}
* [project @ 1998-07-17 11:59:36 by simonm]simonm1998-07-171-0/+3
| | | | Add sameMVar# primop, and use it to define an instance for Eq (MVar a).
* [project @ 1998-02-02 17:27:26 by simonm]simonm1998-02-021-0/+174
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