<!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.BufferedIO</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-BufferedIO.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.3.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (GHC Extensions)</td></tr><tr><th>Stability</th><td>internal</td></tr><tr><th>Maintainer</th><td>cvs-ghc@haskell.org</td></tr></table><p class="caption">GHC.IO.BufferedIO</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Class of buffered IO devices </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">class</span> <a href="#t:BufferedIO">BufferedIO</a> dev <span class="keyword">where</span><ul class="subs"><li><a href="#v:newBuffer">newBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:BufferState">BufferState</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li><a href="#v:fillReadBuffer">fillReadBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li><a href="#v:fillReadBuffer0">fillReadBuffer0</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li><a href="#v:emptyWriteBuffer">emptyWriteBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li><a href="#v:flushWriteBuffer">flushWriteBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li><a href="#v:flushWriteBuffer0">flushWriteBuffer0</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li></ul></li><li class="src short"><a href="#v:readBuf">readBuf</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li class="src short"><a href="#v:readBufNonBlocking">readBufNonBlocking</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li class="src short"><a href="#v:writeBuf">writeBuf</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li class="src short"><a href="#v:writeBufNonBlocking">writeBufNonBlocking</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:BufferedIO" class="def">BufferedIO</a> dev <span class="keyword">where</span></p><div class="doc"><p>The purpose of <code><a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a></code> is to provide a common interface for I/O devices that can read and write data through a buffer. Devices that implement <code><a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a></code> include ordinary files, memory-mapped files, and bytestrings. The underlying device implementing a <code>Handle</code> must provide <code><a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a></code>. </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:newBuffer" class="def">newBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:BufferState">BufferState</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p><div class="doc"><p>allocate a new buffer. The size of the buffer is at the discretion of the device; e.g. for a memory-mapped file the buffer will probably cover the entire file. </p></div><p class="src"><a name="v:fillReadBuffer" class="def">fillReadBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p><div class="doc"><p>reads bytes into the buffer, blocking if there are no bytes available. Returns the number of bytes read (zero indicates end-of-file), and the new buffer. </p></div><p class="src"><a name="v:fillReadBuffer0" class="def">fillReadBuffer0</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p><div class="doc"><p>reads bytes into the buffer without blocking. Returns the number of bytes read (Nothing indicates end-of-file), and the new buffer. </p></div><p class="src"><a name="v:emptyWriteBuffer" class="def">emptyWriteBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p><div class="doc"><p>Prepares an empty write buffer. This lets the device decide how to set up a write buffer: the buffer may need to point to a specific location in memory, for example. This is typically used by the client when switching from reading to writing on a buffered read/write device. </p><p>There is no corresponding operation for read buffers, because before reading the client will always call <code><a href="GHC-IO-BufferedIO.html#v:fillReadBuffer">fillReadBuffer</a></code>. </p></div><p class="src"><a name="v:flushWriteBuffer" class="def">flushWriteBuffer</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p><div class="doc"><p>Flush all the data from the supplied write buffer out to the device. The returned buffer should be empty, and ready for writing. </p></div><p class="src"><a name="v:flushWriteBuffer0" class="def">flushWriteBuffer0</a> :: dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p><div class="doc"><p>Flush data from the supplied write buffer out to the device without blocking. Returns the number of bytes written and the remaining buffer. </p></div></div><div class="subs instances"><p id="control.i:BufferedIO" class="caption collapser" onclick="toggleSection('i:BufferedIO')">Instances</p><div id="section.i:BufferedIO" class="show"><table><tr><td class="src"><a href="GHC-IO-BufferedIO.html#t:BufferedIO">BufferedIO</a> FD</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:readBuf" class="def">readBuf</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p></div><div class="top"><p class="src"><a name="v:readBufNonBlocking" class="def">readBufNonBlocking</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> <a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p></div><div class="top"><p class="src"><a name="v:writeBuf" class="def">writeBuf</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p></div><div class="top"><p class="src"><a name="v:writeBufNonBlocking" class="def">writeBufNonBlocking</a> :: <a href="GHC-IO-Device.html#t:RawIO">RawIO</a> dev => dev -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Int.html#t:Int">Int</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>