{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
module Data.Vector.Storable.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
) where
import qualified Data.Vector.Generic.Mutable.Sized as VGM
import qualified Data.Vector.Storable.Mutable as VSM
import Foreign.Storable
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 VSM.MVector
length :: forall n s a. (KnownNat n)
=> MVector n s a -> Int
length = VGM.length
{-# inline length #-}
length' :: forall n s a. (KnownNat n)
=> MVector n s a -> Proxy n
length' = VGM.length'
{-# inline length' #-}
null :: forall n s a. (KnownNat n)
=> MVector n s a -> Bool
null = VGM.null
{-# inline null #-}
slice :: forall i n k s a p. (KnownNat i, KnownNat n, KnownNat k, Storable a)
=> p i
-> MVector (i+n+k) s a
-> MVector n s a
slice = VGM.slice
{-# inline slice #-}
slice' :: forall i n k s a p
. (KnownNat i, KnownNat n, KnownNat k, Storable a)
=> p i
-> p n
-> MVector (i+n+k) s a
-> MVector n s a
slice' = VGM.slice'
{-# inline slice' #-}
init :: forall n s a. Storable a
=> MVector (n+1) s a -> MVector n s a
init = VGM.init
{-# inline init #-}
tail :: forall n s a. Storable a
=> MVector (1+n) s a -> MVector n s a
tail = VGM.tail
{-# inline tail #-}
take :: forall n k s a. (KnownNat n, KnownNat k, Storable a)
=> MVector (n+k) s a -> MVector n s a
take = VGM.take
{-# inline take #-}
take' :: forall n k s a p. (KnownNat n, KnownNat k, Storable a)
=> p n -> MVector (n+k) s a -> MVector n s a
take' = VGM.take'
{-# inline take' #-}
drop :: forall n k s a. (KnownNat n, KnownNat k, Storable a)
=> MVector (n+k) s a -> MVector k s a
drop = VGM.drop
{-# inline drop #-}
drop' :: forall n k s a p. (KnownNat n, KnownNat k, Storable a)
=> p n -> MVector (n+k) s a -> MVector k s a
drop' = VGM.drop'
{-# inline drop' #-}
splitAt :: forall n m s a. (KnownNat n, KnownNat m, Storable a)
=> MVector (n+m) s a -> (MVector n s a, MVector m s a)
splitAt = VGM.splitAt
{-# inline splitAt #-}
splitAt' :: forall n m s a p. (KnownNat n, KnownNat m, Storable a)
=> p n -> MVector (n+m) s a -> (MVector n s a, MVector m s a)
splitAt' = VGM.splitAt'
{-# inline splitAt' #-}
overlaps :: forall n k s a. (KnownNat n, KnownNat k, Storable a)
=> MVector n s a
-> MVector k s a
-> Bool
overlaps = VGM.overlaps
{-# inline overlaps #-}
new :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> m (MVector n (PrimState m) a)
new = VGM.new
{-# inline new #-}
unsafeNew :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> m (MVector n (PrimState m) a)
unsafeNew = VGM.unsafeNew
{-# inline unsafeNew #-}
replicate :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> a -> m (MVector n (PrimState m) a)
replicate = VGM.replicate
{-# inline replicate #-}
replicate' :: forall n m a p. (KnownNat n, PrimMonad m, Storable a)
=> p n -> a -> m (MVector n (PrimState m) a)
replicate' = VGM.replicate'
{-# inline replicate' #-}
replicateM :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> m a -> m (MVector n (PrimState m) a)
replicateM = VGM.replicateM
{-# inline replicateM #-}
replicateM' :: forall n m a p. (KnownNat n, PrimMonad m, Storable a)
=> p n -> m a -> m (MVector n (PrimState m) a)
replicateM' = VGM.replicateM'
{-# inline replicateM' #-}
clone :: forall n m a. (PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> m (MVector n (PrimState m) a)
clone = VGM.clone
{-# inline clone #-}
grow :: forall n k m a p. (KnownNat k, PrimMonad m, Storable a)
=> p k -> MVector n (PrimState m) a -> m (MVector (n + k) (PrimState m) a)
grow = VGM.grow
{-# inline grow #-}
growFront :: forall n k m a p. (KnownNat k, PrimMonad m, Storable a)
=> p k -> MVector n (PrimState m) a -> m (MVector (n + k) (PrimState m) a)
growFront = VGM.growFront
{-# inline growFront #-}
clear :: (PrimMonad m, Storable a) => MVector n (PrimState m) a -> m ()
clear = VGM.clear
{-# inline clear #-}
read :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Finite n -> m a
read = VGM.read
{-# inline read #-}
read' :: forall n k a m p. (KnownNat n, KnownNat k, PrimMonad m, Storable a)
=> MVector (n+k+1) (PrimState m) a -> p k -> m a
read' = VGM.read'
{-# inline read' #-}
unsafeRead :: forall n a m. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Int -> m a
unsafeRead = VGM.unsafeRead
{-# inline unsafeRead #-}
write :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Finite n -> a -> m ()
write = VGM.write
{-# inline write #-}
write' :: forall n k a m p. (KnownNat n, KnownNat k, PrimMonad m, Storable a)
=> MVector (n+k+1) (PrimState m) a -> p k -> a -> m ()
write' = VGM.write'
{-# inline write' #-}
unsafeWrite :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Int -> a -> m ()
unsafeWrite = VGM.unsafeWrite
{-# inline unsafeWrite #-}
modify :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> (a -> a) -> Finite n -> m ()
modify = VGM.modify
{-# inline modify #-}
modify' :: forall n k a m p. (KnownNat n, KnownNat k, PrimMonad m, Storable a)
=> MVector (n+k+1) (PrimState m) a -> (a -> a) -> p k -> m ()
modify' = VGM.modify'
{-# inline modify' #-}
unsafeModify :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> (a -> a) -> Int -> m ()
unsafeModify = VGM.unsafeModify
{-# inline unsafeModify #-}
swap :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Finite n -> Finite n -> m ()
swap = VGM.swap
{-# inline swap #-}
unsafeSwap :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Int -> Int -> m ()
unsafeSwap = VGM.unsafeSwap
{-# inline unsafeSwap #-}
exchange :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Finite n -> a -> m a
exchange = VGM.exchange
{-# inline exchange #-}
exchange' :: forall n k a m p. (KnownNat n, KnownNat k, PrimMonad m, Storable a)
=> MVector (n+k+1) (PrimState m) a -> p k -> a -> m a
exchange' = VGM.exchange'
{-# inline exchange' #-}
unsafeExchange :: forall n m a. (KnownNat n, PrimMonad m, Storable a)
=> MVector n (PrimState m) a -> Int -> a -> m a
unsafeExchange = VGM.unsafeExchange
{-# inline unsafeExchange #-}
#if MIN_VERSION_vector(0,12,0)
nextPermutation :: forall n e m. (KnownNat n, Ord e, PrimMonad m, Storable e)
=> MVector n (PrimState m) e -> m Bool
nextPermutation = VGM.nextPermutation
{-# inline nextPermutation #-}
#endif
set :: (PrimMonad m, Storable a) => MVector n (PrimState m) a -> a -> m ()
set = VGM.set
{-# inline set #-}
copy :: (PrimMonad m, Storable a)
=> MVector n (PrimState m) a
-> MVector n (PrimState m) a
-> m ()
copy = VGM.copy
{-# inline copy #-}
unsafeCopy :: (PrimMonad m, Storable a)
=> MVector n (PrimState m) a
-> MVector n (PrimState m) a
-> m ()
unsafeCopy = VGM.unsafeCopy
{-# inline unsafeCopy #-}
move :: (PrimMonad m, Storable a)
=> MVector n (PrimState m) a
-> MVector n (PrimState m) a
-> m ()
move = VGM.move
{-# inline move #-}
toSized :: forall n a s. (KnownNat n, Storable a)
=> VSM.MVector s a -> Maybe (MVector n s a)
toSized = VGM.toSized
{-# inline toSized #-}
withSized :: forall s a r. Storable a
=> VSM.MVector s a -> (forall n. KnownNat n => MVector n s a -> r) -> r
withSized = VGM.withSized
{-# inline withSized #-}
fromSized :: MVector n s a -> VSM.MVector s a
fromSized = VGM.fromSized
{-# inline fromSized #-}