1. 23 Sep, 2015 1 commit
  2. 10 Jul, 2015 1 commit
  3. 16 Dec, 2014 1 commit
  4. 27 Oct, 2014 1 commit
  5. 31 Dec, 2013 1 commit
  6. 21 Sep, 2013 1 commit
  7. 17 Sep, 2013 2 commits
  8. 15 Feb, 2013 1 commit
  9. 27 Oct, 2012 1 commit
    • ian@well-typed.com's avatar
      Remove commented types in module export lists · fda30027
      ian@well-typed.com authored
      These comments are rather less useful now that haddock can give docs
      with the same informatino in the module synopsis.
      
      Having to maintain them when making changes to the library is a pain,
      and when people forget about doing so there is nothing that checks that
      the comments are right, so mistakes tend to linger.
      
      Of the comments that my script detected, 78 of 684 were already
      incorrect in one way or another, e.g. missing context:
          Text.Show.showsPrec
          Comment type: Int -> a -> ShowS
          Actual type:  Show a => Int -> a -> ShowS
      wrong context:
          Numeric.readInt
          Comment type: Integral a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
          Actual type:  Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
      not following a class change (e.g. Num losing its Eq superclass):
          Text.Read.Lex.readOctP
          Comment type: Num a => ReadP a
          Actual type:  (Eq a, Num a) => ReadP a
      not following the Exceptions change:
          GHC.Conc.childHandler
          Comment type: Exception -> IO ()
          Actual type:  SomeException -> IO ()
      or just always been wrong:
          GHC.Stable.deRefStablePtr
          Comment type: StablePtr a -> a
          Actual type:  StablePtr a -> IO a
      fda30027
  10. 14 Mar, 2012 1 commit
  11. 26 Oct, 2011 1 commit
  12. 18 Jun, 2011 1 commit
  13. 24 May, 2011 1 commit
  14. 19 Jan, 2011 1 commit
  15. 28 Jan, 2011 1 commit
  16. 06 Jul, 2009 1 commit
  17. 12 Jun, 2009 1 commit
    • Simon Marlow's avatar
      Rewrite of the IO library, including Unicode support · 7b067f2d
      Simon Marlow authored
      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.
      7b067f2d
  18. 30 Jul, 2008 1 commit
  19. 08 Mar, 2008 1 commit
  20. 17 Oct, 2004 1 commit
  21. 22 Apr, 2003 1 commit
  22. 17 Apr, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-04-17 15:23:37 by simonpj] · 7e51e8b3
      simonpj authored
      ----------------------------------
      	Implement Typeable properly
      	----------------------------------
      
      1.  Add 'deriving' for Typeable class. So you can say
      
      	data T a b = .... deriving( Typeable )
      
          At the moment you only get this if you ask for it. If you say
          nothing you get nothing.
      
      2.  Implement Typeable better, with proper O(1) comparison of
          type representations
      
      3.  Add the 'cast' operation described in 'Scrap your boilerplate'
          and use it.
      
      
      4.  Consequence: need to move the definition of IOArray from
          Data.Array.IO.Internals to GHC.IOBase, where it joins IORef.
          This is necssary so that HashTable can be low down in the compilation
          hierarchy, and hence so can Dynamic.
      
      
      
      	WARNING: I'm not certain the imports in HashTable and Dynamic
      		 will all be right for Hugs and NHC. I hope you can
      	  	 fix them up.
      7e51e8b3
  23. 18 Oct, 2002 4 commits
  24. 09 Oct, 2002 1 commit
  25. 16 Jul, 2002 1 commit
  26. 10 May, 2002 1 commit
  27. 09 May, 2002 1 commit
  28. 26 Apr, 2002 1 commit
  29. 24 Apr, 2002 1 commit
  30. 02 Jan, 2002 1 commit
  31. 21 Dec, 2001 1 commit
  32. 03 Jul, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-07-03 11:37:49 by simonmar] · b4358ba0
      simonmar authored
      Latest round of changes, incorporating:
      
        - some changes to the portability/stability requested by Malcolm
        - Control.Monad.Fix is portable, IO/ST instances moved to System.IO,
          Control.Monad.ST respectively.
        - GHC.Tup moved to Data.Tuple, the code in here is mostly portable
          (and the interface better be).
      b4358ba0
  33. 28 Jun, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-06-28 14:15:04 by simonmar] · 4fb94ae5
      simonmar authored
      First cut of the Haskell Core Libraries
      =======================================
      
      NOTE: it's not meant to be a working snapshot.  The code is just here
      to look at and so the NHC/Hugs guys can start playing around with it.
      
      There is no build system.  For GHC, the libraries tree is intended to
      be grafted onto an existing fptools/ tree, and the Makefile in
      libraries/core is a quick hack for that setup.  This won't work at the
      moment without the other changes needed in fptools/ghc, which I
      haven't committed because they'll cause breakage.  However, with the
      changes required these sources build a working Prelude and libraries.
      
      The layout mostly follows the one we agreed on, with one or two minor
      changes; in particular the Data/Array layout probably isn't final
      (there are several choices here).
      
      The document is in libraries/core/doc as promised.
      
      The cbits stuff is just a copy of ghc/lib/std/cbits and has
      GHC-specific stuff in it.  We should really separate the
      compiler-specific C support from any compiler-independent C support
      there might be.
      
      Don't pay too much attention to the portability or stability status
      indicated in the header of each source file at the moment - I haven't
      gone through to make sure they're all consistent and make sense.
      
      I'm using non-literate source outside of GHC/.  Hope that's ok with
      everyone.
      
      We need to discuss how the build system is going to work...
      4fb94ae5