diff --git a/hw-prim.cabal b/hw-prim.cabal
--- a/hw-prim.cabal
+++ b/hw-prim.cabal
@@ -3,7 +3,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           hw-prim
-version:        0.6.2.20
+version:        0.6.2.21
 synopsis:       Primitive functions and data types
 description:    Primitive functions and data types.
 category:       Data
diff --git a/src/HaskellWorks/Data/Vector/Storable.hs b/src/HaskellWorks/Data/Vector/Storable.hs
--- a/src/HaskellWorks/Data/Vector/Storable.hs
+++ b/src/HaskellWorks/Data/Vector/Storable.hs
@@ -6,6 +6,7 @@
   , foldMap
   , mapAccumL
   , mmap
+  , constructSI
   ) where
 
 import Control.Monad.ST     (ST)
@@ -54,3 +55,17 @@
   (fptr :: ForeignPtr Word8, offset, size) <- IO.mmapFileForeignPtr filepath IO.ReadOnly Nothing
   let !v = DVS.unsafeFromForeignPtr fptr offset size
   return (DVS.unsafeCast v)
+
+-- | Construct a vector statefully with index
+constructSI :: forall a s. Storable a => Int -> (Int -> s -> (s, a)) -> s -> (s, DVS.Vector a)
+constructSI n f state = DVS.createT $ do
+  mv <- DVSM.unsafeNew n
+  state' <- go 0 state mv
+  return (state', mv)
+  where go :: Int -> s -> DVSM.MVector t a -> ST t s
+        go i s mv = if i < DVSM.length mv
+          then do
+            let (s', a) = f i s
+            DVSM.unsafeWrite mv i a
+            return s'
+          else return s
