on develop help sign in
fix naming and 1 warning
commit2e2e19d37a5f1151fe985190b479016640751578 authorJames Deikun <james.deikun@obsidian.systems> dateTue 2 Oct 2018, 16:38 (8 years ago) parent537c268
1 file changed+26−26
src/Reflex/Time.hs+26−26
src/Reflex/Time.hs+26−26
@@ -271,26 +271,26 @@ throttle t e = do
271271 return outE
272272
273273data ThrottleState b
274− = Immediate
275− | Buffered (ThrottleBuffer b)
274+ = ThrottleState_Immediate
275+ | ThrottleState_Buffered (ThrottleBuffer b)
276276 deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Generic, Data, Typeable)
277277
278278data 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
280280 -- on PatternSynonyms
281− | Full b
281+ | ThrottleBuffer_Full b
282282 deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Generic, Data, Typeable)
283283
284284instance Semigroup b => Semigroup (ThrottleBuffer b) where
285285 x <> y = case x of
286− BEmpty -> y
287− Full b1 -> case y of
288− BEmpty -> x
289− Full b2 -> Full $ b1 <> b2
286+ ThrottleBuffer_Empty -> y
287+ ThrottleBuffer_Full b1 -> case y of
288+ ThrottleBuffer_Empty -> x
289+ ThrottleBuffer_Full b2 -> ThrottleBuffer_Full $ b1 <> b2
290290 {-# INLINE (<>) #-}
291291
292292instance Semigroup b => Monoid (ThrottleBuffer b) where
293− mempty = BEmpty
293+ mempty = ThrottleBuffer_Empty
294294 {-# INLINE mempty #-}
295295 mappend = (<>)
296296 {-# INLINE mappend #-}
@@ -300,7 +300,7 @@ instance Semigroup b => Monoid (ThrottleBuffer b) where
300300-- If the output event has not occurred recently, occurrences of the input event will cause the output event to fire immediately.
301301-- The first parameter is a function that receives access to the output event, and should construct an event that fires when the receiver is
302302-- 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)
304304-- Invariants:
305305-- * Immediate mode must turn off whenever output is produced.
306306-- * Output must be produced whenever immediate mode turns from on to off.
@@ -313,43 +313,43 @@ throttleBatchWithLag lag e = do
313313 let f state x = case x of -- (Just $ newState, out)
314314 This a -> -- If only the input event fires
315315 case state of
316− Immediate -> -- and we're in immediate mode
316+ ThrottleState_Immediate -> -- and we're in immediate mode
317317 -- Immediate mode turns off, and the buffer is empty.
318318 -- We fire the output event with the input event value immediately.
319− (Just $ Buffered $ BEmpty, Just a)
320− Buffered b -> -- and we're not in immediate mode
319+ (Just $ ThrottleState_Buffered $ ThrottleBuffer_Empty, Just a)
320+ ThrottleState_Buffered b -> -- and we're not in immediate mode
321321 -- Immediate mode remains off, and we accumulate the input value.
322322 -- We don't fire the output event.
323− (Just $ Buffered $ b <> Full a, Nothing)
323+ (Just $ ThrottleState_Buffered $ b <> ThrottleBuffer_Full a, Nothing)
324324 That _ -> -- If only the delayed output event fires,
325325 case state of
326− Immediate -> -- and we're in immediate mode
326+ ThrottleState_Immediate -> -- and we're in immediate mode
327327 -- Nothing happens.
328328 (Nothing, Nothing)
329− Buffered BEmpty -> -- and the buffer is empty:
329+ ThrottleState_Buffered ThrottleBuffer_Empty -> -- and the buffer is empty:
330330 -- Immediate mode turns back on, and the buffer remains empty.
331331 -- We don't fire.
332− (Just Immediate, Nothing)
333− Buffered (Full b) -> -- and the buffer is full:
332+ (Just ThrottleState_Immediate, Nothing)
333+ ThrottleState_Buffered (ThrottleBuffer_Full b) -> -- and the buffer is full:
334334 -- Immediate mode remains off, and the buffer is cleared.
335335 -- We fire with the buffered value.
336− (Just $ Buffered BEmpty, Just b)
336+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just b)
337337 These a _ -> -- If both the input and delayed output event fire simultaneously:
338338 case state of
339− Immediate -> -- and we're in immediate mode
339+ ThrottleState_Immediate -> -- and we're in immediate mode
340340 -- Immediate mode turns off, and the buffer is empty.
341341 -- 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)
343− Buffered BEmpty -> -- and the buffer is empty:
342+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just a)
343+ ThrottleState_Buffered ThrottleBuffer_Empty -> -- and the buffer is empty:
344344 -- Immediate mode stays off, and the buffer remains empty.
345345 -- We fire with the input event's value.
346− (Just $ Buffered BEmpty, Just a)
347− Buffered (Full b) -> -- and the buffer is full:
346+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just a)
347+ ThrottleState_Buffered (ThrottleBuffer_Full b) -> -- and the buffer is full:
348348 -- Immediate mode remains off, and the buffer is cleared.
349349 -- We fire with everything including the buffered value.
350− (Just $ Buffered BEmpty, Just (b <> a))
350+ (Just $ ThrottleState_Buffered ThrottleBuffer_Empty, Just (b <> a))
351351 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.
353353 (align e delayed)
354354 delayed <- lag (void outE)
355355 return outE