Ticket #54: nfdata.dpatch

File nfdata.dpatch, 6.3 kB (added by basvandijk, 17 months ago)
Line 
11 patch for repository http://code.haskell.org/vector:
2
3Sat Jan  7 17:09:49 CET 2012  Bas van Dijk <v.dijk.bas@gmail.com>
4  * Added NFData instances for all vectors
5
6New patches:
7
8[Added NFData instances for all vectors
9Bas van Dijk <v.dijk.bas@gmail.com>**20120107160949
10 Ignore-this: 7def955f95e5af88790e772a0373c0c6
11] {
12hunk ./Data/Vector.hs 1
13-{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies, Rank2Types #-}
14+{-# LANGUAGE FlexibleInstances
15+           , MultiParamTypeClasses
16+           , TypeFamilies
17+           , Rank2Types
18+           , BangPatterns
19+  #-}
20 
21 -- |
22 -- Module      : Data.Vector
23hunk ./Data/Vector.hs 164
24 import           Data.Primitive.Array
25 import qualified Data.Vector.Fusion.Stream as Stream
26 
27+import Control.DeepSeq ( NFData, rnf )
28 import Control.Monad ( MonadPlus(..), liftM, ap )
29 import Control.Monad.ST ( ST )
30 import Control.Monad.Primitive
31hunk ./Data/Vector.hs 200
32                        {-# UNPACK #-} !(Array a)
33         deriving ( Typeable )
34 
35+instance NFData a => NFData (Vector a) where
36+    rnf (Vector i n arr) = force i
37+        where
38+          force !ix | ix < n    = rnf (indexArray arr ix) `seq` force (ix+1)
39+                    | otherwise = ()
40+
41 instance Show a => Show (Vector a) where
42   showsPrec = G.showsPrec
43 
44hunk ./Data/Vector/Mutable.hs 57
45 import           Data.Primitive.Array
46 import           Control.Monad.Primitive
47 
48+import Control.DeepSeq ( NFData, rnf )
49+
50 import Prelude hiding ( length, null, replicate, reverse, map, read,
51                         take, drop, splitAt, init, tail )
52 
53hunk ./Data/Vector/Mutable.hs 75
54 type IOVector = MVector RealWorld
55 type STVector s = MVector s
56 
57+instance NFData a => NFData (MVector s a) where
58+    rnf (MVector i n arr) = unsafeInlineST $ force i
59+        where
60+          force !ix | ix < n    = do x <- readArray arr ix
61+                                     rnf x `seq` force (ix+1)
62+                    | otherwise = return ()
63+
64 instance G.MVector MVector a where
65   {-# INLINE basicLength #-}
66   basicLength (MVector _ n _) = n
67hunk ./Data/Vector/Primitive.hs 143
68 import           Data.Primitive.ByteArray
69 import           Data.Primitive ( Prim, sizeOf )
70 
71+import Control.DeepSeq ( NFData )
72+
73 import Control.Monad ( liftM )
74 import Control.Monad.ST ( ST )
75 import Control.Monad.Primitive
76hunk ./Data/Vector/Primitive.hs 177
77                        {-# UNPACK #-} !ByteArray
78   deriving ( Typeable )
79 
80+instance NFData (Vector a)
81+
82 instance (Show a, Prim a) => Show (Vector a) where
83   showsPrec = G.showsPrec
84 
85hunk ./Data/Vector/Primitive/Mutable.hs 58
86 import           Control.Monad.Primitive
87 import           Control.Monad ( liftM )
88 
89+import Control.DeepSeq ( NFData )
90+
91 import Prelude hiding ( length, null, replicate, reverse, map, read,
92                         take, drop, splitAt, init, tail )
93 
94hunk ./Data/Vector/Primitive/Mutable.hs 76
95 type IOVector = MVector RealWorld
96 type STVector s = MVector s
97 
98+instance NFData (MVector s a)
99+
100 instance Prim a => G.MVector MVector a where
101   basicLength (MVector _ n _) = n
102   basicUnsafeSlice j m (MVector i n arr)
103hunk ./Data/Vector/Storable.hs 149
104 import Foreign.Ptr
105 import Foreign.Marshal.Array ( advancePtr, copyArray )
106 
107+import Control.DeepSeq ( NFData )
108+
109 import Control.Monad.ST ( ST )
110 import Control.Monad.Primitive
111 
112hunk ./Data/Vector/Storable.hs 183
113                        {-# UNPACK #-} !(ForeignPtr a)
114         deriving ( Typeable )
115 
116+instance NFData (Vector a)
117+
118 instance (Show a, Storable a) => Show (Vector a) where
119   showsPrec = G.showsPrec
120 
121hunk ./Data/Vector/Storable/Mutable.hs 60
122   unsafeWith
123 ) where
124 
125+import Control.DeepSeq ( NFData )
126+
127 import qualified Data.Vector.Generic.Mutable as G
128 import Data.Vector.Storable.Internal
129 
130hunk ./Data/Vector/Storable/Mutable.hs 93
131 type IOVector = MVector RealWorld
132 type STVector s = MVector s
133 
134+instance NFData (MVector s a)
135+
136 instance Storable a => G.MVector MVector a where
137   {-# INLINE basicLength #-}
138   basicLength (MVector n _) = n
139hunk ./Data/Vector/Unboxed/Base.hs 25
140 
141 import qualified Data.Vector.Primitive as P
142 
143+import Control.DeepSeq ( NFData )
144+
145 import Control.Monad.Primitive
146 import Control.Monad ( liftM )
147 
148hunk ./Data/Vector/Unboxed/Base.hs 55
149 
150 class (G.Vector Vector a, M.MVector MVector a) => Unbox a
151 
152+instance NFData (Vector a)
153+instance NFData (MVector s a)
154+
155 -- -----------------
156 -- Data and Typeable
157 -- -----------------
158hunk ./vector.cabal 174
159   Install-Includes:
160         vector.h
161 
162-  Build-Depends: base >= 4 && < 5, primitive >= 0.4.0.1 && < 0.5, ghc-prim
163+  Build-Depends: base >= 4 && < 5
164+               , primitive >= 0.4.0.1 && < 0.5
165+               , ghc-prim
166+               , deepseq >= 1.1 && < 1.4
167 
168   if impl(ghc<6.13)
169     Ghc-Options: -finline-if-enough-args -fno-method-sharing
170}
171
172Context:
173
174[Allow streams to produce entire vectors as well as individual elements
175Roman Leshchinskiy <rl@cse.unsw.edu.au>**20120107110600
176 Ignore-this: 727e51c5d236ecb0d1021c5b740b983
177 
178 This is a signficant extension to the stream fusion mechanism. A Stream is now
179 parametrised with a vector type and offers two iteration modes: individual
180 elements and individual elements + vectors. This supports significantly more
181 efficient implementations of block operations. For instance, (++) will now use
182 memcpy where possible rather than iterating through the elements in a loop.
183 
184 Comments are sorely lacking at the moment.
185]
186[Change version number again
187Roman Leshchinskiy <rl@cse.unsw.edu.au>**20120107104052
188 Ignore-this: d52e18bc0bbf221385cc59cfccdabfba
189]
190[Use SPEC in stream comparisons
191Roman Leshchinskiy <rl@cse.unsw.edu.au>**20120107103044
192 Ignore-this: 59ff46e5b834400450af94e425d025ab
193]
194[Export SPEC
195Roman Leshchinskiy <rl@cse.unsw.edu.au>**20120107103031
196 Ignore-this: 7e2a7f45ba99ad62eea28de474bbdd83
197]
198[Bump version
199Roman Leshchinskiy <rl@cse.unsw.edu.au>**20120107102613
200 Ignore-this: d4ff3ccc4c17210317f430fcd4cd4fb7
201]
202[Strictness fix
203Roman Leshchinskiy <rl@cse.unsw.edu.au>**20120107102518
204 Ignore-this: 904948491a2e1a5a21cbabda0ada5706
205]
206[Documentation
207Roman Leshchinskiy <rl@cse.unsw.edu.au>**20111231134323
208 Ignore-this: 6f836ae502f1b072a851a3bc9fccc625
209]
210[Bump version
211Roman Leshchinskiy <rl@cse.unsw.edu.au>**20111231134314
212 Ignore-this: dac62c46a54308d64912d15865f25bbd
213]
214[TAG 0.9.1
215Roman Leshchinskiy <rl@cse.unsw.edu.au>**20111231003141
216 Ignore-this: ee19d3940a3827eefe4cb13b99a863bf
217]
218Patch bundle hash:
219778368550298d4ccca504b0b20aff148a5854f16