Ticket #3337: base.patch

File base.patch, 37.9 KB (added by simonmar, 7 years ago)

patch for the base package

1Tue Jun 30 12:43:13 BST 2009  Simon Marlow <marlowsd@gmail.com>
2  * Export Unicode and newline functionality from System.IO; update Haddock docs
4New patches:
6[Export Unicode and newline functionality from System.IO; update Haddock docs
7Simon Marlow <marlowsd@gmail.com>**20090630114313
8 Ignore-this: 3a599d6dd30a0f68059084f6f3faa1f5
9] {
10hunk ./GHC/IO/Encoding.hs 46
12 -- -----------------------------------------------------------------------------
14-latin1, utf8, utf16, utf16le, utf16be, utf32, utf32le, utf32be, localeEncoding
15-  :: TextEncoding
17 -- | The Latin1 (ISO8859-1) encoding.  This encoding maps bytes
18 -- directly to the first 256 Unicode code points, and is thus not a
19hunk ./GHC/IO/Encoding.hs 48
20--- complete Unicode encoding.
21+-- complete Unicode encoding.  An attempt to write a character greater than
22+-- '\255' to a 'Handle' using the 'latin1' encoding will result in an error.
23+latin1  :: TextEncoding
24 latin1 = Latin1.latin1_checked
26hunk ./GHC/IO/Encoding.hs 53
27--- | The UTF-8 unicode encoding
28+-- | The UTF-8 Unicode encoding
29+utf8  :: TextEncoding
30 utf8 = UTF8.utf8
32hunk ./GHC/IO/Encoding.hs 57
33--- | The UTF-16 unicode encoding (a byte-order-mark should be used to
34+-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to
35 -- indicate endianness).
36hunk ./GHC/IO/Encoding.hs 59
37+utf16  :: TextEncoding
38 utf16 = UTF16.utf16
40hunk ./GHC/IO/Encoding.hs 62
41--- | The UTF-16 unicode encoding (litte-endian)
42+-- | The UTF-16 Unicode encoding (litte-endian)
43+utf16le  :: TextEncoding
44 utf16le = UTF16.utf16le
46hunk ./GHC/IO/Encoding.hs 66
47--- | The UTF-16 unicode encoding (big-endian)
48+-- | The UTF-16 Unicode encoding (big-endian)
49+utf16be  :: TextEncoding
50 utf16be = UTF16.utf16be
52hunk ./GHC/IO/Encoding.hs 70
53--- | The UTF-32 unicode encoding (a byte-order-mark should be used to
54+-- | The UTF-32 Unicode encoding (a byte-order-mark should be used to
55 -- indicate endianness).
56hunk ./GHC/IO/Encoding.hs 72
57+utf32  :: TextEncoding
58 utf32 = UTF32.utf32
60hunk ./GHC/IO/Encoding.hs 75
61--- | The UTF-32 unicode encoding (litte-endian)
62+-- | The UTF-32 Unicode encoding (litte-endian)
63+utf32le  :: TextEncoding
64 utf32le = UTF32.utf32le
66hunk ./GHC/IO/Encoding.hs 79
67--- | The UTF-32 unicode encoding (big-endian)
68+-- | The UTF-32 Unicode encoding (big-endian)
69+utf32be  :: TextEncoding
70 utf32be = UTF32.utf32be
72hunk ./GHC/IO/Encoding.hs 83
73--- | The text encoding of the current locale
74+-- | The Unicode encoding of the current locale
75+localeEncoding  :: TextEncoding
76 #if !defined(mingw32_HOST_OS)
77 localeEncoding = Iconv.localeEncoding
78 #else
79hunk ./GHC/IO/Encoding.hs 91
80 localeEncoding = Latin1.latin1
81 #endif
83--- | Acquire the named text encoding
84+-- | Look up the named Unicode encoding.  May fail with
86+--  * 'isDoesNotExistError' if the encoding is unknown
88+-- The set of known encodings is system-dependent.
90 mkTextEncoding :: String -> IO TextEncoding
91 #if !defined(mingw32_HOST_OS)
92 mkTextEncoding = Iconv.mkTextEncoding
93hunk ./GHC/IO/Encoding.hs 109
94 mkTextEncoding "UTF-32LE" = return utf32le
95 mkTextEncoding "UTF-32BE" = return utf32be
96 mkTextEncoding e = ioException
97-     (IOError Nothing InvalidArgument "mkTextEncoding"
98+     (IOError Nothing NoSuchThing "mkTextEncoding"
99           ("unknown encoding:" ++ e)  Nothing Nothing)
100 #endif
102hunk ./GHC/IO/Handle.hs 249
103 -- hSetEncoding
105 -- | The action 'hSetEncoding' @hdl@ @encoding@ changes the text encoding
106--- for the handle @hdl@ to @encoding@.  Encodings are available from the
107--- module "GHC.IO.Encoding".  The default encoding when a 'Handle' is
108+-- for the handle @hdl@ to @encoding@.  The default encoding when a 'Handle' is
109 -- created is 'localeEncoding', namely the default encoding for the current
110 -- locale.
111 --
112hunk ./GHC/IO/Handle.hs 257
113 -- stop further encoding or decoding on an existing 'Handle', use
114 -- 'hSetBinaryMode'.
115 --
116+-- 'hSetEncoding' may need to flush buffered data in order to change
117+-- the encoding.
119 hSetEncoding :: Handle -> TextEncoding -> IO ()
120 hSetEncoding hdl encoding = do
121   withHandle "hSetEncoding" hdl $ \h_@Handle__{..} -> do
122hunk ./GHC/IO/Handle/Text.hs 681
123 -- 'hPutBuf' ignores any text encoding that applies to the 'Handle',
124 -- writing the bytes directly to the underlying file or device.
125 --
126+-- 'hPutBuf' ignores the prevailing 'TextEncoding' and
127+-- 'NewlineMode' on the 'Handle', and writes bytes directly.
129 -- This operation may fail with:
130 --
131 --  * 'ResourceVanished' if the handle is a pipe or socket, and the
132hunk ./GHC/IO/Handle/Text.hs 787
133 -- If the handle is a pipe or socket, and the writing end
134 -- is closed, 'hGetBuf' will behave as if EOF was reached.
135 --
136+-- 'hGetBuf' ignores the prevailing 'TextEncoding' and 'NewlineMode'
137+-- on the 'Handle', and reads bytes directly.
139 hGetBuf :: Handle -> Ptr a -> Int -> IO Int
140 hGetBuf h ptr count
141hunk ./GHC/IO/Handle/Text.hs 873
142 -- If the handle is a pipe or socket, and the writing end
143 -- is closed, 'hGetBufNonBlocking' will behave as if EOF was reached.
144 --
145+-- 'hGetBufNonBlocking' ignores the prevailing 'TextEncoding' and
146+-- 'NewlineMode' on the 'Handle', and reads bytes directly.
148 hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
149 hGetBufNonBlocking h ptr count
150   | count == 0 = return 0
151hunk ./GHC/IO/Handle/Types.hs 325
152 -- Newline translation
154 -- | The representation of a newline in the external file or stream.
155-data Newline = LF    -- ^ "\n"
156-             | CRLF  -- ^ "\r\n"
157+data Newline = LF    -- ^ '\n'
158+             | CRLF  -- ^ '\r\n'
159              deriving Eq
161 -- | Specifies the translation, if any, of newline characters between
162hunk ./GHC/IO/Handle/Types.hs 342
163                  }
164              deriving Eq
166--- | The native newline representation for the current platform
167+-- | The native newline representation for the current platform: 'LF'
168+-- on Unix systems, 'CRLF' on Windows.
169 nativeNewline :: Newline
170 #ifdef mingw32_HOST_OS
171 nativeNewline = CRLF
172hunk ./GHC/IO/Handle/Types.hs 351
173 nativeNewline = LF
174 #endif
176--- | Map "\r\n" into "\n" on input, and "\n" to the native newline
177+-- | Map '\r\n' into '\n' on input, and '\n' to the native newline
178 -- represetnation on output.  This mode can be used on any platform, and
179 -- works with text files using any newline convention.  The downside is
180 -- that @readFile >>= writeFile@ might yield a different file.
181hunk ./System/IO.hs 162
183     openTempFile,
184     openBinaryTempFile,
186+#if !defined(__NHC__) && !defined(__HUGS__)
187+    -- * Unicode encoding\/decoding
189+    -- | A text-mode 'Handle' has an associated 'TextEncoding', which
190+    -- is used to decode bytes into Unicode characters when reading,
191+    -- and encode Unicode characters into bytes when writing.
192+    --
193+    -- The default 'TextEncoding' is the same as the default encoding
194+    -- on your system, which is also available as 'localeEncoding'.
195+    -- (GHC note: on Windows, currently 'localeEncoding' is always
196+    -- 'latin1'; there is no support for encoding and decoding using
197+    -- the ANSI code page).
198+    --
199+    -- Encoding and decoding errors are always detected and reported,
200+    -- except during lazy I/O ('hGetContents', 'getContents', and
201+    -- 'readFile'), where a decoding error merely results in
202+    -- termination of the character stream, as with other I/O errors.
204+    hSetEncoding,
206+    -- ** Unicode encodings
207+    TextEncoding,
208+    latin1,
209+    utf8,
210+    utf16, utf16le, utf16be,
211+    utf32, utf32le, utf32be,
212+    localeEncoding,
213+    mkTextEncoding,
216+#if !defined(__NHC__) && !defined(__HUGS__)
217+    -- * Newline conversion
219+    -- | In Haskell, a newline is always represented by the character
220+    -- '\n'.  However, in files and external character streams, a
221+    -- newline may be represented by another character sequence, such
222+    -- as '\r\n'.
223+    --
224+    -- A text-mode 'Handle' has an associated 'NewlineMode' that
225+    -- specifies how to transate newline characters.  The
226+    -- 'NewlineMode' specifies the input and output translation
227+    -- separately, so that for instance you can translate '\r\n'
228+    -- to '\n' on input, but leave newlines as '\n' on output.
229+    --
230+    -- The default 'NewlineMode' for a 'Handle' is
231+    -- 'nativeNewlineMode', which does no translation on Unix systems,
232+    -- but translates '\r\n' to '\n' and back on Windows.
233+    --
234+    -- Binary-mode 'Handle's do no newline translation at all.
235+    --
236+    hSetNewlineMode,
237+    Newline(..), nativeNewline,
238+    NewlineMode(..),
239+    noNewlineTranslation, universalNewlineMode, nativeNewlineMode,
241   ) where
243 import Control.Exception.Base
244hunk ./System/IO.hs 239
245 import GHC.IO.Handle
246 import GHC.IORef
247 import GHC.IO.Exception ( userError )
248+import GHC.IO.Encoding
249 import GHC.Exception
250 import GHC.Num
251 import Text.Read
256[not having iconv is not fatal on Windows
257Simon Marlow <marlowsd@gmail.com>**20090625115804
258 Ignore-this: 9232771b68156f12873673e7f7fa714
260[Move directory-related stuff to the unix package
261Simon Marlow <marlowsd@gmail.com>**20090625120325
262 Ignore-this: b997b3cbce0a46ca87ad825bbdc0a411
263 now that it isn't used on Windows any more.
265[fix build failure on Windows
266Simon Marlow <marlowsd@gmail.com>**20090625094609
267 Ignore-this: 56276745fa66875d89e33ec1bdcf79fc
269[Fix iconv detection on OpenBSD
270Ian Lynagh <igloo@earth.li>**20090624125422
271 Matthias Kilian discovered that iconv_open is #define'd to something
272 else on OpenBSD, so the test needs to include the iconv header.
274[setNonBlockingMode now takes a flag, can turn blocking mode back on again
275Simon Marlow <marlowsd@gmail.com>**20090624115029
276 Ignore-this: a4e112d8e2c5a5c3d8ba40c2b1c2861e
278[Call nl_langinfo(CODESET) to get the name of the locale encoding on Unix
279Simon Marlow <marlowsd@gmail.com>**20090623143813
280 Ignore-this: 39d1dc8daf59e6856d1e103d9cb0900b
282[Tidy up use of read/write/recv/send; avoid unnecessary wrappers
283Simon Marlow <marlowsd@gmail.com>**20090622092656
284 Ignore-this: 2ca207489a8c9ec8bd8c1bb6e69c98ad
286[Make this file independent of HsBase.h, use HsBaseConfig.h only
287Simon Marlow <marlowsd@gmail.com>**20090622083957
288 Ignore-this: 21187a10eec1f917be0e162333142971
290[Windows: Unicode openFile and stat functions
291Simon Marlow <marlowsd@gmail.com>**20090618135458
292 Ignore-this: e48260c13effdc4d48ac5529cea2a1dc
294[Add a comment to remind us that memcpy_src_off is used by dph
295Simon Marlow <marlowsd@gmail.com>**20090618112616
296 Ignore-this: c34666110294a933e6b015d3a6ec8864
298[Unconditionally make a (Show Ptr) instance
299Ian Lynagh <igloo@earth.li>**20090620204809
300 It used to only exist if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
302[Remove AC_C_CONST
303Ian Lynagh <igloo@earth.li>**20090615203240
304 It was breaking the build on Windows. The problem was that we included
305 stdio.h which gave a prototype for some functions (e.g. remove), then
306 the AC_C_CONST meant that we did
307     /* Define to empty if `const' does not conform to ANSI C. */
308     #define const /**/
309 and then we included io.h which gave prototypes that, due to const
310 being removed, conflicted with the earlier prototypes.
312[Remove old Integer prototypes
313Ian Lynagh <igloo@earth.li>**20090615202444]
314[Redefine gcdInt to use gcdInteger rather than gcdInt# primop
315Duncan Coutts <duncan@well-typed.com>**20090612142951
316 The gcdInt# primop uses gmp internally, even though the interface is
317 just Int#. Since we want to get gmp out of the rts we cannot keep
318 gcdInt#, however it's also a bit odd for the integer package to export
319 something that doesn't actually use Integer in its interface. Using
320 gcdInteger is still not terribly satisfactory aesthetically. However
321 in the short-term it works and it is no slower since gcdInteger calls
322 gcdInt# for the special case of two small Integers.
324[The IO type has moved to GHC.Types in ghc-prim
325Ian Lynagh <igloo@earth.li>**20090620155208]
326[Fix warnings in configure script
327Ian Lynagh <igloo@earth.li>**20090615214850]
328[Fix warnings in C programs generated by configure; fixes failures with -Werror
329Ian Lynagh <igloo@earth.li>**20090615201634]
330[Save and restore the codec state when re-decoding
331Simon Marlow <marlowsd@gmail.com>**20090614185332
332 Ignore-this: 62b247a51efc2eed65d933f982b06894
334 We previously had an ugly hack to check for a BOM when re-decoding
335 some binary data in flushCharBuffer.  The hack was there essentially
336 because codecs like UTF-16 have a state, and we had not restored it.
337 This patch gives codecs an explicit state, and implemented
338 saving/restoring of the state as necessary.  Hence, the hack in
339 flushCharBuffer is replaced by a more general mechanism that works for
340 any codec with state.
342 Unfortunately, iconv doesn't give us a way to save and restore the
343 state, so this is currently only implemented for the built-in codecs.
345[Allow System.Posix.Internals to compile with nhc98 again.
347 Also affects GHC.IO.Device, which is not very GHC-specific at all.
349[add hFlushAll, flushes both read and write buffers
350Simon Marlow <marlowsd@gmail.com>**20090623133818
351 Ignore-this: 70c57b04438d8d9a25225f7694fd1196
353[fix bug in partial writes
354Simon Marlow <marlowsd@gmail.com>**20090623105004
355 Ignore-this: 384b8409689713f9e766b869c459dcd6
357[Fix #3128: file descriptor leak when hClose fails
358Simon Marlow <marlowsd@gmail.com>**20090616110755
359 Ignore-this: 5b6a51fed9239c61d16d0151cb5b59d3
361[Add iconv as an extra library on platform that need to link with it
362Ian Lynagh <igloo@earth.li>**20090612231307
363 For example, we need -liconv on OS X.
365[Remove unused foreign imports of __encodeFloat/Double
366Duncan Coutts <duncan@well-typed.com>**20090611160100]
367[Rewrite of the IO library, including Unicode support
368Simon Marlow <marlowsd@gmail.com>**20090612135631
369 Ignore-this: fbd43ec854ac5df442e7bf647de8ca5a
371 Highlights:
373 * Unicode support for Handle I/O:
375   ** Automatic encoding and decoding using a per-Handle encoding.
377   ** The encoding defaults to the locale encoding (only on Unix
378      so far, perhaps Windows later).
380   ** Built-in UTF-8, UTF-16 (BE/LE), and UTF-32 (BE/LE) codecs.
382   ** iconv-based codec for other encodings on Unix
384 * Modularity: the low-level IO interface is exposed as a type class
385   (GHC.IO.IODevice) so you can build your own low-level IO providers and
386   make Handles from them.
388 * Newline translation: instead of being Windows-specific wired-in
389   magic, the translation from \r\n -> \n and back again is available
390   on all platforms and is configurable for reading/writing
391   independently.
394 Unicode-aware Handles
395 ~~~~~~~~~~~~~~~~~~~~~
397 This is a significant restructuring of the Handle implementation with
398 the primary goal of supporting Unicode character encodings.
400 The only change to the existing behaviour is that by default, text IO
401 is done in the prevailing locale encoding of the system (except on
402 Windows [1]). 
404 Handles created by openBinaryFile use the Latin-1 encoding, as do
405 Handles placed in binary mode using hSetBinaryMode.
407 We provide a way to change the encoding for an existing Handle:
409    GHC.IO.Handle.hSetEncoding :: Handle -> TextEncoding -> IO ()
411 and various encodings (from GHC.IO.Encoding):
413    latin1,
414    utf8,
415    utf16, utf16le, utf16be,
416    utf32, utf32le, utf32be,
417    localeEncoding,
419 and a way to lookup other encodings:
421    GHC.IO.Encoding.mkTextEncoding :: String -> IO TextEncoding
423 (it's system-dependent whether the requested encoding will be
424 available).
426 We may want to export these from somewhere more permanent; that's a
427 topic for a future library proposal.
429 Thanks to suggestions from Duncan Coutts, it's possible to call
430 hSetEncoding even on buffered read Handles, and the right thing
431 happens.  So we can read from text streams that include multiple
432 encodings, such as an HTTP response or email message, without having
433 to turn buffering off (though there is a penalty for switching
434 encodings on a buffered Handle, as the IO system has to do some
435 re-decoding to figure out where it should start reading from again).
437 If there is a decoding error, it is reported when an attempt is made
438 to read the offending character from the Handle, as you would expect.
440 Performance varies.  For "hGetContents >>= putStr" I found the new
441 library was faster on my x86_64 machine, but slower on an x86.  On the
442 whole I'd expect things to be a bit slower due to the extra
443 decoding/encoding, but probabaly not noticeably.  If performance is
444 critical for your app, then you should be using bytestring and text
445 anyway.
447 [1] Note: locale encoding is not currently implemented on Windows due
448 to the built-in Win32 APIs for encoding/decoding not being sufficient
449 for our purposes.  Ask me for details.  Offers of help gratefully
450 accepted.
453 Newline Translation
454 ~~~~~~~~~~~~~~~~~~~
456 In the old IO library, text-mode Handles on Windows had automatic
457 translation from \r\n -> \n on input, and the opposite on output.  It
458 was implemented using the underlying CRT functions, which meant that
459 there were certain odd restrictions, such as read/write text handles
460 needing to be unbuffered, and seeking not working at all on text
461 Handles.
463 In the rewrite, newline translation is now implemented in the upper
464 layers, as it needs to be since we have to perform Unicode decoding
465 before newline translation.  This means that it is now available on
466 all platforms, which can be quite handy for writing portable code.
468 For now, I have left the behaviour as it was, namely \r\n -> \n on
469 Windows, and no translation on Unix.  However, another reasonable
470 default (similar to what Python does) would be to do \r\n -> \n on
471 input, and convert to the platform-native representation (either \r\n
472 or \n) on output.  This is called universalNewlineMode (below).
474 The API is as follows.  (available from GHC.IO.Handle for now, again
475 this is something we will probably want to try to get into System.IO
476 at some point):
478 -- | The representation of a newline in the external file or stream.
479 data Newline = LF    -- ^ "\n"
480              | CRLF  -- ^ "\r\n"
481              deriving Eq
483 -- | Specifies the translation, if any, of newline characters between
484 -- internal Strings and the external file or stream.  Haskell Strings
485 -- are assumed to represent newlines with the '\n' character; the
486 -- newline mode specifies how to translate '\n' on output, and what to
487 -- translate into '\n' on input.
488 data NewlineMode
489   = NewlineMode { inputNL :: Newline,
490                     -- ^ the representation of newlines on input
491                   outputNL :: Newline
492                     -- ^ the representation of newlines on output
493                  }
494              deriving Eq
496 -- | The native newline representation for the current platform
497 nativeNewline :: Newline
499 -- | Map "\r\n" into "\n" on input, and "\n" to the native newline
500 -- represetnation on output.  This mode can be used on any platform, and
501 -- works with text files using any newline convention.  The downside is
502 -- that @readFile a >>= writeFile b@ might yield a different file.
503 universalNewlineMode :: NewlineMode
504 universalNewlineMode  = NewlineMode { inputNL  = CRLF,
505                                       outputNL = nativeNewline }
507 -- | Use the native newline representation on both input and output
508 nativeNewlineMode    :: NewlineMode
509 nativeNewlineMode     = NewlineMode { inputNL  = nativeNewline,
510                                       outputNL = nativeNewline }
512 -- | Do no newline translation at all.
513 noNewlineTranslation :: NewlineMode
514 noNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
517 -- | Change the newline translation mode on the Handle.
518 hSetNewlineMode :: Handle -> NewlineMode -> IO ()
522 IO Devices
523 ~~~~~~~~~~
525 The major change here is that the implementation of the Handle
526 operations is separated from the underlying IO device, using type
527 classes.  File descriptors are just one IO provider; I have also
528 implemented memory-mapped files (good for random-access read/write)
529 and a Handle that pipes output to a Chan (useful for testing code that
530 writes to a Handle).  New kinds of Handle can be implemented outside
531 the base package, for instance someone could write bytestringToHandle.
532 A Handle is made using mkFileHandle:
534 -- | makes a new 'Handle'
535 mkFileHandle :: (IODevice dev, BufferedIO dev, Typeable dev)
536               => dev -- ^ the underlying IO device, which must support
537                      -- 'IODevice', 'BufferedIO' and 'Typeable'
538               -> FilePath
539                      -- ^ a string describing the 'Handle', e.g. the file
540                      -- path for a file.  Used in error messages.
541               -> IOMode
542                      -- ^ The mode in which the 'Handle' is to be used
543               -> Maybe TextEncoding
544                      -- ^ text encoding to use, if any
545               -> NewlineMode
546                      -- ^ newline translation mode
547               -> IO Handle
549 This also means that someone can write a completely new IO
550 implementation on Windows based on native Win32 HANDLEs, and
551 distribute it as a separate package (I really hope somebody does
552 this!).
554 This restructuring isn't as radical as previous designs.  I haven't
555 made any attempt to make a separate binary I/O layer, for example
556 (although hGetBuf/hPutBuf do bypass the text encoding and newline
557 translation).  The main goal here was to get Unicode support in, and
558 to allow others to experiment with making new kinds of Handle.  We
559 could split up the layers further later.
562 API changes and Module structure
563 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
565 NB. GHC.IOBase and GHC.Handle are now DEPRECATED (they are still
566 present, but are just re-exporting things from other modules now).
567 For 6.12 we'll want to bump base to version 5 and add a base4-compat.
568 For now I'm using #if __GLASGOW_HASKEL__ >= 611 to avoid deprecated
569 warnings.
571 I split modules into smaller parts in many places.  For example, we
572 now have GHC.IORef, GHC.MVar and GHC.IOArray containing the
573 implementations of IORef, MVar and IOArray respectively.  This was
574 necessary for untangling dependencies, but it also makes things easier
575 to follow.
577 The new module structurue for the IO-relatied parts of the base
578 package is:
580 GHC.IO
581    Implementation of the IO monad; unsafe*; throw/catch
583 GHC.IO.IOMode
584    The IOMode type
586 GHC.IO.Buffer
587    Buffers and operations on them
589 GHC.IO.Device
590    The IODevice and RawIO classes.
592 GHC.IO.BufferedIO
593    The BufferedIO class.
596    The FD type, with instances of IODevice, RawIO and BufferedIO.
598 GHC.IO.Exception
599    IO-related Exceptions
601 GHC.IO.Encoding
602    The TextEncoding type; built-in TextEncodings; mkTextEncoding
604 GHC.IO.Encoding.Types
605 GHC.IO.Encoding.Iconv
606 GHC.IO.Encoding.Latin1
607 GHC.IO.Encoding.UTF8
608 GHC.IO.Encoding.UTF16
609 GHC.IO.Encoding.UTF32
610    Implementation internals for GHC.IO.Encoding
612 GHC.IO.Handle
613    The main API for GHC's Handle implementation, provides all the Handle
614    operations + mkFileHandle + hSetEncoding.
616 GHC.IO.Handle.Types
617 GHC.IO.Handle.Internals
618 GHC.IO.Handle.Text
619    Implementation of Handles and operations.
621 GHC.IO.Handle.FD
622    Parts of the Handle API implemented by file-descriptors: openFile,
623    stdin, stdout, stderr, fdToHandle etc.
626[nhc98 must build dirUtils.c as well.
628 Fixes this bootstrapping error:
629   Undefined symbols:
630   "___hscore_readdir", referenced from:
631       _FR_System_46Posix_46Internals_46readdir_35 in libHSbase.a(Internals.o)
633[Remove unnecessary parens
634Ian Lynagh <igloo@earth.li>**20090602183608]
635[Fix validate (on Windows)
636Simon Marlow <marlowsd@gmail.com>**20090529130214
637 Ignore-this: ea31ee9b26cd69b81bb24ecf040dc196
639[Make two type defaults explicit
641 Ignore-this: 398a10db1612dbef1723b449bff26782
643 Now that -Werror rejects programs that use silent type-class defaulting,
644 we must commit in the source code.
646 I've used Double in CPUTime, which is the same as was picked automatically
647 before, but I expect Float would be ok.
649    realToInteger :: Real a => a -> Integer
650    realToInteger ct = round (realToFrac ct :: Double)
652 In GHC.Float I used Float (rather that than the auto-picked Double)
653 because I'm pretty certain it has enough precision.
655        -- f :: Integer, log :: Float -> Float,
656         --               ceiling :: Float -> Int
657         ceiling ((log (fromInteger (f+1) :: Float) +
660[Increase the version number to that in the 6.10 branch
661Ian Lynagh <igloo@earth.li>**20090524155610]
662[Fix warnings
663Ian Lynagh <igloo@earth.li>**20090523224508]
664[Document that the initial quantity for QSem and QSemN must be >= 0
665Ian Lynagh <igloo@earth.li>**20090523200238]
666[Fix #3257: document that exitWith in a forkIO'd thread does not exit the process
667Simon Marlow <marlowsd@gmail.com>**20090528123738
668 Ignore-this: cc5aff45a149acd1627bd7ee31aea4e9
670[add _O_NOINHERIT when opening files on Windows (see #2650)
671Simon Marlow <marlowsd@gmail.com>**20090520130926
672 Ignore-this: 6dfbdfe13e739cc339e627294e077ba6
674[remove msvcrt and kernel32 from extra-libraries
675Simon Marlow <marlowsd@gmail.com>**20090520111626
676 Ignore-this: cd2e24a5144c6ca0efe03ceaea8f577b
678[Add wrappers around fcntl
679Ian Lynagh <igloo@earth.li>**20090520175358
680 We need to do this as it has a (, ...) type, which we aren't allowed to
681 directly call with the FFI.
683[Add more bang patterns, needed to fix the 32bit build
684Ian Lynagh <igloo@earth.li>**20090424160701]
685[Use a bang pattern when we where/let-bind values with unlifted types
686Ian Lynagh <igloo@earth.li>**20090424125320]
687[FIX #3171: make sure we have only one table of signal handlers
688Simon Marlow <marlowsd@gmail.com>**20090423112837
689 Ignore-this: 3d8039b47efac2629e73a7d7e7d58983
691[Fix QSem and QSemN: Initial amount must be non-negative
692Ian Lynagh <igloo@earth.li>**20090410164013]
693[Don't inline enumDeltaToInteger until its rules have had a chance to fire
695 Ignore-this: ab602bac65610e720065b097d46a6f52
697[Import GHC.Err so we see bottoming functions properly
699 Ignore-this: 913e3a4584e73e67ddf9bc3b6f11d11
701 Before this patch, GHC/Err.lhs-boot exported divZeroError and overflowError,
702 as well as plain 'error'.  The latter has a wired-in defn in GHC (MkId.lhs),
703 but the former two do not.  As a result GHC doesn't see that overflowError
704 is a bottoming function at a crucial moment when compiling GHC.Real, and
705 that means that divMod wasn't getting the CPR property.
707 The fix is easy:
708   - GHC/Err.lhs-boot should export only 'error'
710   - GHC.Real, GHC.Int, and GHC.Word should import GHC.Err
711     directly.  They can do this nowadays without creating
712     a module loop, thanks to the new exception story
715[Don't inline unpackCString
717 Ignore-this: 78f9660ffff55ae8bc4c41866d1ad80c
719 There's no point in inlining unpackCString, so this patch adds a
720 NOINLINE pragma.  (Otherwise, it's just on the threshold.)
723[be sure to install Nhc98BaseConfig.h
725[Avoid unnecessarily using Integer when decoding Floats
726Ian Lynagh <igloo@earth.li>**20090330225241]
727[Add another Data.List.intersect example from Christian Maeder
728Ian Lynagh <igloo@earth.li>**20090327232118]
729[Remove some redundant fromInteger's
730Ian Lynagh <igloo@earth.li>**20090324145325]
731[Add an import needed in the new build system
732Ian Lynagh <igloo@earth.li>**20090322162241]
733[ghcconfig.h is __GLASGOW_HASKELL__ only
735[Fix layout to comply with H'98.
737 Also, configure correctly for nhc98, to avoid win32 code.
739[FIX #2189: re-enabled cooked mode for Console-connected Handles on Windows
740Simon Marlow <marlowsd@gmail.com>*-20090305113323
741 Patch from Sigbjorn Finne <sof@galois.com>
743[avoid a space leak building up in the "prodding" IORef (part of #2992)
744Simon Marlow <marlowsd@gmail.com>**20090311093938]
745[Add config.guess, config.sub and install-sh
746Ian Lynagh <igloo@earth.li>**20090307153831]
747[add final newline; fix build (on Windows?)
748Simon Marlow <marlowsd@gmail.com>**20090305120426]
749[FIX #2189: re-enabled cooked mode for Console-connected Handles on Windows
750Simon Marlow <marlowsd@gmail.com>**20090305113323
751 Patch from Sigbjorn Finne <sof@galois.com>
753[Rules to make genericLength strict for Int/Integer lengths, see #2962
755[Partial fix for #2917
756Simon Marlow <marlowsd@gmail.com>**20090305154153
757 Ignore-this: 3a06cd3ea09f1d6454d52031802a93fd
759  - add newAlignedPinnedByteArray# for allocating pinned BAs with
760    arbitrary alignment
762  - the old newPinnedByteArray# now aligns to 16 bytes
764 Foreign.alloca will use newAlignedPinnedByteArray#, and so might end
765 up wasting less space than before (we used to align to 8 by default).
766 Foreign.allocaBytes and Foreign.mallocForeignPtrBytes will get 16-byte
767 aligned memory, which is enough to avoid problems with SSE
768 instructions on x86, for example.
770 There was a bug in the old newPinnedByteArray#: it aligned to 8 bytes,
771 but would have failed if the header was not a multiple of 8
772 (fortunately it always was, even with profiling).  Also we
773 occasionally wasted some space unnecessarily due to alignment in
774 allocatePinned().
776 I haven't done anything about Foreign.malloc/mallocBytes, which will
777 give you the same alignment guarantees as malloc() (8 bytes on
778 Linux/x86 here).
780[#2759: Amend previous patch
781Jose Pedro Magalhaes <jpm@cs.uu.nl>**20090212132327]
782[ifdef out the definition of setCloseOnExec on Windows; fixes the build
783Ian Lynagh <igloo@earth.li>**20090220173041]
784[Fix warnings: put imports inside ifdefs
785Ian Lynagh <igloo@earth.li>**20090220173941]
786[ifdef out the syncIOManager export on Windows; fixes the build
787Ian Lynagh <igloo@earth.li>**20090220173414]
788[Set the IO manager pipe descriptors to FD_CLOEXEC
789Simon Marlow <marlowsd@gmail.com>**20090219114217
790 Ignore-this: ac670a45f8a4d06dd7831a2674d6c119
791 This pipe is an internal implementation detail, we don't really want
792 it to be exposed.
794[Rewrite of signal-handling (base patch; see also ghc and unix patches)
795Simon Marlow <marlowsd@gmail.com>**20090219102203
796 Ignore-this: 2122e05eaaab184b9ef0f269ce4c9282
798 The API is the same (for now).  The new implementation has the
799 capability to define signal handlers that have access to the siginfo
800 of the signal (#592), but this functionality is not exposed in this
801 patch.
803 #2451 is the ticket for the new API.
805 The main purpose of bringing this in now is to fix race conditions in
806 the old signal handling code (#2858).  Later we can enable the new
807 API in the HEAD.
809 Implementation differences:
811  - More of the signal-handling is moved into Haskell.  We store the
812    table of signal handlers in an MVar, rather than having a table of
813    StablePtrs in the RTS.
815  - In the threaded RTS, the siginfo of the signal is passed down the
816    pipe to the IO manager thread, which manages the business of
817    starting up new signal handler threads.  In the non-threaded RTS,
818    the siginfo of caught signals is stored in the RTS, and the
819    scheduler starts new signal handler threads.
821[implement System.IO.Error more fully for nhc98
823[Make System.Posix.Internals buildable by nhc98.
825[Fix #2971: we had lost the non-blocking flag on Handles created by openFile
826Simon Marlow <marlowsd@gmail.com>**20090206165912
827 Ignore-this: 546f1a799b6e80f7b25c73ef642d8f9d
828 This code is a mess, fortunately the new IO library cleans it up.
830[add some rules of thumb for catching exceptions, restructure the docs a bit
831Simon Marlow <marlowsd@gmail.com>**20090205150642
832 Ignore-this: 8294e58f247b2cc3f193991434d336de
834[Fix #2903: ensure CWStringLen contains the length of the array rather than the String
835Ross Paterson <ross@soi.city.ac.uk>**20090203011026]
836[OldException catches unknown exceptions as DynException
837Ian Lynagh <igloo@earth.li>**20090202151856
838 It's important that we put all exceptions into the old Exception
839 type somehow, or throwing a new exception wouldn't cause the
840 cleanup code for bracket, finally etc to happen.
842[Update the Exception docs
843Ian Lynagh <igloo@earth.li>**20090131204845]
844[Require Cabal version >= 1.6
845Ian Lynagh <igloo@earth.li>**20090122011251]
846[Add "bug-reports" and "source-repository" info to the Cabal file
847Ian Lynagh <igloo@earth.li>**20090121182010]
848[Proposal #2875: remove StringRep and StringConstr
849Jose Pedro Magalhaes <jpm@cs.uu.nl>**20090116142617]
850[Fix #2759: add mkRealConstr and mkIntegralConstr, deprecate mkFloatConstr and mkIntConstr
851Jose Pedro Magalhaes <jpm@cs.uu.nl>**20090116140655]
852[Correct SYB's representation of Char
853Jose Pedro Magalhaes <jpm@cs.uu.nl>**20081211144716]
854[avoid `mappend` in monoid laws, because it doesn't work with haddock
855Ross Paterson <ross@soi.city.ac.uk>**20090118011508]
856[Make Data.Typeable imports and exports more explicit
857Ian Lynagh <igloo@earth.li>**20090114234512]
858[add Monoid laws
859Ross Paterson <ross@soi.city.ac.uk>**20090116151624]
860[Unbreak an import cycle caused by moving 'catch' definitions around.
862 The new cycle was introduced for nhc98 only.
864[make the Monoid docs more self-contained
865Ross Paterson <ross@soi.city.ac.uk>**20090115222441]
866[Move some catch definitions around to avoid an import loop
867Ian Lynagh <igloo@earth.li>**20090114211033
868 As suggested by simonpj in trac #2822.
870[Add NoImplicitPrelude to the extensions used when building with GHC
871Ian Lynagh <igloo@earth.li>**20090114202810]
872[#2699: exit silently for EPIPE on stdout
873Simon Marlow <marlowsd@gmail.com>**20090114134612
874 Ignore-this: 4236560e8e9c1135129e9526355f11b4
876[Fix build when we have HTYPE_TCFLAG_T
877Ian Lynagh <igloo@earth.li>**20090105102020]
878[Fix the build on Windows
879Ian Lynagh <igloo@earth.li>**20090105014625]
880[Add errno to the IOError type
881Ian Lynagh <igloo@earth.li>**20090104173018]
882[Fix typo (reqwests -> requests); trac #2908, spotted by bancroft
883Ian Lynagh <igloo@earth.li>**20090104154405]
884[More compact error messages for record selectors
887 Make recSelError generate the standard part of the record selector
888 error message (i.e. "No match in record selector") rather than have
889 that string duplicated for every record selector.
892[extra dependencies for the new build system
893Simon Marlow <marlowsd@gmail.com>**20081217104655]
894[warning fix: don't use -XPatternSignatures in GHC >= 6.10
895Simon Marlow <marlowsd@gmail.com>**20081217104637]
896[Rollback INLINE patches
897Simon Marlow <marlowsd@gmail.com>**20081216104143
899 rolling back:
901 Fri Dec  5 17:00:15 GMT 2008  simonpj@microsoft.com
902   * Update INLINE pragmas for new INLINE story
904   - (.) and foldr should inline when applied to only two arguments
905   - Make unpackCString# NOINLINE; it inlines too much (with little gain)
908     M ./GHC/Base.lhs -10 +31
910[FIX #1364: added support for C finalizers that run as soon as the value is no longer reachable.
911Ivan Tomac <tomac@pacific.net.au>**20081210150510
913 Patch amended by Simon Marlow:
914   - mkWeakFinalizer# commoned up with mkWeakFinalizerEnv#
916[Fix #2760: deprecate mkNorepType, add mkNoRepType
917Jose Pedro Magalhaes <jpm@cs.uu.nl>**20081121141905]
918[Update INLINE pragmas for new INLINE story
921 - (.) and foldr should inline when applied to only two arguments
922 - Make unpackCString# NOINLINE; it inlines too much (with little gain)
925[Fix #2750: change Prelude.(,) to Prelude.(,,)
926Jose Pedro Magalhaes <jpm@cs.uu.nl>**20081201113411]
927[Fix typo (or out of date reference) in throwTo documentation.
928shelarcy <shelarcy@gmail.com>**20081129024639]
929[Add more description of what "round" does, from the H98 report
930Ian Lynagh <igloo@earth.li>**20081119143131]
931[re-instate the gcd/Integer and lcm/Integer RULES
932Simon Marlow <marlowsd@gmail.com>**20081120101826
933 Fixes a performance regression between 6.8.3 and 6.10.1
935[Change an "undefined" into a more informative error; trac #2782
936Ian Lynagh <igloo@earth.li>**20081116160228]
937[updating Haddock documentation
940 Fixed the broken link from Data.Generics to Data.Data.
942[add GHC.Conc.runSparks (required by GHC patch "Run sparks in batches")
943Simon Marlow <marlowsd@gmail.com>**20081106095419]
944[FIX #2722: update RULES for the Category/Arrow split
945Ross Paterson <ross@soi.city.ac.uk>**20081104144515
947 The rule
949        arr id = id
951 interacts unpleasantly with the advice to define
953        id = arr id
955 in instances of Category that are also instances of Arrow (#2722).
957 Also changed a couple of >>>'s to .'s in later rules.
959[Add AnnotationWrapper type so GHC can capture annotation dictionaries during compilation
960Max Bolingbroke <batterseapower@hotmail.com>**20081016122608]
961[docs about how exceptions are handled by forkIO'd threads (#2651)
962Simon Marlow <marlowsd@gmail.com>**20081016100410]
963[Import n_capabilities via import symbol when linking dynamically
964Clemens Fruhwirth <clemens@endorphin.org>**20081013161220]
965[add link to the new syb wiki
967[changing haddock links
969[add readTVarIO :: TVar a -> IO a
970Simon Marlow <marlowsd@gmail.com>**20081010113835]
971[removed (->) instance from Data.Data
973[non-GHC: delete unnecessary imports
974Ross Paterson <ross@soi.city.ac.uk>**20081007134809]
975[added new module Data.Data
976'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002140535
978 The new Data.Data module contains all of Data.Generics.Basics
979 and most of Data.Generics.Instances. The missing instances were
980 deemed dubious and moved to the syb package.
982[add new Data.Data module
983'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002082735]
984[restore Complex's derived Data instance
985'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002082655]
986[update Data.Generics import
987'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002082604]
988[Don't use ^(2::Int) in Data.Complex.magnitude; partially fixes trac #2450
989Ian Lynagh <igloo@earth.li>**20081004142651
990 We still might want to make a RULE for this, so the bug is not fully fixed.
992[Restore the Haskell 98 behaviour of Show Ratio (#1920)
993Simon Marlow <simonmarhaskell@gmail.com>**20080923134949]
994[Pad version number to
995Ian Lynagh <igloo@earth.li>**20080920155801]
996[TAG 6.10 branch has been forked
997Ian Lynagh <igloo@earth.li>**20080919123437]
998Patch bundle hash: