45 lines
32 KiB
HTML
45 lines
32 KiB
HTML
<!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>System.IO.Binary</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_System-IO-Binary.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">MissingH-1.3.0.1: Large utility library</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>Copyright (C) 2004-2011 John Goerzen</td></tr><tr><th>License</th><td>BSD3</td></tr><tr><th>Maintainer</th><td>John Goerzen <jgoerzen@complete.org></td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Portability</th><td>portable to platforms supporting binary I\/O</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">System.IO.Binary</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Support for different types of blocks</a></li><li><a href="#g:2">Entire File/Handle Utilities</a><ul><li><a href="#g:3">Opened Handle Data Copying</a></li><li><a href="#g:4">Disk File Data Copying</a></li></ul></li><li><a href="#g:5">Binary Single-Block I/O</a></li><li><a href="#g:6">Binary Multi-Block I/O</a></li><li><a href="#g:7">Lazy Interaction</a><ul><li><a href="#g:8">Binary Block-based</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module provides various helpful utilities for dealing with binary
|
|
input and output.</p><p>You can use this module to deal with binary blocks of data as either Strings
|
|
or lists of Word8. The BinaryConvertible class provides this abstraction.</p><p>Wherever you see HVIO, you can transparently substite a regular Handle.
|
|
This module can work with any HVIO object, however. See
|
|
<a href="System-IO-HVIO.html">System.IO.HVIO</a> for more details.</p><p>Versions of MissingH prior 0.11.6 lacked the <code><a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a></code> class
|
|
and worked only with Strings and Handles.</p><p>Important note: /binary functions are not supported in all Haskell
|
|
implementations/. Do not import or use this module unless you know you
|
|
are using an implementation that supports them. At this time, here
|
|
is the support status:</p><ul><li>GHC 6.2 and above: yes</li><li>GHC 6.x, earlier versions: unknown</li><li>GHC 5.x: no</li><li>nhc98: no</li><li>Hugs: partial (maybe complete; needs more testing)</li></ul><p>Non-binary functions may be found in <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html">System.IO</a>.</p><p>See also: <a href="System-IO-BlockIO.html">System.IO.BlockIO</a></p><p>Written by John Goerzen, jgoerzen@complete.org</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="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> a) => <a href="#t:BinaryConvertible">BinaryConvertible</a> a <span class="keyword">where</span><ul class="subs"><li><a href="#v:toBuf">toBuf</a> :: [a] -> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-C-Types.html#t:CChar">CChar</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> c) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> c</li><li><a href="#v:fromBuf">fromBuf</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-C-Types.html#t:CChar">CChar</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a>) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [a]</li></ul></li><li class="src short"><a href="#v:hBlockCopy">hBlockCopy</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-HVIO.html#t:HVIO">HVIO</a> b) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> a -> b -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:blockCopy">blockCopy</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:copyFileBlocksToFile">copyFileBlocksToFile</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:hPutBufStr">hPutBufStr</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> [b] -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:putBufStr">putBufStr</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => [b] -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:hGetBufStr">hGetBufStr</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</li><li class="src short"><a href="#v:getBufStr">getBufStr</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</li><li class="src short"><a href="#v:hFullGetBufStr">hFullGetBufStr</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</li><li class="src short"><a href="#v:fullGetBufStr">fullGetBufStr</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</li><li class="src short"><a href="#v:hGetBlocks">hGetBlocks</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</li><li class="src short"><a href="#v:getBlocks">getBlocks</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</li><li class="src short"><a href="#v:hFullGetBlocks">hFullGetBlocks</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</li><li class="src short"><a href="#v:fullGetBlocks">fullGetBlocks</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</li><li class="src short"><a href="#v:readBinaryFile">readBinaryFile</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:writeBinaryFile">writeBinaryFile</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:hBlockInteract">hBlockInteract</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-HVIO.html#t:HVIO">HVIO</a> d, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> a -> d -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:blockInteract">blockInteract</a> :: (<a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:hFullBlockInteract">hFullBlockInteract</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-HVIO.html#t:HVIO">HVIO</a> d, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> a -> d -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:fullBlockInteract">fullBlockInteract</a> :: (<a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li></ul></div><div id="interface"><h1 id="g:1">Support for different types of blocks</h1><div class="top"><p class="src"><span class="keyword">class</span> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> a) => <a name="t:BinaryConvertible" class="def">BinaryConvertible</a> a <span class="keyword">where</span></p><div class="doc"><p>Provides support for handling binary blocks with convenient
|
|
types.</p><p>This module provides implementations for Strings and for [Word8] (lists of
|
|
Word8s). </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:toBuf" class="def">toBuf</a> :: [a] -> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-C-Types.html#t:CChar">CChar</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> c) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> c</p><p class="src"><a name="v:fromBuf" class="def">fromBuf</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Foreign-C-Types.html#t:CChar">CChar</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a>) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [a]</p></div><div class="subs instances"><p id="control.i:BinaryConvertible" class="caption collapser" onclick="toggleSection('i:BinaryConvertible')">Instances</p><div id="section.i:BinaryConvertible" class="show"><table><tr><td class="src"><a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Char.html#t:Char">Char</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Word.html#t:Word8">Word8</a></td><td class="doc empty"> </td></tr></table></div></div></div><h1 id="g:2">Entire File/Handle Utilities</h1><h2 id="g:3">Opened Handle Data Copying</h2><div class="top"><p class="src"><a name="v:hBlockCopy" class="def">hBlockCopy</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-HVIO.html#t:HVIO">HVIO</a> b) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> a -> b -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Copies everything from the input handle to the output handle using binary
|
|
blocks of the given size. This was once the following
|
|
beautiful implementation:</p><pre>hBlockCopy bs hin hout = hBlockInteract bs hin hout id</pre><p>(<code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Function.html#v:id">id</a></code> is the built-in Haskell function that just returns whatever is given
|
|
to it)</p><p>In more recent versions of MissingH, it uses a more optimized routine that
|
|
avoids ever having to convert the binary buffer at all.</p></div></div><div class="top"><p class="src"><a name="v:blockCopy" class="def">blockCopy</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Copies from <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code> to <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdout">stdout</a></code> using binary blocks of the given size.
|
|
An alias for <code><a href="System-IO-Binary.html#v:hBlockCopy">hBlockCopy</a></code> over <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code> and <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdout">stdout</a></code></p></div></div><h2 id="g:4">Disk File Data Copying</h2><div class="top"><p class="src"><a name="v:copyFileBlocksToFile" class="def">copyFileBlocksToFile</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Copies one filename to another in binary mode.</p><p>Please note that the Unix permission bits on the output file cannot
|
|
be set due to a limitation of the Haskell <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:openBinaryFile">openBinaryFile</a></code>
|
|
function. Therefore, you may need to adjust those bits after the copy
|
|
yourself.</p><p>This function is implemented using <code><a href="System-IO-Binary.html#v:hBlockCopy">hBlockCopy</a></code> internally. </p></div></div><h1 id="g:5">Binary Single-Block I/O</h1><div class="top"><p class="src"><a name="v:hPutBufStr" class="def">hPutBufStr</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> [b] -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>As a wrapper around the standard function <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#v:hPutBuf">hPutBuf</a></code>,
|
|
this function takes a standard Haskell <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></code> instead of the far less
|
|
convenient <code>Ptr a</code>. The entire contents of the string will be written
|
|
as a binary buffer using <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#v:hPutBuf">hPutBuf</a></code>. The length of the output will be
|
|
the length of the passed String or list.</p><p>If it helps, you can thing of this function as being of type
|
|
<code>Handle -> String -> IO ()</code> </p></div></div><div class="top"><p class="src"><a name="v:putBufStr" class="def">putBufStr</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => [b] -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hPutBufStr">hPutBufStr</a></code> <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdout">stdout</a></code></p></div></div><div class="top"><p class="src"><a name="v:hGetBufStr" class="def">hGetBufStr</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</p><div class="doc"><p>Acts a wrapper around the standard function <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code>,
|
|
this function returns a standard Haskell String (or [Word8]) instead of
|
|
modifying
|
|
a 'Ptr a' buffer. The length is the maximum length to read and the
|
|
semantice are the same as with <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#v:hGetBuf">hGetBuf</a></code>; namely, the empty string
|
|
is returned with EOF is reached, and any given read may read fewer
|
|
bytes than the given length.</p><p>(Actually, it's a wrapper around <code><a href="System-IO-HVIO.html#v:vGetBuf">vGetBuf</a></code>) </p></div></div><div class="top"><p class="src"><a name="v:getBufStr" class="def">getBufStr</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hGetBufStr">hGetBufStr</a></code> <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code></p></div></div><div class="top"><p class="src"><a name="v:hFullGetBufStr" class="def">hFullGetBufStr</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</p><div class="doc"><p>Like <code><a href="System-IO-Binary.html#v:hGetBufStr">hGetBufStr</a></code>, but guarantees that it will only return fewer than
|
|
the requested number of bytes when EOF is encountered. </p></div></div><div class="top"><p class="src"><a name="v:fullGetBufStr" class="def">fullGetBufStr</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [b]</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hFullGetBufStr">hFullGetBufStr</a></code> <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code></p></div></div><h1 id="g:6">Binary Multi-Block I/O</h1><div class="top"><p class="src"><a name="v:hGetBlocks" class="def">hGetBlocks</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</p><div class="doc"><p>An alias for <code>hPutBlocks</code> <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdout">stdout</a></code>
|
|
putBlocks :: (BinaryConvertible b) => [[b]] -> IO ()
|
|
putBlocks = hPutBlocks stdout </p><p>Returns a lazily-evaluated list of all blocks in the input file,
|
|
as read by <code><a href="System-IO-Binary.html#v:hGetBufStr">hGetBufStr</a></code>. There will be no 0-length block in this list.
|
|
The list simply ends at EOF. </p></div></div><div class="top"><p class="src"><a name="v:getBlocks" class="def">getBlocks</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hGetBlocks">hGetBlocks</a></code> <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code></p></div></div><div class="top"><p class="src"><a name="v:hFullGetBlocks" class="def">hFullGetBlocks</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b) => a -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</p><div class="doc"><p>Same as <code><a href="System-IO-Binary.html#v:hGetBlocks">hGetBlocks</a></code>, but using <code><a href="System-IO-Binary.html#v:hFullGetBufStr">hFullGetBufStr</a></code> underneath. </p></div></div><div class="top"><p class="src"><a name="v:fullGetBlocks" class="def">fullGetBlocks</a> :: <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> [[b]]</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hFullGetBlocks">hFullGetBlocks</a></code> <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code></p></div></div><h1 id="g:7">Lazy Interaction</h1><div class="top"><p class="src"><a name="v:readBinaryFile" class="def">readBinaryFile</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></p><div class="doc"><p>Like the built-in <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#v:readFile">readFile</a></code>, but opens the file in binary instead
|
|
of text mode. </p></div></div><div class="top"><p class="src"><a name="v:writeBinaryFile" class="def">writeBinaryFile</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Like the built-in <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#v:writeFile">writeFile</a></code>, but opens the file in binary instead
|
|
of text mode. </p></div></div><h2 id="g:8">Binary Block-based</h2><div class="top"><p class="src"><a name="v:hBlockInteract" class="def">hBlockInteract</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-HVIO.html#t:HVIO">HVIO</a> d, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> a -> d -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Binary block-based interaction. This is useful for scenarios that
|
|
take binary blocks, manipulate them in some way, and then write them
|
|
out. Take a look at <code><a href="System-IO-Binary.html#v:hBlockCopy">hBlockCopy</a></code> for an example. The integer argument
|
|
is the size of input binary blocks. This function uses <code><a href="System-IO-Binary.html#v:hGetBlocks">hGetBlocks</a></code>
|
|
internally.</p></div></div><div class="top"><p class="src"><a name="v:blockInteract" class="def">blockInteract</a> :: (<a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hBlockInteract">hBlockInteract</a></code> over <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code> and <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdout">stdout</a></code></p></div></div><div class="top"><p class="src"><a name="v:hFullBlockInteract" class="def">hFullBlockInteract</a> :: (<a href="System-IO-HVIO.html#t:HVIO">HVIO</a> a, <a href="System-IO-HVIO.html#t:HVIO">HVIO</a> d, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> a -> d -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Same as <code><a href="System-IO-Binary.html#v:hBlockInteract">hBlockInteract</a></code>, but uses <code><a href="System-IO-Binary.html#v:hFullGetBlocks">hFullGetBlocks</a></code> instead of
|
|
<code><a href="System-IO-Binary.html#v:hGetBlocks">hGetBlocks</a></code> internally. </p></div></div><div class="top"><p class="src"><a name="v:fullBlockInteract" class="def">fullBlockInteract</a> :: (<a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> b, <a href="System-IO-Binary.html#t:BinaryConvertible">BinaryConvertible</a> c) => <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Int.html#t:Int">Int</a> -> ([[b]] -> [[c]]) -> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>An alias for <code><a href="System-IO-Binary.html#v:hFullBlockInteract">hFullBlockInteract</a></code> over <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdin">stdin</a></code> and <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle-FD.html#v:stdout">stdout</a></code></p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.0</p></div></body></html> |