This folder contains the code examples for the Threepenny GUI library.
To run the examples, you can (but don't have to) use the provided runhaskell
and ghci
scripts:
cd samples
./runhaskell Chat.hs
These scripts check whether you have set up a cabal sandbox or, alternatively, the stack utility for use with this library, and uses these instead of the global package database; this is very useful for me as a library author.
(To set up the examples with stack
, do the following
git clone https://github.com/HeinrichApfelmus/threepenny-gui.git
cd threepenny-gui/
stack init
stack setup
stack build
cd samples
./runhaskell Mouse.hs
)
After you have started an example, open your web browser and point it to the address http://localhost:8023. Enjoy!
Here a description of the currently maintained examples.
- BarTab.hs — Dynamic creation of widgets.
- Buttons.hs — Simple buttons to click on.
- Canvas.hs — Graphics using the HTML 5 canvas element.
- Chat.hs — Multi-user chat.
- CRUD.hs — A CRUD example showcasing functional reactice programming (FRP).
- CurrencyConverter.hs — Simple demonstration of two reactive input elements.
- DragNDropExample.hs — Simple drag'N'drop demo.
- DrumMachine.hs — Specify rhythm by activating and deactivating checkboxes.
- FadeInFadeOut.hs — Calling Haskell functions from the browser.
- GetElementsBy.hs — Get elements by tag name or ID.
- Mouse.hs — Test of the
mousemove
event. - Svg.hs — Test of the SVG elements.
There are also a few other examples that are used for testing or that demonstrate library internals. They won't be maintained.
- WorkaroundFastEvent.hs — Demonstrates how to register an event handler without requiring a response from the browser window.