|Maintainer||Roman Leshchinskiy <email@example.com>|
Class of pure vectors
- class MVector (Mutable v) a => Vector v a where
- type family Mutable v :: * -> * -> *
Class of immutable vectors.
Unsafely convert a mutable vector to its immutable version without copying. The mutable vector may not be used after this operation.
Length of the vector (not fusible!)
Yield a part of the vector without copying it. No range checks!
Yield the element at the given position in a monad. The monad allows us to be strict in the vector if we want. Suppose we had
unsafeIndex :: v a -> Int -> a
instead. Now, if we wanted to copy a vector, we'd do something like
copy mv v ... = ... unsafeWrite mv i (unsafeIndex v i) ...
For lazy vectors, the indexing would not be evaluated which means that we would retain a reference to the original vector in each element we write. This is not what we want!
basicUnsafeIndexM, we can do
copy mv v ... = ... case basicUnsafeIndexM v i of Box x -> unsafeWrite mv i x ...
which does not have this problem because indexing (but not the returned element!) is evaluated immediately.
Copy an immutable vector into a mutable one.
|Prim a => Vector Vector a|
|Storable a => Vector Vector a|
|Vector Vector Bool|
|Vector Vector Char|
|Vector Vector Double|
|Vector Vector Float|
|Vector Vector Int|
|Vector Vector Int8|
|Vector Vector Int16|
|Vector Vector Int32|
|Vector Vector Int64|
|Vector Vector Word|
|Vector Vector Word8|
|Vector Vector Word16|
|Vector Vector Word32|
|Vector Vector Word64|
|Vector Vector ()|
|Vector Vector a|
|(RealFloat a, Unbox a) => Vector Vector (Complex a)|
|(Unbox a, Unbox b) => Vector Vector (a, b)|
|(Unbox a, Unbox b, Unbox c) => Vector Vector (a, b, c)|
|(Unbox a, Unbox b, Unbox c, Unbox d) => Vector Vector (a, b, c, d)|
|(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector Vector (a, b, c, d, e)|
|(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector Vector (a, b, c, d, e, f)|