Use Safe Haskell if GHC >= 7.2
authorDavid Terei <davidterei@gmail.com>
Fri, 12 Aug 2011 00:05:40 +0000 (00:05 +0000)
committerDavid Terei <davidterei@gmail.com>
Fri, 12 Aug 2011 00:05:40 +0000 (00:05 +0000)
13 files changed:
Data/Vector/Fusion/Stream/Monadic/Safe.hs [new file with mode: 0644]
Data/Vector/Fusion/Stream/Safe.hs [new file with mode: 0644]
Data/Vector/Fusion/Stream/Size.hs
Data/Vector/Fusion/Util.hs
Data/Vector/Generic/Mutable/Safe.hs [new file with mode: 0644]
Data/Vector/Generic/New/Safe.hs [new file with mode: 0644]
Data/Vector/Generic/Safe.hs [new file with mode: 0644]
Data/Vector/Mutable/Safe.hs [new file with mode: 0644]
Data/Vector/Primitive/Mutable/Safe.hs [new file with mode: 0644]
Data/Vector/Primitive/Safe.hs [new file with mode: 0644]
Data/Vector/Safe.hs [new file with mode: 0644]
Data/Vector/Unboxed/Mutable/Safe.hs [new file with mode: 0644]
Data/Vector/Unboxed/Safe.hs [new file with mode: 0644]

diff --git a/Data/Vector/Fusion/Stream/Monadic/Safe.hs b/Data/Vector/Fusion/Stream/Monadic/Safe.hs
new file mode 100644 (file)
index 0000000..ab40add
--- /dev/null
@@ -0,0 +1,79 @@
+#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
+--
+-- Monadic stream combinators.
+--
+-- Safe API only.
+--
+
+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
+
diff --git a/Data/Vector/Fusion/Stream/Safe.hs b/Data/Vector/Fusion/Stream/Safe.hs
new file mode 100644 (file)
index 0000000..ae36074
--- /dev/null
@@ -0,0 +1,83 @@
+#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
+-- 
+-- Streams for stream fusion.
+--
+-- Safe API only.
+--
+
+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
+
index 00f9daf..ec98b0f 100644 (file)
@@ -1,3 +1,6 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
 -- |
 -- Module      : Data.Vector.Fusion.Stream.Size
 -- Copyright   : (c) Roman Leshchinskiy 2008-2010
index c84abbb..9c7bbcc 100644 (file)
@@ -1,3 +1,6 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
 -- |
 -- Module      : Data.Vector.Fusion.Util
 -- Copyright   : (c) Roman Leshchinskiy 2009
diff --git a/Data/Vector/Generic/Mutable/Safe.hs b/Data/Vector/Generic/Mutable/Safe.hs
new file mode 100644 (file)
index 0000000..75050c0
--- /dev/null
@@ -0,0 +1,65 @@
+#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
+-- 
+-- Generic interface to mutable vectors
+--
+-- Safe API only.
+--
+
+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,
+
+  -- * Deprecated operations
+  newWith
+) where
+
+import Data.Vector.Generic.Mutable
+
diff --git a/Data/Vector/Generic/New/Safe.hs b/Data/Vector/Generic/New/Safe.hs
new file mode 100644 (file)
index 0000000..a62a166
--- /dev/null
@@ -0,0 +1,26 @@
+#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
+-- 
+-- Purely functional interface to initialisation of mutable vectors
+--
+-- Safe API only.
+--
+
+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
+
diff --git a/Data/Vector/Generic/Safe.hs b/Data/Vector/Generic/Safe.hs
new file mode 100644 (file)
index 0000000..6eba3bc
--- /dev/null
@@ -0,0 +1,158 @@
+#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
+-- 
+-- Generic interface to pure vectors.
+--
+-- Safe API only.
+--
+
+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
+
diff --git a/Data/Vector/Mutable/Safe.hs b/Data/Vector/Mutable/Safe.hs
new file mode 100644 (file)
index 0000000..5bb14f8
--- /dev/null
@@ -0,0 +1,58 @@
+#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
+-- 
+-- Mutable boxed vectors.
+--
+-- Safe API only.
+--
+
+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,
+
+  -- * Deprecated operations
+  newWith
+) where
+
+import Data.Vector.Mutable
+
diff --git a/Data/Vector/Primitive/Mutable/Safe.hs b/Data/Vector/Primitive/Mutable/Safe.hs
new file mode 100644 (file)
index 0000000..e092710
--- /dev/null
@@ -0,0 +1,57 @@
+#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
+-- 
+-- Mutable primitive vectors.
+--
+-- Safe API only.
+--
+
+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,
+
+  -- * Deprecated operations
+  newWith
+) where
+
+import Data.Vector.Primitive.Mutable
+
diff --git a/Data/Vector/Primitive/Safe.hs b/Data/Vector/Primitive/Safe.hs
new file mode 100644 (file)
index 0000000..6ca8bf6
--- /dev/null
@@ -0,0 +1,134 @@
+#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
+-- 
+-- Unboxed vectors of primitive types. The use of this module is not
+-- recommended except in very special cases. Adaptive unboxed vectors defined
+-- in "Data.Vector.Unboxed" are significantly more flexible at no performance
+-- cost.
+--
+
+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,
+
+  -- ** 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
+
diff --git a/Data/Vector/Safe.hs b/Data/Vector/Safe.hs
new file mode 100644 (file)
index 0000000..cd846c8
--- /dev/null
@@ -0,0 +1,152 @@
+#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
+-- 
+-- A library for boxed vectors (that is, polymorphic arrays capable of
+-- holding any Haskell value). The vectors come in two flavors:
+--
+--  * mutable
+--
+--  * immutable
+--
+-- and support a rich interface of both list-like operations, and bulk
+-- array operations.
+--
+-- Safe API only.
+--
+-- For unboxed arrays, use the 'Data.Vector.Unboxed' interface.
+--
+
+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,
+
+  -- ** 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
+
diff --git a/Data/Vector/Unboxed/Mutable/Safe.hs b/Data/Vector/Unboxed/Mutable/Safe.hs
new file mode 100644 (file)
index 0000000..063788e
--- /dev/null
@@ -0,0 +1,62 @@
+#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
+--
+-- Mutable adaptive unboxed vectors.
+--
+-- Safe API only.
+--
+
+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,
+
+  -- * Deprecated operations
+  newWith
+
+) where
+
+import Data.Vector.Unboxed.Mutable
+
diff --git a/Data/Vector/Unboxed/Safe.hs b/Data/Vector/Unboxed/Safe.hs
new file mode 100644 (file)
index 0000000..144cc9c
--- /dev/null
@@ -0,0 +1,163 @@
+#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
+--
+-- Adaptive unboxed vectors. The implementation is based on type families
+-- and picks an efficient, specialised representation for every element type.
+-- In particular, unboxed vectors of pairs are represented as pairs of unboxed
+-- vectors.
+--
+-- Safe API only.
+--
+-- Implementing unboxed vectors for new data types can be very easy. Here is
+-- how the library does this for 'Complex' by simply wrapping vectors of
+-- pairs.
+--
+-- @
+-- newtype instance 'MVector' s ('Complex' a) = MV_Complex ('MVector' s (a,a))
+-- newtype instance 'Vector'    ('Complex' a) = V_Complex  ('Vector'    (a,a))
+--
+-- instance ('RealFloat' a, 'Unbox' a) => 'Data.Vector.Generic.Mutable.MVector' 'MVector' ('Complex' a) where
+--   {-\# INLINE basicLength \#-}
+--   basicLength (MV_Complex v) = 'Data.Vector.Generic.Mutable.basicLength' v
+--   ...
+--
+-- instance ('RealFloat' a, 'Unbox' a) => Data.Vector.Generic.Vector 'Vector' ('Complex' a) where
+--   {-\# INLINE basicLength \#-}
+--   basicLength (V_Complex v) = Data.Vector.Generic.basicLength v
+--   ...
+--
+-- instance ('RealFloat' a, 'Unbox' a) => 'Unbox' ('Complex' a)
+-- @
+
+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,
+
+  -- ** 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.Safe
+