Safe Haskell | None |
---|---|
Language | Haskell98 |
Storable-based unboxed vectors.
- data Vec (n :: Nat) a
- type Vec1 = Vec 1
- type Vec2 = Vec 2
- type Vec3 = Vec 3
- type Vec4 = Vec 4
- type Vec5 = Vec 5
- unsafeFromForeignPtr :: ForeignPtr a -> Vec n a
- unsafeToForeignPtr :: Vec n a -> ForeignPtr a
- unsafeWith :: (Ptr a -> IO b) -> Vec n a -> IO b
- newtype MVec (n :: Nat) s a = MVec (ForeignPtr a)
- class Storable a
Immutable
data Vec (n :: Nat) a Source #
Storable-based vector with fixed length
(Arity n, Storable a) => VectorN Vec n a Source # | |
(Arity n, Storable a) => Vector (Vec n) a Source # | |
(Arity n, Storable a) => IVector (Vec n) a Source # | |
(Arity n, Storable a, Eq a) => Eq (Vec n a) Source # | |
(Typeable Nat n, Arity n, Storable a, Data a) => Data (Vec n a) Source # | |
(Arity n, Storable a, Ord a) => Ord (Vec n a) Source # | |
(Arity n, Storable a, Show a) => Show (Vec n a) Source # | |
(Arity n, Storable a, Semigroup a) => Semigroup (Vec n a) Source # | |
(Arity n, Storable a, Monoid a) => Monoid (Vec n a) Source # | |
(Arity n, Storable a) => Storable (Vec n a) Source # | |
(Arity n, Storable a, NFData a) => NFData (Vec n a) Source # | |
type Dim (Vec n) Source # | |
type Mutable (Vec n) Source # | |
Raw pointers
unsafeFromForeignPtr :: ForeignPtr a -> Vec n a Source #
Construct vector from foreign pointer.
unsafeToForeignPtr :: Vec n a -> ForeignPtr a Source #
Get underlying pointer. Data may not be modified through pointer.
Mutable
newtype MVec (n :: Nat) s a Source #
Storable-based mutable vector with fixed length
MVec (ForeignPtr a) |
Type classes
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
Ptr
aa
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 (Int8
, Int16
,
Int32
, Int64
), the fixed size Word
types (Word8
, Word16
,
Word32
, Word64
), StablePtr
, all types from Foreign.C.Types,
as well as Ptr
.
sizeOf, alignment, (peek | peekElemOff | peekByteOff), (poke | pokeElemOff | pokeByteOff)
Storable Bool | Since: 2.1 |
Storable Char | Since: 2.1 |
Storable Double | Since: 2.1 |
Storable Float | Since: 2.1 |
Storable Int | Since: 2.1 |
Storable Int8 | Since: 2.1 |
Storable Int16 | Since: 2.1 |
Storable Int32 | Since: 2.1 |
Storable Int64 | Since: 2.1 |
Storable Word | Since: 2.1 |
Storable Word8 | Since: 2.1 |
Storable Word16 | Since: 2.1 |
Storable Word32 | Since: 2.1 |
Storable Word64 | Since: 2.1 |
Storable () | Since: 4.9.0.0 |
Storable WordPtr | |
Storable IntPtr | |
Storable Fingerprint | Since: 4.4.0.0 |
(Storable a, Integral a) => Storable (Ratio a) | Since: 4.8.0.0 |
Storable (StablePtr a) | Since: 2.1 |
Storable (Ptr a) | Since: 2.1 |
Storable (FunPtr a) | Since: 2.1 |
Storable a => Storable (Complex a) | Since: 4.8.0.0 |
Storable a => Storable (Identity a) | |
Storable a => Storable (Only a) # | |
(Storable a, Arity n) => Storable (VecList n a) # | |
(Storable a, Arity n) => Storable (Vec n a) # | |
(Storable a, Prim a, Arity n) => Storable (Vec n a) # | |
(Arity n, Storable a) => Storable (Vec n a) # | |
(Storable a, Unbox n a) => Storable (Vec n a) # | |
Storable a => Storable (Const k a b) | |