on develop help sign in
Tweak rules a bit
commitf69a1c8122b4ce7a4f6188c383d11029340a94c4 authorRyan Trinkle <ryan.trinkle@gmail.com> dateMon 31 Oct 2016, 00:47 (10 years ago) parent45d06f6
1 file changed+8−5
src/Reflex/Spider/Internal.hs+8−5
src/Reflex/Spider/Internal.hs+8−5
@@ -194,8 +194,11 @@ newtype Event x a = Event { unEvent :: Subscriber x a -> EventM x (EventSubscrip
194194subscribeAndRead :: Event x a -> Subscriber x a -> EventM x (EventSubscription x, Maybe a)
195195subscribeAndRead = unEvent
196196
197−{-# RULES "pushCheap/cacheEvent" forall f e. pushCheap f (cacheEvent e) = pushCheap f e #-}
198−{-# RULES "hold/cacheEvent" forall f e. hold f (cacheEvent e) = hold f e #-}
197+{-# RULES
198+"cacheEvent/cacheEvent" forall e. cacheEvent (cacheEvent e) = cacheEvent e
199+"cacheEvent/pushCheap" forall f e. pushCheap f (cacheEvent e) = cacheEvent (pushCheap f e)
200+"hold/cacheEvent" forall f e. hold f (cacheEvent e) = hold f e
201+ #-}
199202{- RULES
200203 "subscribeAndRead/cacheEvent" forall e. subscribeAndRead (cacheEvent e) = subscribeAndRead e
201204 #-}
@@ -203,8 +206,8 @@ subscribeAndRead = unEvent
203206-- | Construct an 'Event' equivalent to that constructed by 'push', but with no
204207-- caching; if the computation function is very cheap, this is (much) more
205208-- efficient than 'push'
206−{- INLINABLE pushCheap #-}
207−{-# INLINE [1] pushCheap #-}
209+{- INLINE [1] pushCheap #-}
210+{-# NOINLINE pushCheap #-}
208211pushCheap :: HasSpiderTimeline x => (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
209212pushCheap f e = Event $ \sub -> do
210213 (subscription, occ) <- subscribeAndRead e $ sub
@@ -229,7 +232,7 @@ data CacheSubscribed x a
229232--TODO: Try a caching strategy where we subscribe directly to the parent when
230233--there's only one subscriber, and then build our own WeakBag only when a second
231234--subscriber joins
232−{-# NOINLINE [1] cacheEvent #-}
235+{-# NOINLINE cacheEvent #-}
233236cacheEvent :: HasSpiderTimeline x => Event x a -> Event x a
234237cacheEvent e = Event $ \sub -> {-# SCC "cacheEvent" #-} do
235238 let !mSubscribedRef = unsafeNewIORef e Nothing