[Haskell-cafe] Free theorem for `forall z. (A,z) -> (B,z)`?

David Feuer 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>
wrote:

> Hi,
>
> Am Dienstag, den 24.07.2018, 14:47 -0400 schrieb Joachim Breitner:
> > I guess I can use
> >
> https://hackage.haskell.org/package/reflex-dom-0.3/candidate/docs/Reflex-Dom-Time.html
> > for this somehow. But I guess I only want to delay errors, not
> > successes – I will give it a shot
>
> Sure, why not:
> https://github.com/nomeata/free-theorems-static-webui/commit/20c9aca
>
> 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
>
> Cheers,
> Joachim
>
> --
> Joachim Breitner
>   mail at joachim-breitner.de
>   http://www.joachim-breitner.de/
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180724/17f8f257/attachment.html>


More information about the Haskell-Cafe mailing list