diff --git a/library/PrimitiveExtras/FoldMs.hs b/library/PrimitiveExtras/FoldMs.hs
new file mode 100644
--- /dev/null
+++ b/library/PrimitiveExtras/FoldMs.hs
@@ -0,0 +1,20 @@
+module PrimitiveExtras.FoldMs
+where
+
+import PrimitiveExtras.Prelude hiding (fold, foldM)
+import PrimitiveExtras.Types
+import Control.Foldl
+import qualified PrimitiveExtras.UnliftedArray as UA
+
+
+{-|
+Given a size of the array,
+construct a fold, which produces an array of elements.
+-}
+primArray :: Prim a => Int {-^ Array size -} -> FoldM IO a (PrimArray a)
+primArray size = FoldM step init extract where
+  init = Product2 0 <$> newPrimArray size
+  step (Product2 index mutable) a = do
+    writePrimArray mutable index a
+    return (Product2 (succ index) mutable)
+  extract (Product2 _ mutable) = unsafeFreezePrimArray mutable
diff --git a/library/PrimitiveExtras/PrimArray.hs b/library/PrimitiveExtras/PrimArray.hs
--- a/library/PrimitiveExtras/PrimArray.hs
+++ b/library/PrimitiveExtras/PrimArray.hs
@@ -7,6 +7,7 @@
 import qualified Data.Vector.Unboxed as UnboxedVector
 import qualified Data.Vector.Primitive as PrimitiveVector
 import qualified PrimitiveExtras.Folds as Folds
+import qualified PrimitiveExtras.FoldMs as FoldMs
 
 
 oneHot :: Prim a => Int {-^ Size -} -> Int {-^ Index -} -> a -> PrimArray a
@@ -107,3 +108,10 @@
 -}
 indexCountsFold :: (Integral count, Prim count) => Int {-^ Array size -} -> Fold Int (PrimArray count)
 indexCountsFold = Folds.indexCounts
+
+{-|
+Given a size of the array,
+construct a fold, which produces an array of elements.
+-}
+elementsFoldM :: Prim a => Int {-^ Array size -} -> FoldM IO a (PrimArray a)
+elementsFoldM = FoldMs.primArray
diff --git a/primitive-extras.cabal b/primitive-extras.cabal
--- a/primitive-extras.cabal
+++ b/primitive-extras.cabal
@@ -1,7 +1,7 @@
 name:
   primitive-extras
 version:
-  0.6.2.1
+  0.6.3
 category:
   Primitive
 synopsis:
@@ -50,6 +50,7 @@
     PrimitiveExtras.Prelude
     PrimitiveExtras.Types
     PrimitiveExtras.Folds
+    PrimitiveExtras.FoldMs
   build-depends:
     base >=4.7 && <5,
     cereal >=0.5.5 && <0.6,
