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
2
votes
0 answers

Can I build an Event based on a Behavior change in reactive-banana?

The goal here is to build an Event that triggers whenever a Behavior changes under some observation. To make it a bit more concrete, let's say I have: a bFoo :: Behavior a, which I like to think it as a time-varied state. a function diffA :: a -> a…
Javran
  • 3,394
  • 2
  • 23
  • 40
2
votes
1 answer

What are 'Latch' and 'Pulse' in reactive-banana?

Do the Latch and Pulse types exist in FRP literature, or are they an invention of the author of reactive-banana? Just looking at the types, they roughly correspond to Behavior and Event (respectively), but I'd like to know what the difference is,…
MitchellSalad
  • 4,171
  • 8
  • 23
  • 24
2
votes
0 answers

Updating visibility of dynamically created content

Duplicating this from github as per @HeinrichApfelmus's suggestion: This may be just a usage error on my part, but I am noticing a strange phenomenon when trying to set up conditional visibility/layout for dynamically created UI elements (in WX of…
archaephyrryx
  • 415
  • 2
  • 10
2
votes
1 answer

Dynamic inputs from a Behavior in reactive-banana

When I want to work with dynamic inputs in reactive-banana, I usually envision a system that works roughly like this: data InputSpecification -- Some data structure that specifies the inputs -- which should be active right…
Kritzefitz
  • 2,644
  • 1
  • 20
  • 35
2
votes
1 answer

Haskell Reactive-Banana FRP and event loop

I am still trying to wrap my head around Haskell and FRP. Specifically, I have worked through some examples using reactive-banana package and starting to get FRP. However, I still don't understand how the event network knows when an input event has…
phage
  • 584
  • 3
  • 17
2
votes
0 answers

How to buffer events in reactive-banana

I'm new in FRP, but want to try to apply FRP principles on practice. In many resources on the Internet related to FPR on Haskell authors refer to reactive-banana. So I thought to take a look at that as well, but it's not mandatory at all if there is…
klappvisor
  • 1,099
  • 1
  • 10
  • 28
2
votes
1 answer

How to create an Event that contains the difference between the value at current tick and the value at the value at previous tick?

I'm using reactive-banana and sdl2 (using this glue library) for a game-like project. A Behavior is created for the "absolute mouse location", as well as a Behavior for the "relative mouse location" (a.k.a. the mouse movement). When not using FRP…
cies
  • 333
  • 1
  • 7
2
votes
1 answer

Reactive Banana: Alternate buttons events

I am trying for the first time to use Reactive Banana (WX) to display a text like "Pressed button One", "Pressed button Two", etc. on top of five buttons: {-# LANGUAGE ScopedTypeVariables #-} import Graphics.UI.WX hiding (Event) import…
Randomize
  • 8,651
  • 18
  • 78
  • 133
2
votes
2 answers

Multithreading and gtk2hs

I'm writing some code with reactive-banana and gtk2hs that needs to read from a file handle. I need to have at least two threads (one to read keyboard events with reactive banana and one to read from the file handle), so at the moment I have code…
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
2
votes
1 answer

how to solve type issues with Moment t in reactive-banana?

I'm trying to write a function like so: module Main where import Reactive.Banana import Reactive.Banana.Frameworks main = putStrLn "hello world" type MIDIMessage = (Int, Int, Double) startRBMidi f = do (addHandler, fire) <- newAddHandler ::…
miguel.negrao
  • 949
  • 5
  • 13
2
votes
1 answer

What's the inital value of a trimmed behavior

I have the following test program: {-# LANGUAGE RankNTypes #-} module Main where import Reactive.Banana import Reactive.Banana.Frameworks import Reactive.Banana.Switch import Data.IORef import Control.Monad main = do fShowRef <- newIORef…
Tobias Brandt
  • 3,393
  • 18
  • 28
2
votes
0 answers

Dynamic switching with a predicate

Suppose I have a monad M, a function* foo :: forall t. Frameworks t => Int -> M (Behavior t State) and a predicate pred :: State -> Bool I'd like to get a value* (in whatever monad necessary) bar :: forall t. Frameworks t => Behavior t State such…
Josh Kirklin
  • 929
  • 5
  • 14
2
votes
2 answers

Can't find AddHandler in reactive-banana

I am trying out the examples of reactive-banana in its tutorial. When I tried to load the example into ghci, I got an error. Could not find module `Reactive.Banana.Frameworks.AddHandler' Running it with ghci -v gives the output at the bottom. I…
thor
  • 21,418
  • 31
  • 87
  • 173
2
votes
2 answers

Audio synthesis in Haskell using reactive-banana

I'm trying to get started with reactive-banana and want to create a simple synthesizer. There are lots of GUI examples, but I have trouble applying them to audio. Since audio APIs have callbacks that say "give me n samples of audio" I figure I…
absence
  • 821
  • 1
  • 8
  • 13
2
votes
0 answers

What would the general structure of a reactive-banana game look like?

A simple game that runs its logic every iteration and draws to the screen 60 times per second in an imperative language might look like this: function main() { player = new Player() lastUpdateTime, lastDrawTime = getTime() while (!quit)…
mcjohnalds45
  • 667
  • 1
  • 8
  • 16