on develop help sign in
Update documentation for SwitchHold
commit556f442f667b53355b3bcd04b7889b060b158a58 authorAli Abrar <aliabrar@gmail.com> dateSun 31 Mar 2019, 15:23 (8 years ago) parent197c40d
1 file changed+8−10
src/Reflex/Class.hs+8−10
src/Reflex/Class.hs+8−10
@@ -305,20 +305,18 @@ class ( MonadHold t (PushM t)
305305-- | Class representing things that can be switched when the provided 'Event' occurs.
306306class Reflex t => SwitchHold t a | a -> t where
307307 -- | Switches to the new value whenever it is received (via firing of an 'Event').
308− -- When the update 'Event' fires, the previous value is no longer considered (even
309− -- if it is updating at the same time).
310− --
311− -- Because the simultaneous firing case is irrelevant, this function imposes
312− -- laxer "timing requirements" on the overall circuit, avoiding many potential
313− -- cyclic dependency / metastability failures. It's also more performant. Use
314− -- this rather than 'switchHoldPromptly' and 'switchHoldPromptOnly' unless you
315− -- are absolutely sure you need to act on the new event in the coincidental
316− -- case.
317308 switchHold :: MonadHold t m => a -> Event t a -> m a
318309
310+-- | Because the simultaneous firing case is irrelevant, this function imposes
311+-- laxer "timing requirements" on the overall circuit, avoiding many potential
312+-- cyclic dependency / metastability failures. It's also more performant. Use
313+-- this rather than 'switchHoldPromptly' and 'switchHoldPromptOnly' unless you
314+-- are absolutely sure you need to act on the new event in the coincidental
315+-- case.
319316instance Reflex t => SwitchHold t (Event t a) where
320− switchHold = switchHold
317+ switchHold ea0 eea = switch <$> hold ea0 eea
321318
319+-- | Switches to the new 'Dynamic' immediately (i.e., promptly) on firing
322320instance Reflex t => SwitchHold t (Dynamic t a) where
323321 switchHold a e = join <$> holdDyn a e
324322