|
25 | 25 | -- are set to ⊥. |
26 | 26 | module Data.Vector.Strict.Mutable ( |
27 | 27 | -- * Mutable boxed vectors |
28 | | - MVector, IOVector, STVector, |
29 | | - pattern MVector, |
| 28 | + MVector(MVector), IOVector, STVector, |
30 | 29 |
|
31 | 30 | -- * Accessors |
32 | 31 |
|
@@ -78,64 +77,30 @@ module Data.Vector.Strict.Mutable ( |
78 | 77 | PrimMonad, PrimState, RealWorld |
79 | 78 | ) where |
80 | 79 |
|
81 | | -import Data.Primitive.Array |
82 | 80 | import qualified Data.Vector.Generic.Mutable as G |
83 | | -import qualified Data.Vector.Mutable as MV |
84 | | -import Data.Vector.Strict.Mutable.Unsafe (MVector) |
85 | | -import qualified Data.Vector.Strict.Mutable.Unsafe as U |
| 81 | +import Data.Vector.Strict.Pat |
86 | 82 | import Control.Monad.Primitive |
87 | 83 |
|
88 | | -import Prelude ( Ord, Bool, Int, Maybe, Ordering(..), Monad(..), (<$>), ($)) |
| 84 | +import Prelude ( Ord, Bool, Int, Maybe, Ordering(..) ) |
89 | 85 |
|
90 | 86 | #include "vector.h" |
91 | 87 |
|
92 | | -pattern MVector :: MV.MVector s a -> MVector s a |
93 | | -pattern MVector v = U.MVector v |
94 | | -{-# COMPLETE MVector #-} |
95 | | -{-# DEPRECATED MVector "Use MVector constructor exported from \"Data.Vector.Strict.Unsafe\"" #-} |
96 | | - |
97 | 88 | type IOVector = MVector RealWorld |
98 | 89 | type STVector s = MVector s |
99 | 90 |
|
100 | 91 |
|
101 | 92 | -- Conversions - Lazy vectors |
102 | | --- ----------------------------- |
103 | | - |
104 | | --- | /O(1)/ Convert strict mutable vector to lazy mutable |
105 | | --- vector. Vectors will share mutable buffer |
106 | | -toLazy :: MVector s a -> MV.MVector s a |
107 | | -{-# INLINE toLazy #-} |
108 | | -toLazy (MVector vec) = vec |
109 | | - |
110 | | --- | /O(n)/ Convert lazy mutable vector to strict mutable |
111 | | --- vector. Vectors will share mutable buffer. This function evaluates |
112 | | --- vector elements to WHNF. |
113 | | -fromLazy :: PrimMonad m => MV.MVector (PrimState m) a -> m (MVector (PrimState m) a) |
114 | | -fromLazy mvec = stToPrim $ do |
115 | | - G.foldM' (\_ !_ -> return ()) () mvec |
116 | | - return $ MVector mvec |
| 93 | +-- |
| 94 | +-- toLazy, fromLazy are defined in Data.Vector.Strict.Pat |
| 95 | +-- |
| 96 | +-- See NOTE: [Constructor deprecation] |
117 | 97 |
|
118 | 98 |
|
119 | 99 | -- Conversions - Arrays |
120 | | --- ----------------------------- |
121 | | - |
122 | | --- | /O(n)/ Make a copy of a mutable array to a new mutable |
123 | | --- vector. All elements of a vector are evaluated to WHNF |
124 | 100 | -- |
125 | | --- @since 0.13.2.0 |
126 | | -fromMutableArray :: PrimMonad m => MutableArray (PrimState m) a -> m (MVector (PrimState m) a) |
127 | | -{-# INLINE fromMutableArray #-} |
128 | | -fromMutableArray marr = stToPrim $ do |
129 | | - mvec <- MVector <$> MV.fromMutableArray marr |
130 | | - G.foldM' (\_ !_ -> return ()) () mvec |
131 | | - return mvec |
132 | | - |
133 | | --- | /O(n)/ Make a copy of a mutable vector into a new mutable array. |
| 101 | +-- fromMutableArray, toMutableArray are defined in Data.Vector.Strict.Pat |
134 | 102 | -- |
135 | | --- @since 0.13.2.0 |
136 | | -toMutableArray :: PrimMonad m => MVector (PrimState m) a -> m (MutableArray (PrimState m) a) |
137 | | -{-# INLINE toMutableArray #-} |
138 | | -toMutableArray (MVector v) = MV.toMutableArray v |
| 103 | +-- See NOTE: [Constructor deprecation] |
139 | 104 |
|
140 | 105 |
|
141 | 106 | -- Length information |
|
0 commit comments