diff --git a/library/PrimitiveExtras/IO.hs b/library/PrimitiveExtras/IO.hs
--- a/library/PrimitiveExtras/IO.hs
+++ b/library/PrimitiveExtras/IO.hs
@@ -11,3 +11,17 @@
 
 replicateUnliftedArray :: PrimUnlifted a => Int -> IO a -> IO (UnliftedArray a)
 replicateUnliftedArray = A.replicateIO
+
+generateArray :: Int -> (Int -> IO a) -> IO (Array a)
+generateArray size elementIO =
+  do
+    array <- newArray size undefined
+    let
+      loop index =
+        if index < size
+          then do
+            element <- elementIO index
+            writeArray array index element
+            loop (succ index)
+          else unsafeFreezeArray array
+      in loop 0
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.1.2.2
+  0.1.3
 category:
   Primitive
 synopsis:
