<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >Data.Array.Storable</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_Data-Array-Storable.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >array-0.2.0.0: Mutable and immutable arrays</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >Data.Array.Storable</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >non-portable (uses Data.Array.MArray)</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >experimental</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" ><B >Contents</B ></TD ></TR ><TR ><TD ><DL ><DT ><A HREF="#1" >Arrays of <TT ><A HREF="../base/Foreign-Storable.html#t%3AStorable" >Storable</A ></TT > things. </A ></DT ><DT ><A HREF="#2" >Overloaded mutable array interface </A ></DT ><DT ><A HREF="#3" >Accessing the pointer to the array contents </A ></DT ></DL ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" ><P >A storable array is an IO-mutable array which stores its contents in a contiguous memory block living in the C heap. Elements are stored according to the class <TT ><A HREF="../base/Foreign-Storable.html#t%3AStorable" >Storable</A ></TT >. You can obtain the pointer to the array contents to manipulate elements from languages like C. </P ><P >It is similar to Data.Array.IO.IOUArray but slower. Its advantage is that it's compatible with C. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AStorableArray" >StorableArray</A > i e</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" >module <A HREF="Data-Array-MArray.html" >Data.Array.MArray</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AwithStorableArray" >withStorableArray</A > :: <A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > i e -> (<A HREF="../base/Foreign-Ptr.html#t%3APtr" >Ptr</A > e -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtouchStorableArray" >touchStorableArray</A > :: <A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > i e -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AunsafeForeignPtrToStorableArray" >unsafeForeignPtrToStorableArray</A > :: <A HREF="../base/GHC-Arr.html#t%3AIx" >Ix</A > i => <A HREF="../base/Foreign-ForeignPtr.html#t%3AForeignPtr" >ForeignPtr</A > e -> (i, i) -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > i e)</TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="1" ><A NAME="1" >Arrays of <TT ><A HREF="../base/Foreign-Storable.html#t%3AStorable" >Storable</A ></TT > things. </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:StorableArray" ><A NAME="t%3AStorableArray" ></A ></A ><B >StorableArray</B > i e </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >The array type </TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:StorableArray')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:StorableArray" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="../base/Foreign-Storable.html#t%3AStorable" >Storable</A > e => <A HREF="Data-Array-MArray.html#t%3AMArray" >MArray</A > <A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > e <A HREF="../base/System-IO.html#t%3AIO" >IO</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="2" ><A NAME="2" >Overloaded mutable array interface </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="doc" >Module <A HREF="Data-Array-MArray.html" >Data.Array.MArray</A > provides the interface of storable arrays. They are instances of class <TT ><A HREF="Data-Array-MArray.html#t%3AMArray" >MArray</A ></TT > (with the <TT ><A HREF="../base/System-IO.html#t%3AIO" >IO</A ></TT > monad). </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" >module <A HREF="Data-Array-MArray.html" >Data.Array.MArray</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="3" ><A NAME="3" >Accessing the pointer to the array contents </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:withStorableArray" ><A NAME="v%3AwithStorableArray" ></A ></A ><B >withStorableArray</B > :: <A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > i e -> (<A HREF="../base/Foreign-Ptr.html#t%3APtr" >Ptr</A > e -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >The pointer to the array contents is obtained by <TT ><A HREF="Data-Array-Storable.html#v%3AwithStorableArray" >withStorableArray</A ></TT >. The idea is similar to <TT ><A HREF="../base/Foreign-ForeignPtr.html#t%3AForeignPtr" >ForeignPtr</A ></TT > (used internally here). The pointer should be used only during execution of the <TT ><A HREF="../base/System-IO.html#t%3AIO" >IO</A ></TT > action retured by the function passed as argument to <TT ><A HREF="Data-Array-Storable.html#v%3AwithStorableArray" >withStorableArray</A ></TT >. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:touchStorableArray" ><A NAME="v%3AtouchStorableArray" ></A ></A ><B >touchStorableArray</B > :: <A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > i e -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" >If you want to use it afterwards, ensure that you <TT ><A HREF="Data-Array-Storable.html#v%3AtouchStorableArray" >touchStorableArray</A ></TT > after the last use of the pointer, so the array is not freed too early. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:unsafeForeignPtrToStorableArray" ><A NAME="v%3AunsafeForeignPtrToStorableArray" ></A ></A ><B >unsafeForeignPtrToStorableArray</B > :: <A HREF="../base/GHC-Arr.html#t%3AIx" >Ix</A > i => <A HREF="../base/Foreign-ForeignPtr.html#t%3AForeignPtr" >ForeignPtr</A > e -> (i, i) -> <A HREF="../base/System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A > i e)</TD ></TR ><TR ><TD CLASS="doc" >Construct a <TT ><A HREF="Data-Array-Storable.html#t%3AStorableArray" >StorableArray</A ></TT > from an arbitrary <TT ><A HREF="../base/Foreign-ForeignPtr.html#t%3AForeignPtr" >ForeignPtr</A ></TT >. It is the caller's responsibility to ensure that the <TT ><A HREF="../base/Foreign-ForeignPtr.html#t%3AForeignPtr" >ForeignPtr</A ></TT > points to an area of memory sufficient for the specified bounds. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.4.2</TD ></TR ></TABLE ></BODY ></HTML >