array- Mutable and immutable arrays
Copyright(c) The University of Glasgow 2011
LicenseBSD-style (see the file libraries/base/LICENSE)
Portabilitynon-portable (uses Data.Array.MArray)
Safe HaskellSafe-Inferred



Actual implementation of Data.Array.Storable.


This module is considered internal.

The Package Versioning Policy does not apply.

The contents of this module may change in any way whatsoever and without any warning between minor versions of this package.

Authors importing this module are expected to track development closely.




data StorableArray i e Source #

The array type


StorableArray !i !i Int !(ForeignPtr e) 


Instances details
Storable e => MArray StorableArray e IO Source # 
Instance details

Defined in Data.Array.Storable.Internals


getBounds :: Ix i => StorableArray i e -> IO (i, i) Source #

getNumElements :: Ix i => StorableArray i e -> IO Int Source #

newArray :: Ix i => (i, i) -> e -> IO (StorableArray i e) Source #

newArray_ :: Ix i => (i, i) -> IO (StorableArray i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (StorableArray i e) Source #

unsafeRead :: Ix i => StorableArray i e -> Int -> IO e Source #

unsafeWrite :: Ix i => StorableArray i e -> Int -> e -> IO () Source #

withStorableArray :: StorableArray i e -> (Ptr e -> IO a) -> IO a Source #

The pointer to the array contents is obtained by withStorableArray. The idea is similar to ForeignPtr (used internally here). The pointer should be used only during execution of the IO action retured by the function passed as argument to withStorableArray.

touchStorableArray :: StorableArray i e -> IO () Source #

If you want to use it afterwards, ensure that you touchStorableArray after the last use of the pointer, so the array is not freed too early.

unsafeForeignPtrToStorableArray :: Ix i => ForeignPtr e -> (i, i) -> IO (StorableArray i e) Source #

Construct a StorableArray from an arbitrary ForeignPtr. It is the caller's responsibility to ensure that the ForeignPtr points to an area of memory sufficient for the specified bounds.