Copyright | (c) The University of Glasgow 2011 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | experimental |
Portability | non-portable (uses Data.Array.MArray) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Actual implementation of Data.Array.Storable.
WARNING
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.
Since: 0.4.0.0
Synopsis
- data StorableArray i e = StorableArray !i !i Int !(ForeignPtr e)
- withStorableArray :: StorableArray i e -> (Ptr e -> IO a) -> IO a
- touchStorableArray :: StorableArray i e -> IO ()
- unsafeForeignPtrToStorableArray :: Ix i => ForeignPtr e -> (i, i) -> IO (StorableArray i e)
Documentation
data StorableArray i e Source #
The array type
StorableArray !i !i Int !(ForeignPtr e) |
Instances
Storable e => MArray StorableArray e IO Source # | |
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.