Add generate
[darcs-mirrors/vector.git] / Data / Vector.hs
1 {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-}
2
3 -- |
4 -- Module : Data.Vector
5 -- Copyright : (c) Roman Leshchinskiy 2008-2009
6 -- License : BSD-style
7 --
8 -- Maintainer : Roman Leshchinskiy <rl@cse.unsw.edu.au>
9 -- Stability : experimental
10 -- Portability : non-portable
11 --
12 -- Boxed vectors
13 --
14
15 module Data.Vector (
16 Vector, MVector,
17
18 -- * Length information
19 length, null,
20
21 -- * Construction
22 empty, singleton, cons, snoc, replicate, generate, (++), copy,
23
24 -- * Accessing individual elements
25 (!), head, last, indexM, headM, lastM,
26
27 -- * Subvectors
28 slice, init, tail, take, drop,
29 unsafeSlice,
30
31 -- * Permutations
32 accum, accumulate, accumulate_,
33 (//), update, update_,
34 backpermute, reverse,
35
36 -- * Mapping
37 map, imap, concatMap,
38
39 -- * Zipping and unzipping
40 zipWith, zipWith3, zipWith4, zipWith5, zipWith6,
41 izipWith, izipWith3, izipWith4, izipWith5, izipWith6,
42 zip, zip3, zip4, zip5, zip6,
43 unzip, unzip3, unzip4, unzip5, unzip6,
44
45 -- * Filtering
46 filter, ifilter, takeWhile, dropWhile,
47
48 -- * Searching
49 elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
50
51 -- * Folding
52 foldl, foldl1, foldl', foldl1', foldr, foldr1,
53 ifoldl, ifoldl', ifoldr,
54
55 -- * Specialised folds
56 all, any, and, or,
57 sum, product,
58 maximum, maximumBy, minimum, minimumBy,
59 minIndex, minIndexBy, maxIndex, maxIndexBy,
60
61 -- * Unfolding
62 unfoldr,
63
64 -- * Scans
65 prescanl, prescanl',
66 postscanl, postscanl',
67 scanl, scanl', scanl1, scanl1',
68
69 -- * Enumeration
70 enumFromTo, enumFromThenTo,
71
72 -- * Conversion to/from lists
73 toList, fromList,
74
75 -- * Unsafe operations
76 unsafeIndex, unsafeIndexM,
77 unsafeAccum, unsafeAccumulate, unsafeAccumulate_,
78 unsafeUpd, unsafeUpdate, unsafeUpdate_
79 ) where
80
81 import qualified Data.Vector.Generic as G
82 import Data.Vector.Mutable ( MVector(..) )
83 import Data.Primitive.Array
84
85 import Control.Monad ( liftM )
86
87 import Prelude hiding ( length, null,
88 replicate, (++),
89 head, last,
90 init, tail, take, drop, reverse,
91 map, concatMap,
92 zipWith, zipWith3, zip, zip3, unzip, unzip3,
93 filter, takeWhile, dropWhile,
94 elem, notElem,
95 foldl, foldl1, foldr, foldr1,
96 all, any, and, or, sum, product, minimum, maximum,
97 scanl, scanl1,
98 enumFromTo, enumFromThenTo )
99
100 import qualified Prelude
101
102 data Vector a = Vector {-# UNPACK #-} !Int
103 {-# UNPACK #-} !Int
104 {-# UNPACK #-} !(Array a)
105
106 instance Show a => Show (Vector a) where
107 show = (Prelude.++ " :: Data.Vector.Vector") . ("fromList " Prelude.++) . show . toList
108
109 type instance G.Mutable Vector = MVector
110
111 instance G.Vector Vector a where
112 {-# INLINE unsafeFreeze #-}
113 unsafeFreeze (MVector i n marr)
114 = Vector i n `liftM` unsafeFreezeArray marr
115
116 {-# INLINE basicLength #-}
117 basicLength (Vector _ n _) = n
118
119 {-# INLINE basicUnsafeSlice #-}
120 basicUnsafeSlice (Vector i _ arr) j n = Vector (i+j) n arr
121
122 {-# INLINE basicUnsafeIndexM #-}
123 basicUnsafeIndexM (Vector i _ arr) j = indexArrayM arr (i+j)
124
125 instance Eq a => Eq (Vector a) where
126 {-# INLINE (==) #-}
127 (==) = G.eq
128
129 instance Ord a => Ord (Vector a) where
130 {-# INLINE compare #-}
131 compare = G.cmp
132
133 -- Length
134 -- ------
135
136 length :: Vector a -> Int
137 {-# INLINE length #-}
138 length = G.length
139
140 null :: Vector a -> Bool
141 {-# INLINE null #-}
142 null = G.null
143
144 -- Construction
145 -- ------------
146
147 -- | Empty vector
148 empty :: Vector a
149 {-# INLINE empty #-}
150 empty = G.empty
151
152 -- | Vector with exaclty one element
153 singleton :: a -> Vector a
154 {-# INLINE singleton #-}
155 singleton = G.singleton
156
157 -- | Vector of the given length with the given value in each position
158 replicate :: Int -> a -> Vector a
159 {-# INLINE replicate #-}
160 replicate = G.replicate
161
162 -- | Generate a vector of the given length by applying the function to each
163 -- index
164 generate :: Int -> (Int -> a) -> Vector a
165 {-# INLINE generate #-}
166 generate = G.generate
167
168 -- | Prepend an element
169 cons :: a -> Vector a -> Vector a
170 {-# INLINE cons #-}
171 cons = G.cons
172
173 -- | Append an element
174 snoc :: Vector a -> a -> Vector a
175 {-# INLINE snoc #-}
176 snoc = G.snoc
177
178 infixr 5 ++
179 -- | Concatenate two vectors
180 (++) :: Vector a -> Vector a -> Vector a
181 {-# INLINE (++) #-}
182 (++) = (G.++)
183
184 -- | Create a copy of a vector. Useful when dealing with slices.
185 copy :: Vector a -> Vector a
186 {-# INLINE copy #-}
187 copy = G.copy
188
189 -- Accessing individual elements
190 -- -----------------------------
191
192 -- | Indexing
193 (!) :: Vector a -> Int -> a
194 {-# INLINE (!) #-}
195 (!) = (G.!)
196
197 -- | Unsafe indexing without bounds checks
198 unsafeIndex :: Vector a -> Int -> a
199 {-# INLINE unsafeIndex #-}
200 unsafeIndex = G.unsafeIndex
201
202 -- | First element
203 head :: Vector a -> a
204 {-# INLINE head #-}
205 head = G.head
206
207 -- | Last element
208 last :: Vector a -> a
209 {-# INLINE last #-}
210 last = G.last
211
212 -- | Monadic indexing which can be strict in the vector while remaining lazy in
213 -- the element
214 indexM :: Monad m => Vector a -> Int -> m a
215 {-# INLINE indexM #-}
216 indexM = G.indexM
217
218 -- | Unsafe monadic indexing without bounds checks
219 unsafeIndexM :: Monad m => Vector a -> Int -> m a
220 {-# INLINE unsafeIndexM #-}
221 unsafeIndexM = G.unsafeIndexM
222
223 headM :: Monad m => Vector a -> m a
224 {-# INLINE headM #-}
225 headM = G.headM
226
227 lastM :: Monad m => Vector a -> m a
228 {-# INLINE lastM #-}
229 lastM = G.lastM
230
231 -- Subarrays
232 -- ---------
233
234 -- | Yield a part of the vector without copying it. Safer version of
235 -- 'basicUnsafeSlice'.
236 slice :: Vector a -> Int -- ^ starting index
237 -> Int -- ^ length
238 -> Vector a
239 {-# INLINE slice #-}
240 slice = G.slice
241
242 -- | Unsafely yield a part of the vector without copying it and without
243 -- performing bounds checks.
244 unsafeSlice :: Vector a -> Int -- ^ starting index
245 -> Int -- ^ length
246 -> Vector a
247 {-# INLINE unsafeSlice #-}
248 unsafeSlice = G.unsafeSlice
249
250 -- | Yield all but the last element without copying.
251 init :: Vector a -> Vector a
252 {-# INLINE init #-}
253 init = G.init
254
255 -- | All but the first element (without copying).
256 tail :: Vector a -> Vector a
257 {-# INLINE tail #-}
258 tail = G.tail
259
260 -- | Yield the first @n@ elements without copying.
261 take :: Int -> Vector a -> Vector a
262 {-# INLINE take #-}
263 take = G.take
264
265 -- | Yield all but the first @n@ elements without copying.
266 drop :: Int -> Vector a -> Vector a
267 {-# INLINE drop #-}
268 drop = G.drop
269
270 -- Permutations
271 -- ------------
272
273 unsafeAccum :: (a -> b -> a) -> Vector a -> [(Int,b)] -> Vector a
274 {-# INLINE unsafeAccum #-}
275 unsafeAccum = G.unsafeAccum
276
277 unsafeAccumulate :: (a -> b -> a) -> Vector a -> Vector (Int,b) -> Vector a
278 {-# INLINE unsafeAccumulate #-}
279 unsafeAccumulate = G.unsafeAccumulate
280
281 unsafeAccumulate_
282 :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a
283 {-# INLINE unsafeAccumulate_ #-}
284 unsafeAccumulate_ = G.unsafeAccumulate_
285
286 accum :: (a -> b -> a) -> Vector a -> [(Int,b)] -> Vector a
287 {-# INLINE accum #-}
288 accum = G.accum
289
290 accumulate :: (a -> b -> a) -> Vector a -> Vector (Int,b) -> Vector a
291 {-# INLINE accumulate #-}
292 accumulate = G.accumulate
293
294 accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a
295 {-# INLINE accumulate_ #-}
296 accumulate_ = G.accumulate_
297
298 unsafeUpd :: Vector a -> [(Int, a)] -> Vector a
299 {-# INLINE unsafeUpd #-}
300 unsafeUpd = G.unsafeUpd
301
302 unsafeUpdate :: Vector a -> Vector (Int, a) -> Vector a
303 {-# INLINE unsafeUpdate #-}
304 unsafeUpdate = G.unsafeUpdate
305
306 unsafeUpdate_ :: Vector a -> Vector Int -> Vector a -> Vector a
307 {-# INLINE unsafeUpdate_ #-}
308 unsafeUpdate_ = G.unsafeUpdate_
309
310 (//) :: Vector a -> [(Int, a)] -> Vector a
311 {-# INLINE (//) #-}
312 (//) = (G.//)
313
314 update :: Vector a -> Vector (Int, a) -> Vector a
315 {-# INLINE update #-}
316 update = G.update
317
318 update_ :: Vector a -> Vector Int -> Vector a -> Vector a
319 {-# INLINE update_ #-}
320 update_ = G.update_
321
322 backpermute :: Vector a -> Vector Int -> Vector a
323 {-# INLINE backpermute #-}
324 backpermute = G.backpermute
325
326 reverse :: Vector a -> Vector a
327 {-# INLINE reverse #-}
328 reverse = G.reverse
329
330 -- Mapping
331 -- -------
332
333 -- | Map a function over a vector
334 map :: (a -> b) -> Vector a -> Vector b
335 {-# INLINE map #-}
336 map = G.map
337
338 -- | Apply a function to every index/value pair
339 imap :: (Int -> a -> b) -> Vector a -> Vector b
340 {-# INLINE imap #-}
341 imap = G.imap
342
343 concatMap :: (a -> Vector b) -> Vector a -> Vector b
344 {-# INLINE concatMap #-}
345 concatMap = G.concatMap
346
347 -- Zipping/unzipping
348 -- -----------------
349
350 -- | Zip two vectors with the given function.
351 zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c
352 {-# INLINE zipWith #-}
353 zipWith = G.zipWith
354
355 -- | Zip three vectors with the given function.
356 zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
357 {-# INLINE zipWith3 #-}
358 zipWith3 = G.zipWith3
359
360 zipWith4 :: (a -> b -> c -> d -> e)
361 -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
362 {-# INLINE zipWith4 #-}
363 zipWith4 = G.zipWith4
364
365 zipWith5 :: (a -> b -> c -> d -> e -> f)
366 -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
367 -> Vector f
368 {-# INLINE zipWith5 #-}
369 zipWith5 = G.zipWith5
370
371 zipWith6 :: (a -> b -> c -> d -> e -> f -> g)
372 -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
373 -> Vector f -> Vector g
374 {-# INLINE zipWith6 #-}
375 zipWith6 = G.zipWith6
376
377 -- | Zip two vectors and their indices with the given function.
378 izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c
379 {-# INLINE izipWith #-}
380 izipWith = G.izipWith
381
382 -- | Zip three vectors and their indices with the given function.
383 izipWith3 :: (Int -> a -> b -> c -> d)
384 -> Vector a -> Vector b -> Vector c -> Vector d
385 {-# INLINE izipWith3 #-}
386 izipWith3 = G.izipWith3
387
388 izipWith4 :: (Int -> a -> b -> c -> d -> e)
389 -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
390 {-# INLINE izipWith4 #-}
391 izipWith4 = G.izipWith4
392
393 izipWith5 :: (Int -> a -> b -> c -> d -> e -> f)
394 -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
395 -> Vector f
396 {-# INLINE izipWith5 #-}
397 izipWith5 = G.izipWith5
398
399 izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g)
400 -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
401 -> Vector f -> Vector g
402 {-# INLINE izipWith6 #-}
403 izipWith6 = G.izipWith6
404
405 zip :: Vector a -> Vector b -> Vector (a, b)
406 {-# INLINE zip #-}
407 zip = G.zip
408
409 zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)
410 {-# INLINE zip3 #-}
411 zip3 = G.zip3
412
413 zip4 :: Vector a -> Vector b -> Vector c -> Vector d
414 -> Vector (a, b, c, d)
415 {-# INLINE zip4 #-}
416 zip4 = G.zip4
417
418 zip5 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e
419 -> Vector (a, b, c, d, e)
420 {-# INLINE zip5 #-}
421 zip5 = G.zip5
422
423 zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
424 -> Vector (a, b, c, d, e, f)
425 {-# INLINE zip6 #-}
426 zip6 = G.zip6
427
428 unzip :: Vector (a, b) -> (Vector a, Vector b)
429 {-# INLINE unzip #-}
430 unzip = G.unzip
431
432 unzip3 :: Vector (a, b, c) -> (Vector a, Vector b, Vector c)
433 {-# INLINE unzip3 #-}
434 unzip3 = G.unzip3
435
436 unzip4 :: Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)
437 {-# INLINE unzip4 #-}
438 unzip4 = G.unzip4
439
440 unzip5 :: Vector (a, b, c, d, e)
441 -> (Vector a, Vector b, Vector c, Vector d, Vector e)
442 {-# INLINE unzip5 #-}
443 unzip5 = G.unzip5
444
445 unzip6 :: Vector (a, b, c, d, e, f)
446 -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)
447 {-# INLINE unzip6 #-}
448 unzip6 = G.unzip6
449
450 -- Filtering
451 -- ---------
452
453 -- | Drop elements which do not satisfy the predicate
454 filter :: (a -> Bool) -> Vector a -> Vector a
455 {-# INLINE filter #-}
456 filter = G.filter
457
458 -- | Drop elements that do not satisfy the predicate (applied to values and
459 -- their indices)
460 ifilter :: (Int -> a -> Bool) -> Vector a -> Vector a
461 {-# INLINE ifilter #-}
462 ifilter = G.ifilter
463
464 -- | Yield the longest prefix of elements satisfying the predicate.
465 takeWhile :: (a -> Bool) -> Vector a -> Vector a
466 {-# INLINE takeWhile #-}
467 takeWhile = G.takeWhile
468
469 -- | Drop the longest prefix of elements that satisfy the predicate.
470 dropWhile :: (a -> Bool) -> Vector a -> Vector a
471 {-# INLINE dropWhile #-}
472 dropWhile = G.dropWhile
473
474 -- Searching
475 -- ---------
476
477 infix 4 `elem`
478 -- | Check whether the vector contains an element
479 elem :: Eq a => a -> Vector a -> Bool
480 {-# INLINE elem #-}
481 elem = G.elem
482
483 infix 4 `notElem`
484 -- | Inverse of `elem`
485 notElem :: Eq a => a -> Vector a -> Bool
486 {-# INLINE notElem #-}
487 notElem = G.notElem
488
489 -- | Yield 'Just' the first element matching the predicate or 'Nothing' if no
490 -- such element exists.
491 find :: (a -> Bool) -> Vector a -> Maybe a
492 {-# INLINE find #-}
493 find = G.find
494
495 -- | Yield 'Just' the index of the first element matching the predicate or
496 -- 'Nothing' if no such element exists.
497 findIndex :: (a -> Bool) -> Vector a -> Maybe Int
498 {-# INLINE findIndex #-}
499 findIndex = G.findIndex
500
501 -- | Yield the indices of elements satisfying the predicate
502 findIndices :: (a -> Bool) -> Vector a -> Vector Int
503 {-# INLINE findIndices #-}
504 findIndices = G.findIndices
505
506 -- | Yield 'Just' the index of the first occurence of the given element or
507 -- 'Nothing' if the vector does not contain the element
508 elemIndex :: Eq a => a -> Vector a -> Maybe Int
509 {-# INLINE elemIndex #-}
510 elemIndex = G.elemIndex
511
512 -- | Yield the indices of all occurences of the given element
513 elemIndices :: Eq a => a -> Vector a -> Vector Int
514 {-# INLINE elemIndices #-}
515 elemIndices = G.elemIndices
516
517 -- Folding
518 -- -------
519
520 -- | Left fold
521 foldl :: (a -> b -> a) -> a -> Vector b -> a
522 {-# INLINE foldl #-}
523 foldl = G.foldl
524
525 -- | Lefgt fold on non-empty vectors
526 foldl1 :: (a -> a -> a) -> Vector a -> a
527 {-# INLINE foldl1 #-}
528 foldl1 = G.foldl1
529
530 -- | Left fold with strict accumulator
531 foldl' :: (a -> b -> a) -> a -> Vector b -> a
532 {-# INLINE foldl' #-}
533 foldl' = G.foldl'
534
535 -- | Left fold on non-empty vectors with strict accumulator
536 foldl1' :: (a -> a -> a) -> Vector a -> a
537 {-# INLINE foldl1' #-}
538 foldl1' = G.foldl1'
539
540 -- | Right fold
541 foldr :: (a -> b -> b) -> b -> Vector a -> b
542 {-# INLINE foldr #-}
543 foldr = G.foldr
544
545 -- | Right fold on non-empty vectors
546 foldr1 :: (a -> a -> a) -> Vector a -> a
547 {-# INLINE foldr1 #-}
548 foldr1 = G.foldr1
549
550 -- | Left fold (function applied to each element and its index)
551 ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> a
552 {-# INLINE ifoldl #-}
553 ifoldl = G.ifoldl
554
555 -- | Left fold with strict accumulator (function applied to each element and
556 -- its index)
557 ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> a
558 {-# INLINE ifoldl' #-}
559 ifoldl' = G.ifoldl'
560
561 -- | Right fold (function applied to each element and its index)
562 ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b
563 {-# INLINE ifoldr #-}
564 ifoldr = G.ifoldr
565
566 -- Specialised folds
567 -- -----------------
568
569 all :: (a -> Bool) -> Vector a -> Bool
570 {-# INLINE all #-}
571 all = G.all
572
573 any :: (a -> Bool) -> Vector a -> Bool
574 {-# INLINE any #-}
575 any = G.any
576
577 and :: Vector Bool -> Bool
578 {-# INLINE and #-}
579 and = G.and
580
581 or :: Vector Bool -> Bool
582 {-# INLINE or #-}
583 or = G.or
584
585 sum :: Num a => Vector a -> a
586 {-# INLINE sum #-}
587 sum = G.sum
588
589 product :: Num a => Vector a -> a
590 {-# INLINE product #-}
591 product = G.product
592
593 maximum :: Ord a => Vector a -> a
594 {-# INLINE maximum #-}
595 maximum = G.maximum
596
597 maximumBy :: (a -> a -> Ordering) -> Vector a -> a
598 {-# INLINE maximumBy #-}
599 maximumBy = G.maximumBy
600
601 minimum :: Ord a => Vector a -> a
602 {-# INLINE minimum #-}
603 minimum = G.minimum
604
605 minimumBy :: (a -> a -> Ordering) -> Vector a -> a
606 {-# INLINE minimumBy #-}
607 minimumBy = G.minimumBy
608
609 maxIndex :: Ord a => Vector a -> Int
610 {-# INLINE maxIndex #-}
611 maxIndex = G.maxIndex
612
613 maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Int
614 {-# INLINE maxIndexBy #-}
615 maxIndexBy = G.maxIndexBy
616
617 minIndex :: Ord a => Vector a -> Int
618 {-# INLINE minIndex #-}
619 minIndex = G.minIndex
620
621 minIndexBy :: (a -> a -> Ordering) -> Vector a -> Int
622 {-# INLINE minIndexBy #-}
623 minIndexBy = G.minIndexBy
624
625 -- Unfolding
626 -- ---------
627
628 unfoldr :: (b -> Maybe (a, b)) -> b -> Vector a
629 {-# INLINE unfoldr #-}
630 unfoldr = G.unfoldr
631
632 -- Scans
633 -- -----
634
635 -- | Prefix scan
636 prescanl :: (a -> b -> a) -> a -> Vector b -> Vector a
637 {-# INLINE prescanl #-}
638 prescanl = G.prescanl
639
640 -- | Prefix scan with strict accumulator
641 prescanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
642 {-# INLINE prescanl' #-}
643 prescanl' = G.prescanl'
644
645 -- | Suffix scan
646 postscanl :: (a -> b -> a) -> a -> Vector b -> Vector a
647 {-# INLINE postscanl #-}
648 postscanl = G.postscanl
649
650 -- | Suffix scan with strict accumulator
651 postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
652 {-# INLINE postscanl' #-}
653 postscanl' = G.postscanl'
654
655 -- | Haskell-style scan
656 scanl :: (a -> b -> a) -> a -> Vector b -> Vector a
657 {-# INLINE scanl #-}
658 scanl = G.scanl
659
660 -- | Haskell-style scan with strict accumulator
661 scanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
662 {-# INLINE scanl' #-}
663 scanl' = G.scanl'
664
665 -- | Scan over a non-empty 'Vector'
666 scanl1 :: (a -> a -> a) -> Vector a -> Vector a
667 {-# INLINE scanl1 #-}
668 scanl1 = G.scanl1
669
670 -- | Scan over a non-empty 'Vector' with a strict accumulator
671 scanl1' :: (a -> a -> a) -> Vector a -> Vector a
672 {-# INLINE scanl1' #-}
673 scanl1' = G.scanl1'
674
675 -- Enumeration
676 -- -----------
677
678 enumFromTo :: Enum a => a -> a -> Vector a
679 {-# INLINE enumFromTo #-}
680 enumFromTo = G.enumFromTo
681
682 enumFromThenTo :: Enum a => a -> a -> a -> Vector a
683 {-# INLINE enumFromThenTo #-}
684 enumFromThenTo = G.enumFromThenTo
685
686 -- Conversion to/from lists
687 -- ------------------------
688
689 -- | Convert a vector to a list
690 toList :: Vector a -> [a]
691 {-# INLINE toList #-}
692 toList = G.toList
693
694 -- | Convert a list to a vector
695 fromList :: [a] -> Vector a
696 {-# INLINE fromList #-}
697 fromList = G.fromList
698