Storable-based unboxed vectors.
- data Vec n a
- type Vec2 = Vec (S (S Z))
- type Vec3 = Vec (S (S (S Z)))
- type Vec4 = Vec (S (S (S (S Z))))
- type Vec5 = Vec (S (S (S (S (S Z)))))
- unsafeFromForeignPtr :: Storable a => ForeignPtr a -> Vec n a
- unsafeToForeignPtr :: Storable a => Vec n a -> ForeignPtr a
- unsafeWith :: Storable a => (Ptr a -> IO b) -> Vec n a -> IO b
- newtype MVec n s a = MVec (ForeignPtr a)
- class Storable a
Storable-based vector with fixed length
Construct vector from foreign pointer.
Get underlying pointer. Data may not be modified through pointer.
Storable-based mutable vector with fixed length
class Storable a
The member functions of this class facilitate writing values of primitive types to raw memory (which may have been allocated with the above mentioned routines) and reading values from blocks of raw memory. The class, furthermore, includes support for computing the storage requirements and alignment restrictions of storable types.
Memory addresses are represented as values of type
, for some
a which is an instance of class
Storable. The type argument to
Ptr helps provide some valuable type safety in FFI code (you can't
mix pointers of different types without an explicit cast), while
helping the Haskell type system figure out which marshalling method is
needed for a given pointer.
All marshalling between Haskell and a foreign language ultimately
boils down to translating Haskell data structures into the binary
representation of a corresponding data structure of the foreign
language and vice versa. To code this marshalling in Haskell, it is
necessary to manipulate primitive data types stored in unstructured
memory blocks. The class
Storable facilitates this manipulation on
all types for which it is instantiated, which are the standard basic
types of Haskell, the fixed size
Int types (
Int64), the fixed size
Word types (
StablePtr, all types from Foreign.C.Types,
as well as