diff --git a/Changelog b/Changelog
deleted file mode 100644
--- a/Changelog
+++ /dev/null
@@ -1,30 +0,0 @@
-Changes 0.6 - 0.6.0.1
-
-  * Improved documentation
-
-Changes 0.5 - 0.6
-
-  * More efficient representation of Storable vectors
-
-  * Block copy operations used when possible
-
-  * Typeable and Data instances
-
-  * Monadic combinators (replicateM, mapM etc.)
-
-  * Better support for recycling (see create and modify)
-
-  * Performance improvements
-
-Changes 0.4.2 - 0.5
-
-  * Unboxed vectors of primitive types and tuples.
-
-  * Redesigned interface between mutable and immutable vectors. It now
-  includes the popular unsafeFreeze primitive.
-
-  * Many new combinators.
-
-  * Significant performance improvements. Unboxed vectors are usually faster
-  than primitive unboxed DPH arrays.
-
diff --git a/Data/Vector.hs b/Data/Vector.hs
--- a/Data/Vector.hs
+++ b/Data/Vector.hs
@@ -1,4 +1,9 @@
-{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies, Rank2Types #-}
+{-# LANGUAGE FlexibleInstances
+           , MultiParamTypeClasses
+           , TypeFamilies
+           , Rank2Types
+           , BangPatterns
+  #-}
 
 -- |
 -- Module      : Data.Vector
@@ -156,6 +161,7 @@
 import           Data.Primitive.Array
 import qualified Data.Vector.Fusion.Stream as Stream
 
+import Control.DeepSeq ( NFData, rnf )
 import Control.Monad ( MonadPlus(..), liftM, ap )
 import Control.Monad.ST ( ST )
 import Control.Monad.Primitive
@@ -191,6 +197,12 @@
                        {-# UNPACK #-} !(Array a)
         deriving ( Typeable )
 
+instance NFData a => NFData (Vector a) where
+    rnf (Vector i n arr) = force i
+        where
+          force !ix | ix < n    = rnf (indexArray arr ix) `seq` force (ix+1)
+                    | otherwise = ()
+
 instance Show a => Show (Vector a) where
   showsPrec = G.showsPrec
 
@@ -650,7 +662,7 @@
 -- | Execute the monadic action and freeze the resulting vector.
 --
 -- @
--- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\' }) = \<'a','b'\>
+-- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\'; return v }) = \<'a','b'\>
 -- @
 create :: (forall s. ST s (MVector s a)) -> Vector a
 {-# INLINE create #-}
diff --git a/Data/Vector/Fusion/Stream.hs b/Data/Vector/Fusion/Stream.hs
--- a/Data/Vector/Fusion/Stream.hs
+++ b/Data/Vector/Fusion/Stream.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE FlexibleInstances, Rank2Types #-}
+{-# LANGUAGE FlexibleInstances, Rank2Types, BangPatterns #-}
 
 -- |
 -- Module      : Data.Vector.Fusion.Stream
@@ -77,7 +77,7 @@
 
 import Data.Vector.Fusion.Stream.Size
 import Data.Vector.Fusion.Util
-import Data.Vector.Fusion.Stream.Monadic ( Step(..) )
+import Data.Vector.Fusion.Stream.Monadic ( Step(..), SPEC(..) )
 import qualified Data.Vector.Fusion.Stream.Monadic as M
 
 import Prelude hiding ( length, null,
@@ -477,38 +477,40 @@
 -- Comparisons
 -- -----------
 
+-- FIXME: Move these to Monadic
+
 -- | Check if two 'Stream's are equal
 eq :: Eq a => Stream a -> Stream a -> Bool
 {-# INLINE_STREAM eq #-}
-eq (M.Stream step1 s1 _) (M.Stream step2 s2 _) = eq_loop0 s1 s2
+eq (M.Stream step1 s1 _) (M.Stream step2 s2 _) = eq_loop0 SPEC s1 s2
   where
-    eq_loop0 s1 s2 = case unId (step1 s1) of
-                       Yield x s1' -> eq_loop1 x s1' s2
-                       Skip    s1' -> eq_loop0   s1' s2
-                       Done        -> null (M.Stream step2 s2 Unknown)
+    eq_loop0 !sPEC s1 s2 = case unId (step1 s1) of
+                             Yield x s1' -> eq_loop1 SPEC x s1' s2
+                             Skip    s1' -> eq_loop0 SPEC   s1' s2
+                             Done        -> null (M.Stream step2 s2 Unknown)
 
-    eq_loop1 x s1 s2 = case unId (step2 s2) of
-                         Yield y s2' -> x == y && eq_loop0   s1 s2'
-                         Skip    s2' ->           eq_loop1 x s1 s2'
-                         Done        -> False
+    eq_loop1 !sPEC x s1 s2 = case unId (step2 s2) of
+                               Yield y s2' -> x == y && eq_loop0 SPEC   s1 s2'
+                               Skip    s2' ->           eq_loop1 SPEC x s1 s2'
+                               Done        -> False
 
 -- | Lexicographically compare two 'Stream's
 cmp :: Ord a => Stream a -> Stream a -> Ordering
 {-# INLINE_STREAM cmp #-}
-cmp (M.Stream step1 s1 _) (M.Stream step2 s2 _) = cmp_loop0 s1 s2
+cmp (M.Stream step1 s1 _) (M.Stream step2 s2 _) = cmp_loop0 SPEC s1 s2
   where
-    cmp_loop0 s1 s2 = case unId (step1 s1) of
-                        Yield x s1' -> cmp_loop1 x s1' s2
-                        Skip    s1' -> cmp_loop0   s1' s2
-                        Done        -> if null (M.Stream step2 s2 Unknown)
-                                         then EQ else LT
+    cmp_loop0 !sPEC s1 s2 = case unId (step1 s1) of
+                              Yield x s1' -> cmp_loop1 SPEC x s1' s2
+                              Skip    s1' -> cmp_loop0 SPEC   s1' s2
+                              Done        -> if null (M.Stream step2 s2 Unknown)
+                                               then EQ else LT
 
-    cmp_loop1 x s1 s2 = case unId (step2 s2) of
-                          Yield y s2' -> case x `compare` y of
-                                           EQ -> cmp_loop0 s1 s2'
-                                           c  -> c
-                          Skip    s2' -> cmp_loop1 x s1 s2'
-                          Done        -> GT
+    cmp_loop1 !sPEC x s1 s2 = case unId (step2 s2) of
+                                Yield y s2' -> case x `compare` y of
+                                                 EQ -> cmp_loop0 SPEC s1 s2'
+                                                 c  -> c
+                                Skip    s2' -> cmp_loop1 SPEC x s1 s2'
+                                Done        -> GT
 
 instance Eq a => Eq (M.Stream Id a) where
   {-# INLINE (==) #-}
diff --git a/Data/Vector/Fusion/Stream/Monadic.hs b/Data/Vector/Fusion/Stream/Monadic.hs
--- a/Data/Vector/Fusion/Stream/Monadic.hs
+++ b/Data/Vector/Fusion/Stream/Monadic.hs
@@ -13,7 +13,7 @@
 --
 
 module Data.Vector.Fusion.Stream.Monadic (
-  Stream(..), Step(..),
+  Stream(..), Step(..), SPEC(..),
 
   -- * Size hints
   size, sized,
diff --git a/Data/Vector/Fusion/Stream/Monadic/Safe.hs b/Data/Vector/Fusion/Stream/Monadic/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Fusion/Stream/Monadic/Safe.hs
+++ /dev/null
@@ -1,78 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701
-{-# LANGUAGE Trustworthy #-}
-#endif
-
--- |
--- Module      : Data.Vector.Fusion.Stream.Monadic.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
---
--- Safe interface to "Data.Vector.Fusion.Stream.Monadic"
---
-
-module Data.Vector.Fusion.Stream.Monadic.Safe (
-  Stream(..), Step(..),
-
-  -- * Size hints
-  size, sized,
-
-  -- * Length
-  length, null,
-
-  -- * Construction
-  empty, singleton, cons, snoc, replicate, replicateM, generate, generateM, (++),
-
-  -- * Accessing elements
-  head, last, (!!),
-
-  -- * Substreams
-  slice, init, tail, take, drop,
-
-  -- * Mapping
-  map, mapM, mapM_, trans, unbox, concatMap, flatten,
-  
-  -- * Zipping
-  indexed, indexedR, zipWithM_,
-  zipWithM, zipWith3M, zipWith4M, zipWith5M, zipWith6M,
-  zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
-  zip, zip3, zip4, zip5, zip6,
-
-  -- * Filtering
-  filter, filterM, takeWhile, takeWhileM, dropWhile, dropWhileM,
-
-  -- * Searching
-  elem, notElem, find, findM, findIndex, findIndexM,
-
-  -- * Folding
-  foldl, foldlM, foldl1, foldl1M, foldM, fold1M,
-  foldl', foldlM', foldl1', foldl1M', foldM', fold1M',
-  foldr, foldrM, foldr1, foldr1M,
-
-  -- * Specialised folds
-  and, or, concatMapM,
-
-  -- * Unfolding
-  unfoldr, unfoldrM,
-  unfoldrN, unfoldrNM,
-  iterateN, iterateNM,
-
-  -- * Scans
-  prescanl, prescanlM, prescanl', prescanlM',
-  postscanl, postscanlM, postscanl', postscanlM',
-  scanl, scanlM, scanl', scanlM',
-  scanl1, scanl1M, scanl1', scanl1M',
-
-  -- * Enumerations
-  enumFromStepN, enumFromTo, enumFromThenTo,
-
-  -- * Conversions
-  toList, fromList, fromListN
-) where
-
-import Data.Vector.Fusion.Stream.Monadic
-import Prelude ()
-
diff --git a/Data/Vector/Fusion/Stream/Safe.hs b/Data/Vector/Fusion/Stream/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Fusion/Stream/Safe.hs
+++ /dev/null
@@ -1,82 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701
-{-# LANGUAGE Trustworthy #-}
-#endif
-
--- |
--- Module      : Data.Vector.Fusion.Stream.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector.Fusion.Stream"
---
-
-module Data.Vector.Fusion.Stream.Safe (
-  -- * Types
-  Step(..), Stream, MStream,
-
-  -- * In-place markers
-  inplace,
-
-  -- * Size hints
-  size, sized,
-
-  -- * Length information
-  length, null,
-
-  -- * Construction
-  empty, singleton, cons, snoc, replicate, generate, (++),
-
-  -- * Accessing individual elements
-  head, last, (!!),
-
-  -- * Substreams
-  slice, init, tail, take, drop,
-
-  -- * Mapping
-  map, concatMap, flatten, unbox,
-  
-  -- * Zipping
-  indexed, indexedR,
-  zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
-  zip, zip3, zip4, zip5, zip6,
-
-  -- * Filtering
-  filter, takeWhile, dropWhile,
-
-  -- * Searching
-  elem, notElem, find, findIndex,
-
-  -- * Folding
-  foldl, foldl1, foldl', foldl1', foldr, foldr1,
-
-  -- * Specialised folds
-  and, or,
-
-  -- * Unfolding
-  unfoldr, unfoldrN, iterateN,
-
-  -- * Scans
-  prescanl, prescanl',
-  postscanl, postscanl',
-  scanl, scanl',
-  scanl1, scanl1',
-
-  -- * Enumerations
-  enumFromStepN, enumFromTo, enumFromThenTo,
-
-  -- * Conversions
-  toList, fromList, fromListN, liftStream,
-
-  -- * Monadic combinators
-  mapM, mapM_, zipWithM, zipWithM_, filterM, foldM, fold1M, foldM', fold1M',
-
-  eq, cmp
-) where
-
-import Data.Vector.Fusion.Stream
-import Prelude ()
-
diff --git a/Data/Vector/Fusion/Stream/Size.hs b/Data/Vector/Fusion/Stream/Size.hs
--- a/Data/Vector/Fusion/Stream/Size.hs
+++ b/Data/Vector/Fusion/Stream/Size.hs
@@ -1,8 +1,3 @@
-#if __GLASGOW_HASKELL__ >= 703
-{-# LANGUAGE Safe #-}
-#elif __GLASGOW_HASKELL__ >= 701
-{-# LANGUAGE Trustworthy #-}
-#endif
 -- |
 -- Module      : Data.Vector.Fusion.Stream.Size
 -- Copyright   : (c) Roman Leshchinskiy 2008-2010
diff --git a/Data/Vector/Fusion/Util.hs b/Data/Vector/Fusion/Util.hs
--- a/Data/Vector/Fusion/Util.hs
+++ b/Data/Vector/Fusion/Util.hs
@@ -1,8 +1,3 @@
-#if __GLASGOW_HASKELL__ >= 703
-{-# LANGUAGE Safe #-}
-#elif __GLASGOW_HASKELL__ >= 701
-{-# LANGUAGE Trustworthy #-}
-#endif
 -- |
 -- Module      : Data.Vector.Fusion.Util
 -- Copyright   : (c) Roman Leshchinskiy 2009
diff --git a/Data/Vector/Generic.hs b/Data/Vector/Generic.hs
--- a/Data/Vector/Generic.hs
+++ b/Data/Vector/Generic.hs
@@ -709,7 +709,7 @@
 -- | Execute the monadic action and freeze the resulting vector.
 --
 -- @
--- create (do { v \<- 'M.new' 2; 'M.write' v 0 \'a\'; 'M.write' v 1 \'b\' }) = \<'a','b'\>
+-- create (do { v \<- 'M.new' 2; 'M.write' v 0 \'a\'; 'M.write' v 1 \'b\'; return v }) = \<'a','b'\>
 -- @
 create :: Vector v a => (forall s. ST s (Mutable v s a)) -> v a
 {-# INLINE create #-}
diff --git a/Data/Vector/Generic/Mutable.hs b/Data/Vector/Generic/Mutable.hs
--- a/Data/Vector/Generic/Mutable.hs
+++ b/Data/Vector/Generic/Mutable.hs
@@ -72,6 +72,20 @@
 
 -- | Class of mutable vectors parametrised with a primitive state token.
 --
+-- Minimum complete implementation:
+--
+--   * 'basicLength'
+--
+--   * 'basicUnsafeSlice'
+--
+--   * 'basicOverlaps'
+--
+--   * 'basicUnsafeNew'
+--
+--   * 'basicUnsafeRead'
+--
+--   * 'basicUnsafeWrite'
+--
 class MVector v a where
   -- | Length of the mutable vector. This method should not be
   -- called directly, use 'length' instead.
diff --git a/Data/Vector/Generic/Mutable/Safe.hs b/Data/Vector/Generic/Mutable/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Generic/Mutable/Safe.hs
+++ /dev/null
@@ -1,61 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
--- |
--- Module      : Data.Vector.Generic.Mutable.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector.Generic.Mutable"
---
-
-module Data.Vector.Generic.Mutable.Safe (
-  -- * Class of mutable vector types
-  MVector,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Extracting subvectors
-  slice, init, tail, take, drop, splitAt,
-
-  -- ** Overlapping
-  overlaps,
-
-  -- * Construction
-
-  -- ** Initialisation
-  new, replicate, replicateM, clone,
-
-  -- ** Growing
-  grow,
-
-  -- ** Restricting memory usage
-  clear,
-
-  -- * Accessing individual elements
-  read, write, swap,
-
-  -- * Modifying vectors
-
-  -- ** Filling and copying
-  set, copy, move,
-
-  -- * Internal operations
-  unstream, unstreamR,
-  munstream, munstreamR,
-  transform, transformR,
-  fill, fillR,
-  accum, update, reverse,
-  unstablePartition, unstablePartitionStream, partitionStream
-) where
-
-import Data.Vector.Generic.Mutable
-import Prelude ()
-
diff --git a/Data/Vector/Generic/New/Safe.hs b/Data/Vector/Generic/New/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Generic/New/Safe.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
-
--- |
--- Module      : Data.Vector.Generic.New.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector.Generic.New"
---
-
-module Data.Vector.Generic.New.Safe (
-  New(..), create, run, apply, modify, modifyWithStream,
-  unstream, transform, unstreamR, transformR,
-  slice, init, tail, take, drop
-) where
-
-import Data.Vector.Generic.New
-import Prelude ()
-
diff --git a/Data/Vector/Generic/Safe.hs b/Data/Vector/Generic/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Generic/Safe.hs
+++ /dev/null
@@ -1,157 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
--- |
--- Module      : Data.Vector.Generic.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector.Generic"
---
-
-module Data.Vector.Generic.Safe (
-  -- * Immutable vectors
-  Vector, Mutable,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Indexing
-  (!), (!?), head, last,
-
-  -- ** Monadic indexing
-  indexM, headM, lastM,
-
-  -- ** Extracting subvectors (slicing)
-  slice, init, tail, take, drop, splitAt,
-
-  -- * Construction
-
-  -- ** Initialisation
-  empty, singleton, replicate, generate, iterateN,
-
-  -- ** Monadic initialisation
-  replicateM, generateM, create,
-
-  -- ** Unfolding
-  unfoldr, unfoldrN,
-
-  -- ** Enumeration
-  enumFromN, enumFromStepN, enumFromTo, enumFromThenTo,
-
-  -- ** Concatenation
-  cons, snoc, (++), concat,
-
-  -- ** Restricting memory usage
-  force,
-
-  -- * Modifying vectors
-
-  -- ** Bulk updates
-  (//), update, update_,
-
-  -- ** Accumulations
-  accum, accumulate, accumulate_,
-
-  -- ** Permutations 
-  reverse, backpermute,
-
-  -- ** Safe destructive updates
-  modify,
-
-  -- * Elementwise operations
-
-  -- ** Indexing
-  indexed,
-
-  -- ** Mapping
-  map, imap, concatMap,
-
-  -- ** Monadic mapping
-  mapM, mapM_, forM, forM_,
-
-  -- ** Zipping
-  zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
-  izipWith, izipWith3, izipWith4, izipWith5, izipWith6,
-  zip, zip3, zip4, zip5, zip6,
-
-  -- ** Monadic zipping
-  zipWithM, zipWithM_,
-
-  -- ** Unzipping
-  unzip, unzip3, unzip4, unzip5, unzip6,
-
-  -- * Working with predicates
-
-  -- ** Filtering
-  filter, ifilter, filterM,
-  takeWhile, dropWhile,
-
-  -- ** Partitioning
-  partition, unstablePartition, span, break,
-
-  -- ** Searching
-  elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
-
-  -- * Folding
-  foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
-  ifoldl, ifoldl', ifoldr, ifoldr',
-
-  -- ** Specialised folds
-  all, any, and, or,
-  sum, product,
-  maximum, maximumBy, minimum, minimumBy,
-  minIndex, minIndexBy, maxIndex, maxIndexBy,
-
-  -- ** Monadic folds
-  foldM, foldM', fold1M, fold1M',
-  foldM_, foldM'_, fold1M_, fold1M'_,
-
-  -- ** Monadic sequencing
-  sequence, sequence_,
-
-  -- * Prefix sums (scans)
-  prescanl, prescanl',
-  postscanl, postscanl',
-  scanl, scanl', scanl1, scanl1',
-  prescanr, prescanr',
-  postscanr, postscanr',
-  scanr, scanr', scanr1, scanr1',
-
-  -- * Conversions
-
-  -- ** Lists
-  toList, fromList, fromListN,
-
-  -- ** Different vector types
-  convert,
-
-  -- ** Mutable vectors
-  freeze, thaw, copy,
-
-  -- * Fusion support
-
-  -- ** Conversion to/from Streams
-  stream, unstream, streamR, unstreamR,
-
-  -- ** Recycling support
-  new, clone,
-
-  -- * Utilities
-
-  -- ** Comparisons
-  eq, cmp,
-
-  -- ** @Data@ and @Typeable@
-  gfoldl, dataCast, mkType
-) where
-
-import Data.Vector.Generic
-import Prelude ()
-
diff --git a/Data/Vector/Mutable.hs b/Data/Vector/Mutable.hs
--- a/Data/Vector/Mutable.hs
+++ b/Data/Vector/Mutable.hs
@@ -54,6 +54,8 @@
 import           Data.Primitive.Array
 import           Control.Monad.Primitive
 
+import Control.DeepSeq ( NFData, rnf )
+
 import Prelude hiding ( length, null, replicate, reverse, map, read,
                         take, drop, splitAt, init, tail )
 
@@ -69,6 +71,16 @@
 
 type IOVector = MVector RealWorld
 type STVector s = MVector s
+
+-- NOTE: This seems unsafe, see http://trac.haskell.org/vector/ticket/54
+{-
+instance NFData a => NFData (MVector s a) where
+    rnf (MVector i n arr) = unsafeInlineST $ force i
+        where
+          force !ix | ix < n    = do x <- readArray arr ix
+                                     rnf x `seq` force (ix+1)
+                    | otherwise = return ()
+-}
 
 instance G.MVector MVector a where
   {-# INLINE basicLength #-}
diff --git a/Data/Vector/Mutable/Safe.hs b/Data/Vector/Mutable/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Mutable/Safe.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
-
--- |
--- Module      : Data.Vector.Mutable.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector.Mutable"
---
-
-module Data.Vector.Mutable.Safe (
-  -- * Mutable boxed vectors
-  MVector, IOVector, STVector,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Extracting subvectors
-  slice, init, tail, take, drop, splitAt,
-
-  -- ** Overlapping
-  overlaps,
-
-  -- * Construction
-
-  -- ** Initialisation
-  new, replicate, replicateM, clone,
-
-  -- ** Growing
-  grow,
-
-  -- ** Restricting memory usage
-  clear,
-
-  -- * Accessing individual elements
-  read, write, swap,
-
-  -- * Modifying vectors
-
-  -- ** Filling and copying
-  set, copy, move
-) where
-
-import Data.Vector.Mutable
-import Prelude ()
-
diff --git a/Data/Vector/Primitive.hs b/Data/Vector/Primitive.hs
--- a/Data/Vector/Primitive.hs
+++ b/Data/Vector/Primitive.hs
@@ -140,6 +140,8 @@
 import           Data.Primitive.ByteArray
 import           Data.Primitive ( Prim, sizeOf )
 
+import Control.DeepSeq ( NFData )
+
 import Control.Monad ( liftM )
 import Control.Monad.ST ( ST )
 import Control.Monad.Primitive
@@ -172,6 +174,8 @@
                        {-# UNPACK #-} !ByteArray
   deriving ( Typeable )
 
+instance NFData (Vector a)
+
 instance (Show a, Prim a) => Show (Vector a) where
   showsPrec = G.showsPrec
 
@@ -205,7 +209,7 @@
   basicUnsafeSlice j n (Vector i _ arr) = Vector (i+j) n arr
 
   {-# INLINE basicUnsafeIndexM #-}
-  basicUnsafeIndexM (Vector i _ arr) j = return (indexByteArray arr (i+j))
+  basicUnsafeIndexM (Vector i _ arr) j = return $! indexByteArray arr (i+j)
 
   {-# INLINE basicUnsafeCopy #-}
   basicUnsafeCopy (MVector i n dst) (Vector j _ src)
@@ -583,7 +587,7 @@
 -- | Execute the monadic action and freeze the resulting vector.
 --
 -- @
--- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\' }) = \<'a','b'\>
+-- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\'; return v }) = \<'a','b'\>
 -- @
 create :: Prim a => (forall s. ST s (MVector s a)) -> Vector a
 {-# INLINE create #-}
diff --git a/Data/Vector/Primitive/Mutable.hs b/Data/Vector/Primitive/Mutable.hs
--- a/Data/Vector/Primitive/Mutable.hs
+++ b/Data/Vector/Primitive/Mutable.hs
@@ -55,6 +55,8 @@
 import           Control.Monad.Primitive
 import           Control.Monad ( liftM )
 
+import Control.DeepSeq ( NFData )
+
 import Prelude hiding ( length, null, replicate, reverse, map, read,
                         take, drop, splitAt, init, tail )
 
@@ -71,6 +73,8 @@
 type IOVector = MVector RealWorld
 type STVector s = MVector s
 
+instance NFData (MVector s a)
+
 instance Prim a => G.MVector MVector a where
   basicLength (MVector _ n _) = n
   basicUnsafeSlice j m (MVector i n arr)
@@ -104,6 +108,9 @@
     = moveByteArray dst (i*sz) src (j*sz) (n * sz)
     where
       sz = sizeOf (undefined :: a)
+
+  {-# INLINE basicSet #-}
+  basicSet (MVector i n arr) x = setByteArray arr i n x
 
 -- Length information
 -- ------------------
diff --git a/Data/Vector/Primitive/Mutable/Safe.hs b/Data/Vector/Primitive/Mutable/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Primitive/Mutable/Safe.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
--- |
--- Module      : Data.Vector.Primitive.Mutable.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector.Primitive.Mutable"
---
-
-module Data.Vector.Primitive.Mutable.Safe (
-  -- * Mutable vectors of primitive types
-  MVector, IOVector, STVector, Prim,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Extracting subvectors
-  slice, init, tail, take, drop, splitAt,
-
-  -- ** Overlapping
-  overlaps,
-
-  -- * Construction
-
-  -- ** Initialisation
-  new, replicate, replicateM, clone,
-
-  -- ** Growing
-  grow,
-
-  -- ** Restricting memory usage
-  clear,
-
-  -- * Accessing individual elements
-  read, write, swap,
-
-  -- * Modifying vectors
-
-  -- ** Filling and copying
-  set, copy, move
-) where
-
-import Data.Vector.Primitive.Mutable
-import Prelude ()
-
diff --git a/Data/Vector/Primitive/Safe.hs b/Data/Vector/Primitive/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Primitive/Safe.hs
+++ /dev/null
@@ -1,134 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
-
--- |
--- Module      : Data.Vector.Primitive.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
---
--- Safe interface to "Data.Vector.Primitive" 
---
-
-module Data.Vector.Primitive.Safe (
-  -- * Primitive vectors
-  Vector, MVector, Prim,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Indexing
-  (!), (!?), head, last,
-
-  -- ** Monadic indexing
-  indexM, headM, lastM,
-
-  -- ** Extracting subvectors (slicing)
-  slice, init, tail, take, drop, splitAt,
-
-  -- * Construction
-
-  -- ** Initialisation
-  empty, singleton, replicate, generate, iterateN,
-
-  -- ** Monadic initialisation
-  replicateM, generateM, create,
-
-  -- ** Unfolding
-  unfoldr, unfoldrN,
-  constructN, constructrN,
-
-  -- ** Enumeration
-  enumFromN, enumFromStepN, enumFromTo, enumFromThenTo,
-
-  -- ** Concatenation
-  cons, snoc, (++), concat,
-
-  -- ** Restricting memory usage
-  force,
-
-  -- * Modifying vectors
-
-  -- ** Bulk updates
-  (//), update_,
-
-  -- ** Accumulations
-  accum, accumulate_,
-
-  -- ** Permutations 
-  reverse, backpermute,
-
-  -- ** Safe destructive updates
-  modify,
-
-  -- * Elementwise operations
-
-  -- ** Mapping
-  map, imap, concatMap,
-
-  -- ** Monadic mapping
-  mapM, mapM_, forM, forM_,
-
-  -- ** Zipping
-  zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
-  izipWith, izipWith3, izipWith4, izipWith5, izipWith6,
-
-  -- ** Monadic zipping
-  zipWithM, zipWithM_,
-
-  -- * Working with predicates
-
-  -- ** Filtering
-  filter, ifilter, filterM,
-  takeWhile, dropWhile,
-
-  -- ** Partitioning
-  partition, unstablePartition, span, break,
-
-  -- ** Searching
-  elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
-
-  -- * Folding
-  foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
-  ifoldl, ifoldl', ifoldr, ifoldr',
-
-  -- ** Specialised folds
-  all, any,
-  sum, product,
-  maximum, maximumBy, minimum, minimumBy,
-  minIndex, minIndexBy, maxIndex, maxIndexBy,
-
-  -- ** Monadic folds
-  foldM, foldM', fold1M, fold1M',
-  foldM_, foldM'_, fold1M_, fold1M'_,
-
-  -- * Prefix sums (scans)
-  prescanl, prescanl',
-  postscanl, postscanl',
-  scanl, scanl', scanl1, scanl1',
-  prescanr, prescanr',
-  postscanr, postscanr',
-  scanr, scanr', scanr1, scanr1',
-
-  -- * Conversions
-
-  -- ** Lists
-  toList, fromList, fromListN,
-
-  -- ** Other vector types
-  G.convert,
-
-  -- ** Mutable vectors
-  freeze, thaw, copy,
-) where
-
-import Data.Vector.Primitive
-import qualified Data.Vector.Generic as G
-import Prelude ()
-
diff --git a/Data/Vector/Safe.hs b/Data/Vector/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Safe.hs
+++ /dev/null
@@ -1,143 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
--- |
--- Module      : Data.Vector.Safe
--- Copyright   : (c) Roman Leshchinskiy 2008-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
--- 
--- Safe interface to "Data.Vector"
---
-
-module Data.Vector.Safe (
-  -- * Boxed vectors
-  Vector, MVector,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Indexing
-  (!), (!?), head, last,
-
-  -- ** Monadic indexing
-  indexM, headM, lastM,
-
-  -- ** Extracting subvectors (slicing)
-  slice, init, tail, take, drop, splitAt,
-
-  -- * Construction
-
-  -- ** Initialisation
-  empty, singleton, replicate, generate, iterateN,
-
-  -- ** Monadic initialisation
-  replicateM, generateM, create,
-
-  -- ** Unfolding
-  unfoldr, unfoldrN,
-  constructN, constructrN,
-
-  -- ** Enumeration
-  enumFromN, enumFromStepN, enumFromTo, enumFromThenTo,
-
-  -- ** Concatenation
-  cons, snoc, (++), concat,
-
-  -- ** Restricting memory usage
-  force,
-
-  -- * Modifying vectors
-
-  -- ** Bulk updates
-  (//), update, update_,
-
-  -- ** Accumulations
-  accum, accumulate, accumulate_,
-
-  -- ** Permutations 
-  reverse, backpermute,
-
-  -- ** Safe destructive updates
-  modify,
-
-  -- * Elementwise operations
-
-  -- ** Indexing
-  indexed,
-
-  -- ** Mapping
-  map, imap, concatMap,
-
-  -- ** Monadic mapping
-  mapM, mapM_, forM, forM_,
-
-  -- ** Zipping
-  zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
-  izipWith, izipWith3, izipWith4, izipWith5, izipWith6,
-  zip, zip3, zip4, zip5, zip6,
-
-  -- ** Monadic zipping
-  zipWithM, zipWithM_,
-
-  -- ** Unzipping
-  unzip, unzip3, unzip4, unzip5, unzip6,
-
-  -- * Working with predicates
-
-  -- ** Filtering
-  filter, ifilter, filterM,
-  takeWhile, dropWhile,
-
-  -- ** Partitioning
-  partition, unstablePartition, span, break,
-
-  -- ** Searching
-  elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
-
-  -- * Folding
-  foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
-  ifoldl, ifoldl', ifoldr, ifoldr',
-
-  -- ** Specialised folds
-  all, any, and, or,
-  sum, product,
-  maximum, maximumBy, minimum, minimumBy,
-  minIndex, minIndexBy, maxIndex, maxIndexBy,
-
-  -- ** Monadic folds
-  foldM, foldM', fold1M, fold1M',
-  foldM_, foldM'_, fold1M_, fold1M'_,
-
-  -- ** Monadic sequencing
-  sequence, sequence_,
-
-  -- * Prefix sums (scans)
-  prescanl, prescanl',
-  postscanl, postscanl',
-  scanl, scanl', scanl1, scanl1',
-  prescanr, prescanr',
-  postscanr, postscanr',
-  scanr, scanr', scanr1, scanr1',
-
-  -- * Conversions
-
-  -- ** Lists
-  toList, fromList, fromListN,
-
-  -- ** Other vector types
-  G.convert,
-
-  -- ** Mutable vectors
-  freeze, thaw, copy
-) where
-
-import Data.Vector
-import qualified Data.Vector.Generic as G
-import Prelude ()
-
diff --git a/Data/Vector/Storable.hs b/Data/Vector/Storable.hs
--- a/Data/Vector/Storable.hs
+++ b/Data/Vector/Storable.hs
@@ -146,6 +146,8 @@
 import Foreign.Ptr
 import Foreign.Marshal.Array ( advancePtr, copyArray )
 
+import Control.DeepSeq ( NFData )
+
 import Control.Monad.ST ( ST )
 import Control.Monad.Primitive
 
@@ -178,6 +180,8 @@
                        {-# UNPACK #-} !(ForeignPtr a)
         deriving ( Typeable )
 
+instance NFData (Vector a)
+
 instance (Show a, Storable a) => Show (Vector a) where
   showsPrec = G.showsPrec
 
@@ -590,7 +594,7 @@
 -- | Execute the monadic action and freeze the resulting vector.
 --
 -- @
--- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\' }) = \<'a','b'\>
+-- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\'; return v }) = \<'a','b'\>
 -- @
 create :: Storable a => (forall s. ST s (MVector s a)) -> Vector a
 {-# INLINE create #-}
diff --git a/Data/Vector/Storable/Mutable.hs b/Data/Vector/Storable/Mutable.hs
--- a/Data/Vector/Storable/Mutable.hs
+++ b/Data/Vector/Storable/Mutable.hs
@@ -57,6 +57,8 @@
   unsafeWith
 ) where
 
+import Control.DeepSeq ( NFData )
+
 import qualified Data.Vector.Generic.Mutable as G
 import Data.Vector.Storable.Internal
 
@@ -72,7 +74,12 @@
 import Foreign.C.Types ( CInt )
 
 import Control.Monad.Primitive
+import Data.Primitive.Addr
+import Data.Primitive.Types (Prim)
 
+import GHC.Word (Word8, Word16, Word32, Word64)
+import GHC.Ptr (Ptr(..))
+
 import Prelude hiding ( length, null, replicate, reverse, map, read,
                         take, drop, splitAt, init, tail )
 
@@ -88,6 +95,8 @@
 type IOVector = MVector RealWorld
 type STVector s = MVector s
 
+instance NFData (MVector s a)
+
 instance Storable a => G.MVector MVector a where
   {-# INLINE basicLength #-}
   basicLength (MVector n _) = n
@@ -121,6 +130,9 @@
     = unsafePrimToPrim
     $ withForeignPtr fp $ \p -> pokeElemOff p i x
 
+  {-# INLINE basicSet #-}
+  basicSet = storableSet
+
   {-# INLINE basicUnsafeCopy #-}
   basicUnsafeCopy (MVector n fp) (MVector _ fq)
     = unsafePrimToPrim
@@ -134,6 +146,36 @@
     $ withForeignPtr fp $ \p ->
       withForeignPtr fq $ \q ->
       moveArray p q n
+
+storableSet :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> a -> m ()
+{-# INLINE storableSet #-}
+storableSet v@(MVector n fp) x
+  | n == 0 = return ()
+  | otherwise = unsafePrimToPrim $
+                case sizeOf x of
+                  1 -> storableSetAsPrim n fp x (undefined :: Word8)
+                  2 -> storableSetAsPrim n fp x (undefined :: Word16)
+                  4 -> storableSetAsPrim n fp x (undefined :: Word32)
+                  8 -> storableSetAsPrim n fp x (undefined :: Word64)
+                  _ -> withForeignPtr fp $ \p -> do
+                       poke p x
+
+                       let do_set i
+                             | 2*i < n = do
+                                 copyArray (p `advancePtr` i) p i
+                                 do_set (2*i)
+                             | otherwise = copyArray (p `advancePtr` i) p (n-i)
+
+                       do_set 1
+
+storableSetAsPrim
+  :: (Storable a, Prim b) => Int -> ForeignPtr a -> a -> b -> IO ()
+{-# INLINE [0] storableSetAsPrim #-}
+storableSetAsPrim n fp x y = withForeignPtr fp $ \(Ptr p) -> do
+  poke (Ptr p) x
+  let q = Addr p
+  w <- readOffAddr q 0
+  setAddr (q `plusAddr` sizeOf x) (n-1) (w `asTypeOf` y)
 
 {-# INLINE mallocVector #-}
 mallocVector :: Storable a => Int -> IO (ForeignPtr a)
diff --git a/Data/Vector/Unboxed.hs b/Data/Vector/Unboxed.hs
--- a/Data/Vector/Unboxed.hs
+++ b/Data/Vector/Unboxed.hs
@@ -563,7 +563,7 @@
 -- | Execute the monadic action and freeze the resulting vector.
 --
 -- @
--- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\' }) = \<'a','b'\>
+-- create (do { v \<- new 2; write v 0 \'a\'; write v 1 \'b\'; return v }) = \<'a','b'\>
 -- @
 create :: Unbox a => (forall s. ST s (MVector s a)) -> Vector a
 {-# INLINE create #-}
diff --git a/Data/Vector/Unboxed/Base.hs b/Data/Vector/Unboxed/Base.hs
--- a/Data/Vector/Unboxed/Base.hs
+++ b/Data/Vector/Unboxed/Base.hs
@@ -22,6 +22,8 @@
 
 import qualified Data.Vector.Primitive as P
 
+import Control.DeepSeq ( NFData )
+
 import Control.Monad.Primitive
 import Control.Monad ( liftM )
 
@@ -49,6 +51,9 @@
 type instance G.Mutable Vector = MVector
 
 class (G.Vector Vector a, M.MVector MVector a) => Unbox a
+
+instance NFData (Vector a)
+instance NFData (MVector s a)
 
 -- -----------------
 -- Data and Typeable
diff --git a/Data/Vector/Unboxed/Mutable/Safe.hs b/Data/Vector/Unboxed/Mutable/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Unboxed/Mutable/Safe.hs
+++ /dev/null
@@ -1,57 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
--- |
--- Module      : Data.Vector.Unboxed.Mutable.Safe
--- Copyright   : (c) Roman Leshchinskiy 2009-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
---
--- Safe interface to "Data.Vector.Unboxed.Mutable"
---
-
-module Data.Vector.Unboxed.Mutable.Safe (
-  -- * Mutable vectors of primitive types
-  MVector, IOVector, STVector, Unbox,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Extracting subvectors
-  slice, init, tail, take, drop, splitAt,
-
-  -- ** Overlapping
-  overlaps,
-
-  -- * Construction
-
-  -- ** Initialisation
-  new, replicate, replicateM, clone,
-
-  -- ** Growing
-  grow,
-
-  -- ** Restricting memory usage
-  clear,
-
-  -- * Zipping and unzipping
-  zip, zip3, zip4, zip5, zip6,
-  unzip, unzip3, unzip4, unzip5, unzip6,
-
-  -- * Accessing individual elements
-  read, write, swap,
-
-  -- * Modifying vectors
-
-  -- ** Filling and copying
-  set, copy, move
-) where
-
-import Data.Vector.Unboxed.Mutable
-import Prelude ()
-
diff --git a/Data/Vector/Unboxed/Safe.hs b/Data/Vector/Unboxed/Safe.hs
deleted file mode 100644
--- a/Data/Vector/Unboxed/Safe.hs
+++ /dev/null
@@ -1,141 +0,0 @@
-#if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
-{-# LANGUAGE Trustworthy #-}
-#endif
-
--- |
--- Module      : Data.Vector.Unboxed.Safe
--- Copyright   : (c) Roman Leshchinskiy 2009-2010
--- License     : BSD-style
---
--- Maintainer  : Roman Leshchinskiy <rl@cse.unsw.edu.au>
--- Stability   : experimental
--- Portability : non-portable
---
--- Safe interface to "Data.Vector.Unboxed"
---
-
-module Data.Vector.Unboxed.Safe (
-  -- * Unboxed vectors
-  Vector, MVector, Unbox,
-
-  -- * Accessors
-
-  -- ** Length information
-  length, null,
-
-  -- ** Indexing
-  (!), (!?), head, last,
-
-  -- ** Monadic indexing
-  indexM, headM, lastM,
-
-  -- ** Extracting subvectors (slicing)
-  slice, init, tail, take, drop, splitAt,
-
-  -- * Construction
-
-  -- ** Initialisation
-  empty, singleton, replicate, generate, iterateN,
-
-  -- ** Monadic initialisation
-  replicateM, generateM, create,
-
-  -- ** Unfolding
-  unfoldr, unfoldrN,
-  constructN, constructrN,
-
-  -- ** Enumeration
-  enumFromN, enumFromStepN, enumFromTo, enumFromThenTo,
-
-  -- ** Concatenation
-  cons, snoc, (++), concat,
-
-  -- ** Restricting memory usage
-  force,
-
-  -- * Modifying vectors
-
-  -- ** Bulk updates
-  (//), update, update_,
-
-  -- ** Accumulations
-  accum, accumulate, accumulate_,
-
-  -- ** Permutations 
-  reverse, backpermute,
-
-  -- ** Safe destructive updates
-  modify,
-
-  -- * Elementwise operations
-
-  -- ** Indexing
-  indexed,
-
-  -- ** Mapping
-  map, imap, concatMap,
-
-  -- ** Monadic mapping
-  mapM, mapM_, forM, forM_,
-
-  -- ** Zipping
-  zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
-  izipWith, izipWith3, izipWith4, izipWith5, izipWith6,
-  zip, zip3, zip4, zip5, zip6,
-
-  -- ** Monadic zipping
-  zipWithM, zipWithM_,
-
-  -- ** Unzipping
-  unzip, unzip3, unzip4, unzip5, unzip6,
-
-  -- * Working with predicates
-
-  -- ** Filtering
-  filter, ifilter, filterM,
-  takeWhile, dropWhile,
-
-  -- ** Partitioning
-  partition, unstablePartition, span, break,
-
-  -- ** Searching
-  elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
-
-  -- * Folding
-  foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
-  ifoldl, ifoldl', ifoldr, ifoldr',
-
-  -- ** Specialised folds
-  all, any, and, or,
-  sum, product,
-  maximum, maximumBy, minimum, minimumBy,
-  minIndex, minIndexBy, maxIndex, maxIndexBy,
-
-  -- ** Monadic folds
-  foldM, foldM', fold1M, fold1M',
-  foldM_, foldM'_, fold1M_, fold1M'_,
-
-  -- * Prefix sums (scans)
-  prescanl, prescanl',
-  postscanl, postscanl',
-  scanl, scanl', scanl1, scanl1',
-  prescanr, prescanr',
-  postscanr, postscanr',
-  scanr, scanr', scanr1, scanr1',
-
-  -- * Conversions
-
-  -- ** Lists
-  toList, fromList, fromListN,
-
-  -- ** Other vector types
-  G.convert,
-
-  -- ** Mutable vectors
-  freeze, thaw, copy
-) where
-
-import Data.Vector.Unboxed
-import qualified Data.Vector.Generic as G
-import Prelude ()
-
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2008-2009, Roman Leshchinskiy
+Copyright (c) 2008-2012, Roman Leshchinskiy
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/benchmarks/vector-benchmarks.cabal b/benchmarks/vector-benchmarks.cabal
--- a/benchmarks/vector-benchmarks.cabal
+++ b/benchmarks/vector-benchmarks.cabal
@@ -1,10 +1,10 @@
 Name:           vector-benchmarks
-Version:        0.9.1
+Version:        0.10
 License:        BSD3
 License-File:   LICENSE
 Author:         Roman Leshchinskiy <rl@cse.unsw.edu.au>
 Maintainer:     Roman Leshchinskiy <rl@cse.unsw.edu.au>
-Copyright:      (c) Roman Leshchinskiy 2010-2011
+Copyright:      (c) Roman Leshchinskiy 2010-2012
 Cabal-Version:  >= 1.2
 Build-Type:     Simple
 
@@ -12,9 +12,9 @@
   Main-Is: Main.hs
 
   Build-Depends: base >= 2 && < 5, array,
-                 criterion >= 0.5 && < 0.6,
-                 mwc-random >= 0.5 && < 0.11,
-                 vector == 0.9.1
+                 criterion >= 0.5 && < 0.7,
+                 mwc-random >= 0.5 && < 0.13,
+                 vector == 0.10
 
   if impl(ghc<6.13)
     Ghc-Options: -finline-if-enough-args -fno-method-sharing
diff --git a/tests/Tests/Move.hs b/tests/Tests/Move.hs
new file mode 100644
--- /dev/null
+++ b/tests/Tests/Move.hs
@@ -0,0 +1,34 @@
+module Tests.Move (tests) where
+
+import Test.QuickCheck
+import Test.Framework.Providers.QuickCheck2
+
+import Utilities ()
+
+import qualified Data.Vector.Generic as G
+import qualified Data.Vector.Generic.Mutable as M
+
+import qualified Data.Vector as V
+import qualified Data.Vector.Primitive as P
+import qualified Data.Vector.Storable as S
+import qualified Data.Vector.Unboxed as U
+
+basicMove :: G.Vector v a => v a -> Int -> Int -> Int -> v a
+basicMove v dstOff srcOff len 
+  | len > 0 = G.modify (\ mv -> G.copy (M.slice dstOff len mv) (G.slice srcOff len v)) v
+  | otherwise = v
+
+testMove :: (G.Vector v a, Show (v a), Eq (v a)) => v a -> Property
+testMove v = G.length v > 0 ==> (do
+  dstOff <- choose (0, G.length v - 1)
+  srcOff <- choose (0, G.length v - 1)
+  len <- choose (1, G.length v - max dstOff srcOff)
+  let expected = basicMove v dstOff srcOff len
+  let actual = G.modify (\ mv -> M.move (M.slice dstOff len mv) (M.slice srcOff len mv)) v
+  printTestCase ("Move: " ++ show (v, dstOff, srcOff, len)) (expected == actual))
+
+tests =
+    [testProperty "Data.Vector.Mutable (Move)" (testMove :: V.Vector Int -> Property),
+     testProperty "Data.Vector.Primitive.Mutable (Move)" (testMove :: P.Vector Int -> Property),
+     testProperty "Data.Vector.Unboxed.Mutable (Move)" (testMove :: U.Vector Int -> Property),
+     testProperty "Data.Vector.Storable.Mutable (Move)" (testMove :: S.Vector Int -> Property)]
diff --git a/tests/Tests/Vector.hs b/tests/Tests/Vector.hs
--- a/tests/Tests/Vector.hs
+++ b/tests/Tests/Vector.hs
@@ -514,7 +514,7 @@
     --prop_inits        = V.inits       `eq1` (inits       :: v a -> [v a])
     --prop_tails        = V.tails       `eq1` (tails       :: v a -> [v a])
 
-
+testGeneralBoxedVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Vector), Ord a) => Data.Vector.Vector a -> [Test]
 testGeneralBoxedVector dummy = concatMap ($ dummy) [
         testSanity,
         testPolymorphicFunctions,
@@ -534,6 +534,7 @@
   , testBoolFunctions
   ]
 
+testNumericBoxedVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Vector), Ord a, Num a, Enum a, Random a) => Data.Vector.Vector a -> [Test]
 testNumericBoxedVector dummy = concatMap ($ dummy)
   [
     testGeneralBoxedVector
@@ -542,7 +543,7 @@
   ]
 
 
-
+testGeneralPrimitiveVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Primitive.Vector), Data.Vector.Primitive.Prim a, Ord a) => Data.Vector.Primitive.Vector a -> [Test]
 testGeneralPrimitiveVector dummy = concatMap ($ dummy) [
         testSanity,
         testPolymorphicFunctions,
@@ -550,12 +551,7 @@
         testMonoidFunctions
     ]
 
-testBoolPrimitiveVector dummy = concatMap ($ dummy)
-  [
-    testGeneralPrimitiveVector
-  , testBoolFunctions
-  ]
-
+testNumericPrimitiveVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Primitive.Vector), Data.Vector.Primitive.Prim a, Ord a, Num a, Enum a, Random a) => Data.Vector.Primitive.Vector a -> [Test]
 testNumericPrimitiveVector dummy = concatMap ($ dummy)
  [
    testGeneralPrimitiveVector
@@ -564,7 +560,7 @@
  ]
 
 
-
+testGeneralStorableVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Storable.Vector), Data.Vector.Storable.Storable a, Ord a) => Data.Vector.Storable.Vector a -> [Test]
 testGeneralStorableVector dummy = concatMap ($ dummy) [
         testSanity,
         testPolymorphicFunctions,
@@ -572,6 +568,7 @@
         testMonoidFunctions
     ]
 
+testNumericStorableVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Storable.Vector), Data.Vector.Storable.Storable a, Ord a, Num a, Enum a, Random a) => Data.Vector.Storable.Vector a -> [Test]
 testNumericStorableVector dummy = concatMap ($ dummy)
   [
     testGeneralStorableVector
@@ -580,7 +577,7 @@
   ]
 
 
-
+testGeneralUnboxedVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Unboxed.Vector), Data.Vector.Unboxed.Unbox a, Ord a) => Data.Vector.Unboxed.Vector a -> [Test]
 testGeneralUnboxedVector dummy = concatMap ($ dummy) [
         testSanity,
         testPolymorphicFunctions,
@@ -599,6 +596,7 @@
   , testBoolFunctions
   ]
 
+testNumericUnboxedVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Unboxed.Vector), Data.Vector.Unboxed.Unbox a, Ord a, Num a, Enum a, Random a) => Data.Vector.Unboxed.Vector a -> [Test]
 testNumericUnboxedVector dummy = concatMap ($ dummy)
   [
     testGeneralUnboxedVector
@@ -606,6 +604,7 @@
   , testEnumFunctions
   ]
 
+testTupleUnboxedVector :: forall a. (COMMON_CONTEXT(a, Data.Vector.Unboxed.Vector), Data.Vector.Unboxed.Unbox a, Ord a) => Data.Vector.Unboxed.Vector a -> [Test]
 testTupleUnboxedVector dummy = concatMap ($ dummy)
   [
     testGeneralUnboxedVector
diff --git a/tests/vector-tests.cabal b/tests/vector-tests.cabal
--- a/tests/vector-tests.cabal
+++ b/tests/vector-tests.cabal
@@ -1,10 +1,10 @@
 Name:           vector-tests
-Version:        0.9.1
+Version:        0.10
 License:        BSD3
 License-File:   LICENSE
 Author:         Max Bolingbroke, Roman Leshchinskiy
 Maintainer:     Roman Leshchinskiy <rl@cse.unsw.edu.au>
-Copyright:      (c) Max Bolinbroke, Roman Leshchinskiy 2008-2010
+Copyright:      (c) Max Bolinbroke, Roman Leshchinskiy 2008-2012
 Homepage:       http://darcs.haskell.org/vector
 Category:       Data Structures
 Synopsis:       Efficient Arrays
@@ -18,7 +18,7 @@
 Executable "vector-tests-O0"
   Main-Is:  Main.hs
 
-  Build-Depends: base >= 4 && < 5, template-haskell, vector == 0.9.1,
+  Build-Depends: base >= 4 && < 5, template-haskell, vector == 0.10,
                  random,
                  QuickCheck >= 2, test-framework, test-framework-quickcheck2
 
@@ -38,7 +38,7 @@
 Executable "vector-tests-O2"
   Main-Is:  Main.hs
 
-  Build-Depends: base >= 4 && < 5, template-haskell, vector == 0.9.1,
+  Build-Depends: base >= 4 && < 5, template-haskell, vector == 0.10,
                  random,
                  QuickCheck >= 2, test-framework, test-framework-quickcheck2
 
diff --git a/vector.cabal b/vector.cabal
--- a/vector.cabal
+++ b/vector.cabal
@@ -1,10 +1,10 @@
 Name:           vector
-Version:        0.9.1
+Version:        0.10
 License:        BSD3
 License-File:   LICENSE
 Author:         Roman Leshchinskiy <rl@cse.unsw.edu.au>
 Maintainer:     Roman Leshchinskiy <rl@cse.unsw.edu.au>
-Copyright:      (c) Roman Leshchinskiy 2008-2011
+Copyright:      (c) Roman Leshchinskiy 2008-2012
 Homepage:       http://code.haskell.org/vector
 Bug-Reports:    http://trac.haskell.org/vector
 Category:       Data, Data Structures
@@ -29,9 +29,6 @@
         .
         ["Data.Vector.Generic"] Generic interface to the vector types.
         .
-        Each module has a @Safe@ version with is marked as @Trustworthy@
-        (see <http://hackage.haskell.org/trac/ghc/wiki/SafeHaskell>).
-        .
         There is also a (draft) tutorial on common uses of vector.
         .
         * <http://haskell.org/haskellwiki/Numeric_Haskell:_A_Vector_Tutorial>
@@ -41,42 +38,14 @@
         .
         * <http://trac.haskell.org/vector>
         .
-        Changes in version 0.9.1
-        .
-        * New functions: @unsafeFromForeignPtr0@ and @unsafeToForeignPtr0@
-        .
-        * Small performance improvements
-        .
-        * Fixes for GHC 7.4
-        .
-        Changes in version 0.9
-        .
-        * 'MonadPlus' instance for boxed vectors
-        .
-        * Export more @construct@ and @constructN@ from @Safe@ modules
-        .
-        * Require @primitive-0.4.0.1@
-        .
-        Changes in version 0.8
-        .
-        * New functions: @constructN@, @constructrN@
-        .
-        * Support for GHC 7.2 array copying primitives
-        .
-        * New fixity for @(!)@
-        .
-        * Safe Haskell support (contributed by David Terei)
-        .
-        * 'Functor', 'Monad', 'Applicative', 'Alternative', 'Foldable' and
-          'Traversable' instances for boxed vectors
-          (/WARNING: they tend to be slow and are only provided for completeness/)
-        .
-        * 'Show' instances for immutable vectors follow containers conventions
-        .
-        * 'Read' instances for all immutable vector types
-        .
-        * Performance improvements
+        Changes in version 0.10
         .
+	* @NFData@ instances
+	.
+	* More efficient block fills
+	.
+	* Safe Haskell support removed
+	.
 
 Cabal-Version:  >= 1.2.3
 Build-Type:     Simple
@@ -88,6 +57,7 @@
       tests/Main.hs
       tests/Boilerplater.hs
       tests/Utilities.hs
+      tests/Tests/Move.hs
       tests/Tests/Stream.hs
       tests/Tests/Vector.hs
       benchmarks/vector-benchmarks.cabal
@@ -107,7 +77,6 @@
       benchmarks/TestData/Random.hs
       internal/GenUnboxTuple.hs
       internal/unbox-tuple-instances
-      Changelog
 
 Flag BoundsChecks
   Description: Enable bounds checking
@@ -132,22 +101,15 @@
         Data.Vector.Fusion.Util
         Data.Vector.Fusion.Stream.Size
         Data.Vector.Fusion.Stream.Monadic
-        Data.Vector.Fusion.Stream.Monadic.Safe
         Data.Vector.Fusion.Stream
-        Data.Vector.Fusion.Stream.Safe
 
         Data.Vector.Generic.Mutable
-        Data.Vector.Generic.Mutable.Safe
         Data.Vector.Generic.Base
         Data.Vector.Generic.New
-        Data.Vector.Generic.New.Safe
         Data.Vector.Generic
-        Data.Vector.Generic.Safe
 
         Data.Vector.Primitive.Mutable
-        Data.Vector.Primitive.Mutable.Safe
         Data.Vector.Primitive
-        Data.Vector.Primitive.Safe
 
         Data.Vector.Storable.Internal
         Data.Vector.Storable.Mutable
@@ -155,14 +117,10 @@
 
         Data.Vector.Unboxed.Base
         Data.Vector.Unboxed.Mutable
-        Data.Vector.Unboxed.Mutable.Safe
         Data.Vector.Unboxed
-        Data.Vector.Unboxed.Safe
 
         Data.Vector.Mutable
-        Data.Vector.Mutable.Safe
         Data.Vector
-        Data.Vector.Safe
 
   Include-Dirs:
         include, internal
@@ -170,7 +128,10 @@
   Install-Includes:
         vector.h
 
-  Build-Depends: base >= 4 && < 5, primitive >= 0.4.0.1 && < 0.5, ghc-prim
+  Build-Depends: base >= 4 && < 5
+               , primitive >= 0.5 && < 0.6
+               , ghc-prim
+               , deepseq >= 1.1 && < 1.4
 
   if impl(ghc<6.13)
     Ghc-Options: -finline-if-enough-args -fno-method-sharing
