{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Data.Vector.Unboxed.Mutable.Sized
( MVector
, length
, length'
, null
, slice
, slice'
, init
, tail
, take
, take'
, drop
, drop'
, splitAt
, splitAt'
, overlaps
, new
, unsafeNew
, replicate
, replicate'
, replicateM
, replicateM'
, clone
, grow
, growFront
, clear
, read
, read'
, write
, write'
, modify
, modify'
, swap
, exchange
, exchange'
, unsafeRead
, unsafeWrite
, unsafeModify
, unsafeSwap
, unsafeExchange
#if MIN_VERSION_vector(0,12,0)
, nextPermutation
#endif
, set
, copy
, move
, unsafeCopy
, toSized
, withSized
, fromSized
, Unbox
) where
import Data.Vector.Generic.Sized.Internal (Vector(..))
import qualified Data.Vector.Generic as V
import qualified Data.Vector.Generic.Mutable as VM
import qualified Data.Vector.Generic.Sized as VG
import qualified Data.Vector.Generic.Mutable.Sized as VGM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Vector.Unboxed (Unbox)
import GHC.TypeLits
import Data.Finite
import Data.Proxy
import Control.Monad.Primitive
import Prelude hiding ( length, null, replicate, init,
tail, take, drop, splitAt, read )
type MVector = VGM.MVector VUM.MVector
length :: forall n s a. (KnownNat n)
=> MVector n s a -> Int
length :: forall (n :: Nat) s a. KnownNat n => MVector n s a -> Int
length = MVector MVector n s a -> Int
forall (v :: * -> * -> *) (n :: Nat) s a.
KnownNat n =>
MVector v n s a -> Int
VGM.length
{-# inline length #-}
length' :: forall n s a. ()
=> MVector n s a -> Proxy n
length' :: forall (n :: Nat) s a. MVector n s a -> Proxy n
length' = MVector MVector n s a -> Proxy n
forall (v :: * -> * -> *) (n :: Nat) s a.
MVector v n s a -> Proxy n
VGM.length'
{-# inline length' #-}
null :: forall n s a. (KnownNat n)
=> MVector n s a -> Bool
null :: forall (n :: Nat) s a. KnownNat n => MVector n s a -> Bool
null = MVector MVector n s a -> Bool
forall (v :: * -> * -> *) (n :: Nat) s a.
KnownNat n =>
MVector v n s a -> Bool
VGM.null
{-# inline null #-}
slice :: forall i n k s a p. (KnownNat i, KnownNat n, Unbox a)
=> p i
-> MVector (i+n+k) s a
-> MVector n s a
slice :: forall (i :: Nat) (n :: Nat) (k :: Nat) s a (p :: Nat -> *).
(KnownNat i, KnownNat n, Unbox a) =>
p i -> MVector ((i + n) + k) s a -> MVector n s a
slice = p i -> MVector MVector ((i + n) + k) s a -> MVector MVector n s a
forall (v :: * -> * -> *) (i :: Nat) (n :: Nat) (k :: Nat) s a
(p :: Nat -> *).
(KnownNat i, KnownNat n, MVector v a) =>
p i -> MVector v ((i + n) + k) s a -> MVector v n s a
VGM.slice
{-# inline slice #-}
slice' :: forall i n k s a p
. (KnownNat i, KnownNat n, Unbox a)
=> p i
-> p n
-> MVector (i+n+k) s a
-> MVector n s a
slice' :: forall (i :: Nat) (n :: Nat) (k :: Nat) s a (p :: Nat -> *).
(KnownNat i, KnownNat n, Unbox a) =>
p i -> p n -> MVector ((i + n) + k) s a -> MVector n s a
slice' = p i
-> p n
-> MVector MVector ((i + n) + k) s a
-> MVector MVector n s a
forall (v :: * -> * -> *) (i :: Nat) (n :: Nat) (k :: Nat) s a
(p :: Nat -> *).
(KnownNat i, KnownNat n, MVector v a) =>
p i -> p n -> MVector v ((i + n) + k) s a -> MVector v n s a
VGM.slice'
{-# inline slice' #-}
init :: forall n s a. Unbox a
=> MVector (n+1) s a -> MVector n s a
init :: forall (n :: Nat) s a.
Unbox a =>
MVector (n + 1) s a -> MVector n s a
init = MVector MVector (n + 1) s a -> MVector MVector n s a
forall (v :: * -> * -> *) (n :: Nat) s a.
MVector v a =>
MVector v (n + 1) s a -> MVector v n s a
VGM.init
{-# inline init #-}
tail :: forall n s a. Unbox a
=> MVector (1+n) s a -> MVector n s a
tail :: forall (n :: Nat) s a.
Unbox a =>
MVector (1 + n) s a -> MVector n s a
tail = MVector MVector (1 + n) s a -> MVector MVector n s a
forall (v :: * -> * -> *) (n :: Nat) s a.
MVector v a =>
MVector v (1 + n) s a -> MVector v n s a
VGM.tail
{-# inline tail #-}
take :: forall n k s a. (KnownNat n, Unbox a)
=> MVector (n+k) s a -> MVector n s a
take :: forall (n :: Nat) (k :: Nat) s a.
(KnownNat n, Unbox a) =>
MVector (n + k) s a -> MVector n s a
take = MVector MVector (n + k) s a -> MVector MVector n s a
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) s a.
(KnownNat n, MVector v a) =>
MVector v (n + k) s a -> MVector v n s a
VGM.take
{-# inline take #-}
take' :: forall n k s a p. (KnownNat n, Unbox a)
=> p n -> MVector (n+k) s a -> MVector n s a
take' :: forall (n :: Nat) (k :: Nat) s a (p :: Nat -> *).
(KnownNat n, Unbox a) =>
p n -> MVector (n + k) s a -> MVector n s a
take' = p n -> MVector MVector (n + k) s a -> MVector MVector n s a
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) s a
(p :: Nat -> *).
(KnownNat n, MVector v a) =>
p n -> MVector v (n + k) s a -> MVector v n s a
VGM.take'
{-# inline take' #-}
drop :: forall n k s a. (KnownNat n, Unbox a)
=> MVector (n+k) s a -> MVector k s a
drop :: forall (n :: Nat) (k :: Nat) s a.
(KnownNat n, Unbox a) =>
MVector (n + k) s a -> MVector k s a
drop = MVector MVector (n + k) s a -> MVector MVector k s a
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) s a.
(KnownNat n, MVector v a) =>
MVector v (n + k) s a -> MVector v k s a
VGM.drop
{-# inline drop #-}
drop' :: forall n k s a p. (KnownNat n, Unbox a)
=> p n -> MVector (n+k) s a -> MVector k s a
drop' :: forall (n :: Nat) (k :: Nat) s a (p :: Nat -> *).
(KnownNat n, Unbox a) =>
p n -> MVector (n + k) s a -> MVector k s a
drop' = p n -> MVector MVector (n + k) s a -> MVector MVector k s a
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) s a
(p :: Nat -> *).
(KnownNat n, MVector v a) =>
p n -> MVector v (n + k) s a -> MVector v k s a
VGM.drop'
{-# inline drop' #-}
splitAt :: forall n m s a. (KnownNat n, Unbox a)
=> MVector (n+m) s a -> (MVector n s a, MVector m s a)
splitAt :: forall (n :: Nat) (m :: Nat) s a.
(KnownNat n, Unbox a) =>
MVector (n + m) s a -> (MVector n s a, MVector m s a)
splitAt = MVector MVector (n + m) s a
-> (MVector MVector n s a, MVector MVector m s a)
forall (v :: * -> * -> *) (n :: Nat) (m :: Nat) s a.
(KnownNat n, MVector v a) =>
MVector v (n + m) s a -> (MVector v n s a, MVector v m s a)
VGM.splitAt
{-# inline splitAt #-}
splitAt' :: forall n m s a p. (KnownNat n, Unbox a)
=> p n -> MVector (n+m) s a -> (MVector n s a, MVector m s a)
splitAt' :: forall (n :: Nat) (m :: Nat) s a (p :: Nat -> *).
(KnownNat n, Unbox a) =>
p n -> MVector (n + m) s a -> (MVector n s a, MVector m s a)
splitAt' = p n
-> MVector MVector (n + m) s a
-> (MVector MVector n s a, MVector MVector m s a)
forall (v :: * -> * -> *) (n :: Nat) (m :: Nat) s a
(p :: Nat -> *).
(KnownNat n, MVector v a) =>
p n -> MVector v (n + m) s a -> (MVector v n s a, MVector v m s a)
VGM.splitAt'
{-# inline splitAt' #-}
overlaps :: forall n k s a. Unbox a
=> MVector n s a
-> MVector k s a
-> Bool
overlaps :: forall (n :: Nat) (k :: Nat) s a.
Unbox a =>
MVector n s a -> MVector k s a -> Bool
overlaps = MVector MVector n s a -> MVector MVector k s a -> Bool
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) s a.
MVector v a =>
MVector v n s a -> MVector v k s a -> Bool
VGM.overlaps
{-# inline overlaps #-}
new :: forall n m a. (KnownNat n, PrimMonad m, Unbox a)
=> m (MVector n (PrimState m) a)
new :: forall (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, Unbox a) =>
m (MVector n (PrimState m) a)
new = m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, MVector v a) =>
m (MVector v n (PrimState m) a)
VGM.new
{-# inline new #-}
unsafeNew :: forall n m a. (KnownNat n, PrimMonad m, Unbox a)
=> m (MVector n (PrimState m) a)
unsafeNew :: forall (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, Unbox a) =>
m (MVector n (PrimState m) a)
unsafeNew = m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, MVector v a) =>
m (MVector v n (PrimState m) a)
VGM.unsafeNew
{-# inline unsafeNew #-}
replicate :: forall n m a. (KnownNat n, PrimMonad m, Unbox a)
=> a -> m (MVector n (PrimState m) a)
replicate :: forall (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, Unbox a) =>
a -> m (MVector n (PrimState m) a)
replicate = a -> m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, MVector v a) =>
a -> m (MVector v n (PrimState m) a)
VGM.replicate
{-# inline replicate #-}
replicate' :: forall n m a p. (KnownNat n, PrimMonad m, Unbox a)
=> p n -> a -> m (MVector n (PrimState m) a)
replicate' :: forall (n :: Nat) (m :: * -> *) a (p :: Nat -> *).
(KnownNat n, PrimMonad m, Unbox a) =>
p n -> a -> m (MVector n (PrimState m) a)
replicate' = p n -> a -> m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a
(p :: Nat -> *).
(KnownNat n, PrimMonad m, MVector v a) =>
p n -> a -> m (MVector v n (PrimState m) a)
VGM.replicate'
{-# inline replicate' #-}
replicateM :: forall n m a. (KnownNat n, PrimMonad m, Unbox a)
=> m a -> m (MVector n (PrimState m) a)
replicateM :: forall (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, Unbox a) =>
m a -> m (MVector n (PrimState m) a)
replicateM = m a -> m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(KnownNat n, PrimMonad m, MVector v a) =>
m a -> m (MVector v n (PrimState m) a)
VGM.replicateM
{-# inline replicateM #-}
replicateM' :: forall n m a p. (KnownNat n, PrimMonad m, Unbox a)
=> p n -> m a -> m (MVector n (PrimState m) a)
replicateM' :: forall (n :: Nat) (m :: * -> *) a (p :: Nat -> *).
(KnownNat n, PrimMonad m, Unbox a) =>
p n -> m a -> m (MVector n (PrimState m) a)
replicateM' = p n -> m a -> m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a
(p :: Nat -> *).
(KnownNat n, PrimMonad m, MVector v a) =>
p n -> m a -> m (MVector v n (PrimState m) a)
VGM.replicateM'
{-# inline replicateM' #-}
clone :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> m (MVector n (PrimState m) a)
clone :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> m (MVector n (PrimState m) a)
clone = MVector MVector n (PrimState m) a
-> m (MVector MVector n (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> m (MVector v n (PrimState m) a)
VGM.clone
{-# inline clone #-}
grow :: forall n k m a p. (KnownNat k, PrimMonad m, Unbox a)
=> p k -> MVector n (PrimState m) a -> m (MVector (n + k) (PrimState m) a)
grow :: forall (n :: Nat) (k :: Nat) (m :: * -> *) a (p :: Nat -> *).
(KnownNat k, PrimMonad m, Unbox a) =>
p k
-> MVector n (PrimState m) a -> m (MVector (n + k) (PrimState m) a)
grow = p k
-> MVector MVector n (PrimState m) a
-> m (MVector MVector (n + k) (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) (m :: * -> *) a
(p :: Nat -> *).
(KnownNat k, PrimMonad m, MVector v a) =>
p k
-> MVector v n (PrimState m) a
-> m (MVector v (n + k) (PrimState m) a)
VGM.grow
{-# inline grow #-}
growFront :: forall n k m a p. (KnownNat k, PrimMonad m, Unbox a)
=> p k -> MVector n (PrimState m) a -> m (MVector (n + k) (PrimState m) a)
growFront :: forall (n :: Nat) (k :: Nat) (m :: * -> *) a (p :: Nat -> *).
(KnownNat k, PrimMonad m, Unbox a) =>
p k
-> MVector n (PrimState m) a -> m (MVector (n + k) (PrimState m) a)
growFront = p k
-> MVector MVector n (PrimState m) a
-> m (MVector MVector (n + k) (PrimState m) a)
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) (m :: * -> *) a
(p :: Nat -> *).
(KnownNat k, PrimMonad m, MVector v a) =>
p k
-> MVector v n (PrimState m) a
-> m (MVector v (n + k) (PrimState m) a)
VGM.growFront
{-# inline growFront #-}
clear :: (PrimMonad m, Unbox a) => MVector n (PrimState m) a -> m ()
clear :: forall (m :: * -> *) a (n :: Nat).
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> m ()
clear = MVector MVector n (PrimState m) a -> m ()
forall (m :: * -> *) (v :: * -> * -> *) a (n :: Nat).
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> m ()
VGM.clear
{-# inline clear #-}
read :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Finite n -> m a
read :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Finite n -> m a
read = MVector MVector n (PrimState m) a -> Finite n -> m a
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Finite n -> m a
VGM.read
{-# inline read #-}
read' :: forall n k a m p. (KnownNat k, PrimMonad m, Unbox a)
=> MVector (n+k+1) (PrimState m) a -> p k -> m a
read' :: forall (n :: Nat) (k :: Nat) a (m :: * -> *) (p :: Nat -> *).
(KnownNat k, PrimMonad m, Unbox a) =>
MVector ((n + k) + 1) (PrimState m) a -> p k -> m a
read' = MVector MVector ((n + k) + 1) (PrimState m) a -> p k -> m a
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) a (m :: * -> *)
(p :: Nat -> *).
(KnownNat k, PrimMonad m, MVector v a) =>
MVector v ((n + k) + 1) (PrimState m) a -> p k -> m a
VGM.read'
{-# inline read' #-}
unsafeRead :: forall n a m. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Int -> m a
unsafeRead :: forall (n :: Nat) a (m :: * -> *).
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Int -> m a
unsafeRead = MVector MVector n (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) (n :: Nat) a (m :: * -> *).
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Int -> m a
VGM.unsafeRead
{-# inline unsafeRead #-}
write :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Finite n -> a -> m ()
write :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Finite n -> a -> m ()
write = MVector MVector n (PrimState m) a -> Finite n -> a -> m ()
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Finite n -> a -> m ()
VGM.write
{-# inline write #-}
write' :: forall n k a m p. (KnownNat k, PrimMonad m, Unbox a)
=> MVector (n+k+1) (PrimState m) a -> p k -> a -> m ()
write' :: forall (n :: Nat) (k :: Nat) a (m :: * -> *) (p :: Nat -> *).
(KnownNat k, PrimMonad m, Unbox a) =>
MVector ((n + k) + 1) (PrimState m) a -> p k -> a -> m ()
write' = MVector MVector ((n + k) + 1) (PrimState m) a -> p k -> a -> m ()
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) a (m :: * -> *)
(p :: Nat -> *).
(KnownNat k, PrimMonad m, MVector v a) =>
MVector v ((n + k) + 1) (PrimState m) a -> p k -> a -> m ()
VGM.write'
{-# inline write' #-}
unsafeWrite :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Int -> a -> m ()
unsafeWrite :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Int -> a -> m ()
unsafeWrite = MVector MVector n (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Int -> a -> m ()
VGM.unsafeWrite
{-# inline unsafeWrite #-}
modify :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> (a -> a) -> Finite n -> m ()
modify :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> (a -> a) -> Finite n -> m ()
modify = MVector MVector n (PrimState m) a -> (a -> a) -> Finite n -> m ()
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> (a -> a) -> Finite n -> m ()
VGM.modify
{-# inline modify #-}
modify' :: forall n k a m p. (KnownNat k, PrimMonad m, Unbox a)
=> MVector (n+k+1) (PrimState m) a -> (a -> a) -> p k -> m ()
modify' :: forall (n :: Nat) (k :: Nat) a (m :: * -> *) (p :: Nat -> *).
(KnownNat k, PrimMonad m, Unbox a) =>
MVector ((n + k) + 1) (PrimState m) a -> (a -> a) -> p k -> m ()
modify' = MVector MVector ((n + k) + 1) (PrimState m) a
-> (a -> a) -> p k -> m ()
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) a (m :: * -> *)
(p :: Nat -> *).
(KnownNat k, PrimMonad m, MVector v a) =>
MVector v ((n + k) + 1) (PrimState m) a -> (a -> a) -> p k -> m ()
VGM.modify'
{-# inline modify' #-}
unsafeModify :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> (a -> a) -> Int -> m ()
unsafeModify :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> (a -> a) -> Int -> m ()
unsafeModify = MVector MVector n (PrimState m) a -> (a -> a) -> Int -> m ()
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> (a -> a) -> Int -> m ()
VGM.unsafeModify
{-# inline unsafeModify #-}
swap :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Finite n -> Finite n -> m ()
swap :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Finite n -> Finite n -> m ()
swap = MVector MVector n (PrimState m) a -> Finite n -> Finite n -> m ()
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Finite n -> Finite n -> m ()
VGM.swap
{-# inline swap #-}
unsafeSwap :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Int -> Int -> m ()
unsafeSwap :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Int -> Int -> m ()
unsafeSwap = MVector MVector n (PrimState m) a -> Int -> Int -> m ()
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Int -> Int -> m ()
VGM.unsafeSwap
{-# inline unsafeSwap #-}
exchange :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Finite n -> a -> m a
exchange :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Finite n -> a -> m a
exchange = MVector MVector n (PrimState m) a -> Finite n -> a -> m a
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Finite n -> a -> m a
VGM.exchange
{-# inline exchange #-}
exchange' :: forall n k a m p. (KnownNat k, PrimMonad m, Unbox a)
=> MVector (n+k+1) (PrimState m) a -> p k -> a -> m a
exchange' :: forall (n :: Nat) (k :: Nat) a (m :: * -> *) (p :: Nat -> *).
(KnownNat k, PrimMonad m, Unbox a) =>
MVector ((n + k) + 1) (PrimState m) a -> p k -> a -> m a
exchange' = MVector MVector ((n + k) + 1) (PrimState m) a -> p k -> a -> m a
forall (v :: * -> * -> *) (n :: Nat) (k :: Nat) a (m :: * -> *)
(p :: Nat -> *).
(KnownNat k, PrimMonad m, MVector v a) =>
MVector v ((n + k) + 1) (PrimState m) a -> p k -> a -> m a
VGM.exchange'
{-# inline exchange' #-}
unsafeExchange :: forall n m a. (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a -> Int -> a -> m a
unsafeExchange :: forall (n :: Nat) (m :: * -> *) a.
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> Int -> a -> m a
unsafeExchange = MVector MVector n (PrimState m) a -> Int -> a -> m a
forall (v :: * -> * -> *) (n :: Nat) (m :: * -> *) a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Int -> a -> m a
VGM.unsafeExchange
{-# inline unsafeExchange #-}
#if MIN_VERSION_vector(0,12,0)
nextPermutation :: forall n e m. (Ord e, PrimMonad m, Unbox e)
=> MVector n (PrimState m) e -> m Bool
nextPermutation :: forall (n :: Nat) e (m :: * -> *).
(Ord e, PrimMonad m, Unbox e) =>
MVector n (PrimState m) e -> m Bool
nextPermutation = MVector MVector n (PrimState m) e -> m Bool
forall (v :: * -> * -> *) (n :: Nat) e (m :: * -> *).
(Ord e, PrimMonad m, MVector v e) =>
MVector v n (PrimState m) e -> m Bool
VGM.nextPermutation
{-# inline nextPermutation #-}
#endif
set :: (PrimMonad m, Unbox a) => MVector n (PrimState m) a -> a -> m ()
set :: forall (m :: * -> *) a (n :: Nat).
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> a -> m ()
set = MVector MVector n (PrimState m) a -> a -> m ()
forall (m :: * -> *) (v :: * -> * -> *) a (n :: Nat).
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> a -> m ()
VGM.set
{-# inline set #-}
copy :: (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a
-> MVector n (PrimState m) a
-> m ()
copy :: forall (m :: * -> *) a (n :: Nat).
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> MVector n (PrimState m) a -> m ()
copy = MVector MVector n (PrimState m) a
-> MVector MVector n (PrimState m) a -> m ()
forall (m :: * -> *) (v :: * -> * -> *) a (n :: Nat).
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> MVector v n (PrimState m) a -> m ()
VGM.copy
{-# inline copy #-}
unsafeCopy :: (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a
-> MVector n (PrimState m) a
-> m ()
unsafeCopy :: forall (m :: * -> *) a (n :: Nat).
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> MVector n (PrimState m) a -> m ()
unsafeCopy = MVector MVector n (PrimState m) a
-> MVector MVector n (PrimState m) a -> m ()
forall (m :: * -> *) (v :: * -> * -> *) a (n :: Nat).
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> MVector v n (PrimState m) a -> m ()
VGM.unsafeCopy
{-# inline unsafeCopy #-}
move :: (PrimMonad m, Unbox a)
=> MVector n (PrimState m) a
-> MVector n (PrimState m) a
-> m ()
move :: forall (m :: * -> *) a (n :: Nat).
(PrimMonad m, Unbox a) =>
MVector n (PrimState m) a -> MVector n (PrimState m) a -> m ()
move = MVector MVector n (PrimState m) a
-> MVector MVector n (PrimState m) a -> m ()
forall (m :: * -> *) (v :: * -> * -> *) a (n :: Nat).
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> MVector v n (PrimState m) a -> m ()
VGM.move
{-# inline move #-}
toSized :: forall n a s. (KnownNat n, Unbox a)
=> VUM.MVector s a -> Maybe (MVector n s a)
toSized :: forall (n :: Nat) a s.
(KnownNat n, Unbox a) =>
MVector s a -> Maybe (MVector n s a)
toSized = MVector s a -> Maybe (MVector MVector n s a)
forall (v :: * -> * -> *) (n :: Nat) s a.
(MVector v a, KnownNat n) =>
v s a -> Maybe (MVector v n s a)
VGM.toSized
{-# inline toSized #-}
withSized :: forall s a r. Unbox a
=> VUM.MVector s a -> (forall n. KnownNat n => MVector n s a -> r) -> r
withSized :: forall s a r.
Unbox a =>
MVector s a
-> (forall (n :: Nat). KnownNat n => MVector n s a -> r) -> r
withSized = MVector s a
-> (forall (n :: Nat). KnownNat n => MVector MVector n s a -> r)
-> r
forall (v :: * -> * -> *) s a r.
MVector v a =>
v s a
-> (forall (n :: Nat). KnownNat n => MVector v n s a -> r) -> r
VGM.withSized
{-# inline withSized #-}
fromSized :: MVector n s a -> VUM.MVector s a
fromSized :: forall (n :: Nat) s a. MVector n s a -> MVector s a
fromSized = MVector MVector n s a -> MVector s a
forall (v :: * -> * -> *) (n :: Nat) s a. MVector v n s a -> v s a
VGM.fromSized
{-# inline fromSized #-}
instance (Unbox a, KnownNat n) => Unbox (VG.Vector VU.Vector n a)
newtype instance VUM.MVector s (VG.Vector VU.Vector n a) = MV_Sized (VUM.MVector s a)
newtype instance VU.Vector (VG.Vector VU.Vector n a) = V_Sized (VU.Vector a)
instance (Unbox a, KnownNat n) => VM.MVector VUM.MVector (VG.Vector VU.Vector n a) where
basicLength :: forall s. MVector s (Vector Vector n a) -> Int
basicLength vs :: MVector s (Vector Vector n a)
vs@(MV_Sized MVector s a
v) = MVector s a -> Int
forall s. MVector s a -> Int
forall (v :: * -> * -> *) a s. MVector v a => v s a -> Int
VM.basicLength MVector s a
v Int -> Int -> Int
forall a. Integral a => a -> a -> a
`quot` MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs
{-# inline basicLength #-}
basicUnsafeSlice :: forall s.
Int
-> Int
-> MVector s (Vector Vector n a)
-> MVector s (Vector Vector n a)
basicUnsafeSlice Int
i Int
n vs :: MVector s (Vector Vector n a)
vs@(MV_Sized MVector s a
v) = MVector s a -> MVector s (Vector Vector n a)
forall s (n :: Nat) a. MVector s a -> MVector s (Vector Vector n a)
MV_Sized (Int -> Int -> MVector s a -> MVector s a
forall s. Int -> Int -> MVector s a -> MVector s a
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
VM.basicUnsafeSlice (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs) (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs) MVector s a
v)
{-# inline basicUnsafeSlice #-}
basicOverlaps :: forall s.
MVector s (Vector Vector n a)
-> MVector s (Vector Vector n a) -> Bool
basicOverlaps (MV_Sized MVector s a
v1) (MV_Sized MVector s a
v2) = MVector s a -> MVector s a -> Bool
forall s. MVector s a -> MVector s a -> Bool
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> Bool
VM.basicOverlaps MVector s a
v1 MVector s a
v2
{-# inline basicOverlaps #-}
basicUnsafeNew :: forall s. Int -> ST s (MVector s (Vector Vector n a))
basicUnsafeNew Int
n = MVector s a -> MVector s (Vector Vector n a)
forall s (n :: Nat) a. MVector s a -> MVector s (Vector Vector n a)
MV_Sized (MVector s a -> MVector s (Vector Vector n a))
-> ST s (MVector s a) -> ST s (MVector s (Vector Vector n a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> ST s (MVector s a)
forall s. Int -> ST s (MVector s a)
forall (v :: * -> * -> *) a s. MVector v a => Int -> ST s (v s a)
VM.basicUnsafeNew (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)))
{-# inline basicUnsafeNew #-}
basicInitialize :: forall s. MVector s (Vector Vector n a) -> ST s ()
basicInitialize (MV_Sized MVector s a
v) = MVector s a -> ST s ()
forall s. MVector s a -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
VM.basicInitialize MVector s a
v
{-# inline basicInitialize #-}
basicClear :: forall s. MVector s (Vector Vector n a) -> ST s ()
basicClear (MV_Sized MVector s a
v) = MVector s a -> ST s ()
forall s. MVector s a -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
VM.basicClear MVector s a
v
{-# inline basicClear #-}
basicUnsafeCopy :: forall s.
MVector s (Vector Vector n a)
-> MVector s (Vector Vector n a) -> ST s ()
basicUnsafeCopy (MV_Sized MVector s a
v1) (MV_Sized MVector s a
v2) = MVector s a -> MVector s a -> ST s ()
forall s. MVector s a -> MVector s a -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> ST s ()
VM.basicUnsafeCopy MVector s a
v1 MVector s a
v2
{-# inline basicUnsafeCopy #-}
basicUnsafeMove :: forall s.
MVector s (Vector Vector n a)
-> MVector s (Vector Vector n a) -> ST s ()
basicUnsafeMove (MV_Sized MVector s a
v1) (MV_Sized MVector s a
v2) = MVector s a -> MVector s a -> ST s ()
forall s. MVector s a -> MVector s a -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> ST s ()
VM.basicUnsafeMove MVector s a
v1 MVector s a
v2
{-# inline basicUnsafeMove #-}
basicUnsafeGrow :: forall s.
MVector s (Vector Vector n a)
-> Int -> ST s (MVector s (Vector Vector n a))
basicUnsafeGrow vs :: MVector s (Vector Vector n a)
vs@(MV_Sized MVector s a
v) Int
n = MVector s a -> MVector s (Vector Vector n a)
forall s (n :: Nat) a. MVector s a -> MVector s (Vector Vector n a)
MV_Sized (MVector s a -> MVector s (Vector Vector n a))
-> ST s (MVector s a) -> ST s (MVector s (Vector Vector n a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVector s a -> Int -> ST s (MVector s a)
forall s. MVector s a -> Int -> ST s (MVector s a)
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> ST s (v s a)
VM.basicUnsafeGrow MVector s a
v (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs)
{-# inline basicUnsafeGrow #-}
basicUnsafeRead :: forall s.
MVector s (Vector Vector n a) -> Int -> ST s (Vector Vector n a)
basicUnsafeRead vs :: MVector s (Vector Vector n a)
vs@(MV_Sized MVector s a
v) Int
i = Vector a -> Vector Vector n a
forall (v :: * -> *) (n :: Nat) a. v a -> Vector v n a
Vector (Vector a -> Vector Vector n a)
-> ST s (Vector a) -> ST s (Vector Vector n a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mutable Vector (PrimState (ST s)) a -> ST s (Vector a)
forall (m :: * -> *) (v :: * -> *) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> m (v a)
V.freeze (Int -> Int -> MVector s a -> MVector s a
forall s. Int -> Int -> MVector s a -> MVector s a
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
VM.basicUnsafeSlice (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs) (MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs) MVector s a
v)
{-# inline basicUnsafeRead #-}
basicUnsafeWrite :: forall s.
MVector s (Vector Vector n a)
-> Int -> Vector Vector n a -> ST s ()
basicUnsafeWrite vs :: MVector s (Vector Vector n a)
vs@(MV_Sized MVector s a
v) Int
i (Vector Vector a
x) = Mutable Vector s a -> Vector a -> ST s ()
forall s. Mutable Vector s a -> Vector a -> ST s ()
forall (v :: * -> *) a s.
Vector v a =>
Mutable v s a -> v a -> ST s ()
V.basicUnsafeCopy (Int -> Int -> MVector s a -> MVector s a
forall s. Int -> Int -> MVector s a -> MVector s a
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
VM.basicUnsafeSlice (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs) (MVector s (Vector Vector n a) -> Int
forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
vs) MVector s a
v) Vector a
x
{-# inline basicUnsafeWrite #-}
intLenM :: forall s n a. KnownNat n => VUM.MVector s (VG.Vector VU.Vector n a) -> Int
intLenM :: forall s (n :: Nat) a.
KnownNat n =>
MVector s (Vector Vector n a) -> Int
intLenM MVector s (Vector Vector n a)
_ = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n))
instance (Unbox a, KnownNat n) => V.Vector VU.Vector (VG.Vector VU.Vector n a) where
basicUnsafeFreeze :: forall s.
Mutable Vector s (Vector Vector n a)
-> ST s (Vector (Vector Vector n a))
basicUnsafeFreeze (MV_Sized MVector s a
v) = Vector a -> Vector (Vector Vector n a)
forall (n :: Nat) a. Vector a -> Vector (Vector Vector n a)
V_Sized (Vector a -> Vector (Vector Vector n a))
-> ST s (Vector a) -> ST s (Vector (Vector Vector n a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mutable Vector s a -> ST s (Vector a)
forall s. Mutable Vector s a -> ST s (Vector a)
forall (v :: * -> *) a s. Vector v a => Mutable v s a -> ST s (v a)
V.basicUnsafeFreeze Mutable Vector s a
MVector s a
v
{-# inline basicUnsafeFreeze #-}
basicUnsafeThaw :: forall s.
Vector (Vector Vector n a)
-> ST s (Mutable Vector s (Vector Vector n a))
basicUnsafeThaw (V_Sized Vector a
v) = MVector s a -> MVector s (Vector Vector n a)
forall s (n :: Nat) a. MVector s a -> MVector s (Vector Vector n a)
MV_Sized (MVector s a -> MVector s (Vector Vector n a))
-> ST s (MVector s a) -> ST s (MVector s (Vector Vector n a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector a -> ST s (Mutable Vector s a)
forall s. Vector a -> ST s (Mutable Vector s a)
forall (v :: * -> *) a s. Vector v a => v a -> ST s (Mutable v s a)
V.basicUnsafeThaw Vector a
v
{-# inline basicUnsafeThaw #-}
basicLength :: Vector (Vector Vector n a) -> Int
basicLength vs :: Vector (Vector Vector n a)
vs@(V_Sized Vector a
v) = Vector a -> Int
forall (v :: * -> *) a. Vector v a => v a -> Int
V.basicLength Vector a
v Int -> Int -> Int
forall a. Integral a => a -> a -> a
`quot` Vector (Vector Vector n a) -> Int
forall (n :: Nat) a.
KnownNat n =>
Vector (Vector Vector n a) -> Int
intLen Vector (Vector Vector n a)
vs
{-# inline basicLength #-}
basicUnsafeSlice :: Int
-> Int -> Vector (Vector Vector n a) -> Vector (Vector Vector n a)
basicUnsafeSlice Int
i Int
n vs :: Vector (Vector Vector n a)
vs@(V_Sized Vector a
v) = Vector a -> Vector (Vector Vector n a)
forall (n :: Nat) a. Vector a -> Vector (Vector Vector n a)
V_Sized (Int -> Int -> Vector a -> Vector a
forall (v :: * -> *) a. Vector v a => Int -> Int -> v a -> v a
V.basicUnsafeSlice (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Vector (Vector Vector n a) -> Int
forall (n :: Nat) a.
KnownNat n =>
Vector (Vector Vector n a) -> Int
intLen Vector (Vector Vector n a)
vs) (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* Vector (Vector Vector n a) -> Int
forall (n :: Nat) a.
KnownNat n =>
Vector (Vector Vector n a) -> Int
intLen Vector (Vector Vector n a)
vs) Vector a
v)
{-# inline basicUnsafeSlice #-}
basicUnsafeCopy :: forall s.
Mutable Vector s (Vector Vector n a)
-> Vector (Vector Vector n a) -> ST s ()
basicUnsafeCopy (MV_Sized MVector s a
mv) (V_Sized Vector a
v) = Mutable Vector s a -> Vector a -> ST s ()
forall s. Mutable Vector s a -> Vector a -> ST s ()
forall (v :: * -> *) a s.
Vector v a =>
Mutable v s a -> v a -> ST s ()
V.basicUnsafeCopy Mutable Vector s a
MVector s a
mv Vector a
v
{-# inline basicUnsafeCopy #-}
elemseq :: forall b. Vector (Vector Vector n a) -> Vector Vector n a -> b -> b
elemseq Vector (Vector Vector n a)
_ = Vector Vector n a -> b -> b
forall a b. a -> b -> b
seq
{-# inline elemseq #-}
basicUnsafeIndexM :: Vector (Vector Vector n a) -> Int -> Box (Vector Vector n a)
basicUnsafeIndexM vs :: Vector (Vector Vector n a)
vs@(V_Sized Vector a
v) Int
i = Vector Vector n a -> Box (Vector Vector n a)
forall a. a -> Box a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector Vector n a -> Box (Vector Vector n a))
-> Vector Vector n a -> Box (Vector Vector n a)
forall a b. (a -> b) -> a -> b
$! Vector a -> Vector Vector n a
forall (v :: * -> *) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> Int -> Vector a -> Vector a
forall (v :: * -> *) a. Vector v a => Int -> Int -> v a -> v a
V.basicUnsafeSlice (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Vector (Vector Vector n a) -> Int
forall (n :: Nat) a.
KnownNat n =>
Vector (Vector Vector n a) -> Int
intLen Vector (Vector Vector n a)
vs) (Vector (Vector Vector n a) -> Int
forall (n :: Nat) a.
KnownNat n =>
Vector (Vector Vector n a) -> Int
intLen Vector (Vector Vector n a)
vs) Vector a
v)
{-# inline basicUnsafeIndexM #-}
intLen :: forall n a. KnownNat n => VU.Vector (VG.Vector VU.Vector n a) -> Int
intLen :: forall (n :: Nat) a.
KnownNat n =>
Vector (Vector Vector n a) -> Int
intLen Vector (Vector Vector n a)
_ = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n))