Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 2314

ghc-7.4.2-4.mga5.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>GHC.IO.Handle</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_GHC-IO-Handle.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">base-4.5.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr></table><p class="caption">GHC.IO.Handle</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>External API for GHC's Handle implementation
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span>  <a href="#t:Handle">Handle</a> </li><li class="src short"><span class="keyword">data</span>  <a href="#t:BufferMode">BufferMode</a> <ul class="subs"><li>= <a href="#v:NoBuffering">NoBuffering</a>  </li><li>| <a href="#v:LineBuffering">LineBuffering</a>  </li><li>| <a href="#v:BlockBuffering">BlockBuffering</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Int.html#t:Int">Int</a>)  </li></ul></li><li class="src short"><a href="#v:mkFileHandle">mkFileHandle</a> :: (<a href="GHC-IO-Device.html#t:IODevice">IODevice</a> dev, <a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a> dev, <a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a> dev) =&gt; dev -&gt; <a href="System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="System-IO.html#t:IOMode">IOMode</a> -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a> -&gt; <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></li><li class="src short"><a href="#v:mkDuplexHandle">mkDuplexHandle</a> :: (<a href="GHC-IO-Device.html#t:IODevice">IODevice</a> dev, <a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a> dev, <a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a> dev) =&gt; dev -&gt; <a href="System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a> -&gt; <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></li><li class="src short"><a href="#v:hFileSize">hFileSize</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Prelude.html#t:Integer">Integer</a></li><li class="src short"><a href="#v:hSetFileSize">hSetFileSize</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Prelude.html#t:Integer">Integer</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hIsEOF">hIsEOF</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hLookAhead">hLookAhead</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:hSetBuffering">hSetBuffering</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hSetBinaryMode">hSetBinaryMode</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hSetEncoding">hSetEncoding</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hGetEncoding">hGetEncoding</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a>)</li><li class="src short"><a href="#v:hFlush">hFlush</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hFlushAll">hFlushAll</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hDuplicate">hDuplicate</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></li><li class="src short"><a href="#v:hDuplicateTo">hDuplicateTo</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hClose">hClose</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hClose_help">hClose_help</a> :: Handle__ -&gt; <a href="System-IO.html#t:IO">IO</a> (Handle__, <a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Control-Exception-Base.html#t:SomeException">SomeException</a>)</li><li class="src short"><span class="keyword">type</span> <a href="#t:HandlePosition">HandlePosition</a> = <a href="Prelude.html#t:Integer">Integer</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:HandlePosn">HandlePosn</a>  = <a href="#v:HandlePosn">HandlePosn</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a> <a href="GHC-IO-Handle.html#t:HandlePosition">HandlePosition</a></li><li class="src short"><a href="#v:hGetPosn">hGetPosn</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a></li><li class="src short"><a href="#v:hSetPosn">hSetPosn</a> :: <a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:SeekMode">SeekMode</a> <ul class="subs"><li>= <a href="#v:AbsoluteSeek">AbsoluteSeek</a>  </li><li>| <a href="#v:RelativeSeek">RelativeSeek</a>  </li><li>| <a href="#v:SeekFromEnd">SeekFromEnd</a>  </li></ul></li><li class="src short"><a href="#v:hSeek">hSeek</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a> -&gt; <a href="Prelude.html#t:Integer">Integer</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hTell">hTell</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Prelude.html#t:Integer">Integer</a></li><li class="src short"><a href="#v:hIsOpen">hIsOpen</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hIsClosed">hIsClosed</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hIsReadable">hIsReadable</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hIsWritable">hIsWritable</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hGetBuffering">hGetBuffering</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a></li><li class="src short"><a href="#v:hIsSeekable">hIsSeekable</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hSetEcho">hSetEcho</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hGetEcho">hGetEcho</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hIsTerminalDevice">hIsTerminalDevice</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hSetNewlineMode">hSetNewlineMode</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:Newline">Newline</a> <ul class="subs"><li>= <a href="#v:LF">LF</a>  </li><li>| <a href="#v:CRLF">CRLF</a>  </li></ul></li><li class="src short"><span class="keyword">data</span>  <a href="#t:NewlineMode">NewlineMode</a>  = <a href="#v:NewlineMode">NewlineMode</a> {<ul class="subs"><li><a href="#v:inputNL">inputNL</a> :: <a href="GHC-IO-Handle.html#t:Newline">Newline</a></li><li><a href="#v:outputNL">outputNL</a> :: <a href="GHC-IO-Handle.html#t:Newline">Newline</a></li></ul>}</li><li class="src short"><a href="#v:nativeNewline">nativeNewline</a> :: <a href="GHC-IO-Handle.html#t:Newline">Newline</a></li><li class="src short"><a href="#v:noNewlineTranslation">noNewlineTranslation</a> :: <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></li><li class="src short"><a href="#v:universalNewlineMode">universalNewlineMode</a> :: <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></li><li class="src short"><a href="#v:nativeNewlineMode">nativeNewlineMode</a> :: <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></li><li class="src short"><a href="#v:hShow">hShow</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:hWaitForInput">hWaitForInput</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hGetChar">hGetChar</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:hGetLine">hGetLine</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:hGetContents">hGetContents</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:hPutChar">hPutChar</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Char.html#t:Char">Char</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hPutStr">hPutStr</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-String.html#t:String">String</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hGetBuf">hGetBuf</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:hGetBufNonBlocking">hGetBufNonBlocking</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:hPutBuf">hPutBuf</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hPutBufNonBlocking">hPutBufNonBlocking</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Int.html#t:Int">Int</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Handle" class="def">Handle</a>  </p><div class="doc"><p>Haskell defines operations to read and write characters from and to files,
 represented by values of type <code>Handle</code>.  Each value of this type is a
 <em>handle</em>: a record used by the Haskell run-time system to <em>manage</em> I/O
 with file system objects.  A handle has at least the following properties:
</p><ul><li> whether it manages input or output or both;
</li><li> whether it is <em>open</em>, <em>closed</em> or <em>semi-closed</em>;
</li><li> whether the object is seekable;
</li><li> whether buffering is disabled, or enabled on a line or block basis;
</li><li> a buffer (whose length may be zero).
</li></ul><p>Most handles will also have a current I/O position indicating where the next
 input or output operation will occur.  A handle is <em>readable</em> if it
 manages only input or both input and output; likewise, it is <em>writable</em> if
 it manages only output or both input and output.  A handle is <em>open</em> when
 first allocated.
 Once it is closed it can no longer be used for either input or output,
 though an implementation cannot re-use its storage while references
 remain to it.  Handles are in the <code><a href="Text-Show.html#t:Show">Show</a></code> and <code><a href="Data-Eq.html#t:Eq">Eq</a></code> classes.  The string
 produced by showing a handle is system dependent; it should include
 enough information to identify the handle for debugging.  A handle is
 equal according to <code><a href="Data-Eq.html#v:-61--61-">==</a></code> only to itself; no attempt
 is made to compare the internal state of different handles for equality.
</p></div><div class="subs instances"><p id="control.i:Handle" class="caption collapser" onclick="toggleSection('i:Handle')">Instances</p><div id="section.i:Handle" class="show"><table><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:BufferMode" class="def">BufferMode</a>  </p><div class="doc"><p>Three kinds of buffering are supported: line-buffering, 
 block-buffering or no-buffering.  These modes have the following
 effects. For output, items are written out, or <em>flushed</em>,
 from the internal buffer according to the buffer mode:
</p><ul><li> <em>line-buffering</em>: the entire output buffer is flushed
    whenever a newline is output, the buffer overflows, 
    a <code><a href="System-IO.html#v:hFlush">hFlush</a></code> is issued, or the handle is closed.
</li><li> <em>block-buffering</em>: the entire buffer is written out whenever it
    overflows, a <code><a href="System-IO.html#v:hFlush">hFlush</a></code> is issued, or the handle is closed.
</li><li> <em>no-buffering</em>: output is written immediately, and never stored
    in the buffer.
</li></ul><p>An implementation is free to flush the buffer more frequently,
 but not less frequently, than specified above.
 The output buffer is emptied as soon as it has been written out.
</p><p>Similarly, input occurs according to the buffer mode for the handle:
</p><ul><li> <em>line-buffering</em>: when the buffer for the handle is not empty,
    the next item is obtained from the buffer; otherwise, when the
    buffer is empty, characters up to and including the next newline
    character are read into the buffer.  No characters are available
    until the newline character is available or the buffer is full.
</li><li> <em>block-buffering</em>: when the buffer for the handle becomes empty,
    the next block of data is read into the buffer.
</li><li> <em>no-buffering</em>: the next input item is read and returned.
    The <code><a href="System-IO.html#v:hLookAhead">hLookAhead</a></code> operation implies that even a no-buffered
    handle may require a one-character buffer.
</li></ul><p>The default buffering mode when a handle is opened is
 implementation-dependent and may depend on the file system object
 which is attached to that handle.
 For most implementations, physical files will normally be block-buffered 
 and terminals will normally be line-buffered.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:NoBuffering" class="def">NoBuffering</a></td><td class="doc"><p>buffering is disabled if possible.
</p></td></tr><tr><td class="src"><a name="v:LineBuffering" class="def">LineBuffering</a></td><td class="doc"><p>line-buffering should be enabled if possible.
</p></td></tr><tr><td class="src"><a name="v:BlockBuffering" class="def">BlockBuffering</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>block-buffering should be enabled if possible.
 The size of the buffer is <code>n</code> items if the argument
 is <code><a href="Data-Maybe.html#v:Just">Just</a></code> <code>n</code> and is otherwise implementation-dependent.
</p></td></tr></table></div><div class="subs instances"><p id="control.i:BufferMode" class="caption collapser" onclick="toggleSection('i:BufferMode')">Instances</p><div id="section.i:BufferMode" class="show"><table><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ord.html#t:Ord">Ord</a> <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Read.html#t:Read">Read</a> <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:mkFileHandle" class="def">mkFileHandle</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="GHC-IO-Device.html#t:IODevice">IODevice</a> dev, <a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a> dev, <a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a> dev)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">=&gt; dev</td><td class="doc"><p>the underlying IO device, which must support 
 <code><a href="GHC-IO-Device.html#t:IODevice">IODevice</a></code>, <code><a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a></code> and <code><a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a></code>
</p></td></tr><tr><td class="src">-&gt; <a href="System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>a string describing the <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>, e.g. the file
 path for a file.  Used in error messages.
</p></td></tr><tr><td class="src">-&gt; <a href="System-IO.html#t:IOMode">IOMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">-&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">-&gt; <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">-&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>makes a new <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:mkDuplexHandle" class="def">mkDuplexHandle</a> :: (<a href="GHC-IO-Device.html#t:IODevice">IODevice</a> dev, <a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a> dev, <a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a> dev) =&gt; dev -&gt; <a href="System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a> -&gt; <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></p><div class="doc"><p>like <code><a href="GHC-IO-Handle.html#v:mkFileHandle">mkFileHandle</a></code>, except that a <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code> is created with two
 independent buffers, one for reading and one for writing.  Used for
 full-duplex streams, such as network sockets.
</p></div></div><div class="top"><p class="src"><a name="v:hFileSize" class="def">hFileSize</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Prelude.html#t:Integer">Integer</a></p><div class="doc"><p>For a handle <code>hdl</code> which attached to a physical file,
 <code><a href="GHC-IO-Handle.html#v:hFileSize">hFileSize</a></code> <code>hdl</code> returns the size of that file in 8-bit bytes.
</p></div></div><div class="top"><p class="src"><a name="v:hSetFileSize" class="def">hSetFileSize</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Prelude.html#t:Integer">Integer</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p><code><a href="GHC-IO-Handle.html#v:hSetFileSize">hSetFileSize</a></code> <code>hdl</code> <code>size</code> truncates the physical file with handle <code>hdl</code> to <code>size</code> bytes.
</p></div></div><div class="top"><p class="src"><a name="v:hIsEOF" class="def">hIsEOF</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>For a readable handle <code>hdl</code>, <code><a href="GHC-IO-Handle.html#v:hIsEOF">hIsEOF</a></code> <code>hdl</code> returns
 <code><a href="Data-Bool.html#v:True">True</a></code> if no further input can be taken from <code>hdl</code> or for a
 physical file, if the current I/O position is equal to the length of
 the file.  Otherwise, it returns <code><a href="Data-Bool.html#v:False">False</a></code>.
</p><p>NOTE: <code><a href="GHC-IO-Handle.html#v:hIsEOF">hIsEOF</a></code> may block, because it has to attempt to read from
 the stream to determine whether there is any more data to be read.
</p></div></div><div class="top"><p class="src"><a name="v:hLookAhead" class="def">hLookAhead</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Char.html#t:Char">Char</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hLookAhead">hLookAhead</a></code> returns the next character from the handle
 without removing it from the input buffer, blocking until a character
 is available.
</p><p>This operation may fail with:
</p><ul><li> <code>isEOFError</code> if the end of file has been reached.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hSetBuffering" class="def">hSetBuffering</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hSetBuffering">hSetBuffering</a></code> <code>hdl mode</code> sets the mode of buffering for
 handle <code>hdl</code> on subsequent reads and writes.
</p><p>If the buffer mode is changed from <code><a href="GHC-IO-Handle.html#v:BlockBuffering">BlockBuffering</a></code> or
 <code><a href="GHC-IO-Handle.html#v:LineBuffering">LineBuffering</a></code> to <code><a href="GHC-IO-Handle.html#v:NoBuffering">NoBuffering</a></code>, then
</p><ul><li> if <code>hdl</code> is writable, the buffer is flushed as for <code><a href="GHC-IO-Handle.html#v:hFlush">hFlush</a></code>;
</li><li> if <code>hdl</code> is not writable, the contents of the buffer is discarded.
</li></ul><p>This operation may fail with:
</p><ul><li> <code>isPermissionError</code> if the handle has already been used for reading
    or writing and the implementation does not allow the buffering mode
    to be changed.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hSetBinaryMode" class="def">hSetBinaryMode</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Select binary mode (<code><a href="Data-Bool.html#v:True">True</a></code>) or text mode (<code><a href="Data-Bool.html#v:False">False</a></code>) on a open handle.
 (See also <code>openBinaryFile</code>.)
</p><p>This has the same effect as calling <code><a href="GHC-IO-Handle.html#v:hSetEncoding">hSetEncoding</a></code> with <code><a href="GHC-IO-Encoding.html#v:char8">char8</a></code>, together
 with <code><a href="GHC-IO-Handle.html#v:hSetNewlineMode">hSetNewlineMode</a></code> with <code><a href="GHC-IO-Handle.html#v:noNewlineTranslation">noNewlineTranslation</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:hSetEncoding" class="def">hSetEncoding</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>The action <code><a href="GHC-IO-Handle.html#v:hSetEncoding">hSetEncoding</a></code> <code>hdl</code> <code>encoding</code> changes the text encoding
 for the handle <code>hdl</code> to <code>encoding</code>.  The default encoding when a <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code> is
 created is <code>localeEncoding</code>, namely the default encoding for the current
 locale.
</p><p>To create a <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code> with no encoding at all, use <code>openBinaryFile</code>.  To
 stop further encoding or decoding on an existing <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>, use
 <code><a href="GHC-IO-Handle.html#v:hSetBinaryMode">hSetBinaryMode</a></code>.
</p><p><code><a href="GHC-IO-Handle.html#v:hSetEncoding">hSetEncoding</a></code> may need to flush buffered data in order to change
 the encoding.
</p></div></div><div class="top"><p class="src"><a name="v:hGetEncoding" class="def">hGetEncoding</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a>)</p><div class="doc"><p>Return the current <code><a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></code> for the specified <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>, or
 <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code> if the <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code> is in binary mode.
</p><p>Note that the <code><a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></code> remembers nothing about the state of
 the encoder/decoder in use on this <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>.  For example, if the
 encoding in use is UTF-16, then using <code><a href="GHC-IO-Handle.html#v:hGetEncoding">hGetEncoding</a></code> and
 <code><a href="GHC-IO-Handle.html#v:hSetEncoding">hSetEncoding</a></code> to save and restore the encoding may result in an
 extra byte-order-mark being written to the file.
</p></div></div><div class="top"><p class="src"><a name="v:hFlush" class="def">hFlush</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>The action <code><a href="GHC-IO-Handle.html#v:hFlush">hFlush</a></code> <code>hdl</code> causes any items buffered for output
 in handle <code>hdl</code> to be sent immediately to the operating system.
</p><p>This operation may fail with:
</p><ul><li> <code>isFullError</code> if the device is full;
</li><li> <code>isPermissionError</code> if a system resource limit would be exceeded.
    It is unspecified whether the characters in the buffer are discarded
    or retained under these circumstances.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hFlushAll" class="def">hFlushAll</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>The action <code><a href="GHC-IO-Handle.html#v:hFlushAll">hFlushAll</a></code> <code>hdl</code> flushes all buffered data in <code>hdl</code>,
 including any buffered read data.  Buffered read data is flushed
 by seeking the file position back to the point before the bufferred
 data was read, and hence only works if <code>hdl</code> is seekable (see
 <code><a href="GHC-IO-Handle.html#v:hIsSeekable">hIsSeekable</a></code>).
</p><p>This operation may fail with:
</p><ul><li> <code>isFullError</code> if the device is full;
</li><li> <code>isPermissionError</code> if a system resource limit would be exceeded.
    It is unspecified whether the characters in the buffer are discarded
    or retained under these circumstances;
</li><li> <code>isIllegalOperation</code> if <code>hdl</code> has buffered read data, and is not
    seekable.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hDuplicate" class="def">hDuplicate</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a></p><div class="doc"><p>Returns a duplicate of the original handle, with its own buffer.
 The two Handles will share a file pointer, however.  The original
 handle's buffer is flushed, including discarding any input data,
 before the handle is duplicated.
</p></div></div><div class="top"><p class="src"><a name="v:hDuplicateTo" class="def">hDuplicateTo</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Makes the second handle a duplicate of the first handle.  The second 
handle will be closed first, if it is not already.
</p><p>This can be used to retarget the standard Handles, for example:
</p><pre> do h &lt;- openFile &quot;mystdout&quot; WriteMode
    hDuplicateTo h stdout
</pre></div></div><div class="top"><p class="src"><a name="v:hClose" class="def">hClose</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hClose">hClose</a></code> <code>hdl</code> makes handle <code>hdl</code> closed.  Before the
 computation finishes, if <code>hdl</code> is writable its buffer is flushed as
 for <code><a href="GHC-IO-Handle.html#v:hFlush">hFlush</a></code>.
 Performing <code><a href="GHC-IO-Handle.html#v:hClose">hClose</a></code> on a handle that has already been closed has no effect; 
 doing so is not an error.  All other operations on a closed handle will fail.
 If <code><a href="GHC-IO-Handle.html#v:hClose">hClose</a></code> fails for any reason, any further operations (apart from
 <code><a href="GHC-IO-Handle.html#v:hClose">hClose</a></code>) on the handle will still fail as if <code>hdl</code> had been successfully
 closed.
</p></div></div><div class="top"><p class="src"><a name="v:hClose_help" class="def">hClose_help</a> :: Handle__ -&gt; <a href="System-IO.html#t:IO">IO</a> (Handle__, <a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Control-Exception-Base.html#t:SomeException">SomeException</a>)</p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:HandlePosition" class="def">HandlePosition</a> = <a href="Prelude.html#t:Integer">Integer</a></p></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:HandlePosn" class="def">HandlePosn</a>  </p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:HandlePosn" class="def">HandlePosn</a> <a href="GHC-IO-Handle.html#t:Handle">Handle</a> <a href="GHC-IO-Handle.html#t:HandlePosition">HandlePosition</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:HandlePosn" class="caption collapser" onclick="toggleSection('i:HandlePosn')">Instances</p><div id="section.i:HandlePosn" class="show"><table><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> <a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:hGetPosn" class="def">hGetPosn</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hGetPosn">hGetPosn</a></code> <code>hdl</code> returns the current I/O position of
 <code>hdl</code> as a value of the abstract type <code><a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:hSetPosn" class="def">hSetPosn</a> :: <a href="GHC-IO-Handle.html#t:HandlePosn">HandlePosn</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>If a call to <code><a href="GHC-IO-Handle.html#v:hGetPosn">hGetPosn</a></code> <code>hdl</code> returns a position <code>p</code>,
 then computation <code><a href="GHC-IO-Handle.html#v:hSetPosn">hSetPosn</a></code> <code>p</code> sets the position of <code>hdl</code>
 to the position it held at the time of the call to <code><a href="GHC-IO-Handle.html#v:hGetPosn">hGetPosn</a></code>.
</p><p>This operation may fail with:
</p><ul><li> <code>isPermissionError</code> if a system resource limit would be exceeded.
</li></ul></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:SeekMode" class="def">SeekMode</a>  </p><div class="doc"><p>A mode that determines the effect of <code>hSeek</code> <code>hdl mode i</code>.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:AbsoluteSeek" class="def">AbsoluteSeek</a></td><td class="doc"><p>the position of <code>hdl</code> is set to <code>i</code>.
</p></td></tr><tr><td class="src"><a name="v:RelativeSeek" class="def">RelativeSeek</a></td><td class="doc"><p>the position of <code>hdl</code> is set to offset <code>i</code>
 from the current position.
</p></td></tr><tr><td class="src"><a name="v:SeekFromEnd" class="def">SeekFromEnd</a></td><td class="doc"><p>the position of <code>hdl</code> is set to offset <code>i</code>
 from the end of the file.
</p></td></tr></table></div><div class="subs instances"><p id="control.i:SeekMode" class="caption collapser" onclick="toggleSection('i:SeekMode')">Instances</p><div id="section.i:SeekMode" class="show"><table><tr><td class="src"><a href="Prelude.html#t:Enum">Enum</a> <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ord.html#t:Ord">Ord</a> <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Read.html#t:Read">Read</a> <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:hSeek" class="def">hSeek</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:SeekMode">SeekMode</a> -&gt; <a href="Prelude.html#t:Integer">Integer</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hSeek">hSeek</a></code> <code>hdl mode i</code> sets the position of handle
 <code>hdl</code> depending on <code>mode</code>.
 The offset <code>i</code> is given in terms of 8-bit bytes.
</p><p>If <code>hdl</code> is block- or line-buffered, then seeking to a position which is not
 in the current buffer will first cause any items in the output buffer to be
 written to the device, and then cause the input buffer to be discarded.
 Some handles may not be seekable (see <code><a href="GHC-IO-Handle.html#v:hIsSeekable">hIsSeekable</a></code>), or only support a
 subset of the possible positioning operations (for instance, it may only
 be possible to seek to the end of a tape, or to a positive offset from
 the beginning or current position).
 It is not possible to set a negative I/O position, or for
 a physical file, an I/O position beyond the current end-of-file.
</p><p>This operation may fail with:
</p><ul><li> <code>isIllegalOperationError</code> if the Handle is not seekable, or does
     not support the requested seek mode.
</li><li> <code>isPermissionError</code> if a system resource limit would be exceeded.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hTell" class="def">hTell</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Prelude.html#t:Integer">Integer</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hTell">hTell</a></code> <code>hdl</code> returns the current position of the
 handle <code>hdl</code>, as the number of bytes from the beginning of
 the file.  The value returned may be subsequently passed to
 <code><a href="GHC-IO-Handle.html#v:hSeek">hSeek</a></code> to reposition the handle to the current position.
</p><p>This operation may fail with:
</p><ul><li> <code>isIllegalOperationError</code> if the Handle is not seekable.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hIsOpen" class="def">hIsOpen</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:hIsClosed" class="def">hIsClosed</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:hIsReadable" class="def">hIsReadable</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:hIsWritable" class="def">hIsWritable</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:hGetBuffering" class="def">hGetBuffering</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="GHC-IO-Handle.html#t:BufferMode">BufferMode</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hGetBuffering">hGetBuffering</a></code> <code>hdl</code> returns the current buffering mode
 for <code>hdl</code>.
</p></div></div><div class="top"><p class="src"><a name="v:hIsSeekable" class="def">hIsSeekable</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:hSetEcho" class="def">hSetEcho</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Set the echoing status of a handle connected to a terminal.
</p></div></div><div class="top"><p class="src"><a name="v:hGetEcho" class="def">hGetEcho</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Get the echoing status of a handle connected to a terminal.
</p></div></div><div class="top"><p class="src"><a name="v:hIsTerminalDevice" class="def">hIsTerminalDevice</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is the handle connected to a terminal?
</p></div></div><div class="top"><p class="src"><a name="v:hSetNewlineMode" class="def">hSetNewlineMode</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Set the <code><a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></code> on the specified <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>.  All buffered
 data is flushed first.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Newline" class="def">Newline</a>  </p><div class="doc"><p>The representation of a newline in the external file or stream.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:LF" class="def">LF</a></td><td class="doc"><p>'\n'
</p></td></tr><tr><td class="src"><a name="v:CRLF" class="def">CRLF</a></td><td class="doc"><p>'\r\n'
</p></td></tr></table></div><div class="subs instances"><p id="control.i:Newline" class="caption collapser" onclick="toggleSection('i:Newline')">Instances</p><div id="section.i:Newline" class="show"><table><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> <a href="GHC-IO-Handle.html#t:Newline">Newline</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ord.html#t:Ord">Ord</a> <a href="GHC-IO-Handle.html#t:Newline">Newline</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Read.html#t:Read">Read</a> <a href="GHC-IO-Handle.html#t:Newline">Newline</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Handle.html#t:Newline">Newline</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:NewlineMode" class="def">NewlineMode</a>  </p><div class="doc"><p>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.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:NewlineMode" class="def">NewlineMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:inputNL" class="def">inputNL</a> :: <a href="GHC-IO-Handle.html#t:Newline">Newline</a></dt><dd class="doc"><p>the representation of newlines on input
</p></dd><dt class="src"><a name="v:outputNL" class="def">outputNL</a> :: <a href="GHC-IO-Handle.html#t:Newline">Newline</a></dt><dd class="doc"><p>the representation of newlines on output
</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:NewlineMode" class="caption collapser" onclick="toggleSection('i:NewlineMode')">Instances</p><div id="section.i:NewlineMode" class="show"><table><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ord.html#t:Ord">Ord</a> <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Read.html#t:Read">Read</a> <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:nativeNewline" class="def">nativeNewline</a> :: <a href="GHC-IO-Handle.html#t:Newline">Newline</a></p><div class="doc"><p>The native newline representation for the current platform: <code><a href="GHC-IO-Handle.html#v:LF">LF</a></code>
 on Unix systems, <code><a href="GHC-IO-Handle.html#v:CRLF">CRLF</a></code> on Windows.
</p></div></div><div class="top"><p class="src"><a name="v:noNewlineTranslation" class="def">noNewlineTranslation</a> :: <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></p><div class="doc"><p>Do no newline translation at all.
</p><pre> noNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
</pre></div></div><div class="top"><p class="src"><a name="v:universalNewlineMode" class="def">universalNewlineMode</a> :: <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></p><div class="doc"><p>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 <code>readFile &gt;&gt;= writeFile</code> might yield a different file.
</p><pre> universalNewlineMode  = NewlineMode { inputNL  = CRLF, 
                                       outputNL = nativeNewline }
</pre></div></div><div class="top"><p class="src"><a name="v:nativeNewlineMode" class="def">nativeNewlineMode</a> :: <a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></p><div class="doc"><p>Use the native newline representation on both input and output
</p><pre> nativeNewlineMode  = NewlineMode { inputNL  = nativeNewline
                                    outputNL = nativeNewline }
</pre></div></div><div class="top"><p class="src"><a name="v:hShow" class="def">hShow</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-String.html#t:String">String</a></p><div class="doc"><p><code><a href="GHC-IO-Handle.html#v:hShow">hShow</a></code> is in the <code><a href="System-IO.html#t:IO">IO</a></code> monad, and gives more comprehensive output
 than the (pure) instance of <code><a href="Text-Show.html#t:Show">Show</a></code> for <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:hWaitForInput" class="def">hWaitForInput</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hWaitForInput">hWaitForInput</a></code> <code>hdl t</code>
 waits until input is available on handle <code>hdl</code>.
 It returns <code><a href="Data-Bool.html#v:True">True</a></code> as soon as input is available on <code>hdl</code>,
 or <code><a href="Data-Bool.html#v:False">False</a></code> if no input is available within <code>t</code> milliseconds.  Note that
 <code><a href="GHC-IO-Handle.html#v:hWaitForInput">hWaitForInput</a></code> waits until one or more full <em>characters</em> are available,
 which means that it needs to do decoding, and hence may fail
 with a decoding error.
</p><p>If <code>t</code> is less than zero, then <code>hWaitForInput</code> waits indefinitely.
</p><p>This operation may fail with:
</p><ul><li> <code><a href="System-IO-Error.html#v:isEOFError">isEOFError</a></code> if the end of file has been reached.
</li><li> a decoding error, if the input begins with an invalid byte sequence
    in this Handle's encoding.
</li></ul><p>NOTE for GHC users: unless you use the <code>-threaded</code> flag,
 <code>hWaitForInput t</code> where <code>t &gt;= 0</code> will block all other Haskell
 threads for the duration of the call.  It behaves like a
 <code>safe</code> foreign call in this respect.
</p></div></div><div class="top"><p class="src"><a name="v:hGetChar" class="def">hGetChar</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Char.html#t:Char">Char</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hGetChar">hGetChar</a></code> <code>hdl</code> reads a character from the file or
 channel managed by <code>hdl</code>, blocking until a character is available.
</p><p>This operation may fail with:
</p><ul><li> <code><a href="System-IO-Error.html#v:isEOFError">isEOFError</a></code> if the end of file has been reached.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hGetLine" class="def">hGetLine</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-String.html#t:String">String</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hGetLine">hGetLine</a></code> <code>hdl</code> reads a line from the file or
 channel managed by <code>hdl</code>.
</p><p>This operation may fail with:
</p><ul><li> <code><a href="System-IO-Error.html#v:isEOFError">isEOFError</a></code> if the end of file is encountered when reading
    the <em>first</em> character of the line.
</li></ul><p>If <code><a href="GHC-IO-Handle.html#v:hGetLine">hGetLine</a></code> encounters end-of-file at any other point while reading
 in a line, it is treated as a line terminator and the (partial)
 line is returned.
</p></div></div><div class="top"><p class="src"><a name="v:hGetContents" class="def">hGetContents</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-String.html#t:String">String</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hGetContents">hGetContents</a></code> <code>hdl</code> returns the list of characters
 corresponding to the unread portion of the channel or file managed
 by <code>hdl</code>, which is put into an intermediate state, <em>semi-closed</em>.
 In this state, <code>hdl</code> is effectively closed,
 but items are read from <code>hdl</code> on demand and accumulated in a special
 list returned by <code><a href="GHC-IO-Handle.html#v:hGetContents">hGetContents</a></code> <code>hdl</code>.
</p><p>Any operation that fails because a handle is closed,
 also fails if a handle is semi-closed.  The only exception is <code>hClose</code>.
 A semi-closed handle becomes closed:
</p><ul><li> if <code>hClose</code> is applied to it;
</li><li> if an I/O error occurs when reading an item from the handle;
</li><li> or once the entire contents of the handle has been read.
</li></ul><p>Once a semi-closed handle becomes closed, the contents of the
 associated list becomes fixed.  The contents of this final list is
 only partially specified: it will contain at least all the items of
 the stream that were evaluated prior to the handle becoming closed.
</p><p>Any I/O errors encountered while a handle is semi-closed are simply
 discarded.
</p><p>This operation may fail with:
</p><ul><li> <code><a href="System-IO-Error.html#v:isEOFError">isEOFError</a></code> if the end of file has been reached.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hPutChar" class="def">hPutChar</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-Char.html#t:Char">Char</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hPutChar">hPutChar</a></code> <code>hdl ch</code> writes the character <code>ch</code> to the
 file or channel managed by <code>hdl</code>.  Characters may be buffered if
 buffering is enabled for <code>hdl</code>.
</p><p>This operation may fail with:
</p><ul><li> <code><a href="System-IO-Error.html#v:isFullError">isFullError</a></code> if the device is full; or
</li><li> <code><a href="System-IO-Error.html#v:isPermissionError">isPermissionError</a></code> if another system resource limit would be exceeded.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hPutStr" class="def">hPutStr</a> :: <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Data-String.html#t:String">String</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Computation <code><a href="GHC-IO-Handle.html#v:hPutStr">hPutStr</a></code> <code>hdl s</code> writes the string
 <code>s</code> to the file or channel managed by <code>hdl</code>.
</p><p>This operation may fail with:
</p><ul><li> <code><a href="System-IO-Error.html#v:isFullError">isFullError</a></code> if the device is full; or
</li><li> <code><a href="System-IO-Error.html#v:isPermissionError">isPermissionError</a></code> if another system resource limit would be exceeded.
</li></ul></div></div><div class="top"><p class="src"><a name="v:hGetBuf" class="def">hGetBuf</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Int.html#t:Int">Int</a></p><div class="doc"><p><code><a href="GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code> <code>hdl buf count</code> reads data from the handle <code>hdl</code>
 into the buffer <code>buf</code> until either EOF is reached or
 <code>count</code> 8-bit bytes have been read.
 It returns the number of bytes actually read.  This may be zero if
 EOF was reached before any data was read (or if <code>count</code> is zero).
</p><p><code><a href="GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code> never raises an EOF exception, instead it returns a value
 smaller than <code>count</code>.
</p><p>If the handle is a pipe or socket, and the writing end
 is closed, <code><a href="GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code> will behave as if EOF was reached.
</p><p><code><a href="GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code> ignores the prevailing <code>TextEncoding</code> and <code><a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></code>
 on the <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>, and reads bytes directly.
</p></div></div><div class="top"><p class="src"><a name="v:hGetBufNonBlocking" class="def">hGetBufNonBlocking</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Int.html#t:Int">Int</a></p><div class="doc"><p><code><a href="GHC-IO-Handle.html#v:hGetBufNonBlocking">hGetBufNonBlocking</a></code> <code>hdl buf count</code> reads data from the handle <code>hdl</code>
 into the buffer <code>buf</code> until either EOF is reached, or
 <code>count</code> 8-bit bytes have been read, or there is no more data available
 to read immediately.
</p><p><code><a href="GHC-IO-Handle.html#v:hGetBufNonBlocking">hGetBufNonBlocking</a></code> is identical to <code><a href="GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code>, except that it will
 never block waiting for data to become available, instead it returns
 only whatever data is available.  To wait for data to arrive before
 calling <code><a href="GHC-IO-Handle.html#v:hGetBufNonBlocking">hGetBufNonBlocking</a></code>, use <code><a href="GHC-IO-Handle.html#v:hWaitForInput">hWaitForInput</a></code>.
</p><p>If the handle is a pipe or socket, and the writing end
 is closed, <code><a href="GHC-IO-Handle.html#v:hGetBufNonBlocking">hGetBufNonBlocking</a></code> will behave as if EOF was reached.
</p><p><code><a href="GHC-IO-Handle.html#v:hGetBufNonBlocking">hGetBufNonBlocking</a></code> ignores the prevailing <code>TextEncoding</code> and
 <code><a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></code> on the <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>, and reads bytes directly.
</p><p>NOTE: on Windows, this function does not work correctly; it
 behaves identically to <code><a href="GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:hPutBuf" class="def">hPutBuf</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p><code><a href="GHC-IO-Handle.html#v:hPutBuf">hPutBuf</a></code> <code>hdl buf count</code> writes <code>count</code> 8-bit bytes from the
 buffer <code>buf</code> to the handle <code>hdl</code>.  It returns ().
</p><p><code><a href="GHC-IO-Handle.html#v:hPutBuf">hPutBuf</a></code> ignores any text encoding that applies to the <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>,
 writing the bytes directly to the underlying file or device.
</p><p><code><a href="GHC-IO-Handle.html#v:hPutBuf">hPutBuf</a></code> ignores the prevailing <code>TextEncoding</code> and
 <code><a href="GHC-IO-Handle.html#t:NewlineMode">NewlineMode</a></code> on the <code><a href="GHC-IO-Handle.html#t:Handle">Handle</a></code>, and writes bytes directly.
</p><p>This operation may fail with:
</p><ul><li> <code>ResourceVanished</code> if the handle is a pipe or socket, and the
    reading end is closed.  (If this is a POSIX system, and the program
    has not asked to ignore SIGPIPE, then a SIGPIPE may be delivered
    instead, whose default action is to terminate the program).
</li></ul></div></div><div class="top"><p class="src"><a name="v:hPutBufNonBlocking" class="def">hPutBufNonBlocking</a> ::  <a href="GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Int.html#t:Int">Int</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>