Sophie

Sophie

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

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.Marshal.Array</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-Marshal-Array.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.Marshal.Array</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Marshalling arrays
</a><ul><li><a href="#g:2">Allocation
</a></li><li><a href="#g:3">Marshalling
</a></li><li><a href="#g:4">Combined allocation and marshalling
</a></li><li><a href="#g:5">Copying
</a></li><li><a href="#g:6">Finding the length
</a></li><li><a href="#g:7">Indexing
</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>The module <a href="../base-4.5.1.0/Foreign-Marshal-Array.html">Foreign.Marshal.Array</a> provides operations for marshalling Haskell
lists into monolithic arrays and vice versa.  Most functions come in two
flavours: one for arrays terminated by a special termination element and one
where an explicit length parameter is used to determine the extent of an
array.  The typical example for the former case are C's NUL terminated
strings.  However, please note that C strings should usually be marshalled
using the functions provided by <a href="../base-4.5.1.0/Foreign-C-String.html">Foreign.C.String</a> as
the Unicode encoding has to be taken into account.  All functions specifically
operating on arrays that are terminated by a special termination element have
a name ending on <code>0</code>---e.g., <code><a href="Foreign-Marshal-Array.html#v:mallocArray">mallocArray</a></code> allocates space for an
array of the given size, whereas <code><a href="Foreign-Marshal-Array.html#v:mallocArray0">mallocArray0</a></code> allocates space for one
more element to ensure that there is room for the terminator.
</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"><a href="#v:mallocArray">mallocArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</li><li class="src short"><a href="#v:mallocArray0">mallocArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</li><li class="src short"><a href="#v:allocaArray">allocaArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:allocaArray0">allocaArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:reallocArray">reallocArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <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 href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</li><li class="src short"><a href="#v:reallocArray0">reallocArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <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 href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</li><li class="src short"><a href="#v:peekArray">peekArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> [a]</li><li class="src short"><a href="#v:peekArray0">peekArray0</a> :: (<a href="Foreign-Storable.html#t:Storable">Storable</a> a, <a href="Prelude.html#t:Eq">Eq</a> a) =&gt; a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> [a]</li><li class="src short"><a href="#v:pokeArray">pokeArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; [a] -&gt; <a href="Prelude.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:pokeArray0">pokeArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; [a] -&gt; <a href="Prelude.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:newArray">newArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; [a] -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</li><li class="src short"><a href="#v:newArray0">newArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; [a] -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)</li><li class="src short"><a href="#v:withArray">withArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; [a] -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:withArray0">withArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; [a] -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:withArrayLen">withArrayLen</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; [a] -&gt; (<a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:withArrayLen0">withArrayLen0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; [a] -&gt; (<a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:copyArray">copyArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <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> ()</li><li class="src short"><a href="#v:moveArray">moveArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <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> ()</li><li class="src short"><a href="#v:lengthArray0">lengthArray0</a> :: (<a href="Foreign-Storable.html#t:Storable">Storable</a> a, <a href="Prelude.html#t:Eq">Eq</a> a) =&gt; a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> <a href="Prelude.html#t:Int">Int</a></li><li class="src short"><a href="#v:advancePtr">advancePtr</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a</li></ul></div><div id="interface"><h1 id="g:1">Marshalling arrays
</h1><h2 id="g:2">Allocation
</h2><div class="top"><p class="src"><a name="v:mallocArray" class="def">mallocArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#mallocArray" class="link">Source</a></p><div class="doc"><p>Allocate storage for the given number of elements of a storable type
 (like <code><a href="../base-4.5.1.0/Foreign-Marshal-Alloc.html#v:malloc">malloc</a></code>, but for multiple elements).
</p></div></div><div class="top"><p class="src"><a name="v:mallocArray0" class="def">mallocArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#mallocArray0" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Foreign-Marshal-Array.html#v:mallocArray">mallocArray</a></code>, but add an extra position to hold a special
 termination element.
</p></div></div><div class="top"><p class="src"><a name="v:allocaArray" class="def">allocaArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#allocaArray" class="link">Source</a></p><div class="doc"><p>Temporarily allocate space for the given number of elements
 (like <code><a href="../base-4.5.1.0/Foreign-Marshal-Alloc.html#v:alloca">alloca</a></code>, but for multiple elements).
</p></div></div><div class="top"><p class="src"><a name="v:allocaArray0" class="def">allocaArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#allocaArray0" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Foreign-Marshal-Array.html#v:allocaArray">allocaArray</a></code>, but add an extra position to hold a special
 termination element.
</p></div></div><div class="top"><p class="src"><a name="v:reallocArray" class="def">reallocArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <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 href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#reallocArray" class="link">Source</a></p><div class="doc"><p>Adjust the size of an array
</p></div></div><div class="top"><p class="src"><a name="v:reallocArray0" class="def">reallocArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <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 href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#reallocArray0" class="link">Source</a></p><div class="doc"><p>Adjust the size of an array including an extra position for the end marker.
</p></div></div><h2 id="g:3">Marshalling
</h2><div class="top"><p class="src"><a name="v:peekArray" class="def">peekArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> [a]</p><div class="doc"><p>Convert an array of given length into a Haskell list.
</p></div></div><div class="top"><p class="src"><a name="v:peekArray0" class="def">peekArray0</a> :: (<a href="Foreign-Storable.html#t:Storable">Storable</a> a, <a href="Prelude.html#t:Eq">Eq</a> a) =&gt; a -&gt; <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-Marshal-Array.html#peekArray0" class="link">Source</a></p><div class="doc"><p>Convert an array terminated by the given end marker into a Haskell list
</p></div></div><div class="top"><p class="src"><a name="v:pokeArray" class="def">pokeArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <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-Marshal-Array.html#pokeArray" class="link">Source</a></p><div class="doc"><p>Write the list elements consecutive into memory
</p></div></div><div class="top"><p class="src"><a name="v:pokeArray0" class="def">pokeArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; <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-Marshal-Array.html#pokeArray0" class="link">Source</a></p><div class="doc"><p>Write the list elements consecutive into memory and terminate them with the
 given marker element
</p></div></div><h2 id="g:4">Combined allocation and marshalling
</h2><div class="top"><p class="src"><a name="v:newArray" class="def">newArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; [a] -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#newArray" class="link">Source</a></p><div class="doc"><p>Write a list of storable elements into a newly allocated, consecutive
 sequence of storable values
 (like <code><a href="../base-4.5.1.0/Foreign-Marshal-Utils.html#v:new">new</a></code>, but for multiple elements).
</p></div></div><div class="top"><p class="src"><a name="v:newArray0" class="def">newArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; [a] -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a)<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#newArray0" class="link">Source</a></p><div class="doc"><p>Write a list of storable elements into a newly allocated, consecutive
 sequence of storable values, where the end is fixed by the given end marker
</p></div></div><div class="top"><p class="src"><a name="v:withArray" class="def">withArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; [a] -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#withArray" class="link">Source</a></p><div class="doc"><p>Temporarily store a list of storable values in memory
 (like <code><a href="../base-4.5.1.0/Foreign-Marshal-Utils.html#v:with">with</a></code>, but for multiple elements).
</p></div></div><div class="top"><p class="src"><a name="v:withArray0" class="def">withArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; [a] -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#withArray0" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Foreign-Marshal-Array.html#v:withArray">withArray</a></code>, but a terminator indicates where the array ends
</p></div></div><div class="top"><p class="src"><a name="v:withArrayLen" class="def">withArrayLen</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; [a] -&gt; (<a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#withArrayLen" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Foreign-Marshal-Array.html#v:withArray">withArray</a></code>, but the action gets the number of values
 as an additional parameter
</p></div></div><div class="top"><p class="src"><a name="v:withArrayLen0" class="def">withArrayLen0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; a -&gt; [a] -&gt; (<a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&gt; <a href="Prelude.html#t:IO">IO</a> b<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#withArrayLen0" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Foreign-Marshal-Array.html#v:withArrayLen">withArrayLen</a></code>, but a terminator indicates where the array ends
</p></div></div><h2 id="g:5">Copying
</h2><div class="doc"><p>(argument order: destination, source)
</p></div><div class="top"><p class="src"><a name="v:copyArray" class="def">copyArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <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 href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#copyArray" class="link">Source</a></p><div class="doc"><p>Copy the given number of elements from the second array (source) into the
 first array (destination); the copied areas may <em>not</em> overlap
</p></div></div><div class="top"><p class="src"><a name="v:moveArray" class="def">moveArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <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 href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#moveArray" class="link">Source</a></p><div class="doc"><p>Copy the given number of elements from the second array (source) into the
 first array (destination); the copied areas <em>may</em> overlap
</p></div></div><h2 id="g:6">Finding the length
</h2><div class="top"><p class="src"><a name="v:lengthArray0" class="def">lengthArray0</a> :: (<a href="Foreign-Storable.html#t:Storable">Storable</a> a, <a href="Prelude.html#t:Eq">Eq</a> a) =&gt; a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> <a href="Prelude.html#t:Int">Int</a><a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#lengthArray0" class="link">Source</a></p><div class="doc"><p>Return the number of elements in an array, excluding the terminator
</p></div></div><h2 id="g:7">Indexing
</h2><div class="top"><p class="src"><a name="v:advancePtr" class="def">advancePtr</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:Int">Int</a> -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a<a href="../base-4.5.1.0/src/Foreign-Marshal-Array.html#advancePtr" class="link">Source</a></p><div class="doc"><p>Advance a pointer into an array by the given number of elements
</p></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>