Questions tagged [reactive-banana]

reactive banana is a Haskell library for functional reactive programming

Reactive Banana:

Functional reactive programming offers an elegant and concise way to express interactive programs such as graphical user interfaces, animations, computer music or robot controllers. It promises to avoid the spaghetti code that is all too common in traditional approaches to GUI programming.

The goal of the library is to provide a solid foundation.

115 questions
7
votes
1 answer

Why are there no functions for building Events out of non-events in reactive-banana?

I'm in the process of teaching myself FRP and Reactive-banana while writing what I hope will be a more useful tutorial for those that follow me. You can check out my progress on the tutorial here. I'm stuck at trying to implement the simple beepy…
Echo Nolan
  • 1,111
  • 1
  • 11
  • 23
6
votes
2 answers

How do you remove repeating events in reactive-banana

In reactive-banana I've got an event stream that produces a series of numbers, some of which repeat several times in a row (I'm not concerned with all duplicates, just sequential duplicates). How can I modify that event stream to contain only…
Orclev
  • 695
  • 1
  • 6
  • 16
6
votes
2 answers

UI input with reactive-banana-wx

How do you get the content of ui elements when using reactive-banana? The event0 returns an event of type Event (), which has unit type instead of the type of the control. event1 takes an event of type Event w (a -> IO ()), but command is of type…
Masse
  • 4,334
  • 3
  • 30
  • 41
6
votes
0 answers

In what way is the execution order of reactiva-banana's execute not guaranteed?

The documentation for the execute function in Reactive.Banana.Frameworks says that "there is no guarantee about the order in which the actions are executed." I'm not sure which ordering is meant here. As the event only fires one action at once,…
Kritzefitz
  • 2,644
  • 1
  • 20
  • 35
6
votes
1 answer

Looking for `flatten :: Event [a] -> Event a` in Reactive Banana

I'm looking for something like flatten :: Event [a] -> Event a (swap [] with Foldable f => f if you want) which would generate a separate event for each a in an Event's list, like split in an old version of sodium. I suspect that this is somehow…
Sebastian Graf
  • 3,602
  • 3
  • 27
  • 38
6
votes
1 answer

Reactive Banana 1.0.0 - Why is this old code breaking?

Here's code that used to work (truncated appropriately I hope) makeNetworkDescription :: forall t . Frameworks t => Parameters -> Moment t () makeNetworkDescription params = do eInput <- fromAddHandler (input params) eTick <- fromAddHandler…
user1198582
6
votes
1 answer

Create an event stream of polymorphic functions - possible? If yes, how?

I am currently learning FRP with reactive-banana and wanted to create a stream of random functions. I've come up with this: -- | take number generator, and some pulse event stream, generate random function stream mkRandom :: (Random a,RandomGen g)…
apirogov
  • 1,296
  • 1
  • 12
  • 22
6
votes
2 answers

Reactive Banana: consume parametrized call to an external API

Starting from a previous question here: Reactive Banana: how to use values from a remote API and merge them in the event stream I have a bit different problem now: How can I use the Behaviour output as input for an IO operation and finally display…
Randomize
  • 8,651
  • 18
  • 78
  • 133
6
votes
2 answers

In reactive-banana, is it safe to trigger handler actions from multiple threads?

Is it safe to trigger the fire action in (addHandler, fire) <- newAddHandler from a different thread from which the reactive-banana graph was compiled?
miguel.negrao
  • 949
  • 5
  • 13
6
votes
1 answer

Performing a single switch in reactive-banana

I'm building a multi-modal editor using reactive-banana - and for the most part it's going perfect. To expand on my scenario, the editor is some mapping software, or you could think of it as a very simple vector graphics editor. It currently has two…
ocharles
  • 6,172
  • 2
  • 35
  • 46
6
votes
1 answer

Behavior that is both recursive, and depends on other behaviors

My network looks like this: ePhysics :: Event t () bPlayerForce :: Behavior t (Double,Double) bPlayerPosition :: Behavior t (Double, Double) ePhysics is fired repeatedly from a timer. I'm having issues with defining bPlayerPosition. What I intend…
MasterMastic
  • 20,711
  • 12
  • 68
  • 90
6
votes
1 answer

Dealing with the current time in reactive-banana

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 Behaviours with Events (via <@ etc.) gives me the value of the Behaviour from the previous…
Tom Ellis
  • 9,224
  • 1
  • 29
  • 54
6
votes
1 answer

reactive-banana-wx `sink` does not generate an event enabling post-sink processing

I am currently redesigning a piece of legacy wxHaskell using the reactive-banana and reactive-banana-wx packages. However, in order to avoid dynamic network construction (where I ran into a thread block on an MVar), I now mimic this by…
atze
  • 86
  • 2
6
votes
2 answers

Doing some basic calculus using Reactive Banana

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 …
John F. Miller
  • 26,961
  • 10
  • 71
  • 121
6
votes
3 answers

How does Reactive Banana's mapAccum function work?

I have looked at a number answers to questions here on Stack Overflow trying to find a solution to my problem in using the Reactive Banana library. All the answers use some magic using 'mapAccum' that I can't quite understand. Looking at the API…
John F. Miller
  • 26,961
  • 10
  • 71
  • 121