Personal tools

Reactive-banana/Examples

From HaskellWiki

< Reactive-banana(Difference between revisions)
Jump to: navigation, search
m (Core Examples: “run” was renamed to “actuate” in the repo.)
(GUI Examples - Very simple)
(10 intermediate revisions by 2 users not shown)
Line 11: Line 11:
   
 
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Arithmetic.hs Arithmetic.hs]
 
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Arithmetic.hs Arithmetic.hs]
: Minimalistic calculator that can add two numbers. Demonstrates how to read values from text entries and respond to button clicks.
+
: Minimalistic calculator that can add two numbers. Demonstrates how to read values from text entries.
 
[[Image:Reactive-banana-Arithmetic.png]]
 
[[Image:Reactive-banana-Arithmetic.png]]
   
 
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Counter.hs Counter.hs]
 
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Counter.hs Counter.hs]
: A simple counter that can be manipulated with two buttons "Up" or "Down". Demonstrates the <code>accumD</code> function.
+
: A simple counter that can be manipulated with two buttons "Up" or "Down". Demonstrates how to get events from button clicks and how to accumulate values using the <code>accumB</code> function.
 
[[Image:Reactive-banana-Counter.png]]
 
[[Image:Reactive-banana-Counter.png]]
   
Line 22: Line 22:
 
[[Image:Reactive-banana-NetMonitor.png]]
 
[[Image:Reactive-banana-NetMonitor.png]]
   
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/CurrencyConverter.hs CurrencyConverter.hs]
+
; <span id="CurrencyConverter">[https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/CurrencyConverter.hs CurrencyConverter.hs]
: Simple currency converter. Reads and writes values to text entry widgets in real-time. Demonstrates how to use value recursion in the <code>NetworkDescription</code> monad.
+
: Simple currency converter. Reads and writes values to text entry widgets in real-time. Demonstrates bidirectional controls.
 
[[Image:Reactive-banana-CurrencyConverter.png]]
 
[[Image:Reactive-banana-CurrencyConverter.png]]
   
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/TwoCounters.hs TwoCounters.hs]
+
; <span id="twoCounters">[https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/TwoCounters.hs TwoCounters.hs]
 
: Two simple counters. There is only one pair of buttons "Up" or "Down", the button "Switch Counters" allows you to specify which counter should be affected. [[Image:Reactive-banana-TwoCounters.png]]
 
: Two simple counters. There is only one pair of buttons "Up" or "Down", the button "Switch Counters" allows you to specify which counter should be affected. [[Image:Reactive-banana-TwoCounters.png]]
   
 
== GUI Examples - More elaborate ==
 
== GUI Examples - More elaborate ==
   
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Asteroids.hs Asteroids.hs]
+
; <span id="animation">[https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Animation.hs Animation.hs]</span>
  +
: A small interactive animation. The sprite follows the mouse pointer.
  +
[[Image:Reactive-banana-Animation.png]]
  +
  +
; <span id="asteroids">[https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Asteroids.hs Asteroids.hs]</span>
 
: Port of the [[wxAsteroids]] example.
 
: Port of the [[wxAsteroids]] example.
 
[[Image:Reactive-banana-wxAsteroids.png]]
 
[[Image:Reactive-banana-wxAsteroids.png]]
  +
  +
; <span id="bartab">[https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/BarTab.hs BarTab.hs]</span>
  +
: Add all numbers on the tab. Demonstrates how to dynamically create widgets and <code>Behavior</code>s.
  +
[[Image:Reactive-banana-BarTab.png]]
   
 
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/CRUD.hs CRUD.hs]
 
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/CRUD.hs CRUD.hs]
: A toy CRUD (Create/Read/Update/Destroy) application. Demonstrates how to do incremental updates. Of course, this makes the code quite messy, but I think it's still pretty nice. For instance, it was quite easy to add the filter box.
+
: A toy CRUD (Create/Read/Update/Destroy) application. The code is quite pleasant. Unfortunately, bidirectional controls are still hard to describe, I have left this in a somewhat buggy state. Future updates will rectify this.
 
[[Image:Reactive-banana-CRUD1.png]] [[Image:Reactive-banana-CRUD2.png]]
 
[[Image:Reactive-banana-CRUD1.png]] [[Image:Reactive-banana-CRUD2.png]]
   
Line 43: Line 47:
 
[[Image:Reactive-banana-TicTacToe.png]]
 
[[Image:Reactive-banana-TicTacToe.png]]
   
; [https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Wave.hs Wave.hs]
+
; <span id="wave">[https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana-wx/src/Wave.hs Wave.hs]</span>
: A wave-like pattern. Not the most beautiful code, but it demonstrates that you can generated timed events.
+
: A wave-like pattern. Not the most beautiful code, but it demonstrates that you can generate timed events.
 
[[Image:Reactive-banana-Wave.png]]
 
[[Image:Reactive-banana-Wave.png]]

Revision as of 10:06, 25 March 2013

Examples for the reactive-banana library.

1 Core Examples

SlotMachine.hs
Mainly demonstrates how to set up an event network with your own event loop. Also demonstrates the FRP functionality.
ActuatePause.hs
Demonstrates how to set up an event network with your own event loop and how to pause or resume it.

2 GUI Examples - Very simple

Arithmetic.hs
Minimalistic calculator that can add two numbers. Demonstrates how to read values from text entries.

Reactive-banana-Arithmetic.png

Counter.hs
A simple counter that can be manipulated with two buttons "Up" or "Down". Demonstrates how to get events from button clicks and how to accumulate values using the accumB function.

Reactive-banana-Counter.png

NetMonitor.hs
Minimalistic application that displays network statistics in real time. Demonstrates the fromPoll function.

Reactive-banana-NetMonitor.png

CurrencyConverter.hs
Simple currency converter. Reads and writes values to text entry widgets in real-time. Demonstrates bidirectional controls.

Reactive-banana-CurrencyConverter.png

TwoCounters.hs
Two simple counters. There is only one pair of buttons "Up" or "Down", the button "Switch Counters" allows you to specify which counter should be affected. Reactive-banana-TwoCounters.png

3 GUI Examples - More elaborate

Animation.hs
A small interactive animation. The sprite follows the mouse pointer.

Reactive-banana-Animation.png

Asteroids.hs
Port of the wxAsteroids example.

Reactive-banana-wxAsteroids.png

BarTab.hs
Add all numbers on the tab. Demonstrates how to dynamically create widgets and Behaviors.

Reactive-banana-BarTab.png

CRUD.hs
A toy CRUD (Create/Read/Update/Destroy) application. The code is quite pleasant. Unfortunately, bidirectional controls are still hard to describe, I have left this in a somewhat buggy state. Future updates will rectify this.

Reactive-banana-CRUD1.png Reactive-banana-CRUD2.png

TicTacToe.hs
A version of TicTacToe with eclectic interface elements, courtesy of Gideon Sireling.

Reactive-banana-TicTacToe.png

Wave.hs
A wave-like pattern. Not the most beautiful code, but it demonstrates that you can generate timed events.

Reactive-banana-Wave.png