[Haskell-cafe] FRP: Why is Behavior not a Monad?
ollie at ocharles.org.uk
Sat Jan 20 15:48:19 UTC 2018
Monad Behaviour in the context of reactive-banana
On 20 Jan 2018 3:19 pm, "Alexey Vagarenko" <vagarenko at gmail.com> wrote:
> Both `reflex` and `frpnow` provide Monad instance for behavior.
> AFAIK only `reactive-banana` and arrowized FRP libraries don't have it.
>  https://github.com/reflex-frp/reflex/blob/develop/src/
>  https://hackage.haskell.org/package/frpnow-0.18/docs/
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
> 2018-01-20 19:00 GMT+05:00 martin <martin.drautzburg at web.de>:
>> Hello all,
>> it appears to be difficult to define a Monad instance for Behavior and in
>> many (if not all) reactive libraries Behavior
>> is not a Monad. Why is that so?
>> If a Beahvior is conceptionally a function from Time to something,
>> newtype Behavior a = Behavior (Time -> a)
>> then its Monad instance should work like a Reader Monad.
>> Alternatively one can look at the join function
>> join :: Behavior (Behavior a) -> Behavior a.
>> This corresponds to the situation where you switch between Channels on a
>> TV remote controle and each Channel is a
>> behavior of Image. Then
>> join Behavior (Behavior image)
>> should give you the video stream you see on the screen. How can one
>> possibly live without this operation?
>> I assume this has something to do with the actual implementation and not
>> so much with the semantics, because
>> semantically I don't see any problems.
>> - why is Behavior not a Monad and
>> - how would you express the TV-remote example without a Monad?
>> 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.
> 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