module Data.StorableVector.ST.Lazy (
Vector,
new,
new_,
read,
write,
modify,
unsafeRead,
unsafeWrite,
unsafeModify,
freeze,
unsafeFreeze,
thaw,
VST.length,
runSTVector,
mapST,
mapSTLazy,
) where
import qualified Data.StorableVector as VS
import qualified Data.StorableVector.Lazy as VL
import qualified Data.StorableVector.ST.Strict as VST
import Data.StorableVector.ST.Strict (Vector)
import qualified Control.Monad.ST.Lazy as ST
import Control.Monad.ST.Lazy (ST)
import Foreign.Storable (Storable)
import Prelude hiding (read, length, )
new :: (Storable e) =>
Int -> e -> ST s (Vector s e)
new n x = ST.strictToLazyST (VST.new n x)
new_ :: (Storable e) =>
Int -> ST s (Vector s e)
new_ n = ST.strictToLazyST (VST.new_ n)
read :: (Storable e) =>
Vector s e -> Int -> ST s e
read xs n = ST.strictToLazyST (VST.read xs n)
write :: (Storable e) =>
Vector s e -> Int -> e -> ST s ()
write xs n x = ST.strictToLazyST (VST.write xs n x)
modify :: (Storable e) =>
Vector s e -> Int -> (e -> e) -> ST s ()
modify xs n f = ST.strictToLazyST (VST.modify xs n f)
unsafeRead :: (Storable e) =>
Vector s e -> Int -> ST s e
unsafeRead xs n = ST.strictToLazyST (VST.unsafeRead xs n)
unsafeWrite :: (Storable e) =>
Vector s e -> Int -> e -> ST s ()
unsafeWrite xs n x = ST.strictToLazyST (VST.unsafeWrite xs n x)
unsafeModify :: (Storable e) =>
Vector s e -> Int -> (e -> e) -> ST s ()
unsafeModify xs n f = ST.strictToLazyST (VST.unsafeModify xs n f)
freeze :: (Storable e) =>
Vector s e -> ST s (VS.Vector e)
freeze xs = ST.strictToLazyST (VST.freeze xs)
unsafeFreeze :: (Storable e) =>
Vector s e -> ST s (VS.Vector e)
unsafeFreeze xs = ST.strictToLazyST (VST.unsafeFreeze xs)
thaw :: (Storable e) =>
VS.Vector e -> ST s (Vector s e)
thaw xs = ST.strictToLazyST (VST.thaw xs)
runSTVector :: (Storable e) =>
(forall s. ST s (Vector s e)) -> VS.Vector e
runSTVector m = VST.runSTVector (ST.lazyToStrictST m)
mapST :: (Storable a, Storable b) =>
(a -> ST s b) -> VS.Vector a -> ST s (VS.Vector b)
mapST f xs =
ST.strictToLazyST (VST.mapST (ST.lazyToStrictST . f) xs)
mapSTLazy :: (Storable a, Storable b) =>
(a -> ST s b) -> VL.Vector a -> ST s (VL.Vector b)
mapSTLazy f (VL.SV xs) =
fmap VL.SV $ mapM (mapST f) xs