Ticket #14: reactive-snapshot-patches.bundle

File reactive-snapshot-patches.bundle, 4.8 kB (added by lilac, 6 years ago)

Possible fix

Line 
1Tue Dec  2 21:51:33 GMT 2008  Richard Smith <richard-reactive@metafoo.co.uk>
2  * Make Data.AddBounds' Ord instance require less information.
3
4Tue Dec  2 22:00:53 GMT 2008  Richard Smith <richard-reactive@metafoo.co.uk>
5  * Need TypeCompose 0.6.3 for Data.Zip.zipWith
6
7Tue Dec  2 22:01:26 GMT 2008  Richard Smith <richard-reactive@metafoo.co.uk>
8  * Fix blocking and resulting space leak in snapshot.
9
10New patches:
11
12[Make Data.AddBounds' Ord instance require less information.
13Richard Smith <richard-reactive@metafoo.co.uk>**20081202215133] {
14hunk ./src/Data/AddBounds.hs 17
15+import Data.Unamb (unamb)
16hunk ./src/Data/AddBounds.hs 45
17+--
18+--   MaxBound `max` undefined can return full information while the default
19+--   implementation cannot. And likewise undefined `max` MaxBound.
20hunk ./src/Data/AddBounds.hs 50
21-  MinBound  <= _         = True
22-  NoBound _ <= MinBound  = False
23-  NoBound a <= NoBound b = a <= b
24-  NoBound _ <= MaxBound  = True
25-  MaxBound  <= MaxBound  = True
26-  MaxBound  <= _         = False        -- given previous
27+  a <= b = c1 a b `unamb` c2 a b
28+    where c1 MinBound     _            = True
29+          c1 _            MinBound     = False
30+          c1 (NoBound a') (NoBound b') = a' < b'
31+          c1 MaxBound     (NoBound _)  = False
32+          c1 _            _            = undefined
33+          c2 _            MaxBound     = True
34+          c2 _            _            = undefined
35hunk ./src/Data/AddBounds.hs 59
36-  MinBound  `min` _         = MinBound
37-  _         `min` MinBound  = MinBound
38-  NoBound a `min` NoBound b = NoBound (a `min` b)
39-  u         `min` MaxBound  = u
40-  MaxBound  `min` v         = v
41
42-  MinBound  `max` v         = v
43-  u         `max` MinBound  = u
44-  NoBound a `max` NoBound b = NoBound (a `max` b)
45-  _         `max` MaxBound  = MaxBound
46-  MaxBound  `max` _         = MaxBound
47+  a `min` b = c1 a b `unamb` c2 a b
48+    where c1 MinBound     _            = MinBound
49+          c1 (NoBound a') (NoBound b') = NoBound $ a' `max` b'
50+          c1 (NoBound _)  MaxBound     = a
51+          c1 MaxBound     (NoBound _)  = b
52+          c1 MaxBound     MaxBound     = MaxBound
53+          c1 _            _            = undefined
54+          c2 _            MinBound     = MinBound
55+          c2 _            _            = undefined
56+
57+  a `max` b = c1 a b `unamb` c2 a b
58+    where c1 MaxBound     _            = MaxBound
59+          c1 (NoBound a') (NoBound b') = NoBound $ a' `max` b'
60+          c1 (NoBound _)  MinBound     = a
61+          c1 MinBound     (NoBound _)  = b
62+          c1 MinBound     MinBound     = MinBound
63+          c1 _            _            = undefined
64+          c2 _            MaxBound     = MaxBound
65+          c2 _            _            = undefined
66}
67
68[Need TypeCompose 0.6.3 for Data.Zip.zipWith
69Richard Smith <richard-reactive@metafoo.co.uk>**20081202220053] hunk ./reactive.cabal 35
70-                         TypeCompose>=0.6.0, vector-space>=0.5,
71+                         TypeCompose>=0.6.3, vector-space>=0.5,
72
73[Fix blocking and resulting space leak in snapshot.
74Richard Smith <richard-reactive@metafoo.co.uk>**20081202220126] {
75hunk ./src/FRP/Reactive/PrimReactive.hs 438
76--- This variant of 'snapshot' has 'Nothing's where @b@ changed and @a@
77--- didn't.
78-snap :: forall a b t. Ord t =>
79-        EventG t a -> ReactiveG t b -> EventG t (Maybe a, b)
80-Event (Future (Max MaxBound, _)) `snap` _ = mempty
81-ea `snap` (b0 `Stepper` eb) =
82-  (Nothing, b0) `accumE` (fmap fa ea `mappend` fmap fb eb)
83- where
84-   fa :: a -> Unop (Maybe a, b)
85-   fb :: b -> Unop (Maybe a, b)
86-   fa a (_,b) = (Just a , b)
87-   fb b _     = (Nothing, b)
88-
89hunk ./src/FRP/Reactive/PrimReactive.hs 442
90-snapshotWith f e r = joinMaybes $ fmap h (e `snap` r)
91+snapshotWith f (Event (Future (t, ~(v `Stepper` es)))) r =
92+  (Event (Future (t `max` t', f v w `Stepper` es')))
93hunk ./src/FRP/Reactive/PrimReactive.hs 445
94-   h (Nothing,_) = Nothing
95-   h (Just a ,b) = Just (f a b)
96+   (t', r'@(w `Stepper` _)) = skipToR t r
97+   es' = snapshotWith f es r'
98+
99+-- | Find the last event before a given time.
100+skipToR :: Ord t => Time t -> ReactiveG t b -> (Time t, ReactiveG t b)
101+skipToR t r@(_ `Stepper` Event (Future (t', r')))
102+  | t' <= t   = let (t'', r'') = skipToR t r' in (t' `max` t'', r'')
103+  | otherwise = (t, r)
104+
105}
106
107Context:
108
109[Fun Zip; Richard Smith's (lilac's) snap mempty fix
110Conal Elliott <conal@conal.net>**20081130204649]
111[TAG 0.9.6
112Conal Elliott <conal@conal.net>**20081128183303]
113[releasing version 0.9.6
114Conal Elliott <conal@conal.net>**20081128183241
115 Fixes some doc bugs blocking haddock
116]
117[TAG 0.9.5
118Conal Elliott <conal@conal.net>**20081128053142]
119[0.9.5
120Conal Elliott <conal@conal.net>**20081128053126]
121[generalized behavior ops; completed Num-inc
122Conal Elliott <conal@conal.net>**20081128053112]
123[TAG 0.9.4
124Conal Elliott <conal@conal.net>**20081127232536]
125Patch bundle hash:
126bcde129b3ab4981d2912b24e0f204a9bc0832659