on develop help sign in
fix naming and 1 warning
2e2e19dJames Deikun
src/Reflex/Time.hs+26−26
@@ -271,26 +271,26 @@ throttle t e = do
271 return outE
271 return outE
272
272
273data ThrottleState b
273data ThrottleState b
274− = Immediate
274+ = ThrottleState_Immediate
275− | Buffered (ThrottleBuffer b)
275+ | ThrottleState_Buffered (ThrottleBuffer b)
276 deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Generic, Data, Typeable)
276 deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Generic, Data, Typeable)
277
277
278data ThrottleBuffer b
278data ThrottleBuffer b
279− = BEmpty -- Empty conflicts with lens, and hiding it would require turning
279+ = ThrottleBuffer_Empty -- Empty conflicts with lens, and hiding it would require turning
280 -- on PatternSynonyms
280 -- on PatternSynonyms
281− | Full b
281+ | ThrottleBuffer_Full b
282 deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Generic, Data, Typeable)
282 deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Generic, Data, Typeable)
283
283
284instance Semigroup b => Semigroup (ThrottleBuffer b) where
284instance Semigroup b => Semigroup (ThrottleBuffer b) where
285 x <> y = case x of
285 x <> y = case x of
286− BEmpty -> y
286+ ThrottleBuffer_Empty -> y
287− Full b1 -> case y of
287+ ThrottleBuffer_Full b1 -> case y of
288− BEmpty -> x
288+ ThrottleBuffer_Empty -> x
289− Full b2 -> Full $ b1 <> b2
289+ ThrottleBuffer_Full b2 -> ThrottleBuffer_Full $ b1 <> b2
290 {-# INLINE (<>) #-}
290 {-# INLINE (<>) #-}
291
291
292instance Semigroup b => Monoid (ThrottleBuffer b) where
292instance Semigroup b => Monoid (ThrottleBuffer b) where
293− mempty = BEmpty
293+ mempty = ThrottleBuffer_Empty
294 {-# INLINE mempty #-}
294 {-# INLINE mempty #-}
295 mappend = (<>)
295 mappend = (<>)
296 {-# INLINE mappend #-}
296 {-# INLINE mappend #-}
@@ -300,7 +300,7 @@ instance Semigroup b => Monoid (ThrottleBuffer b) where
300-- If the output event has not occurred recently, occurrences of the input event will cause the output event to fire immediately.
300-- If the output event has not occurred recently, occurrences of the input event will cause the output event to fire immediately.
301-- The first parameter is a function that receives access to the output event, and should construct an event that fires when the receiver is
301-- The first parameter is a function that receives access to the output event, and should construct an event that fires when the receiver is
302-- ready for more input. For example, using @delay 20@ would give a simple time-based throttle.
302-- ready for more input. For example, using @delay 20@ would give a simple time-based throttle.
303−throttleBatchWithLag :: (MonadFix m, MonadHold t m, PerformEvent t m, TriggerEvent t m, MonadIO (Performable m), Semigroup a) => (Event t () -> m (Event t ())) -> Event t a -> m (Event t a)
303+throttleBatchWithLag :: (MonadFix m, MonadHold t m, PerformEvent t m, Semigroup a) => (Event t () -> m (Event t ())) -> Event t a -> m (Event t a)
304-- Invariants:
304-- Invariants:
305-- * Immediate mode must turn off whenever output is produced.
305-- * Immediate mode must turn off whenever output is produced.
306-- * Output must be produced whenever immediate mode turns from on to off.
306-- * Output must be produced whenever immediate mode turns from on to off.
@@ -313,43 +313,43 @@ throttleBatchWithLag lag e = do
313 let f state x = case x of -- (Just $ newState, out)
313 let f state x = case x of -- (Just $ newState, out)
314 This a -> -- If only the input event fires
314 This a -> -- If only the input event fires
315 case state of
315 case state of
316− Immediate -> -- and we're in immediate mode
316+ ThrottleState_Immediate -> -- and we're in immediate mode
317 -- Immediate mode turns off, and the buffer is empty.
317 -- Immediate mode turns off, and the buffer is empty.
318 -- We fire the output event with the input event value immediately.
318 -- We fire the output event with the input event value immediately.
319− (Just $ Buffered $ BEmpty, Just a)
319+ (Just $ ThrottleState_Buffered $ ThrottleBuffer_Empty, Just a)
320− Buffered b -> -- and we're not in immediate mode
320+ ThrottleState_Buffered b -> -- and we're not in immediate mode
321 -- Immediate mode remains off, and we accumulate the input value.
321 -- Immediate mode remains off, and we accumulate the input value.
322 -- We don't fire the output event.
322 -- We don't fire the output event.
323− (Just $ Buffered $ b <> Full a, Nothing)
323+ (Just $ ThrottleState_Buffered $ b <> ThrottleBuffer_Full a, Nothing)
324 That _ -> -- If only the delayed output event fires,
324 That _ -> -- If only the delayed output event fires,
325 case state of
325 case state of
326− Immediate -> -- and we're in immediate mode
326+ ThrottleState_Immediate -> -- and we're in immediate mode
327 -- Nothing happens.
327 -- Nothing happens.
328 (Nothing, Nothing)
328 (Nothing, Nothing)
329− Buffered BEmpty -> -- and the buffer is empty:
329+ ThrottleState_Buffered ThrottleBuffer_Empty -> -- and the buffer is empty:
330 -- Immediate mode turns back on, and the buffer remains empty.
330 -- Immediate mode turns back on, and the buffer remains empty.
331 -- We don't fire.
331 -- We don't fire.
332− (Just Immediate, Nothing)
332+ (Just ThrottleState_Immediate, Nothing)
333− Buffered (Full b) -> -- and the buffer is full:
333+ ThrottleState_Buffered (ThrottleBuffer_Full b) -> -- and the buffer is full:
334 -- Immediate mode remains off, and the buffer is cleared.
334 -- Immediate mode remains off, and the buffer is cleared.
335 -- We fire with the buffered value.
335 -- We fire with the buffered value.
336− (Just $ Buffered BEmpty, Just b)
336+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just b)
337 These a _ -> -- If both the input and delayed output event fire simultaneously:
337 These a _ -> -- If both the input and delayed output event fire simultaneously:
338 case state of
338 case state of
339− Immediate -> -- and we're in immediate mode
339+ ThrottleState_Immediate -> -- and we're in immediate mode
340 -- Immediate mode turns off, and the buffer is empty.
340 -- Immediate mode turns off, and the buffer is empty.
341 -- We fire with the input event's value, as it is the most recent we have seen at this moment.
341 -- We fire with the input event's value, as it is the most recent we have seen at this moment.
342− (Just $ Buffered BEmpty, Just a)
342+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just a)
343− Buffered BEmpty -> -- and the buffer is empty:
343+ ThrottleState_Buffered ThrottleBuffer_Empty -> -- and the buffer is empty:
344 -- Immediate mode stays off, and the buffer remains empty.
344 -- Immediate mode stays off, and the buffer remains empty.
345 -- We fire with the input event's value.
345 -- We fire with the input event's value.
346− (Just $ Buffered BEmpty, Just a)
346+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just a)
347− Buffered (Full b) -> -- and the buffer is full:
347+ ThrottleState_Buffered (ThrottleBuffer_Full b) -> -- and the buffer is full:
348 -- Immediate mode remains off, and the buffer is cleared.
348 -- Immediate mode remains off, and the buffer is cleared.
349 -- We fire with everything including the buffered value.
349 -- We fire with everything including the buffered value.
350− (Just $ Buffered BEmpty, Just (b <> a))
350+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just (b <> a))
351 rec (_stateDyn, outE) <- mapAccumMaybeDyn f
351 rec (_stateDyn, outE) <- mapAccumMaybeDyn f
352− Immediate -- We start in immediate mode with an empty buffer.
352+ ThrottleState_Immediate -- We start in immediate mode with an empty buffer.
353 (align e delayed)
353 (align e delayed)
354 delayed <- lag (void outE)
354 delayed <- lag (void outE)
355 return outE
355 return outE