Export Unicode and newline functionality from System.IO; update Haddock docs
[ghc-base.git] / GHC / IO / Handle / Types.hs
index f3cf717..a45f298 100644 (file)
@@ -121,17 +121,17 @@ instance Eq Handle where
  _ == _ = False 
 
 data Handle__
-  = forall dev . (IODevice dev, BufferedIO dev, Typeable dev) =>
+  = forall dev enc_state dec_state . (IODevice dev, BufferedIO dev, Typeable dev) =>
     Handle__ {
       haDevice      :: !dev,
       haType        :: HandleType,           -- type (read/write/append etc.)
       haByteBuffer  :: !(IORef (Buffer Word8)),
       haBufferMode  :: BufferMode,
-      haLastDecode  :: !(IORef (Buffer Word8)),
+      haLastDecode  :: !(IORef (dec_state, Buffer Word8)),
       haCharBuffer  :: !(IORef (Buffer CharBufElem)), -- the current buffer
       haBuffers     :: !(IORef (BufferList CharBufElem)),  -- spare buffers
-      haEncoder     :: Maybe TextEncoder,
-      haDecoder     :: Maybe TextDecoder,
+      haEncoder     :: Maybe (TextEncoder enc_state),
+      haDecoder     :: Maybe (TextDecoder dec_state),
       haInputNL     :: Newline,
       haOutputNL    :: Newline,
       haOtherSide   :: Maybe (MVar Handle__) -- ptr to the write side of a 
@@ -322,8 +322,8 @@ and hence it is only possible on a seekable Handle.
 -- 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
@@ -339,7 +339,8 @@ data NewlineMode
                  }
              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
@@ -347,7 +348,7 @@ nativeNewline = CRLF
 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.