2f86c3e02abd86065432e49834e2206558768a94
[darcs-mirrors/vector.git] / Data / Vector / Safe.hs
1 #if __GLASGOW_HASKELL__ >= 701 && defined(VECTOR_BOUNDS_CHECKS)
2 {-# LANGUAGE Trustworthy #-}
3 #endif
4 -- |
5 -- Module : Data.Vector.Safe
6 -- Copyright : (c) Roman Leshchinskiy 2008-2010
7 -- License : BSD-style
8 --
9 -- Maintainer : Roman Leshchinskiy <rl@cse.unsw.edu.au>
10 -- Stability : experimental
11 -- Portability : non-portable
12 --
13 -- Safe interface to "Data.Vector"
14 --
15
16 module Data.Vector.Safe (
17 -- * Boxed vectors
18 Vector, MVector,
19
20 -- * Accessors
21
22 -- ** Length information
23 length, null,
24
25 -- ** Indexing
26 (!), (!?), head, last,
27
28 -- ** Monadic indexing
29 indexM, headM, lastM,
30
31 -- ** Extracting subvectors (slicing)
32 slice, init, tail, take, drop, splitAt,
33
34 -- * Construction
35
36 -- ** Initialisation
37 empty, singleton, replicate, generate, iterateN,
38
39 -- ** Monadic initialisation
40 replicateM, generateM, create,
41
42 -- ** Unfolding
43 unfoldr, unfoldrN,
44 constructN, constructrN,
45
46 -- ** Enumeration
47 enumFromN, enumFromStepN, enumFromTo, enumFromThenTo,
48
49 -- ** Concatenation
50 cons, snoc, (++), concat,
51
52 -- ** Restricting memory usage
53 force,
54
55 -- * Modifying vectors
56
57 -- ** Bulk updates
58 (//), update, update_,
59
60 -- ** Accumulations
61 accum, accumulate, accumulate_,
62
63 -- ** Permutations
64 reverse, backpermute,
65
66 -- ** Safe destructive updates
67 modify,
68
69 -- * Elementwise operations
70
71 -- ** Indexing
72 indexed,
73
74 -- ** Mapping
75 map, imap, concatMap,
76
77 -- ** Monadic mapping
78 mapM, mapM_, forM, forM_,
79
80 -- ** Zipping
81 zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
82 izipWith, izipWith3, izipWith4, izipWith5, izipWith6,
83 zip, zip3, zip4, zip5, zip6,
84
85 -- ** Monadic zipping
86 zipWithM, zipWithM_,
87
88 -- ** Unzipping
89 unzip, unzip3, unzip4, unzip5, unzip6,
90
91 -- * Working with predicates
92
93 -- ** Filtering
94 filter, ifilter, filterM,
95 takeWhile, dropWhile,
96
97 -- ** Partitioning
98 partition, unstablePartition, span, break,
99
100 -- ** Searching
101 elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
102
103 -- * Folding
104 foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
105 ifoldl, ifoldl', ifoldr, ifoldr',
106
107 -- ** Specialised folds
108 all, any, and, or,
109 sum, product,
110 maximum, maximumBy, minimum, minimumBy,
111 minIndex, minIndexBy, maxIndex, maxIndexBy,
112
113 -- ** Monadic folds
114 foldM, foldM', fold1M, fold1M',
115 foldM_, foldM'_, fold1M_, fold1M'_,
116
117 -- ** Monadic sequencing
118 sequence, sequence_,
119
120 -- * Prefix sums (scans)
121 prescanl, prescanl',
122 postscanl, postscanl',
123 scanl, scanl', scanl1, scanl1',
124 prescanr, prescanr',
125 postscanr, postscanr',
126 scanr, scanr', scanr1, scanr1',
127
128 -- * Conversions
129
130 -- ** Lists
131 toList, fromList, fromListN,
132
133 -- ** Other vector types
134 G.convert,
135
136 -- ** Mutable vectors
137 freeze, thaw, copy
138 ) where
139
140 import Data.Vector
141 import qualified Data.Vector.Generic as G
142 import Prelude ()
143