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
3
votes
1 answer

Reactive Banana: Bindings

I am working on a small terminal-based UI and I want to use Reactive Banana for describing interactions. The only external event I am interested in, is whether the user has pressed a key. From what I gathered from the Frameworks documentation, I…
ftl
  • 647
  • 3
  • 13
3
votes
2 answers

How does `valueB` work? It always returns the same value?

Consider the following code: module Main where import Control.Event.Handler import Reactive.Banana import Reactive.Banana.Frameworks main :: IO () main = do (addHandler, fire) <- newAddHandler compile (network addHandler) >>= actuate fire…
Buttons840
  • 9,239
  • 15
  • 58
  • 85
3
votes
1 answer

Implementing game states using reactive-banana

In my breakout implementation there are two main behaviors that describe the game's main state: paddlePosition :: Behavior t Point ballPosition :: Behavior t Point Both are implemented in terms of tickEvent :: Event t () which discretely updates…
3
votes
1 answer

reactive-banana 1.0 monadic API: How to define recursive behaviors now?

In reactive-banana <1.0.0, this worked: -- takes a start value, minimum and maximum value, flag whether counter is -- cyclic, an increment and decrement event stream and returns a behavior mkCounter :: (Enum a,Ord a) => a -> Maybe a -> Maybe a ->…
apirogov
  • 1,296
  • 1
  • 12
  • 22
3
votes
1 answer

How to look back to the previous moment

I am reading a button's state (whether being pressed or not) every moment: readButton :: IO Boolean readButton = ... main = do (add, fire) <- newAddHandler network <- compile (desc add) actuate network forever $ do …
Ryoichiro Oka
  • 1,949
  • 2
  • 13
  • 20
3
votes
1 answer

Resettable accumulator behaviors?

I'm trying to wrap my head around FRP and I'm not sure that I'm doing it right. I want to build up a string from key press events up until enter is pressed. Once enter is pressed, the string gets written out and the accumulator is reset to the empty…
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
3
votes
1 answer

Dynamically updating UI based on previous updates

I'm doing some research into practical aspects of FRP for UI's and I've been struggling with implementing the following functionality using reactive banana: based on the value of a selection box, a variable amount of list boxes are rendered which…
Jacob
  • 106
  • 5
3
votes
2 answers

Is it possible?: Behavior t [Behavior t a] -> Behavior t [a]

Is there a way to have a Behavior t [a] where the values of [a] at time t are the values contained in a Behavior t [Behavior t a] at time t? I.e, a function with the type of: Behavior t [Behavior t a] -> Behavior t [a] If this is not possible, is…
mcjohnalds45
  • 667
  • 1
  • 8
  • 16
3
votes
1 answer

How to implement reactive-banana behaviors that recursively depend on themself?

I have a Behavior whose value I want to change based on the occurrence of an Event and the Behavior's current value. In the example below I have two counters that are updated based on whether a boolean behaviour is True or False. As it is this code…
merijn
  • 131
  • 2
3
votes
1 answer

Functional Banana Traveller - input Handling : Will this do what I want?

The way I want to manage input for my game is to poll a TChan, and then create an Event when an eTick happens. But will the way I'm trying it work? data UAC = UAC (AID,PlayerCommand) deriving Show makeNetworkDescription :: forall t . Frameworks t…
user1198582
3
votes
1 answer

Dynamic event switching in reactive-banana causes severe leak

I'm not sure whether this behavior is expected (i.e. I'm misusing Reactive.Banana.Switch) or a bug. Let's say I have two like-typed input Behaviors, and I want to switch between them based on an Event. I wrote this function: switchBehaviors :: …
Christian Conkle
  • 5,932
  • 1
  • 28
  • 52
3
votes
1 answer

Haskell Cannot deduce (t ~ t1) from the context (Frameworks t)

I am learning how to use the Haskell FRP library called Reactive Banana, and also fairly new to Haskell in general. Currently I am creating a function that will take a network as a parameter, and in the function body do some initialization before…
chanko08
  • 284
  • 1
  • 10
3
votes
0 answers

wxHaskell and Reactive-Banana staticText not Updating Size When Text Changes

I'm trying to build a simple UI as an exercise in learning wxHaskell and Reactive Banana, but I've run into a wall trying to solve a seemingly simple problem. Specifically, I'd like to resize the window to fit around a label when the label's text is…
Rose Kunkel
  • 3,102
  • 2
  • 27
  • 53
3
votes
2 answers

SDL-Mixer audio stops upon starting Reactive-Banana input loop

I've been working on a game that uses multiple audio tracks whose volumes are adjusted in realtime based on mouse motion. I'm using SDl-Mixer for audio, and Reactive-Banana for the game in general. The problem is that the tracks, which have all been…
2
votes
2 answers

How to handle multiple windows and single data structure in reactive-banana

I'm wondering how reactive-banana was designed to handle the following situation: Let's say I have a central data structure. The user is able to freely open and close any number of different types of windows that both display the data, and allow the…
mentics
  • 6,852
  • 5
  • 39
  • 93