[Haskell-cafe] Free theorem for `forall z. (A,z) -> (B,z)`?
david.feuer at gmail.com
Tue Jul 24 19:21:08 UTC 2018
Personally, I'm old-fashioned. I don't mind having to press a button to
make it go. But my preferences are obviously not the end of the discussion.
On Tue, Jul 24, 2018, 3:15 PM Joachim Breitner <mail at joachim-breitner.de>
> Am Dienstag, den 24.07.2018, 14:47 -0400 schrieb Joachim Breitner:
> > I guess I can use
> > for this somehow. But I guess I only want to delay errors, not
> > successes – I will give it a shot
> Sure, why not:
> it seems to work. If some reflex-expert could check if this makes
> sense, that would be great:
> -- | Errors are delayed, but successes go through immediatelly
> delayError :: (PerformEvent t m, MonadHold t m, TriggerEvent t m, MonadIO
> (Performable m)) =>
> Dynamic t (Either a b) -> m (Dynamic t (Either a b))
> delayError d = do
> delayedEvents <- delay 0.5 (updated d)
> d' <- holdDyn Nothing (Just <$> delayedEvents)
> return $ do
> now <- d
> past <- d'
> return $ case (past, now) of
> (Nothing, _) -> now -- before any delayed events arrive
> (_, Right _ ) -> now -- current value is good
> (Just x, Left _) -> x -- current value is bad, delay
> Joachim Breitner
> mail at joachim-breitner.de
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe