Copyright | (c) Sam Stites 2017 |
---|---|
License | BSD3 |
Maintainer | sam@stites.io |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Storages are basically a way to access memory of a C pointer or array. Storages can also map the contents of a file to memory. A Storage is an array of basic C types.
Several Storage classes for all the basic C types exist and have the following self-explanatory names: ByteStorage, CharStorage, ShortStorage, IntStorage, LongStorage, FloatStorage, DoubleStorage.
Note that ByteStorage and CharStorage represent both arrays of bytes. ByteStorage represents an array of unsigned chars, while CharStorage represents an array of signed chars.
Synopsis
- class IsList l where
- data Storage
- cstorage :: Storage -> ForeignPtr CStorage
- storage :: ForeignPtr CState -> ForeignPtr CStorage -> Storage
- storageState :: Storage -> (ForeignPtr CState, ForeignPtr CStorage)
- storageStateRef :: Storage -> ForeignPtr CState
- storagedata :: Storage -> [HsReal]
- size :: Storage -> Int
- set :: Storage -> Word -> HsReal -> IO ()
- get :: Storage -> Word -> HsReal
- empty :: Storage
- newWithSize :: Word -> Storage
- newWithSize1 :: HsReal -> Storage
- newWithSize2 :: HsReal -> HsReal -> Storage
- newWithSize3 :: HsReal -> HsReal -> HsReal -> Storage
- newWithSize4 :: HsReal -> HsReal -> HsReal -> HsReal -> Storage
- newWithMapping :: [Int8] -> Word64 -> Int32 -> IO Storage
- newWithData :: [HsReal] -> Word64 -> Storage
- setFlag :: Storage -> Int8 -> IO ()
- clearFlag :: Storage -> Int8 -> IO ()
- retain :: Storage -> IO ()
- resize :: Storage -> Word32 -> IO ()
- fill :: Storage -> HsReal -> IO ()
Documentation
The IsList
class and its methods are intended to be used in
conjunction with the OverloadedLists extension.
Since: base-4.7.0.0
The fromList
function constructs the structure l
from the given
list of Item l
fromListN :: Int -> [Item l] -> l #
The fromListN
function takes the input list's length as a hint. Its
behaviour should be equivalent to fromList
. The hint can be used to
construct the structure l
more efficiently compared to fromList
. If
the given hint does not equal to the input list's length the behaviour of
fromListN
is not specified.
The toList
function extracts a list of Item l
from the structure l
.
It should satisfy fromList . toList = id.
Instances
IsList CallStack | Be aware that 'fromList . toList = id' only for unfrozen Since: base-4.9.0.0 |
IsList Version | Since: base-4.8.0.0 |
IsList IntSet | Since: containers-0.5.6.2 |
IsList Storage Source # | |
IsList Dynamic Source # | |
IsList ByteArray | |
IsList [a] | Since: base-4.7.0.0 |
IsList (NonEmpty a) | Since: base-4.9.0.0 |
IsList (IntMap a) | Since: containers-0.5.6.2 |
IsList (Seq a) | |
Ord a => IsList (Set a) | Since: containers-0.5.6.2 |
IsList (Vector a) | |
Storable a => IsList (Vector a) | |
Prim a => IsList (Vector a) | |
IsList (Array a) | |
Prim a => IsList (PrimArray a) | |
IsList (SmallArray a) | |
PrimUnlifted a => IsList (UnliftedArray a) | |
Ord k => IsList (Map k v) | Since: containers-0.5.6.2 |
cstorage :: Storage -> ForeignPtr CStorage #
storage :: ForeignPtr CState -> ForeignPtr CStorage -> Storage #
storageState :: Storage -> (ForeignPtr CState, ForeignPtr CStorage) #
storageStateRef :: Storage -> ForeignPtr CState #
storagedata :: Storage -> [HsReal] Source #
return the internal data of Storage
as a list of haskell values.
newWithSize :: Word -> Storage Source #
create a new storage of a given length, StorageSize
.
newWithSize4 :: HsReal -> HsReal -> HsReal -> HsReal -> Storage Source #
make a new Storage
with four values.
FIXME: This is totally broken. This takes a filename, size, and flags, and produces
Storage
from these inputs. Figure out how to fix this, ideally.
make a new Storage
from a given list and StorageSize
.
FIXME: find out if StorageSize
always corresponds to the length of the list. If so,
remove it!
setFlag :: Storage -> Int8 -> IO () Source #
set the flags of a given Storage
. Flags are applied via bitwise-or.
clearFlag :: Storage -> Int8 -> IO () Source #
clear the flags of a given Storage
. Flags are cleanred via bitwise-and.
retain :: Storage -> IO () Source #
Increment the reference counter of the storage.
This method should be used with extreme care. In general, they should never be called, except if you know what you are doing, as the handling of references is done automatically. They can be useful in threaded environments. Note that these methods are atomic operations.
resize :: Storage -> Word32 -> IO () Source #
Resize the storage to the provided size. The new contents are undetermined.