Safe Haskell | None |
---|
Type classes for vectors which are implemented on top of the arrays
and support in-place mutation. API is similar to one used in the
vector
package.
- class Arity n where
- type family Mutable v :: * -> * -> *
- type family DimM v :: *
- class Arity (DimM v) => MVector v a where
- overlaps :: v s a -> v s a -> Bool
- copy :: PrimMonad m => v (PrimState m) a -> v (PrimState m) a -> m ()
- move :: PrimMonad m => v (PrimState m) a -> v (PrimState m) a -> m ()
- new :: PrimMonad m => m (v (PrimState m) a)
- unsafeRead :: PrimMonad m => v (PrimState m) a -> Int -> m a
- unsafeWrite :: PrimMonad m => v (PrimState m) a -> Int -> a -> m ()
- lengthM :: forall v s a. Arity (DimM v) => v s a -> Int
- read :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m a
- write :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> a -> m ()
- clone :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (v (PrimState m) a)
- class (Dim v ~ DimM (Mutable v), MVector (Mutable v) a) => IVector v a where
- unsafeFreeze :: PrimMonad m => Mutable v (PrimState m) a -> m (v a)
- unsafeThaw :: PrimMonad m => v a -> m (Mutable v (PrimState m) a)
- unsafeIndex :: v a -> Int -> a
- index :: IVector v a => v a -> Int -> a
- lengthI :: IVector v a => v a -> Int
- freeze :: (PrimMonad m, IVector v a) => Mutable v (PrimState m) a -> m (v a)
- thaw :: (PrimMonad m, IVector v a) => v a -> m (Mutable v (PrimState m) a)
- constructVec :: forall v a. (Arity (Dim v), IVector v a) => Fun (Dim v) a (v a)
- inspectVec :: forall v a b. (Arity (Dim v), IVector v a) => v a -> Fun (Dim v) a b -> b
Mutable vectors
Type class for handling n-ary functions.
class Arity (DimM v) => MVector v a whereSource
Type class for mutable vectors.
overlaps :: v s a -> v s a -> BoolSource
Checks whether vectors' buffers overlaps
Copy vector. The two vectors may not overlap. Since vectors' length is encoded in the type there is no need in runtime checks.
Copy vector. The two vectors may overlap. Since vectors' length is encoded in the type there is no need in runtime checks.
new :: PrimMonad m => m (v (PrimState m) a)Source
Allocate new vector
unsafeRead :: PrimMonad m => v (PrimState m) a -> Int -> m aSource
Read value at index without bound checks.
unsafeWrite :: PrimMonad m => v (PrimState m) a -> Int -> a -> m ()Source
Write value at index without bound checks.
Arity n => MVector (MVec n) a | |
(Arity n, Prim a) => MVector (MVec n) a | |
Arity n => MVector (MVec n) Double | |
Arity n => MVector (MVec n) Float | |
Arity n => MVector (MVec n) Char | |
Arity n => MVector (MVec n) Word64 | |
Arity n => MVector (MVec n) Word32 | |
Arity n => MVector (MVec n) Word16 | |
Arity n => MVector (MVec n) Word8 | |
Arity n => MVector (MVec n) Word | |
Arity n => MVector (MVec n) Int64 | |
Arity n => MVector (MVec n) Int32 | |
Arity n => MVector (MVec n) Int16 | |
Arity n => MVector (MVec n) Int8 | |
Arity n => MVector (MVec n) Int | |
Arity n => MVector (MVec n) Bool | |
Arity n => MVector (MVec n) () | |
(Arity n, Storable a) => MVector (MVec n) a | |
(Arity n, MVector (MVec n) a) => MVector (MVec n) (Complex a) | |
(Arity n, MVector (MVec n) a, MVector (MVec n) b) => MVector (MVec n) (a, b) | |
(Arity n, MVector (MVec n) a, MVector (MVec n) b, MVector (MVec n) c) => MVector (MVec n) (a, b, c) |
lengthM :: forall v s a. Arity (DimM v) => v s a -> IntSource
Length of mutable vector. Function doesn't evaluate its argument.
read :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m aSource
Read value at index with bound checks.
write :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> a -> m ()Source
Write value at index with bound checks.
clone :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (v (PrimState m) a)Source
Create copy of vector.
Immutable vectors
class (Dim v ~ DimM (Mutable v), MVector (Mutable v) a) => IVector v a whereSource
Type class for immutable vectors
unsafeFreeze :: PrimMonad m => Mutable v (PrimState m) a -> m (v a)Source
Convert vector to immutable state. Mutable vector must not be modified afterwards.
unsafeThaw :: PrimMonad m => v a -> m (Mutable v (PrimState m) a)Source
Convert immutable vector to mutable. Immutable vector must not be used afterwards.
unsafeIndex :: v a -> Int -> aSource
Get element at specified index without bounds check.
Arity n => IVector (Vec n) a | |
(Arity n, Prim a) => IVector (Vec n) a | |
Arity n => IVector (Vec n) Double | |
Arity n => IVector (Vec n) Float | |
Arity n => IVector (Vec n) Char | |
Arity n => IVector (Vec n) Word64 | |
Arity n => IVector (Vec n) Word32 | |
Arity n => IVector (Vec n) Word16 | |
Arity n => IVector (Vec n) Word8 | |
Arity n => IVector (Vec n) Word | |
Arity n => IVector (Vec n) Int64 | |
Arity n => IVector (Vec n) Int32 | |
Arity n => IVector (Vec n) Int16 | |
Arity n => IVector (Vec n) Int8 | |
Arity n => IVector (Vec n) Int | |
Arity n => IVector (Vec n) Bool | |
Arity n => IVector (Vec n) () | |
(Arity n, Storable a) => IVector (Vec n) a | |
(Arity n, IVector (Vec n) a) => IVector (Vec n) (Complex a) | |
(Arity n, IVector (Vec n) a, IVector (Vec n) b) => IVector (Vec n) (a, b) | |
(Arity n, Vector (Vec n) a, Vector (Vec n) b, Vector (Vec n) c, IVector (Vec n) a, IVector (Vec n) b, IVector (Vec n) c) => IVector (Vec n) (a, b, c) |
lengthI :: IVector v a => v a -> IntSource
Length of immutable vector. Function doesn't evaluate its argument.
freeze :: (PrimMonad m, IVector v a) => Mutable v (PrimState m) a -> m (v a)Source
Safely convert mutable vector to immutable.
thaw :: (PrimMonad m, IVector v a) => v a -> m (Mutable v (PrimState m) a)Source
Safely convert immutable vector to mutable.