Sophie

Sophie

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

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.Utils</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-Utils.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.Utils</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">General marshalling utilities
</a><ul><li><a href="#g:2">Combined allocation and marshalling
</a></li><li><a href="#g:3">Marshalling of Boolean values (non-zero corresponds to <code><a href="Prelude.html#v:True">True</a></code>)
</a></li><li><a href="#g:4">Marshalling of Maybe values
</a></li><li><a href="#g:5">Marshalling lists of storable objects
</a></li><li><a href="#g:6">Haskellish interface to memcpy and memmove
</a></li></ul></li></ul></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:with">with</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:new">new</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:fromBool">fromBool</a> :: <a href="Prelude.html#t:Num">Num</a> a =&gt; <a href="Prelude.html#t:Bool">Bool</a> -&gt; a</li><li class="src short"><a href="#v:toBool">toBool</a> :: (<a href="Prelude.html#t:Eq">Eq</a> a, <a href="Prelude.html#t:Num">Num</a> a) =&gt; a -&gt; <a href="Prelude.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:maybeNew">maybeNew</a> ::  (a -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b)) -&gt; <a href="Prelude.html#t:Maybe">Maybe</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b)</li><li class="src short"><a href="#v:maybeWith">maybeWith</a> ::  (a -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:IO">IO</a> c) -&gt; <a href="Prelude.html#t:IO">IO</a> c) -&gt; <a href="Prelude.html#t:Maybe">Maybe</a> a -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:IO">IO</a> c) -&gt; <a href="Prelude.html#t:IO">IO</a> c</li><li class="src short"><a href="#v:maybePeek">maybePeek</a> ::  (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&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:Maybe">Maybe</a> b)</li><li class="src short"><a href="#v:withMany">withMany</a> ::  (a -&gt; (b -&gt; res) -&gt; res) -&gt; [a] -&gt; ([b] -&gt; res) -&gt; res</li><li class="src short"><a href="#v:copyBytes">copyBytes</a> ::  <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:moveBytes">moveBytes</a> ::  <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></ul></div><div id="interface"><h1 id="g:1">General marshalling utilities
</h1><h2 id="g:2">Combined allocation and marshalling
</h2><div class="top"><p class="src"><a name="v:with" class="def">with</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-Utils.html#with" class="link">Source</a></p><div class="doc"><p><code><code><a href="Foreign-Marshal-Utils.html#v:with">with</a></code> val f</code> executes the computation <code>f</code>, passing as argument
 a pointer to a temporarily allocated block of memory into which
 <code>val</code> has been marshalled (the combination of <code><a href="Foreign-Marshal-Alloc.html#v:alloca">alloca</a></code> and <code><a href="Foreign-Storable.html#v:poke">poke</a></code>).
</p><p>The memory is freed when <code>f</code> terminates (either normally or via an
 exception), so the pointer passed to <code>f</code> must <em>not</em> be used after this.
</p></div></div><div class="top"><p class="src"><a name="v:new" class="def">new</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-Utils.html#new" class="link">Source</a></p><div class="doc"><p>Allocate a block of memory and marshal a value into it
 (the combination of <code><a href="Foreign-Marshal-Alloc.html#v:malloc">malloc</a></code> and <code><a href="Foreign-Storable.html#v:poke">poke</a></code>).
 The size of the area allocated is determined by the <code><a href="../base-4.5.1.0/Foreign-Storable.html#v:sizeOf">sizeOf</a></code>
 method from the instance of <code><a href="Foreign-Storable.html#t:Storable">Storable</a></code> for the appropriate type.
</p><p>The memory may be deallocated using <code><a href="../base-4.5.1.0/Foreign-Marshal-Alloc.html#v:free">free</a></code> or
 <code><a href="../base-4.5.1.0/Foreign-Marshal-Alloc.html#v:finalizerFree">finalizerFree</a></code> when no longer required.
</p></div></div><h2 id="g:3">Marshalling of Boolean values (non-zero corresponds to <code><a href="Prelude.html#v:True">True</a></code>)
</h2><div class="top"><p class="src"><a name="v:fromBool" class="def">fromBool</a> :: <a href="Prelude.html#t:Num">Num</a> a =&gt; <a href="Prelude.html#t:Bool">Bool</a> -&gt; a<a href="../base-4.5.1.0/src/Foreign-Marshal-Utils.html#fromBool" class="link">Source</a></p><div class="doc"><p>Convert a Haskell <code><a href="Prelude.html#t:Bool">Bool</a></code> to its numeric representation
</p></div></div><div class="top"><p class="src"><a name="v:toBool" class="def">toBool</a> :: (<a href="Prelude.html#t:Eq">Eq</a> a, <a href="Prelude.html#t:Num">Num</a> a) =&gt; a -&gt; <a href="Prelude.html#t:Bool">Bool</a><a href="../base-4.5.1.0/src/Foreign-Marshal-Utils.html#toBool" class="link">Source</a></p><div class="doc"><p>Convert a Boolean in numeric representation to a Haskell value
</p></div></div><h2 id="g:4">Marshalling of Maybe values
</h2><div class="top"><p class="src"><a name="v:maybeNew" class="def">maybeNew</a> ::  (a -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b)) -&gt; <a href="Prelude.html#t:Maybe">Maybe</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b)<a href="../base-4.5.1.0/src/Foreign-Marshal-Utils.html#maybeNew" class="link">Source</a></p><div class="doc"><p>Allocate storage and marshal a storable value wrapped into a <code><a href="Prelude.html#t:Maybe">Maybe</a></code>
</p><ul><li> the <code><a href="Foreign-Ptr.html#v:nullPtr">nullPtr</a></code> is used to represent <code><a href="Prelude.html#v:Nothing">Nothing</a></code>
</li></ul></div></div><div class="top"><p class="src"><a name="v:maybeWith" class="def">maybeWith</a> ::  (a -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:IO">IO</a> c) -&gt; <a href="Prelude.html#t:IO">IO</a> c) -&gt; <a href="Prelude.html#t:Maybe">Maybe</a> a -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> b -&gt; <a href="Prelude.html#t:IO">IO</a> c) -&gt; <a href="Prelude.html#t:IO">IO</a> c<a href="../base-4.5.1.0/src/Foreign-Marshal-Utils.html#maybeWith" class="link">Source</a></p><div class="doc"><p>Converts a <code>withXXX</code> combinator into one marshalling a value wrapped
 into a <code><a href="Prelude.html#t:Maybe">Maybe</a></code>, using <code><a href="Foreign-Ptr.html#v:nullPtr">nullPtr</a></code> to represent <code><a href="Prelude.html#v:Nothing">Nothing</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:maybePeek" class="def">maybePeek</a> ::  (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="Prelude.html#t:IO">IO</a> b) -&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:Maybe">Maybe</a> b)<a href="../base-4.5.1.0/src/Foreign-Marshal-Utils.html#maybePeek" class="link">Source</a></p><div class="doc"><p>Convert a peek combinator into a one returning <code><a href="Prelude.html#v:Nothing">Nothing</a></code> if applied to a
 <code><a href="Foreign-Ptr.html#v:nullPtr">nullPtr</a></code> 
</p></div></div><h2 id="g:5">Marshalling lists of storable objects
</h2><div class="top"><p class="src"><a name="v:withMany" class="def">withMany</a> ::  (a -&gt; (b -&gt; res) -&gt; res) -&gt; [a] -&gt; ([b] -&gt; res) -&gt; res<a href="../base-4.5.1.0/src/Foreign-Marshal-Utils.html#withMany" class="link">Source</a></p><div class="doc"><p>Replicates a <code>withXXX</code> combinator over a list of objects, yielding a list of
 marshalled objects
</p></div></div><h2 id="g:6">Haskellish interface to memcpy and memmove
</h2><div class="doc"><p>(argument order: destination, source)
</p></div><div class="top"><p class="src"><a name="v:copyBytes" class="def">copyBytes</a> ::  <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-Utils.html#copyBytes" class="link">Source</a></p><div class="doc"><p>Copies the given number of bytes from the second area (source) into the
 first (destination); the copied areas may <em>not</em> overlap
</p></div></div><div class="top"><p class="src"><a name="v:moveBytes" class="def">moveBytes</a> ::  <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-Utils.html#moveBytes" class="link">Source</a></p><div class="doc"><p>Copies the given number of bytes from the second area (source) into the
 first (destination); the copied areas <em>may</em> overlap
</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>