Sophie

Sophie

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

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>Foreign.Storable</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_Foreign-Storable.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">haskell2010-1.1.0.1: Compatibility with Haskell 2010</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>Safe</td></tr></table><p class="caption">Foreign.Storable</p></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:Storable">Storable</a> a  <span class="keyword">where</span><ul class="subs"><li><a href="#v:sizeOf">sizeOf</a> :: a -&gt; <a href="Prelude.html#t:Int">Int</a></li><li><a href="#v:alignment">alignment</a> :: a -&gt; <a href="Prelude.html#t:Int">Int</a></li><li><a href="#v:peekElemOff">peekElemOff</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> a</li><li><a href="#v:pokeElemOff">pokeElemOff</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; a -&gt; <a href="Prelude.html#t:IO">IO</a> ()</li><li><a href="#v:peekByteOff">peekByteOff</a> ::  <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> a</li><li><a href="#v:pokeByteOff">pokeByteOff</a> ::  <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; a -&gt; <a href="Prelude.html#t:IO">IO</a> ()</li><li><a href="#v:peek">peek</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> a</li><li><a href="#v:poke">poke</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; a -&gt; <a href="Prelude.html#t:IO">IO</a> ()</li></ul></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span>  <a name="t:Storable" class="def">Storable</a> a  <span class="keyword">where</span><a href="../base-4.5.1.0/src/Foreign-Storable.html#Storable" class="link">Source</a></p><div class="doc"><p>The member functions of this class facilitate writing values of
primitive types to raw memory (which may have been allocated with the
above mentioned routines) and reading values from blocks of raw
memory.  The class, furthermore, includes support for computing the
storage requirements and alignment restrictions of storable types.
</p><p>Memory addresses are represented as values of type <code><code><a href="Foreign-Ptr.html#t:Ptr">Ptr</a></code> a</code>, for some
<code>a</code> which is an instance of class <code><a href="Foreign-Storable.html#t:Storable">Storable</a></code>.  The type argument to
<code><a href="Foreign-Ptr.html#t:Ptr">Ptr</a></code> helps provide some valuable type safety in FFI code (you can't
mix pointers of different types without an explicit cast), while
helping the Haskell type system figure out which marshalling method is
needed for a given pointer.
</p><p>All marshalling between Haskell and a foreign language ultimately
boils down to translating Haskell data structures into the binary
representation of a corresponding data structure of the foreign
language and vice versa.  To code this marshalling in Haskell, it is
necessary to manipulate primitive data types stored in unstructured
memory blocks.  The class <code><a href="Foreign-Storable.html#t:Storable">Storable</a></code> facilitates this manipulation on
all types for which it is instantiated, which are the standard basic
types of Haskell, the fixed size <code>Int</code> types (<code><a href="Data-Int.html#t:Int8">Int8</a></code>, <code><a href="Data-Int.html#t:Int16">Int16</a></code>,
<code><a href="Data-Int.html#t:Int32">Int32</a></code>, <code><a href="Data-Int.html#t:Int64">Int64</a></code>), the fixed size <code>Word</code> types (<code><a href="Data-Word.html#t:Word8">Word8</a></code>, <code><a href="Data-Word.html#t:Word16">Word16</a></code>,
<code><a href="Data-Word.html#t:Word32">Word32</a></code>, <code><a href="Data-Word.html#t:Word64">Word64</a></code>), <code><a href="Foreign-StablePtr.html#t:StablePtr">StablePtr</a></code>, all types from <a href="../base-4.5.1.0/Foreign-C-Types.html">Foreign.C.Types</a>,
as well as <code><a href="Foreign-Ptr.html#t:Ptr">Ptr</a></code>.
</p><p>Minimal complete definition: <code><a href="Foreign-Storable.html#v:sizeOf">sizeOf</a></code>, <code><a href="Foreign-Storable.html#v:alignment">alignment</a></code>, one of <code><a href="Foreign-Storable.html#v:peek">peek</a></code>,
<code><a href="Foreign-Storable.html#v:peekElemOff">peekElemOff</a></code> and <code><a href="Foreign-Storable.html#v:peekByteOff">peekByteOff</a></code>, and one of <code><a href="Foreign-Storable.html#v:poke">poke</a></code>, <code><a href="Foreign-Storable.html#v:pokeElemOff">pokeElemOff</a></code> and
<code><a href="Foreign-Storable.html#v:pokeByteOff">pokeByteOff</a></code>.
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:sizeOf" class="def">sizeOf</a> :: a -&gt; <a href="Prelude.html#t:Int">Int</a><a href="../base-4.5.1.0/src/Foreign-Storable.html#sizeOf" class="link">Source</a></p><div class="doc"><p>Computes the storage requirements (in bytes) of the argument.
 The value of the argument is not used.
</p></div><p class="src"><a name="v:alignment" class="def">alignment</a> :: a -&gt; <a href="Prelude.html#t:Int">Int</a><a href="../base-4.5.1.0/src/Foreign-Storable.html#alignment" class="link">Source</a></p><div class="doc"><p>Computes the alignment constraint of the argument.  An
 alignment constraint <code>x</code> is fulfilled by any address divisible
 by <code>x</code>.  The value of the argument is not used.
</p></div><p class="src"><a name="v:peekElemOff" class="def">peekElemOff</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> a<a href="../base-4.5.1.0/src/Foreign-Storable.html#peekElemOff" class="link">Source</a></p><div class="doc"><p>Read a value from a memory area regarded as an array
         of values of the same kind.  The first argument specifies
         the start address of the array and the second the index into
         the array (the first element of the array has index
         <code>0</code>).  The following equality holds,
</p><pre> peekElemOff addr idx = IOExts.fixIO $ \result -&gt;
   peek (addr `plusPtr` (idx * sizeOf result))
</pre><p>Note that this is only a specification, not
         necessarily the concrete implementation of the
         function.
</p></div><p class="src"><a name="v:pokeElemOff" class="def">pokeElemOff</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; a -&gt; <a href="Prelude.html#t:IO">IO</a> ()<a href="../base-4.5.1.0/src/Foreign-Storable.html#pokeElemOff" class="link">Source</a></p><div class="doc"><p>Write a value to a memory area regarded as an array of
         values of the same kind.  The following equality holds:
</p><pre> pokeElemOff addr idx x = 
   poke (addr `plusPtr` (idx * sizeOf x)) x
</pre></div><p class="src"><a name="v:peekByteOff" class="def">peekByteOff</a> ::  <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> a<a href="../base-4.5.1.0/src/Foreign-Storable.html#peekByteOff" class="link">Source</a></p><div class="doc"><p>Read a value from a memory location given by a base
         address and offset.  The following equality holds:
</p><pre> peekByteOff addr off = peek (addr `plusPtr` off)
</pre></div><p class="src"><a name="v:pokeByteOff" class="def">pokeByteOff</a> ::  <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; a -&gt; <a href="Prelude.html#t:IO">IO</a> ()<a href="../base-4.5.1.0/src/Foreign-Storable.html#pokeByteOff" class="link">Source</a></p><div class="doc"><p>Write a value to a memory location given by a base
         address and offset.  The following equality holds:
</p><pre> pokeByteOff addr off x = poke (addr `plusPtr` off) x
</pre></div><p class="src"><a name="v:peek" class="def">peek</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> a<a href="../base-4.5.1.0/src/Foreign-Storable.html#peek" class="link">Source</a></p><div class="doc"><p>Read a value from the given memory location.
</p><p>Note that the peek and poke functions might require properly
  aligned addresses to function correctly.  This is architecture
  dependent; thus, portable code should ensure that when peeking or
  poking values of some type <code>a</code>, the alignment
  constraint for <code>a</code>, as given by the function
  <code><a href="Foreign-Storable.html#v:alignment">alignment</a></code> is fulfilled.
</p></div><p class="src"><a name="v:poke" class="def">poke</a> :: <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; a -&gt; <a href="Prelude.html#t:IO">IO</a> ()<a href="../base-4.5.1.0/src/Foreign-Storable.html#poke" class="link">Source</a></p><div class="doc"><p>Write the given value to the given memory location.  Alignment
 restrictions might apply; see <code><a href="Foreign-Storable.html#v:peek">peek</a></code>.
</p></div></div><div class="subs instances"><p id="control.i:Storable" class="caption collapser" onclick="toggleSection('i:Storable')">Instances</p><div id="section.i:Storable" class="show"><table><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Prelude.html#t:Bool">Bool</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Prelude.html#t:Char">Char</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Prelude.html#t:Double">Double</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Prelude.html#t:Float">Float</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Prelude.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Int.html#t:Int8">Int8</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Int.html#t:Int16">Int16</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Int.html#t:Int32">Int32</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Int.html#t:Int64">Int64</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Word.html#t:Word">Word</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Word.html#t:Word8">Word8</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Word.html#t:Word16">Word16</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Word.html#t:Word32">Word32</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Data-Word.html#t:Word64">Word64</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-Ptr.html#t:WordPtr">WordPtr</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-Ptr.html#t:IntPtr">IntPtr</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CChar">CChar</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CSChar">CSChar</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CUChar">CUChar</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CShort">CShort</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CUShort">CUShort</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CInt">CInt</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CUInt">CUInt</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CLong">CLong</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CULong">CULong</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CLLong">CLLong</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CULLong">CULLong</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CFloat">CFloat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CDouble">CDouble</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CPtrdiff">CPtrdiff</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CSize">CSize</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CWchar">CWchar</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CSigAtomic">CSigAtomic</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CClock">CClock</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CTime">CTime</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="../base-4.5.1.0/Foreign-C-Types.html#t:CUSeconds">CUSeconds</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="../base-4.5.1.0/Foreign-C-Types.html#t:CSUSeconds">CSUSeconds</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CIntPtr">CIntPtr</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CUIntPtr">CUIntPtr</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CIntMax">CIntMax</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="Foreign-C-Types.html#t:CUIntMax">CUIntMax</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> <a href="../base-4.5.1.0/GHC-Fingerprint-Type.html#t:Fingerprint">Fingerprint</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> (<a href="Foreign-StablePtr.html#t:StablePtr">StablePtr</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Foreign-Storable.html#t:Storable">Storable</a> (<a href="Foreign-Ptr.html#t:FunPtr">FunPtr</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></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>