<!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>Data.Array.Unsafe</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_Data-Array-Unsafe.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">array-0.4.0.0: Mutable and immutable arrays</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (uses Data.Array.MArray)</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">Data.Array.Unsafe</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Unsafe operations </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Contains the various unsafe operations that can be performed on arrays. </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:castSTUArray">castSTUArray</a> :: <a href="Data-Array-ST.html#t:STUArray">STUArray</a> s ix a -> <a href="../base-4.5.1.0/Control-Monad-ST-Safe.html#t:ST">ST</a> s (<a href="Data-Array-ST.html#t:STUArray">STUArray</a> s ix b)</li><li class="src short"><a href="#v:castIOUArray">castIOUArray</a> :: <a href="Data-Array-IO.html#t:IOUArray">IOUArray</a> ix a -> <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> (<a href="Data-Array-IO.html#t:IOUArray">IOUArray</a> ix b)</li><li class="src short"><a href="#v:unsafeFreeze">unsafeFreeze</a> :: (<a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> i, <a href="Data-Array-MArray.html#t:MArray">MArray</a> a e m, <a href="Data-Array-IArray.html#t:IArray">IArray</a> b e) => a i e -> m (b i e)</li><li class="src short"><a href="#v:unsafeThaw">unsafeThaw</a> :: (<a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> i, <a href="Data-Array-IArray.html#t:IArray">IArray</a> a e, <a href="Data-Array-MArray.html#t:MArray">MArray</a> b e m) => a i e -> m (b i e)</li><li class="src short"><a href="#v:unsafeForeignPtrToStorableArray">unsafeForeignPtrToStorableArray</a> :: <a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> i => <a href="../base-4.5.1.0/Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> e -> (i, i) -> <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> (<a href="Data-Array-Storable.html#t:StorableArray">StorableArray</a> i e)</li></ul></div><div id="interface"><h1 id="g:1">Unsafe operations </h1><div class="top"><p class="src"><a name="v:castSTUArray" class="def">castSTUArray</a> :: <a href="Data-Array-ST.html#t:STUArray">STUArray</a> s ix a -> <a href="../base-4.5.1.0/Control-Monad-ST-Safe.html#t:ST">ST</a> s (<a href="Data-Array-ST.html#t:STUArray">STUArray</a> s ix b)</p><div class="doc"><p>Casts an <code><a href="Data-Array-ST.html#t:STUArray">STUArray</a></code> with one element type into one with a different element type. All the elements of the resulting array are undefined (unless you know what you're doing...). </p></div></div><div class="top"><p class="src"><a name="v:castIOUArray" class="def">castIOUArray</a> :: <a href="Data-Array-IO.html#t:IOUArray">IOUArray</a> ix a -> <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> (<a href="Data-Array-IO.html#t:IOUArray">IOUArray</a> ix b)</p><div class="doc"><p>Casts an <code><a href="Data-Array-IO.html#t:IOUArray">IOUArray</a></code> with one element type into one with a different element type. All the elements of the resulting array are undefined (unless you know what you're doing...). </p></div></div><div class="top"><p class="src"><a name="v:unsafeFreeze" class="def">unsafeFreeze</a> :: (<a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> i, <a href="Data-Array-MArray.html#t:MArray">MArray</a> a e m, <a href="Data-Array-IArray.html#t:IArray">IArray</a> b e) => a i e -> m (b i e)</p><div class="doc"><p>Converts an mutable array into an immutable array. The implementation may either simply cast the array from one type to the other without copying the array, or it may take a full copy of the array. </p><p>Note that because the array is possibly not copied, any subsequent modifications made to the mutable version of the array may be shared with the immutable version. It is safe to use, therefore, if the mutable version is never modified after the freeze operation. </p><p>The non-copying implementation is supported between certain pairs of array types only; one constraint is that the array types must have identical representations. In GHC, The following pairs of array types have a non-copying O(1) implementation of <code><a href="Data-Array-Unsafe.html#v:unsafeFreeze">unsafeFreeze</a></code>. Because the optimised versions are enabled by specialisations, you will need to compile with optimisation (-O) to get them. </p><ul><li> <code><a href="Data-Array-IO.html#t:IOUArray">IOUArray</a></code> -> <code><a href="Data-Array-Unboxed.html#t:UArray">UArray</a></code> </li><li> <code><a href="Data-Array-ST.html#t:STUArray">STUArray</a></code> -> <code><a href="Data-Array-Unboxed.html#t:UArray">UArray</a></code> </li><li> <code><a href="Data-Array-IO.html#t:IOArray">IOArray</a></code> -> <code><a href="Data-Array.html#t:Array">Array</a></code> </li><li> <code><a href="Data-Array-ST.html#t:STArray">STArray</a></code> -> <code><a href="Data-Array.html#t:Array">Array</a></code> </li></ul></div></div><div class="top"><p class="src"><a name="v:unsafeThaw" class="def">unsafeThaw</a> :: (<a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> i, <a href="Data-Array-IArray.html#t:IArray">IArray</a> a e, <a href="Data-Array-MArray.html#t:MArray">MArray</a> b e m) => a i e -> m (b i e)</p><div class="doc"><p>Converts an immutable array into a mutable array. The implementation may either simply cast the array from one type to the other without copying the array, or it may take a full copy of the array. </p><p>Note that because the array is possibly not copied, any subsequent modifications made to the mutable version of the array may be shared with the immutable version. It is only safe to use, therefore, if the immutable array is never referenced again in this thread, and there is no possibility that it can be also referenced in another thread. If you use an unsafeThaw<em>write</em>unsafeFreeze sequence in a multi-threaded setting, then you must ensure that this sequence is atomic with respect to other threads, or a garbage collector crash may result (because the write may be writing to a frozen array). </p><p>The non-copying implementation is supported between certain pairs of array types only; one constraint is that the array types must have identical representations. In GHC, The following pairs of array types have a non-copying O(1) implementation of <code><a href="Data-Array-Unsafe.html#v:unsafeThaw">unsafeThaw</a></code>. Because the optimised versions are enabled by specialisations, you will need to compile with optimisation (-O) to get them. </p><ul><li> <code><a href="Data-Array-Unboxed.html#t:UArray">UArray</a></code> -> <code><a href="Data-Array-IO.html#t:IOUArray">IOUArray</a></code> </li><li> <code><a href="Data-Array-Unboxed.html#t:UArray">UArray</a></code> -> <code><a href="Data-Array-ST.html#t:STUArray">STUArray</a></code> </li><li> <code><a href="Data-Array.html#t:Array">Array</a></code> -> <code><a href="Data-Array-IO.html#t:IOArray">IOArray</a></code> </li><li> <code><a href="Data-Array.html#t:Array">Array</a></code> -> <code><a href="Data-Array-ST.html#t:STArray">STArray</a></code> </li></ul></div></div><div class="top"><p class="src"><a name="v:unsafeForeignPtrToStorableArray" class="def">unsafeForeignPtrToStorableArray</a> :: <a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> i => <a href="../base-4.5.1.0/Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> e -> (i, i) -> <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> (<a href="Data-Array-Storable.html#t:StorableArray">StorableArray</a> i e)</p><div class="doc"><p>Construct a <code><a href="Data-Array-Storable.html#t:StorableArray">StorableArray</a></code> from an arbitrary <code><a href="../base-4.5.1.0/Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code>. It is the caller's responsibility to ensure that the <code><a href="../base-4.5.1.0/Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> points to an area of memory sufficient for the specified bounds. </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>