Safe Haskell | None |
---|

Type classes for array based vector. They are quite similar to ones
from `vector`

package but those only suitable for vectors with
variable length.

- 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

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.

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.

# 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

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.