Safe Haskell | None |
---|---|
Language | Haskell98 |
Storable-based unboxed vectors.
Synopsis
- 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
Instances
(Arity n, Storable a) => VectorN Vec n a Source # | |
Defined in Data.Vector.Fixed.Storable | |
(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 n, Arity n, Storable a, Data a) => Data (Vec n a) Source # | |
Defined in Data.Vector.Fixed.Storable gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Vec n a -> c (Vec n a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Vec n a) # toConstr :: Vec n a -> Constr # dataTypeOf :: Vec n a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Vec n a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Vec n a)) # gmapT :: (forall b. Data b => b -> b) -> Vec n a -> Vec n a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Vec n a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Vec n a -> r # gmapQ :: (forall d. Data d => d -> u) -> Vec n a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Vec n a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Vec n a -> m (Vec n a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Vec n a -> m (Vec n a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Vec n a -> m (Vec n a) # | |
(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 # | |
Defined in Data.Vector.Fixed.Storable | |
type Dim (Vec n) Source # | |
Defined in Data.Vector.Fixed.Storable | |
type Mutable (Vec n) Source # | |
Defined in Data.Vector.Fixed.Storable |
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) |
Instances
(Arity n, Storable a) => MVector (MVec n) a Source # | |
Defined in Data.Vector.Fixed.Storable copy :: PrimMonad m => MVec n (PrimState m) a -> MVec n (PrimState m) a -> m () Source # move :: PrimMonad m => MVec n (PrimState m) a -> MVec n (PrimState m) a -> m () Source # new :: PrimMonad m => m (MVec n (PrimState m) a) Source # unsafeRead :: PrimMonad m => MVec n (PrimState m) a -> Int -> m a Source # unsafeWrite :: PrimMonad m => MVec n (PrimState m) a -> Int -> a -> m () Source # | |
type DimM (MVec n) Source # | |
Defined in Data.Vector.Fixed.Storable |
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)