Tue Jun 30 12:43:13 BST 2009  Simon Marlow <marlowsd@gmail.com>
  * Export Unicode and newline functionality from System.IO; update Haddock docs

New patches:

[Export Unicode and newline functionality from System.IO; update Haddock docs
Simon Marlow <marlowsd@gmail.com>**20090630114313
 Ignore-this: 3a599d6dd30a0f68059084f6f3faa1f5
] {
hunk ./GHC/IO/Encoding.hs 46
 
 -- -----------------------------------------------------------------------------
 
-latin1, utf8, utf16, utf16le, utf16be, utf32, utf32le, utf32be, localeEncoding
-  :: TextEncoding
-
 -- | The Latin1 (ISO8859-1) encoding.  This encoding maps bytes
 -- directly to the first 256 Unicode code points, and is thus not a
hunk ./GHC/IO/Encoding.hs 48
--- complete Unicode encoding.
+-- complete Unicode encoding.  An attempt to write a character greater than
+-- '\255' to a 'Handle' using the 'latin1' encoding will result in an error.
+latin1  :: TextEncoding
 latin1 = Latin1.latin1_checked
 
hunk ./GHC/IO/Encoding.hs 53
--- | The UTF-8 unicode encoding
+-- | The UTF-8 Unicode encoding
+utf8  :: TextEncoding
 utf8 = UTF8.utf8
 
hunk ./GHC/IO/Encoding.hs 57
--- | The UTF-16 unicode encoding (a byte-order-mark should be used to
+-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to
 -- indicate endianness).
hunk ./GHC/IO/Encoding.hs 59
+utf16  :: TextEncoding
 utf16 = UTF16.utf16
 
hunk ./GHC/IO/Encoding.hs 62
--- | The UTF-16 unicode encoding (litte-endian)
+-- | The UTF-16 Unicode encoding (litte-endian)
+utf16le  :: TextEncoding
 utf16le = UTF16.utf16le
 
hunk ./GHC/IO/Encoding.hs 66
--- | The UTF-16 unicode encoding (big-endian)
+-- | The UTF-16 Unicode encoding (big-endian)
+utf16be  :: TextEncoding
 utf16be = UTF16.utf16be
 
hunk ./GHC/IO/Encoding.hs 70
--- | The UTF-32 unicode encoding (a byte-order-mark should be used to
+-- | The UTF-32 Unicode encoding (a byte-order-mark should be used to
 -- indicate endianness).
hunk ./GHC/IO/Encoding.hs 72
+utf32  :: TextEncoding
 utf32 = UTF32.utf32
 
hunk ./GHC/IO/Encoding.hs 75
--- | The UTF-32 unicode encoding (litte-endian)
+-- | The UTF-32 Unicode encoding (litte-endian)
+utf32le  :: TextEncoding
 utf32le = UTF32.utf32le
 
hunk ./GHC/IO/Encoding.hs 79
--- | The UTF-32 unicode encoding (big-endian)
+-- | The UTF-32 Unicode encoding (big-endian)
+utf32be  :: TextEncoding
 utf32be = UTF32.utf32be
 
hunk ./GHC/IO/Encoding.hs 83
--- | The text encoding of the current locale
+-- | The Unicode encoding of the current locale
+localeEncoding  :: TextEncoding
 #if !defined(mingw32_HOST_OS)
 localeEncoding = Iconv.localeEncoding
 #else
hunk ./GHC/IO/Encoding.hs 91
 localeEncoding = Latin1.latin1
 #endif
 
--- | Acquire the named text encoding
+-- | Look up the named Unicode encoding.  May fail with 
+--
+--  * 'isDoesNotExistError' if the encoding is unknown
+--
+-- The set of known encodings is system-dependent.
+--
 mkTextEncoding :: String -> IO TextEncoding
 #if !defined(mingw32_HOST_OS)
 mkTextEncoding = Iconv.mkTextEncoding
hunk ./GHC/IO/Encoding.hs 109
 mkTextEncoding "UTF-32LE" = return utf32le
 mkTextEncoding "UTF-32BE" = return utf32be
 mkTextEncoding e = ioException
-     (IOError Nothing InvalidArgument "mkTextEncoding"
+     (IOError Nothing NoSuchThing "mkTextEncoding"
           ("unknown encoding:" ++ e)  Nothing Nothing)
 #endif
 
hunk ./GHC/IO/Handle.hs 249
 -- hSetEncoding
 
 -- | The action 'hSetEncoding' @hdl@ @encoding@ changes the text encoding
--- for the handle @hdl@ to @encoding@.  Encodings are available from the
--- module "GHC.IO.Encoding".  The default encoding when a 'Handle' is
+-- for the handle @hdl@ to @encoding@.  The default encoding when a 'Handle' is
 -- created is 'localeEncoding', namely the default encoding for the current
 -- locale.
 --
hunk ./GHC/IO/Handle.hs 257
 -- stop further encoding or decoding on an existing 'Handle', use
 -- 'hSetBinaryMode'.
 --
+-- 'hSetEncoding' may need to flush buffered data in order to change
+-- the encoding.
+--
 hSetEncoding :: Handle -> TextEncoding -> IO ()
 hSetEncoding hdl encoding = do
   withHandle "hSetEncoding" hdl $ \h_@Handle__{..} -> do
hunk ./GHC/IO/Handle/Text.hs 681
 -- 'hPutBuf' ignores any text encoding that applies to the 'Handle',
 -- writing the bytes directly to the underlying file or device.
 --
+-- 'hPutBuf' ignores the prevailing 'TextEncoding' and
+-- 'NewlineMode' on the 'Handle', and writes bytes directly.
+--
 -- This operation may fail with:
 --
 --  * 'ResourceVanished' if the handle is a pipe or socket, and the
hunk ./GHC/IO/Handle/Text.hs 787
 -- If the handle is a pipe or socket, and the writing end
 -- is closed, 'hGetBuf' will behave as if EOF was reached.
 --
+-- 'hGetBuf' ignores the prevailing 'TextEncoding' and 'NewlineMode'
+-- on the 'Handle', and reads bytes directly.
 
 hGetBuf :: Handle -> Ptr a -> Int -> IO Int
 hGetBuf h ptr count
hunk ./GHC/IO/Handle/Text.hs 873
 -- If the handle is a pipe or socket, and the writing end
 -- is closed, 'hGetBufNonBlocking' will behave as if EOF was reached.
 --
+-- 'hGetBufNonBlocking' ignores the prevailing 'TextEncoding' and
+-- 'NewlineMode' on the 'Handle', and reads bytes directly.
+
 hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
 hGetBufNonBlocking h ptr count
   | count == 0 = return 0
hunk ./GHC/IO/Handle/Types.hs 325
 -- Newline translation
 
 -- | The representation of a newline in the external file or stream.
-data Newline = LF    -- ^ "\n"
-             | CRLF  -- ^ "\r\n"
+data Newline = LF    -- ^ '\n'
+             | CRLF  -- ^ '\r\n'
              deriving Eq
 
 -- | Specifies the translation, if any, of newline characters between
hunk ./GHC/IO/Handle/Types.hs 342
                  }
              deriving Eq
 
--- | The native newline representation for the current platform
+-- | The native newline representation for the current platform: 'LF'
+-- on Unix systems, 'CRLF' on Windows.
 nativeNewline :: Newline
 #ifdef mingw32_HOST_OS
 nativeNewline = CRLF
hunk ./GHC/IO/Handle/Types.hs 351
 nativeNewline = LF
 #endif
 
--- | Map "\r\n" into "\n" on input, and "\n" to the native newline
+-- | Map '\r\n' into '\n' on input, and '\n' to the native newline
 -- represetnation on output.  This mode can be used on any platform, and
 -- works with text files using any newline convention.  The downside is
 -- that @readFile >>= writeFile@ might yield a different file.
hunk ./System/IO.hs 162
 
     openTempFile,
     openBinaryTempFile,
+
+#if !defined(__NHC__) && !defined(__HUGS__)
+    -- * Unicode encoding\/decoding
+
+    -- | A text-mode 'Handle' has an associated 'TextEncoding', which
+    -- is used to decode bytes into Unicode characters when reading,
+    -- and encode Unicode characters into bytes when writing.
+    --
+    -- The default 'TextEncoding' is the same as the default encoding
+    -- on your system, which is also available as 'localeEncoding'.
+    -- (GHC note: on Windows, currently 'localeEncoding' is always
+    -- 'latin1'; there is no support for encoding and decoding using
+    -- the ANSI code page).
+    --
+    -- Encoding and decoding errors are always detected and reported,
+    -- except during lazy I/O ('hGetContents', 'getContents', and
+    -- 'readFile'), where a decoding error merely results in
+    -- termination of the character stream, as with other I/O errors.
+
+    hSetEncoding, 
+
+    -- ** Unicode encodings
+    TextEncoding, 
+    latin1,
+    utf8, 
+    utf16, utf16le, utf16be,
+    utf32, utf32le, utf32be, 
+    localeEncoding,
+    mkTextEncoding,
+#endif
+
+#if !defined(__NHC__) && !defined(__HUGS__)
+    -- * Newline conversion
+    
+    -- | In Haskell, a newline is always represented by the character
+    -- '\n'.  However, in files and external character streams, a
+    -- newline may be represented by another character sequence, such
+    -- as '\r\n'.
+    --
+    -- A text-mode 'Handle' has an associated 'NewlineMode' that
+    -- specifies how to transate newline characters.  The
+    -- 'NewlineMode' specifies the input and output translation
+    -- separately, so that for instance you can translate '\r\n'
+    -- to '\n' on input, but leave newlines as '\n' on output.
+    --
+    -- The default 'NewlineMode' for a 'Handle' is
+    -- 'nativeNewlineMode', which does no translation on Unix systems,
+    -- but translates '\r\n' to '\n' and back on Windows.
+    --
+    -- Binary-mode 'Handle's do no newline translation at all.
+    --
+    hSetNewlineMode, 
+    Newline(..), nativeNewline, 
+    NewlineMode(..), 
+    noNewlineTranslation, universalNewlineMode, nativeNewlineMode,
+#endif
   ) where
 
 import Control.Exception.Base
hunk ./System/IO.hs 239
 import GHC.IO.Handle
 import GHC.IORef
 import GHC.IO.Exception ( userError )
+import GHC.IO.Encoding
 import GHC.Exception
 import GHC.Num
 import Text.Read
}

Context:

[not having iconv is not fatal on Windows
Simon Marlow <marlowsd@gmail.com>**20090625115804
 Ignore-this: 9232771b68156f12873673e7f7fa714
] 
[Move directory-related stuff to the unix package
Simon Marlow <marlowsd@gmail.com>**20090625120325
 Ignore-this: b997b3cbce0a46ca87ad825bbdc0a411
 now that it isn't used on Windows any more.
] 
[fix build failure on Windows
Simon Marlow <marlowsd@gmail.com>**20090625094609
 Ignore-this: 56276745fa66875d89e33ec1bdcf79fc
] 
[Fix iconv detection on OpenBSD
Ian Lynagh <igloo@earth.li>**20090624125422
 Matthias Kilian discovered that iconv_open is #define'd to something
 else on OpenBSD, so the test needs to include the iconv header.
] 
[setNonBlockingMode now takes a flag, can turn blocking mode back on again
Simon Marlow <marlowsd@gmail.com>**20090624115029
 Ignore-this: a4e112d8e2c5a5c3d8ba40c2b1c2861e
] 
[Call nl_langinfo(CODESET) to get the name of the locale encoding on Unix
Simon Marlow <marlowsd@gmail.com>**20090623143813
 Ignore-this: 39d1dc8daf59e6856d1e103d9cb0900b
] 
[Tidy up use of read/write/recv/send; avoid unnecessary wrappers
Simon Marlow <marlowsd@gmail.com>**20090622092656
 Ignore-this: 2ca207489a8c9ec8bd8c1bb6e69c98ad
] 
[Make this file independent of HsBase.h, use HsBaseConfig.h only
Simon Marlow <marlowsd@gmail.com>**20090622083957
 Ignore-this: 21187a10eec1f917be0e162333142971
] 
[Windows: Unicode openFile and stat functions
Simon Marlow <marlowsd@gmail.com>**20090618135458
 Ignore-this: e48260c13effdc4d48ac5529cea2a1dc
] 
[Add a comment to remind us that memcpy_src_off is used by dph
Simon Marlow <marlowsd@gmail.com>**20090618112616
 Ignore-this: c34666110294a933e6b015d3a6ec8864
] 
[Unconditionally make a (Show Ptr) instance
Ian Lynagh <igloo@earth.li>**20090620204809
 It used to only exist if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
] 
[Remove AC_C_CONST
Ian Lynagh <igloo@earth.li>**20090615203240
 It was breaking the build on Windows. The problem was that we included
 stdio.h which gave a prototype for some functions (e.g. remove), then
 the AC_C_CONST meant that we did
     /* Define to empty if `const' does not conform to ANSI C. */
     #define const /**/
 and then we included io.h which gave prototypes that, due to const
 being removed, conflicted with the earlier prototypes.
] 
[Remove old Integer prototypes
Ian Lynagh <igloo@earth.li>**20090615202444] 
[Redefine gcdInt to use gcdInteger rather than gcdInt# primop
Duncan Coutts <duncan@well-typed.com>**20090612142951
 The gcdInt# primop uses gmp internally, even though the interface is
 just Int#. Since we want to get gmp out of the rts we cannot keep
 gcdInt#, however it's also a bit odd for the integer package to export
 something that doesn't actually use Integer in its interface. Using
 gcdInteger is still not terribly satisfactory aesthetically. However
 in the short-term it works and it is no slower since gcdInteger calls
 gcdInt# for the special case of two small Integers.
] 
[The IO type has moved to GHC.Types in ghc-prim
Ian Lynagh <igloo@earth.li>**20090620155208] 
[Fix warnings in configure script
Ian Lynagh <igloo@earth.li>**20090615214850] 
[Fix warnings in C programs generated by configure; fixes failures with -Werror
Ian Lynagh <igloo@earth.li>**20090615201634] 
[Save and restore the codec state when re-decoding
Simon Marlow <marlowsd@gmail.com>**20090614185332
 Ignore-this: 62b247a51efc2eed65d933f982b06894
 
 We previously had an ugly hack to check for a BOM when re-decoding
 some binary data in flushCharBuffer.  The hack was there essentially
 because codecs like UTF-16 have a state, and we had not restored it.
 This patch gives codecs an explicit state, and implemented
 saving/restoring of the state as necessary.  Hence, the hack in
 flushCharBuffer is replaced by a more general mechanism that works for
 any codec with state.
 
 Unfortunately, iconv doesn't give us a way to save and restore the
 state, so this is currently only implemented for the built-in codecs.
] 
[Allow System.Posix.Internals to compile with nhc98 again.
Malcolm.Wallace@cs.york.ac.uk**20090615155249
 Also affects GHC.IO.Device, which is not very GHC-specific at all.
] 
[add hFlushAll, flushes both read and write buffers
Simon Marlow <marlowsd@gmail.com>**20090623133818
 Ignore-this: 70c57b04438d8d9a25225f7694fd1196
] 
[fix bug in partial writes
Simon Marlow <marlowsd@gmail.com>**20090623105004
 Ignore-this: 384b8409689713f9e766b869c459dcd6
] 
[Fix #3128: file descriptor leak when hClose fails
Simon Marlow <marlowsd@gmail.com>**20090616110755
 Ignore-this: 5b6a51fed9239c61d16d0151cb5b59d3
] 
[Add iconv as an extra library on platform that need to link with it
Ian Lynagh <igloo@earth.li>**20090612231307
 For example, we need -liconv on OS X.
] 
[Remove unused foreign imports of __encodeFloat/Double
Duncan Coutts <duncan@well-typed.com>**20090611160100] 
[Rewrite of the IO library, including Unicode support
Simon Marlow <marlowsd@gmail.com>**20090612135631
 Ignore-this: fbd43ec854ac5df442e7bf647de8ca5a
 
 Highlights:
 
 * Unicode support for Handle I/O:
 
   ** Automatic encoding and decoding using a per-Handle encoding.
 
   ** The encoding defaults to the locale encoding (only on Unix 
      so far, perhaps Windows later).
 
   ** Built-in UTF-8, UTF-16 (BE/LE), and UTF-32 (BE/LE) codecs.
 
   ** iconv-based codec for other encodings on Unix
 
 * Modularity: the low-level IO interface is exposed as a type class
   (GHC.IO.IODevice) so you can build your own low-level IO providers and
   make Handles from them.
 
 * Newline translation: instead of being Windows-specific wired-in
   magic, the translation from \r\n -> \n and back again is available
   on all platforms and is configurable for reading/writing
   independently.
 
 
 Unicode-aware Handles
 ~~~~~~~~~~~~~~~~~~~~~
 
 This is a significant restructuring of the Handle implementation with
 the primary goal of supporting Unicode character encodings.
 
 The only change to the existing behaviour is that by default, text IO
 is done in the prevailing locale encoding of the system (except on
 Windows [1]).  
 
 Handles created by openBinaryFile use the Latin-1 encoding, as do
 Handles placed in binary mode using hSetBinaryMode.
 
 We provide a way to change the encoding for an existing Handle:
 
    GHC.IO.Handle.hSetEncoding :: Handle -> TextEncoding -> IO ()
 
 and various encodings (from GHC.IO.Encoding):
 
    latin1,
    utf8,
    utf16, utf16le, utf16be,
    utf32, utf32le, utf32be,
    localeEncoding,
 
 and a way to lookup other encodings:
 
    GHC.IO.Encoding.mkTextEncoding :: String -> IO TextEncoding
 
 (it's system-dependent whether the requested encoding will be
 available).
 
 We may want to export these from somewhere more permanent; that's a
 topic for a future library proposal.
 
 Thanks to suggestions from Duncan Coutts, it's possible to call
 hSetEncoding even on buffered read Handles, and the right thing
 happens.  So we can read from text streams that include multiple
 encodings, such as an HTTP response or email message, without having
 to turn buffering off (though there is a penalty for switching
 encodings on a buffered Handle, as the IO system has to do some
 re-decoding to figure out where it should start reading from again).
 
 If there is a decoding error, it is reported when an attempt is made
 to read the offending character from the Handle, as you would expect.
 
 Performance varies.  For "hGetContents >>= putStr" I found the new
 library was faster on my x86_64 machine, but slower on an x86.  On the
 whole I'd expect things to be a bit slower due to the extra
 decoding/encoding, but probabaly not noticeably.  If performance is
 critical for your app, then you should be using bytestring and text
 anyway.
 
 [1] Note: locale encoding is not currently implemented on Windows due
 to the built-in Win32 APIs for encoding/decoding not being sufficient
 for our purposes.  Ask me for details.  Offers of help gratefully
 accepted.
 
 
 Newline Translation
 ~~~~~~~~~~~~~~~~~~~
 
 In the old IO library, text-mode Handles on Windows had automatic
 translation from \r\n -> \n on input, and the opposite on output.  It
 was implemented using the underlying CRT functions, which meant that
 there were certain odd restrictions, such as read/write text handles
 needing to be unbuffered, and seeking not working at all on text
 Handles.
 
 In the rewrite, newline translation is now implemented in the upper
 layers, as it needs to be since we have to perform Unicode decoding
 before newline translation.  This means that it is now available on
 all platforms, which can be quite handy for writing portable code.
 
 For now, I have left the behaviour as it was, namely \r\n -> \n on
 Windows, and no translation on Unix.  However, another reasonable
 default (similar to what Python does) would be to do \r\n -> \n on
 input, and convert to the platform-native representation (either \r\n
 or \n) on output.  This is called universalNewlineMode (below).
 
 The API is as follows.  (available from GHC.IO.Handle for now, again
 this is something we will probably want to try to get into System.IO
 at some point):
 
 -- | The representation of a newline in the external file or stream.
 data Newline = LF    -- ^ "\n"
              | CRLF  -- ^ "\r\n"
              deriving Eq
 
 -- | Specifies the translation, if any, of newline characters between
 -- internal Strings and the external file or stream.  Haskell Strings
 -- are assumed to represent newlines with the '\n' character; the
 -- newline mode specifies how to translate '\n' on output, and what to
 -- translate into '\n' on input.
 data NewlineMode 
   = NewlineMode { inputNL :: Newline,
                     -- ^ the representation of newlines on input
                   outputNL :: Newline
                     -- ^ the representation of newlines on output
                  }
              deriving Eq
 
 -- | The native newline representation for the current platform
 nativeNewline :: Newline
 
 -- | Map "\r\n" into "\n" on input, and "\n" to the native newline
 -- represetnation on output.  This mode can be used on any platform, and
 -- works with text files using any newline convention.  The downside is
 -- that @readFile a >>= writeFile b@ might yield a different file.
 universalNewlineMode :: NewlineMode
 universalNewlineMode  = NewlineMode { inputNL  = CRLF, 
                                       outputNL = nativeNewline }
 
 -- | Use the native newline representation on both input and output
 nativeNewlineMode    :: NewlineMode
 nativeNewlineMode     = NewlineMode { inputNL  = nativeNewline, 
                                       outputNL = nativeNewline }
 
 -- | Do no newline translation at all.
 noNewlineTranslation :: NewlineMode
 noNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
 
 
 -- | Change the newline translation mode on the Handle.
 hSetNewlineMode :: Handle -> NewlineMode -> IO ()
 
 
 
 IO Devices
 ~~~~~~~~~~
 
 The major change here is that the implementation of the Handle
 operations is separated from the underlying IO device, using type
 classes.  File descriptors are just one IO provider; I have also
 implemented memory-mapped files (good for random-access read/write)
 and a Handle that pipes output to a Chan (useful for testing code that
 writes to a Handle).  New kinds of Handle can be implemented outside
 the base package, for instance someone could write bytestringToHandle.
 A Handle is made using mkFileHandle:
 
 -- | makes a new 'Handle'
 mkFileHandle :: (IODevice dev, BufferedIO dev, Typeable dev)
               => dev -- ^ the underlying IO device, which must support
                      -- 'IODevice', 'BufferedIO' and 'Typeable'
               -> FilePath
                      -- ^ a string describing the 'Handle', e.g. the file
                      -- path for a file.  Used in error messages.
               -> IOMode
                      -- ^ The mode in which the 'Handle' is to be used
               -> Maybe TextEncoding
                      -- ^ text encoding to use, if any
               -> NewlineMode
                      -- ^ newline translation mode
               -> IO Handle
 
 This also means that someone can write a completely new IO
 implementation on Windows based on native Win32 HANDLEs, and
 distribute it as a separate package (I really hope somebody does
 this!).
 
 This restructuring isn't as radical as previous designs.  I haven't
 made any attempt to make a separate binary I/O layer, for example
 (although hGetBuf/hPutBuf do bypass the text encoding and newline
 translation).  The main goal here was to get Unicode support in, and
 to allow others to experiment with making new kinds of Handle.  We
 could split up the layers further later.
 
 
 API changes and Module structure
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 NB. GHC.IOBase and GHC.Handle are now DEPRECATED (they are still
 present, but are just re-exporting things from other modules now).
 For 6.12 we'll want to bump base to version 5 and add a base4-compat.
 For now I'm using #if __GLASGOW_HASKEL__ >= 611 to avoid deprecated
 warnings.
 
 I split modules into smaller parts in many places.  For example, we
 now have GHC.IORef, GHC.MVar and GHC.IOArray containing the
 implementations of IORef, MVar and IOArray respectively.  This was
 necessary for untangling dependencies, but it also makes things easier
 to follow.
 
 The new module structurue for the IO-relatied parts of the base
 package is:
 
 GHC.IO
    Implementation of the IO monad; unsafe*; throw/catch
 
 GHC.IO.IOMode
    The IOMode type
 
 GHC.IO.Buffer
    Buffers and operations on them
 
 GHC.IO.Device
    The IODevice and RawIO classes.
 
 GHC.IO.BufferedIO
    The BufferedIO class.
 
 GHC.IO.FD
    The FD type, with instances of IODevice, RawIO and BufferedIO.
 
 GHC.IO.Exception
    IO-related Exceptions
 
 GHC.IO.Encoding
    The TextEncoding type; built-in TextEncodings; mkTextEncoding
 
 GHC.IO.Encoding.Types
 GHC.IO.Encoding.Iconv
 GHC.IO.Encoding.Latin1
 GHC.IO.Encoding.UTF8
 GHC.IO.Encoding.UTF16
 GHC.IO.Encoding.UTF32
    Implementation internals for GHC.IO.Encoding
 
 GHC.IO.Handle
    The main API for GHC's Handle implementation, provides all the Handle
    operations + mkFileHandle + hSetEncoding.
 
 GHC.IO.Handle.Types
 GHC.IO.Handle.Internals
 GHC.IO.Handle.Text
    Implementation of Handles and operations.
 
 GHC.IO.Handle.FD
    Parts of the Handle API implemented by file-descriptors: openFile,
    stdin, stdout, stderr, fdToHandle etc.
 
] 
[nhc98 must build dirUtils.c as well.
Malcolm.Wallace@cs.york.ac.uk**20090605091730
 Fixes this bootstrapping error:
   Undefined symbols:
   "___hscore_readdir", referenced from:
       _FR_System_46Posix_46Internals_46readdir_35 in libHSbase.a(Internals.o)
] 
[Remove unnecessary parens
Ian Lynagh <igloo@earth.li>**20090602183608] 
[Fix validate (on Windows)
Simon Marlow <marlowsd@gmail.com>**20090529130214
 Ignore-this: ea31ee9b26cd69b81bb24ecf040dc196
] 
[Make two type defaults explicit
simonpj@microsoft.com**20090529083549
 Ignore-this: 398a10db1612dbef1723b449bff26782
 
 Now that -Werror rejects programs that use silent type-class defaulting,
 we must commit in the source code.
 
 I've used Double in CPUTime, which is the same as was picked automatically
 before, but I expect Float would be ok.
 
    realToInteger :: Real a => a -> Integer
    realToInteger ct = round (realToFrac ct :: Double)
 
 In GHC.Float I used Float (rather that than the auto-picked Double)
 because I'm pretty certain it has enough precision.
 
 	-- f :: Integer, log :: Float -> Float, 
         --               ceiling :: Float -> Int
         ceiling ((log (fromInteger (f+1) :: Float) +
  
] 
[Increase the version number to that in the 6.10 branch
Ian Lynagh <igloo@earth.li>**20090524155610] 
[Fix warnings
Ian Lynagh <igloo@earth.li>**20090523224508] 
[Document that the initial quantity for QSem and QSemN must be >= 0
Ian Lynagh <igloo@earth.li>**20090523200238] 
[Fix #3257: document that exitWith in a forkIO'd thread does not exit the process
Simon Marlow <marlowsd@gmail.com>**20090528123738
 Ignore-this: cc5aff45a149acd1627bd7ee31aea4e9
] 
[add _O_NOINHERIT when opening files on Windows (see #2650)
Simon Marlow <marlowsd@gmail.com>**20090520130926
 Ignore-this: 6dfbdfe13e739cc339e627294e077ba6
] 
[remove msvcrt and kernel32 from extra-libraries
Simon Marlow <marlowsd@gmail.com>**20090520111626
 Ignore-this: cd2e24a5144c6ca0efe03ceaea8f577b
] 
[Add wrappers around fcntl
Ian Lynagh <igloo@earth.li>**20090520175358
 We need to do this as it has a (, ...) type, which we aren't allowed to
 directly call with the FFI.
] 
[Add more bang patterns, needed to fix the 32bit build
Ian Lynagh <igloo@earth.li>**20090424160701] 
[Use a bang pattern when we where/let-bind values with unlifted types
Ian Lynagh <igloo@earth.li>**20090424125320] 
[FIX #3171: make sure we have only one table of signal handlers
Simon Marlow <marlowsd@gmail.com>**20090423112837
 Ignore-this: 3d8039b47efac2629e73a7d7e7d58983
] 
[Fix QSem and QSemN: Initial amount must be non-negative
Ian Lynagh <igloo@earth.li>**20090410164013] 
[Don't inline enumDeltaToInteger until its rules have had a chance to fire
simonpj@microsoft.com**20090403091750
 Ignore-this: ab602bac65610e720065b097d46a6f52
] 
[Import GHC.Err so we see bottoming functions properly
simonpj@microsoft.com**20090403091118
 Ignore-this: 913e3a4584e73e67ddf9bc3b6f11d11
 
 Before this patch, GHC/Err.lhs-boot exported divZeroError and overflowError,
 as well as plain 'error'.  The latter has a wired-in defn in GHC (MkId.lhs),
 but the former two do not.  As a result GHC doesn't see that overflowError
 is a bottoming function at a crucial moment when compiling GHC.Real, and
 that means that divMod wasn't getting the CPR property.
 
 The fix is easy:
   - GHC/Err.lhs-boot should export only 'error'
 
   - GHC.Real, GHC.Int, and GHC.Word should import GHC.Err
     directly.  They can do this nowadays without creating
     a module loop, thanks to the new exception story
 
] 
[Don't inline unpackCString
simonpj@microsoft.com**20090403090844
 Ignore-this: 78f9660ffff55ae8bc4c41866d1ad80c
 
 There's no point in inlining unpackCString, so this patch adds a
 NOINLINE pragma.  (Otherwise, it's just on the threshold.)
 
] 
[be sure to install Nhc98BaseConfig.h
Malcolm.Wallace@cs.york.ac.uk**20090401122028] 
[Avoid unnecessarily using Integer when decoding Floats
Ian Lynagh <igloo@earth.li>**20090330225241] 
[Add another Data.List.intersect example from Christian Maeder
Ian Lynagh <igloo@earth.li>**20090327232118] 
[Remove some redundant fromInteger's
Ian Lynagh <igloo@earth.li>**20090324145325] 
[Add an import needed in the new build system
Ian Lynagh <igloo@earth.li>**20090322162241] 
[ghcconfig.h is __GLASGOW_HASKELL__ only
Malcolm.Wallace@cs.york.ac.uk**20090316134532] 
[Fix layout to comply with H'98.
Malcolm.Wallace@cs.york.ac.uk**20090316125651
 Also, configure correctly for nhc98, to avoid win32 code.
] 
[FIX #2189: re-enabled cooked mode for Console-connected Handles on Windows
Simon Marlow <marlowsd@gmail.com>*-20090305113323
 Patch from Sigbjorn Finne <sof@galois.com>
] 
[avoid a space leak building up in the "prodding" IORef (part of #2992)
Simon Marlow <marlowsd@gmail.com>**20090311093938] 
[Add config.guess, config.sub and install-sh
Ian Lynagh <igloo@earth.li>**20090307153831] 
[add final newline; fix build (on Windows?)
Simon Marlow <marlowsd@gmail.com>**20090305120426] 
[FIX #2189: re-enabled cooked mode for Console-connected Handles on Windows
Simon Marlow <marlowsd@gmail.com>**20090305113323
 Patch from Sigbjorn Finne <sof@galois.com>
] 
[Rules to make genericLength strict for Int/Integer lengths, see #2962
naur@post11.tele.dk**20090207181427] 
[Partial fix for #2917
Simon Marlow <marlowsd@gmail.com>**20090305154153
 Ignore-this: 3a06cd3ea09f1d6454d52031802a93fd
 
  - add newAlignedPinnedByteArray# for allocating pinned BAs with
    arbitrary alignment
 
  - the old newPinnedByteArray# now aligns to 16 bytes
 
 Foreign.alloca will use newAlignedPinnedByteArray#, and so might end
 up wasting less space than before (we used to align to 8 by default).
 Foreign.allocaBytes and Foreign.mallocForeignPtrBytes will get 16-byte
 aligned memory, which is enough to avoid problems with SSE
 instructions on x86, for example.
 
 There was a bug in the old newPinnedByteArray#: it aligned to 8 bytes,
 but would have failed if the header was not a multiple of 8
 (fortunately it always was, even with profiling).  Also we
 occasionally wasted some space unnecessarily due to alignment in
 allocatePinned().
 
 I haven't done anything about Foreign.malloc/mallocBytes, which will
 give you the same alignment guarantees as malloc() (8 bytes on
 Linux/x86 here).
] 
[#2759: Amend previous patch
Jose Pedro Magalhaes <jpm@cs.uu.nl>**20090212132327] 
[ifdef out the definition of setCloseOnExec on Windows; fixes the build
Ian Lynagh <igloo@earth.li>**20090220173041] 
[Fix warnings: put imports inside ifdefs
Ian Lynagh <igloo@earth.li>**20090220173941] 
[ifdef out the syncIOManager export on Windows; fixes the build
Ian Lynagh <igloo@earth.li>**20090220173414] 
[Set the IO manager pipe descriptors to FD_CLOEXEC
Simon Marlow <marlowsd@gmail.com>**20090219114217
 Ignore-this: ac670a45f8a4d06dd7831a2674d6c119
 This pipe is an internal implementation detail, we don't really want
 it to be exposed.
] 
[Rewrite of signal-handling (base patch; see also ghc and unix patches)
Simon Marlow <marlowsd@gmail.com>**20090219102203
 Ignore-this: 2122e05eaaab184b9ef0f269ce4c9282
 
 The API is the same (for now).  The new implementation has the
 capability to define signal handlers that have access to the siginfo
 of the signal (#592), but this functionality is not exposed in this
 patch.
 
 #2451 is the ticket for the new API.
 
 The main purpose of bringing this in now is to fix race conditions in
 the old signal handling code (#2858).  Later we can enable the new
 API in the HEAD.
 
 Implementation differences:
 
  - More of the signal-handling is moved into Haskell.  We store the
    table of signal handlers in an MVar, rather than having a table of
    StablePtrs in the RTS.
 
  - In the threaded RTS, the siginfo of the signal is passed down the
    pipe to the IO manager thread, which manages the business of
    starting up new signal handler threads.  In the non-threaded RTS,
    the siginfo of caught signals is stored in the RTS, and the
    scheduler starts new signal handler threads.
] 
[implement System.IO.Error more fully for nhc98
Malcolm.Wallace@cs.york.ac.uk**20090206173314] 
[Make System.Posix.Internals buildable by nhc98.
Malcolm.Wallace@cs.york.ac.uk**20090206111152] 
[Fix #2971: we had lost the non-blocking flag on Handles created by openFile
Simon Marlow <marlowsd@gmail.com>**20090206165912
 Ignore-this: 546f1a799b6e80f7b25c73ef642d8f9d
 This code is a mess, fortunately the new IO library cleans it up.
] 
[add some rules of thumb for catching exceptions, restructure the docs a bit
Simon Marlow <marlowsd@gmail.com>**20090205150642
 Ignore-this: 8294e58f247b2cc3f193991434d336de
] 
[Fix #2903: ensure CWStringLen contains the length of the array rather than the String
Ross Paterson <ross@soi.city.ac.uk>**20090203011026] 
[OldException catches unknown exceptions as DynException
Ian Lynagh <igloo@earth.li>**20090202151856
 It's important that we put all exceptions into the old Exception
 type somehow, or throwing a new exception wouldn't cause the
 cleanup code for bracket, finally etc to happen.
] 
[Update the Exception docs
Ian Lynagh <igloo@earth.li>**20090131204845] 
[Require Cabal version >= 1.6
Ian Lynagh <igloo@earth.li>**20090122011251] 
[Add "bug-reports" and "source-repository" info to the Cabal file
Ian Lynagh <igloo@earth.li>**20090121182010] 
[Proposal #2875: remove StringRep and StringConstr
Jose Pedro Magalhaes <jpm@cs.uu.nl>**20090116142617] 
[Fix #2759: add mkRealConstr and mkIntegralConstr, deprecate mkFloatConstr and mkIntConstr
Jose Pedro Magalhaes <jpm@cs.uu.nl>**20090116140655] 
[Correct SYB's representation of Char
Jose Pedro Magalhaes <jpm@cs.uu.nl>**20081211144716] 
[avoid `mappend` in monoid laws, because it doesn't work with haddock
Ross Paterson <ross@soi.city.ac.uk>**20090118011508] 
[Make Data.Typeable imports and exports more explicit
Ian Lynagh <igloo@earth.li>**20090114234512] 
[add Monoid laws
Ross Paterson <ross@soi.city.ac.uk>**20090116151624] 
[Unbreak an import cycle caused by moving 'catch' definitions around.
Malcolm.Wallace@cs.york.ac.uk**20090116110132
 The new cycle was introduced for nhc98 only.
] 
[make the Monoid docs more self-contained
Ross Paterson <ross@soi.city.ac.uk>**20090115222441] 
[Move some catch definitions around to avoid an import loop
Ian Lynagh <igloo@earth.li>**20090114211033
 As suggested by simonpj in trac #2822.
] 
[Add NoImplicitPrelude to the extensions used when building with GHC
Ian Lynagh <igloo@earth.li>**20090114202810] 
[#2699: exit silently for EPIPE on stdout
Simon Marlow <marlowsd@gmail.com>**20090114134612
 Ignore-this: 4236560e8e9c1135129e9526355f11b4
] 
[Fix build when we have HTYPE_TCFLAG_T
Ian Lynagh <igloo@earth.li>**20090105102020] 
[Fix the build on Windows
Ian Lynagh <igloo@earth.li>**20090105014625] 
[Add errno to the IOError type
Ian Lynagh <igloo@earth.li>**20090104173018] 
[Fix typo (reqwests -> requests); trac #2908, spotted by bancroft
Ian Lynagh <igloo@earth.li>**20090104154405] 
[More compact error messages for record selectors
simonpj@microsoft.com**20090102145325
 
 Make recSelError generate the standard part of the record selector
 error message (i.e. "No match in record selector") rather than have
 that string duplicated for every record selector.
 
] 
[extra dependencies for the new build system
Simon Marlow <marlowsd@gmail.com>**20081217104655] 
[warning fix: don't use -XPatternSignatures in GHC >= 6.10
Simon Marlow <marlowsd@gmail.com>**20081217104637] 
[Rollback INLINE patches
Simon Marlow <marlowsd@gmail.com>**20081216104143
 
 rolling back:
 
 Fri Dec  5 17:00:15 GMT 2008  simonpj@microsoft.com
   * Update INLINE pragmas for new INLINE story
   
   - (.) and foldr should inline when applied to only two arguments
   - Make unpackCString# NOINLINE; it inlines too much (with little gain)
   
 
     M ./GHC/Base.lhs -10 +31
] 
[FIX #1364: added support for C finalizers that run as soon as the value is no longer reachable.
Ivan Tomac <tomac@pacific.net.au>**20081210150510
 
 Patch amended by Simon Marlow:
   - mkWeakFinalizer# commoned up with mkWeakFinalizerEnv#
] 
[Fix #2760: deprecate mkNorepType, add mkNoRepType
Jose Pedro Magalhaes <jpm@cs.uu.nl>**20081121141905] 
[Update INLINE pragmas for new INLINE story
simonpj@microsoft.com**20081205170015
 
 - (.) and foldr should inline when applied to only two arguments
 - Make unpackCString# NOINLINE; it inlines too much (with little gain)
 
] 
[Fix #2750: change Prelude.(,) to Prelude.(,,)
Jose Pedro Magalhaes <jpm@cs.uu.nl>**20081201113411] 
[Fix typo (or out of date reference) in throwTo documentation.
shelarcy <shelarcy@gmail.com>**20081129024639] 
[Add more description of what "round" does, from the H98 report
Ian Lynagh <igloo@earth.li>**20081119143131] 
[re-instate the gcd/Integer and lcm/Integer RULES
Simon Marlow <marlowsd@gmail.com>**20081120101826
 Fixes a performance regression between 6.8.3 and 6.10.1
] 
[Change an "undefined" into a more informative error; trac #2782
Ian Lynagh <igloo@earth.li>**20081116160228] 
[updating Haddock documentation
jpm@cs.uu.nl**20081111095023
 
 Fixed the broken link from Data.Generics to Data.Data.
] 
[add GHC.Conc.runSparks (required by GHC patch "Run sparks in batches")
Simon Marlow <marlowsd@gmail.com>**20081106095419] 
[FIX #2722: update RULES for the Category/Arrow split
Ross Paterson <ross@soi.city.ac.uk>**20081104144515
 
 The rule
 
 	arr id = id
 
 interacts unpleasantly with the advice to define
 
 	id = arr id
 
 in instances of Category that are also instances of Arrow (#2722).
 
 Also changed a couple of >>>'s to .'s in later rules.
] 
[Add AnnotationWrapper type so GHC can capture annotation dictionaries during compilation
Max Bolingbroke <batterseapower@hotmail.com>**20081016122608] 
[docs about how exceptions are handled by forkIO'd threads (#2651)
Simon Marlow <marlowsd@gmail.com>**20081016100410] 
[Import n_capabilities via import symbol when linking dynamically
Clemens Fruhwirth <clemens@endorphin.org>**20081013161220] 
[add link to the new syb wiki
jpm@cs.uu.nl**20081013111605] 
[changing haddock links
jpm@cs.uu.nl**20081010095434] 
[add readTVarIO :: TVar a -> IO a
Simon Marlow <marlowsd@gmail.com>**20081010113835] 
[removed (->) instance from Data.Data
jpm@cs.uu.nl**20081006075254] 
[non-GHC: delete unnecessary imports
Ross Paterson <ross@soi.city.ac.uk>**20081007134809] 
[added new module Data.Data
'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002140535
 
 The new Data.Data module contains all of Data.Generics.Basics 
 and most of Data.Generics.Instances. The missing instances were 
 deemed dubious and moved to the syb package.
] 
[add new Data.Data module
'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002082735] 
[restore Complex's derived Data instance
'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002082655] 
[update Data.Generics import
'Jose Pedro Magalhaes <jpm@cs.uu.nl>'**20081002082604] 
[Don't use ^(2::Int) in Data.Complex.magnitude; partially fixes trac #2450
Ian Lynagh <igloo@earth.li>**20081004142651
 We still might want to make a RULE for this, so the bug is not fully fixed.
] 
[Restore the Haskell 98 behaviour of Show Ratio (#1920)
Simon Marlow <simonmarhaskell@gmail.com>**20080923134949] 
[Pad version number to 4.0.0.0
Ian Lynagh <igloo@earth.li>**20080920155801] 
[TAG 6.10 branch has been forked
Ian Lynagh <igloo@earth.li>**20080919123437] 
Patch bundle hash:
a663b9cec42ae2656591acdf856d9ad1e7a781af
