reactive-banana

Why should we use Behavior in FRP

徘徊边缘 提交于 2019-12-03 11:53:32
I am learning reactive-banana. In order to understand the library I have decide to implement a dummy application that would increase a counter whenever someone pushes a button. The UI library I am using is Gtk but that is not relevant for the explanation. Here is the very simple implementation that I have come up with: import Graphics.UI.Gtk import Reactive.Banana import Reactive.Banana.Frameworks makeNetworkDescription addEvent = do eClick <- fromAddHandler addEvent reactimate $ (putStrLn . show) <$> (accumE 0 ((+1) <$ eClick)) main :: IO () main = do (addHandler, fireEvent) <- newAddHandler

reactive-banana time delays

偶尔善良 提交于 2019-12-03 07:00:00
I have scoured the documentation of reactive-banana , and I can't find a way to specify explicit time delays. Say, for example, I would like to take an Event t a and shift all of its occurrences 1 second into the future; or get an event that fires 1 second from now (within Moment t ); or anything like that. Are explicit delays representable in reactive-banana? If not, how do users implement, e.g., echoing input delayed by a second? As Ben indicates, this is correct: reactive-banana is no built-in notion of time and delays. The main reason is that it is hard to guarantee that logical time and

Am I using reactive-banana right?

陌路散爱 提交于 2019-12-03 05:04:36
问题 Here's an example Haskell FRP program using the reactive-banana library. I'm only just starting to feel my way with Haskell, and especially haven't quite got my head around what FRP means. I'd really appreciate some critique of the code below {-# LANGUAGE DeriveDataTypeable #-} module Main where {- Example FRP/zeromq app. The idea is that messages come into a zeromq socket in the form "id state". The state is of each id is tracked until it's complete. -} import Control.Monad import Data

Does push-pull FRP help when implementing games?

女生的网名这么多〃 提交于 2019-12-02 18:57:56
I've been comparing pull-only FRP (ie netwire) with push-pull FRP (ie reactive-bannana) in the implementation of games. Are there advantages to one over the other? Things I've notices are: Push events make it easy to have events for mouse clicks / key presses from GLFW or GLUT Arrowized FRP that netwire uses has much less IO floating around, which is always better. It looks like having pull-only responses to things like mouse movement could cause time leaks. What else have I missed? Edit, to make this less opinion-based: The main goal is to have something that is as expressive/concise as

Doing some basic calculus using Reactive Banana

佐手、 提交于 2019-12-01 16:31:35
问题 Setup : I am using Reactive Banana along with OpenGL and I have a gear that I want to spin. I have the following signals: bTime :: Behavior t Int -- the time in ms from start of rendering bAngularVelosity :: Behavior t Double -- the angular velocity -- which can be increase or -- decreased by the user eDisplay :: Event t () -- need to redraw the screen eKey :: Event t KeyState -- user input Ultimately, I need to calculate bAngle which is then past to the drawing function: reactimate $ (draw

“Behavior now” in FRP

徘徊边缘 提交于 2019-12-01 03:36:44
In a previous SO question ( Is it possible?: Behavior t [Behavior t a] -> Behavior t [a] ) we were analyzing the existence of a Behavior join (to use reactive-banana terms). Behavior t (Behavior t a) -> Behavior t a Implemented in the semantic model as follows type Behavior t a = t -> a behaviorNow :: Behavior t (Behavior t a) -> Behavior t a behaviorNow f t = f t t While implementing this directly would be unfortunate since we could produce a Behavior Monad using const and behaviorNow , if and how does behaviorNow violate the semantics of FRP? I'd love to hear answers using the terminology of

Is there a reactive-banana-gtk?

假装没事ソ 提交于 2019-12-01 03:08:06
I found the reactive-banana-wx and wonder if there is also a similiar package for gtk as reactive banana should support gtk according to http://www.haskell.org/haskellwiki/Reactive-banana The reactive-banana library can be used on top of any imperative event-based library via the AddHandler type. However, it is often convenient to write a little glue code that is specific to the library you want to build on. This is what reactive-banana-wx does for the wx library. I have trouble installing GTK on my Mac, that's why I haven't written a similar glue code package for the gtk library. However,

Dealing with the current time in reactive-banana

邮差的信 提交于 2019-12-01 02:38:44
问题 How do you deal with the current time in reactive-banana? Ideally I'd like to have a Behaviour which I can "poll" to get the current time. However, polling Behaviour s with Event s (via <@ etc.) gives me the value of the Behaviour from the previous Event , not the current value. (I realise this is to avoid cyclic definitions which is indeed useful.) I found fromPoll which I thought would help. Behaviour s that are observed from fromPoll cannot depend on themselves, thus no cycles can be

Is there a reactive-banana-gtk?

只愿长相守 提交于 2019-11-30 23:05:26
问题 I found the reactive-banana-wx and wonder if there is also a similiar package for gtk as reactive banana should support gtk according to http://www.haskell.org/haskellwiki/Reactive-banana 回答1: The reactive-banana library can be used on top of any imperative event-based library via the AddHandler type. However, it is often convenient to write a little glue code that is specific to the library you want to build on. This is what reactive-banana-wx does for the wx library. I have trouble

Which FRP package to choose? [closed]

谁说我不能喝 提交于 2019-11-30 14:29:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm just starting to look into the world of Functional Reactive Programming in Haskell, and I would like to experiment with GUI programming (with gtk, because of substantial binding) in a reactional setting. Now, I've been looking a bit at Grapefruit, Reactive-Banana and Buster, and I would like any testament to