rebase
Safe HaskellNone
LanguageHaskell2010

Rebase.Data.Vector.Generic.Base

Synopsis

Documentation

type family Mutable (v :: Type -> Type) = (mv :: Type -> Type -> Type) | mv -> v #

Mutable v s a is the mutable version of the immutable vector type v a with the state token s. It is injective on GHC 8 and newer.

Instances

Instances details
type Mutable Array # 
Instance details

Defined in Data.Vector.Generic.Base

type Mutable PrimArray # 
Instance details

Defined in Data.Vector.Generic.Base

type Mutable SmallArray # 
Instance details

Defined in Data.Vector.Generic.Base

type Mutable Vector # 
Instance details

Defined in Data.Vector

type Mutable Vector # 
Instance details

Defined in Data.Vector.Primitive

type Mutable Vector # 
Instance details

Defined in Data.Vector.Storable

type Mutable Vector # 
Instance details

Defined in Data.Vector.Strict

type Mutable Vector # 
Instance details

Defined in Data.Vector.Unboxed.Base

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

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:

Methods

basicUnsafeFreeze :: Mutable v s a -> ST s (v a) #

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 :: v a -> ST s (Mutable v s a) #

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 #

Assumed complexity: O(1)

Yield the length of the vector.

basicUnsafeSlice #

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 :: v a -> Int -> Box a #

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 :: Mutable v s a -> v a -> ST s () #

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 based on basicUnsafeIndexM and basicUnsafeWrite.

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

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. This 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 definition: a is not evaluated at all.

Instances

Instances details
Vector Vector a # 
Instance details

Defined in Data.Vector

Methods

basicUnsafeFreeze :: Mutable Vector s a -> ST s (Vector a) #

basicUnsafeThaw :: Vector a -> ST s (Mutable Vector s a) #

basicLength :: Vector a -> Int #

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

basicUnsafeIndexM :: Vector a -> Int -> Box a #

basicUnsafeCopy :: Mutable Vector s a -> Vector a -> ST s () #

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

Prim a => Vector Vector a # 
Instance details

Defined in Data.Vector.Primitive

Methods

basicUnsafeFreeze :: Mutable Vector s a -> ST s (Vector a) #

basicUnsafeThaw :: Vector a -> ST s (Mutable Vector s a) #

basicLength :: Vector a -> Int #

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

basicUnsafeIndexM :: Vector a -> Int -> Box a #

basicUnsafeCopy :: Mutable Vector s a -> Vector a -> ST s () #

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

Storable a => Vector Vector a # 
Instance details

Defined in Data.Vector.Storable

Methods

basicUnsafeFreeze :: Mutable Vector s a -> ST s (Vector a) #

basicUnsafeThaw :: Vector a -> ST s (Mutable Vector s a) #

basicLength :: Vector a -> Int #

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

basicUnsafeIndexM :: Vector a -> Int -> Box a #

basicUnsafeCopy :: Mutable Vector s a -> Vector a -> ST s () #

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

Vector Vector a # 
Instance details

Defined in Data.Vector.Strict

Methods

basicUnsafeFreeze :: Mutable Vector s a -> ST s (Vector a) #

basicUnsafeThaw :: Vector a -> ST s (Mutable Vector s a) #

basicLength :: Vector a -> Int #

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

basicUnsafeIndexM :: Vector a -> Int -> Box a #

basicUnsafeCopy :: Mutable Vector s a -> Vector a -> ST s () #

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

Vector Vector All # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Any # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int16 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int32 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int64 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int8 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word16 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word32 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word64 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word8 # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector () # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s () -> ST s (Vector ()) #

basicUnsafeThaw :: Vector () -> ST s (Mutable Vector s ()) #

basicLength :: Vector () -> Int #

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

basicUnsafeIndexM :: Vector () -> Int -> Box () #

basicUnsafeCopy :: Mutable Vector s () -> Vector () -> ST s () #

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

Vector Vector Bool # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Char # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Double # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Float # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word # 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Vector Vector (Complex a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Vector Vector (First a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Vector Vector (Last a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Last a) -> ST s (Vector (Last a)) #

basicUnsafeThaw :: Vector (Last a) -> ST s (Mutable Vector s (Last a)) #

basicLength :: Vector (Last a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Last a) -> Vector (Last a) #

basicUnsafeIndexM :: Vector (Last a) -> Int -> Box (Last a) #

basicUnsafeCopy :: Mutable Vector s (Last a) -> Vector (Last a) -> ST s () #

elemseq :: Vector (Last a) -> Last a -> b -> b #

Unbox a => Vector Vector (Max a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Max a) -> ST s (Vector (Max a)) #

basicUnsafeThaw :: Vector (Max a) -> ST s (Mutable Vector s (Max a)) #

basicLength :: Vector (Max a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Max a) -> Vector (Max a) #

basicUnsafeIndexM :: Vector (Max a) -> Int -> Box (Max a) #

basicUnsafeCopy :: Mutable Vector s (Max a) -> Vector (Max a) -> ST s () #

elemseq :: Vector (Max a) -> Max a -> b -> b #

Unbox a => Vector Vector (Min a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Min a) -> ST s (Vector (Min a)) #

basicUnsafeThaw :: Vector (Min a) -> ST s (Mutable Vector s (Min a)) #

basicLength :: Vector (Min a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Min a) -> Vector (Min a) #

basicUnsafeIndexM :: Vector (Min a) -> Int -> Box (Min a) #

basicUnsafeCopy :: Mutable Vector s (Min a) -> Vector (Min a) -> ST s () #

elemseq :: Vector (Min a) -> Min a -> b -> b #

Unbox a => Vector Vector (WrappedMonoid a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Vector Vector (Identity a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Vector Vector (Down a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Down a) -> ST s (Vector (Down a)) #

basicUnsafeThaw :: Vector (Down a) -> ST s (Mutable Vector s (Down a)) #

basicLength :: Vector (Down a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Down a) -> Vector (Down a) #

basicUnsafeIndexM :: Vector (Down a) -> Int -> Box (Down a) #

basicUnsafeCopy :: Mutable Vector s (Down a) -> Vector (Down a) -> ST s () #

elemseq :: Vector (Down a) -> Down a -> b -> b #

Unbox a => Vector Vector (Dual a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Dual a) -> ST s (Vector (Dual a)) #

basicUnsafeThaw :: Vector (Dual a) -> ST s (Mutable Vector s (Dual a)) #

basicLength :: Vector (Dual a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Dual a) -> Vector (Dual a) #

basicUnsafeIndexM :: Vector (Dual a) -> Int -> Box (Dual a) #

basicUnsafeCopy :: Mutable Vector s (Dual a) -> Vector (Dual a) -> ST s () #

elemseq :: Vector (Dual a) -> Dual a -> b -> b #

Unbox a => Vector Vector (Product a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Vector Vector (Sum a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Sum a) -> ST s (Vector (Sum a)) #

basicUnsafeThaw :: Vector (Sum a) -> ST s (Mutable Vector s (Sum a)) #

basicLength :: Vector (Sum a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Sum a) -> Vector (Sum a) #

basicUnsafeIndexM :: Vector (Sum a) -> Int -> Box (Sum a) #

basicUnsafeCopy :: Mutable Vector s (Sum a) -> Vector (Sum a) -> ST s () #

elemseq :: Vector (Sum a) -> Sum a -> b -> b #

Vector Vector (DoNotUnboxLazy a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

NFData a => Vector Vector (DoNotUnboxNormalForm a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector (DoNotUnboxStrict a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Prim a => Vector Vector (UnboxViaPrim a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

(Unbox a, Unbox b) => Vector Vector (Arg a b) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Arg a b) -> ST s (Vector (Arg a b)) #

basicUnsafeThaw :: Vector (Arg a b) -> ST s (Mutable Vector s (Arg a b)) #

basicLength :: Vector (Arg a b) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Arg a b) -> Vector (Arg a b) #

basicUnsafeIndexM :: Vector (Arg a b) -> Int -> Box (Arg a b) #

basicUnsafeCopy :: Mutable Vector s (Arg a b) -> Vector (Arg a b) -> ST s () #

elemseq :: Vector (Arg a b) -> Arg a b -> b0 -> b0 #

(IsoUnbox a b, Unbox b) => Vector Vector (As a b) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (As a b) -> ST s (Vector (As a b)) #

basicUnsafeThaw :: Vector (As a b) -> ST s (Mutable Vector s (As a b)) #

basicLength :: Vector (As a b) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (As a b) -> Vector (As a b) #

basicUnsafeIndexM :: Vector (As a b) -> Int -> Box (As a b) #

basicUnsafeCopy :: Mutable Vector s (As a b) -> Vector (As a b) -> ST s () #

elemseq :: Vector (As a b) -> As a b -> b0 -> b0 #

(Unbox a, Unbox b) => Vector Vector (a, b) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (a, b) -> ST s (Vector (a, b)) #

basicUnsafeThaw :: Vector (a, b) -> ST s (Mutable Vector s (a, b)) #

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

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

basicUnsafeIndexM :: Vector (a, b) -> Int -> Box (a, b) #

basicUnsafeCopy :: Mutable Vector s (a, b) -> Vector (a, b) -> ST s () #

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

Unbox a => Vector Vector (Const a b) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Const a b) -> ST s (Vector (Const a b)) #

basicUnsafeThaw :: Vector (Const a b) -> ST s (Mutable Vector s (Const a b)) #

basicLength :: Vector (Const a b) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Const a b) -> Vector (Const a b) #

basicUnsafeIndexM :: Vector (Const a b) -> Int -> Box (Const a b) #

basicUnsafeCopy :: Mutable Vector s (Const a b) -> Vector (Const a b) -> ST s () #

elemseq :: Vector (Const a b) -> Const a b -> b0 -> b0 #

Unbox (f a) => Vector Vector (Alt f a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Alt f a) -> ST s (Vector (Alt f a)) #

basicUnsafeThaw :: Vector (Alt f a) -> ST s (Mutable Vector s (Alt f a)) #

basicLength :: Vector (Alt f a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Alt f a) -> Vector (Alt f a) #

basicUnsafeIndexM :: Vector (Alt f a) -> Int -> Box (Alt f a) #

basicUnsafeCopy :: Mutable Vector s (Alt f a) -> Vector (Alt f a) -> ST s () #

elemseq :: Vector (Alt f a) -> Alt f a -> b -> b #

(Unbox a, Unbox b, Unbox c) => Vector Vector (a, b, c) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (a, b, c) -> ST s (Vector (a, b, c)) #

basicUnsafeThaw :: Vector (a, b, c) -> ST s (Mutable Vector s (a, b, c)) #

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

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

basicUnsafeIndexM :: Vector (a, b, c) -> Int -> Box (a, b, c) #

basicUnsafeCopy :: Mutable Vector s (a, b, c) -> Vector (a, b, c) -> ST s () #

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

(Unbox a, Unbox b, Unbox c, Unbox d) => Vector Vector (a, b, c, d) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (a, b, c, d) -> ST s (Vector (a, b, c, d)) #

basicUnsafeThaw :: Vector (a, b, c, d) -> ST s (Mutable Vector s (a, b, c, d)) #

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

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

basicUnsafeIndexM :: Vector (a, b, c, d) -> Int -> Box (a, b, c, d) #

basicUnsafeCopy :: Mutable Vector s (a, b, c, d) -> Vector (a, b, c, d) -> ST s () #

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

Unbox (f (g a)) => Vector Vector (Compose f g a) # 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: Mutable Vector s (Compose f g a) -> ST s (Vector (Compose f g a)) #

basicUnsafeThaw :: Vector (Compose f g a) -> ST s (Mutable Vector s (Compose f g a)) #

basicLength :: Vector (Compose f g a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Compose f g a) -> Vector (Compose f g a) #

basicUnsafeIndexM :: Vector (Compose f g a) -> Int -> Box (Compose f g a) #

basicUnsafeCopy :: Mutable Vector s (Compose f g a) -> Vector (Compose f g a) -> ST s () #

elemseq :: Vector (Compose f g a) -> Compose f g a -> b -> b #

(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 :: Mutable Vector s (a, b, c, d, e) -> ST s (Vector (a, b, c, d, e)) #

basicUnsafeThaw :: Vector (a, b, c, d, e) -> ST s (Mutable Vector s (a, b, c, d, e)) #

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

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

basicUnsafeIndexM :: Vector (a, b, c, d, e) -> Int -> Box (a, b, c, d, e) #

basicUnsafeCopy :: Mutable Vector s (a, b, c, d, e) -> Vector (a, b, c, d, e) -> ST s () #

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

(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 :: Mutable Vector s (a, b, c, d, e, f) -> ST s (Vector (a, b, c, d, e, f)) #

basicUnsafeThaw :: Vector (a, b, c, d, e, f) -> ST s (Mutable Vector s (a, b, c, d, e, f)) #

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

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

basicUnsafeIndexM :: Vector (a, b, c, d, e, f) -> Int -> Box (a, b, c, d, e, f) #

basicUnsafeCopy :: Mutable Vector s (a, b, c, d, e, f) -> Vector (a, b, c, d, e, f) -> ST s () #

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