rio-0.1.8.0: A standard library for Haskell

Safe Haskell | None
Language | Haskell2010

RIO.Vector.Unsafe

Contents

- Immutable vectors
- Accessors
  - Indexing
  - Monadic indexing
  - Extracting subvectors
- Modifying vectors
  - Bulk updates
  - Accumulations
  - Permutations
- Conversions
  - Mutable vectors

Synopsis

- class MVector (Mutable v) a => Vector (v :: Type -> Type) a where
  - basicUnsafeFreeze :: PrimMonad m => Mutable v (PrimState m) a -> m (v a)
  - basicUnsafeThaw :: PrimMonad m => v a -> m (Mutable v (PrimState m) a)
  - basicLength :: v a -> Int
  - basicUnsafeSlice :: Int -> Int -> v a -> v a
  - basicUnsafeIndexM :: Monad m => v a -> Int -> m a
  - basicUnsafeCopy :: PrimMonad m => Mutable v (PrimState m) a -> v a -> m ()
  - elemseq :: v a -> a -> b -> b
- unsafeIndex :: Vector v a => v a -> Int -> a
- unsafeHead :: Vector v a => v a -> a
- unsafeLast :: Vector v a => v a -> a
- unsafeIndexM :: (Vector v a, Monad m) => v a -> Int -> m a
- unsafeHeadM :: (Vector v a, Monad m) => v a -> m a
- unsafeLastM :: (Vector v a, Monad m) => v a -> m a
- unsafeSlice :: Vector v a => Int -> Int -> v a -> v a
- unsafeInit :: Vector v a => v a -> v a
- unsafeTail :: Vector v a => v a -> v a
- unsafeTake :: Vector v a => Int -> v a -> v a
- unsafeDrop :: Vector v a => Int -> v a -> v a
- unsafeUpd :: Vector v a => v a -> [(Int, a)] -> v a
- unsafeUpdate :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a
- unsafeUpdate_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a
- unsafeAccum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a
- unsafeAccumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a
- unsafeAccumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a
- unsafeBackpermute :: (Vector v a, Vector v Int) => v a -> v Int -> v a
- unsafeFreeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)
- unsafeThaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)
- unsafeCopy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m ()

# Immutable vectors

class MVector (Mutable v) a => Vector (v :: Type -> Type) a where Source #

Class of immutable vectors. Every immutable vector is associated with its mutable version through the `Mutable` type family. Methods of this class should not be used directly. Instead, Data.Vector.Generic and other Data.Vector modules provide safe and fusible wrappers.

Minimum complete implementation:

- `basicUnsafeFreeze`
- `basicUnsafeThaw`
- `basicLength`
- `basicUnsafeSlice`
- `basicUnsafeIndexM`

Minimal complete definition

basicUnsafeFreeze, basicUnsafeThaw, basicLength, basicUnsafeSlice, basicUnsafeIndexM

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable v (PrimState m) a -> m (v a) Source #

Assumed complexity: O(1)

Unsafely convert a mutable vector to its immutable version without copying. The mutable vector may not be used after this operation.

basicUnsafeThaw :: PrimMonad m => v a -> m (Mutable v (PrimState m) a) Source #

Assumed complexity: O(1)

Unsafely convert an immutable vector to its mutable version without copying. The immutable vector may not be used after this operation.

basicLength :: v a -> Int Source #

Assumed complexity: O(1)

Yield the length of the vector.

basicUnsafeSlice Source #

Arguments

:: Int | starting index
-> Int | length
-> v a |
-> v a |

Assumed complexity: O(1)

Yield a slice of the vector without copying it. No range checks are performed.

basicUnsafeIndexM :: Monad m => v a -> Int -> m a Source #

Assumed complexity: O(1)

Yield the element at the given position in a monad. No range checks are performed.

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!

With `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.

basicUnsafeCopy :: PrimMonad m => Mutable v (PrimState m) a -> v a -> m () Source #

Assumed complexity: O(n)

Copy an immutable vector into a mutable one. The two vectors must have the same length but this is not checked.

Instances of `Vector` should redefine this method if they wish to support an efficient block copy operation.

Default definition: copying basic on `basicUnsafeIndexM` and `basicUnsafeWrite`.

elemseq :: v a -> a -> b -> b Source #

Evaluate `a` as far as storing it in a vector would and yield `b`. The `v a` argument only fixes the type and is not touched. The method is only used for optimisation purposes. Thus, it is safe for instances of `Vector` to evaluate `a` less than it would be when stored in a vector although this might result in suboptimal code.

    elemseq v x y = (singleton x `asTypeOf` v) `seq` y

Default defintion: `a` is not evaluated at all

Instances

Vector Vector Bool |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Bool -> m (Vector Bool) Source #

basicUnsafeThaw :: PrimMonad m => Vector Bool -> m (Mutable Vector (PrimState m) Bool) Source #

basicLength :: Vector Bool -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Bool -> Vector Bool Source #

basicUnsafeIndexM :: Monad m => Vector Bool -> Int -> m Bool Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Bool -> Vector Bool -> m () Source #

elemseq :: Vector Bool -> Bool -> b -> b Source #

Vector Vector Char |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Char -> m (Vector Char) Source #

basicUnsafeThaw :: PrimMonad m => Vector Char -> m (Mutable Vector (PrimState m) Char) Source #

basicLength :: Vector Char -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Char -> Vector Char Source #

basicUnsafeIndexM :: Monad m => Vector Char -> Int -> m Char Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Char -> Vector Char -> m () Source #

elemseq :: Vector Char -> Char -> b -> b Source #

Vector Vector Double |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Double -> m (Vector Double) Source #

basicUnsafeThaw :: PrimMonad m => Vector Double -> m (Mutable Vector (PrimState m) Double) Source #

basicLength :: Vector Double -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Double -> Vector Double Source #

basicUnsafeIndexM :: Monad m => Vector Double -> Int -> m Double Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Double -> Vector Double -> m () Source #

elemseq :: Vector Double -> Double -> b -> b Source #

Vector Vector Float |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Float -> m (Vector Float) Source #

basicUnsafeThaw :: PrimMonad m => Vector Float -> m (Mutable Vector (PrimState m) Float) Source #

basicLength :: Vector Float -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Float -> Vector Float Source #

basicUnsafeIndexM :: Monad m => Vector Float -> Int -> m Float Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Float -> Vector Float -> m () Source #

elemseq :: Vector Float -> Float -> b -> b Source #

Vector Vector Int |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Int -> m (Vector Int) Source #

basicUnsafeThaw :: PrimMonad m => Vector Int -> m (Mutable Vector (PrimState m) Int) Source #

basicLength :: Vector Int -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Int -> Vector Int Source #

basicUnsafeIndexM :: Monad m => Vector Int -> Int -> m Int Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Int -> Vector Int -> m () Source #

elemseq :: Vector Int -> Int -> b -> b Source #

Vector Vector Int8 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Int8 -> m (Vector Int8) Source #

basicUnsafeThaw :: PrimMonad m => Vector Int8 -> m (Mutable Vector (PrimState m) Int8) Source #

basicLength :: Vector Int8 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Int8 -> Vector Int8 Source #

basicUnsafeIndexM :: Monad m => Vector Int8 -> Int -> m Int8 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Int8 -> Vector Int8 -> m () Source #

elemseq :: Vector Int8 -> Int8 -> b -> b Source #

Vector Vector Int16 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Int16 -> m (Vector Int16) Source #

basicUnsafeThaw :: PrimMonad m => Vector Int16 -> m (Mutable Vector (PrimState m) Int16) Source #

basicLength :: Vector Int16 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Int16 -> Vector Int16 Source #

basicUnsafeIndexM :: Monad m => Vector Int16 -> Int -> m Int16 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Int16 -> Vector Int16 -> m () Source #

elemseq :: Vector Int16 -> Int16 -> b -> b Source #

Vector Vector Int32 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Int32 -> m (Vector Int32) Source #

basicUnsafeThaw :: PrimMonad m => Vector Int32 -> m (Mutable Vector (PrimState m) Int32) Source #

basicLength :: Vector Int32 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Int32 -> Vector Int32 Source #

basicUnsafeIndexM :: Monad m => Vector Int32 -> Int -> m Int32 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Int32 -> Vector Int32 -> m () Source #

elemseq :: Vector Int32 -> Int32 -> b -> b Source #

Vector Vector Int64 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Int64 -> m (Vector Int64) Source #

basicUnsafeThaw :: PrimMonad m => Vector Int64 -> m (Mutable Vector (PrimState m) Int64) Source #

basicLength :: Vector Int64 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Int64 -> Vector Int64 Source #

basicUnsafeIndexM :: Monad m => Vector Int64 -> Int -> m Int64 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Int64 -> Vector Int64 -> m () Source #

elemseq :: Vector Int64 -> Int64 -> b -> b Source #

Vector Vector Word |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Word -> m (Vector Word) Source #

basicUnsafeThaw :: PrimMonad m => Vector Word -> m (Mutable Vector (PrimState m) Word) Source #

basicLength :: Vector Word -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Word -> Vector Word Source #

basicUnsafeIndexM :: Monad m => Vector Word -> Int -> m Word Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Word -> Vector Word -> m () Source #

elemseq :: Vector Word -> Word -> b -> b Source #

Vector Vector Word8 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Word8 -> m (Vector Word8) Source #

basicUnsafeThaw :: PrimMonad m => Vector Word8 -> m (Mutable Vector (PrimState m) Word8) Source #

basicLength :: Vector Word8 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Word8 -> Vector Word8 Source #

basicUnsafeIndexM :: Monad m => Vector Word8 -> Int -> m Word8 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Word8 -> Vector Word8 -> m () Source #

elemseq :: Vector Word8 -> Word8 -> b -> b Source #

Vector Vector Word16 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Word16 -> m (Vector Word16) Source #

basicUnsafeThaw :: PrimMonad m => Vector Word16 -> m (Mutable Vector (PrimState m) Word16) Source #

basicLength :: Vector Word16 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Word16 -> Vector Word16 Source #

basicUnsafeIndexM :: Monad m => Vector Word16 -> Int -> m Word16 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Word16 -> Vector Word16 -> m () Source #

elemseq :: Vector Word16 -> Word16 -> b -> b Source #

Vector Vector Word32 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Word32 -> m (Vector Word32) Source #

basicUnsafeThaw :: PrimMonad m => Vector Word32 -> m (Mutable Vector (PrimState m) Word32) Source #

basicLength :: Vector Word32 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Word32 -> Vector Word32 Source #

basicUnsafeIndexM :: Monad m => Vector Word32 -> Int -> m Word32 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Word32 -> Vector Word32 -> m () Source #

elemseq :: Vector Word32 -> Word32 -> b -> b Source #

Vector Vector Word64 |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Word64 -> m (Vector Word64) Source #

basicUnsafeThaw :: PrimMonad m => Vector Word64 -> m (Mutable Vector (PrimState m) Word64) Source #

basicLength :: Vector Word64 -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector Word64 -> Vector Word64 Source #

basicUnsafeIndexM :: Monad m => Vector Word64 -> Int -> m Word64 Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Word64 -> Vector Word64 -> m () Source #

elemseq :: Vector Word64 -> Word64 -> b -> b Source #

Vector Vector () |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) () -> m (Vector ()) Source #

basicUnsafeThaw :: PrimMonad m => Vector () -> m (Mutable Vector (PrimState m) ()) Source #

basicLength :: Vector () -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector () -> Vector () Source #

basicUnsafeIndexM :: Monad m => Vector () -> Int -> m () Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) () -> Vector () -> m () Source #

elemseq :: Vector () -> () -> b -> b Source #

Storable a => Vector Vector a |

Instance details

Defined in Data.Vector.Storable

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) a -> m (Vector a) Source #

basicUnsafeThaw :: PrimMonad m => Vector a -> m (Mutable Vector (PrimState m) a) Source #

basicLength :: Vector a -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector a -> Vector a Source #

basicUnsafeIndexM :: Monad m => Vector a -> Int -> m a Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) a -> Vector a -> m () Source #

elemseq :: Vector a -> a -> b -> b Source #

Prim a => Vector Vector a |

Instance details

Defined in Data.Vector.Primitive

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) a -> m (Vector a) Source #

basicUnsafeThaw :: PrimMonad m => Vector a -> m (Mutable Vector (PrimState m) a) Source #

basicLength :: Vector a -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector a -> Vector a Source #

basicUnsafeIndexM :: Monad m => Vector a -> Int -> m a Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) a -> Vector a -> m () Source #

elemseq :: Vector a -> a -> b -> b Source #

Vector Vector a |

Instance details

Defined in Data.Vector

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) a -> m (Vector a) Source #

basicUnsafeThaw :: PrimMonad m => Vector a -> m (Mutable Vector (PrimState m) a) Source #

basicLength :: Vector a -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector a -> Vector a Source #

basicUnsafeIndexM :: Monad m => Vector a -> Int -> m a Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) a -> Vector a -> m () Source #

elemseq :: Vector a -> a -> b -> b Source #

Unbox a => Vector Vector (Complex a) |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Complex a) -> m (Vector (Complex a)) Source #

basicUnsafeThaw :: PrimMonad m => Vector (Complex a) -> m (Mutable Vector (PrimState m) (Complex a)) Source #

basicLength :: Vector (Complex a) -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector (Complex a) -> Vector (Complex a) Source #

basicUnsafeIndexM :: Monad m => Vector (Complex a) -> Int -> m (Complex a) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Complex a) -> Vector (Complex a) -> m () Source #

elemseq :: Vector (Complex a) -> Complex a -> b -> b Source #

(Unbox a, Unbox b) => Vector Vector (a, b) |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b) -> m (Vector (a, b)) Source #

basicUnsafeThaw :: PrimMonad m => Vector (a, b) -> m (Mutable Vector (PrimState m) (a, b)) Source #

basicLength :: Vector (a, b) -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector (a, b) -> Vector (a, b) Source #

basicUnsafeIndexM :: Monad m => Vector (a, b) -> Int -> m (a, b) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b) -> Vector (a, b) -> m () Source #

elemseq :: Vector (a, b) -> (a, b) -> b0 -> b0 Source #

(Unbox a, Unbox b, Unbox c) => Vector Vector (a, b, c) |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c) -> m (Vector (a, b, c)) Source #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c) -> m (Mutable Vector (PrimState m) (a, b, c)) Source #

basicLength :: Vector (a, b, c) -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c) -> Vector (a, b, c) Source #

basicUnsafeIndexM :: Monad m => Vector (a, b, c) -> Int -> m (a, b, c) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c) -> Vector (a, b, c) -> m () Source #

elemseq :: Vector (a, b, c) -> (a, b, c) -> b0 -> b0 Source #

(Unbox a, Unbox b, Unbox c, Unbox d) => Vector Vector (a, b, c, d) |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d) -> m (Vector (a, b, c, d)) Source #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c, d) -> m (Mutable Vector (PrimState m) (a, b, c, d)) Source #

basicLength :: Vector (a, b, c, d) -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c, d) -> Vector (a, b, c, d) Source #

basicUnsafeIndexM :: Monad m => Vector (a, b, c, d) -> Int -> m (a, b, c, d) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d) -> Vector (a, b, c, d) -> m () Source #

elemseq :: Vector (a, b, c, d) -> (a, b, c, d) -> b0 -> b0 Source #

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector Vector (a, b, c, d, e) |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e) -> m (Vector (a, b, c, d, e)) Source #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c, d, e) -> m (Mutable Vector (PrimState m) (a, b, c, d, e)) Source #

basicLength :: Vector (a, b, c, d, e) -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c, d, e) -> Vector (a, b, c, d, e) Source #

basicUnsafeIndexM :: Monad m => Vector (a, b, c, d, e) -> Int -> m (a, b, c, d, e) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e) -> Vector (a, b, c, d, e) -> m () Source #

elemseq :: Vector (a, b, c, d, e) -> (a, b, c, d, e) -> b0 -> b0 Source #

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector Vector (a, b, c, d, e, f) |

Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e, f) -> m (Vector (a, b, c, d, e, f)) Source #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c, d, e, f) -> m (Mutable Vector (PrimState m) (a, b, c, d, e, f)) Source #

basicLength :: Vector (a, b, c, d, e, f) -> Int Source #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c, d, e, f) -> Vector (a, b, c, d, e, f) Source #

basicUnsafeIndexM :: Monad m => Vector (a, b, c, d, e, f) -> Int -> m (a, b, c, d, e, f) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e, f) -> Vector (a, b, c, d, e, f) -> m () Source #

elemseq :: Vector (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> b0 -> b0 Source #

# Accessors

## Indexing

unsafeIndex :: Vector v a => v a -> Int -> a Source #

O(1) Unsafe indexing without bounds checking

unsafeHead :: Vector v a => v a -> a Source #

O(1) First element without checking if the vector is empty

unsafeLast :: Vector v a => v a -> a Source #

O(1) Last element without checking if the vector is empty

## Monadic indexing

unsafeIndexM :: (Vector v a, Monad m) => v a -> Int -> m a Source #

O(1) Indexing in a monad without bounds checks. See `indexM` for an explanation of why this is useful.

unsafeHeadM :: (Vector v a, Monad m) => v a -> m a Source #

O(1) First element in a monad without checking for empty vectors. See `indexM` for an explanation of why this is useful.

unsafeLastM :: (Vector v a, Monad m) => v a -> m a Source #

O(1) Last element in a monad without checking for empty vectors. See `indexM` for an explanation of why this is useful.

## Extracting subvectors

unsafeSlice Source #

Arguments

:: Vector v a |
=> Int | `i` starting index
-> Int | `n` length
-> v a |
-> v a |

O(1) Yield a slice of the vector without copying. The vector must contain at least `i+n` elements but this is not checked.

unsafeInit :: Vector v a => v a -> v a Source #

O(1) Yield all but the last element without copying. The vector may not be empty but this is not checked.

unsafeTail :: Vector v a => v a -> v a Source #

O(1) Yield all but the first element without copying. The vector may not be empty but this is not checked.

unsafeTake :: Vector v a => Int -> v a -> v a Source #

O(1) Yield the first `n` elements without copying. The vector must contain at least `n` elements but this is not checked.

unsafeDrop :: Vector v a => Int -> v a -> v a Source #

O(1) Yield all but the first `n` elements without copying. The vector must contain at least `n` elements but this is not checked.

# Modifying vectors

## Bulk updates

unsafeUpd :: Vector v a => v a -> [(Int, a)] -> v a Source #

Same as (`//`) but without bounds checking.

unsafeUpdate :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a Source #

Same as `update` but without bounds checking.

unsafeUpdate_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a Source #

Same as `update_` but without bounds checking.

## Accumulations

unsafeAccum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a Source #

Same as `accum` but without bounds checking.

unsafeAccumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a Source #

Same as `accumulate` but without bounds checking.

unsafeAccumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a Source #

Same as `accumulate_` but without bounds checking.

## Permutations

unsafeBackpermute :: (Vector v a, Vector v Int) => v a -> v Int -> v a Source #

Same as `backpermute` but without bounds checking.

# Conversions

## Mutable vectors

unsafeFreeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a) Source #

O(1) Unsafe convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation.

unsafeThaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a) Source #

O(1) Unsafely convert an immutable vector to a mutable one without copying. The immutable vector may not be used after this operation.

unsafeCopy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m () Source #

O(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked.