summaryrefslogtreecommitdiff
path: root/ghc/lib/std/System.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2002-02-12 15:17:13 by simonmar]simonmar2002-02-121-142/+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-11-08 16:36:39 by simonmar]simonmar2001-11-081-2/+3
| | | | getProgArgv can be an unsafe foreign import.
* [project @ 2001-10-13 16:02:47 by sof]sof2001-10-131-7/+18
| | | | | - unpackProgName: recognise '/' and '\\' as path separators under Win32. - donated in-house version of basename, it's cool (== doesn't use reverse).
* [project @ 2001-09-21 13:24:37 by simonmar]simonmar2001-09-211-3/+2
| | | | | oops, it might help to commit the same version of the file that I tested.
* [project @ 2001-09-21 11:55:56 by simonmar]simonmar2001-09-211-2/+2
| | | | | | Fix type of foreign import of getProgArgv: the first arg should be Ptr CInt, not Ptr Int. Fixes a bug on Alpha (not the bug I was looking for, unfortunately). MERGE TO STABLE.
* [project @ 2001-08-14 17:14:22 by sof]sof2001-08-141-11/+18
| | | | | Don't use 'foreign label' to get at prog_arg{v,c}, use the RtsAPI-provided getProgArgv().
* [project @ 2001-08-10 13:48:06 by simonmar]simonmar2001-08-101-5/+5
| | | | Remove UnsafeCString (normal CString is fast enough now).
* [project @ 2001-05-22 15:06:47 by simonmar]simonmar2001-05-221-36/+17
| | | | | | | | - 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-71/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-01-11 17:51:02 by simonmar]simonmar2001-01-111-3/+3
| | | | | oops, I broke getArgs. Unbreak it, and remove an unused import while I'm here.
* [project @ 2001-01-11 17:25:56 by simonmar]simonmar2001-01-111-133/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+6
| | | | Change the representation of IOException: add optional filename.
* [project @ 2000-07-07 11:03:57 by simonmar]simonmar2000-07-071-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-08 13:40:24 by panne]panne2000-05-081-2/+2
| | | | *argl* Sorry, my usual Monday-typos...
* [project @ 2000-05-08 13:39:17 by panne]panne2000-05-081-4/+3
| | | | shutdownHaskellAndExit is "safe" again
* [project @ 2000-05-01 14:53:47 by panne]panne2000-05-011-1/+4
| | | | | Adding a bunch of `unsafe's to foreign imports. TODO: Could somebody verify that declaring shutdownHaskellAndExit as unsafe is OK?
* [project @ 2000-04-10 14:28:14 by sewardj]sewardj2000-04-101-1/+1
| | | | | Make getArgs and getProgName behave identically in combined and standalone modes.
* [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-16/+15
| | | | 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-09 21:16:49 by andy]andy2000-03-091-1/+0
| | | | Wibble: rm needless import Prelude used by Hugs.
* [project @ 2000-03-09 06:14:38 by andy]andy2000-03-091-0/+17
| | | | | | | | | | | | | | | 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 @ 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 10:32:37 by sewardj]sewardj1999-11-231-1/+1
| | | | Fix typo in exitWith.
* [project @ 1999-11-22 16:00:21 by sewardj]sewardj1999-11-221-4/+9
| | | | Enforce multiple reader, single writer semantics for Handles.
* [project @ 1999-11-22 11:46:25 by sewardj]sewardj1999-11-221-0/+3
| | | | Add comment about Hugs (non-)compliance.
* [project @ 1999-11-22 10:56:03 by sewardj]sewardj1999-11-221-6/+21
| | | | Implement System.system, System.exitWith for Hugs.
* [project @ 1999-10-29 01:16:48 by andy]andy1999-10-291-8/+51
| | | | | | | 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-10-22 08:40:25 by sof]sof1999-10-221-9/+8
| | | | Dotted the i's
* [project @ 1999-07-05 18:53:53 by sof]sof1999-07-051-1/+1
| | | | Remove -#include "RtsAPI.h" - you now get it for free.
* [project @ 1999-07-03 18:43:46 by sof]sof1999-07-031-2/+2
| | | | exitWith: don't call exit(), but use the RTS' shutdownHaskellAndExit()
* [project @ 1999-01-23 17:40:07 by sof]sof1999-01-231-3/+3
| | | | Tag all 'foreign import's as being unsafe.
* [project @ 1999-01-14 18:12:47 by sof]sof1999-01-141-77/+45
| | | | | | | 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-3/+60
| | | | Move 4.01 onto the main trunk.
* [project @ 1998-08-14 12:59:24 by sof]sof1998-08-141-5/+5
| | | | Generate better IOErrors
* [project @ 1998-06-29 16:56:00 by sof]sof1998-06-291-1/+0
| | | | import decl update
* [project @ 1998-05-05 10:31:14 by sof]sof1998-05-051-2/+2
| | | | 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/+159
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