Personal tools

Grapefruit

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(changing of repo links to point to the new code.haskell.org repos)
(Development versions: adapted info to changes in darcs repositories related to the start of Grapefruit 0.2)
 
(30 intermediate revisions by 5 users not shown)
Line 2: Line 2:
 
[[Category:Libraries]]
 
[[Category:Libraries]]
 
[[Category:Arrow]]
 
[[Category:Arrow]]
  +
[[Category:Graphics]]
  +
[[Category:FRP]]
  +
[[Category:Packages]]
   
 
== About ==
 
== About ==
Line 21: Line 24:
   
 
You might be interested in a [[Grapefruit/Comparison to other FRP libraries|comparison of Grapefruit to other FRP libaries]]
 
You might be interested in a [[Grapefruit/Comparison to other FRP libraries|comparison of Grapefruit to other FRP libaries]]
 
== Versions ==
 
 
There is a first official Grapefruit release which is release 0.0.0.0.
 
 
Grapefruit underwent fundamental interface and implementation changes before this release. A version from before these changes is available as the “classic” version. In contrast to the released version, the classic version contains support for animated graphics, incrementally updating list signals and a restricted form of dynamic user interfaces (user interfaces whose widget structure may change). These features are expected to come back in future releases.
 
   
 
== Installation ==
 
== Installation ==
   
First, a note for GHC 6.8 users. If you get warnings of the form “Can’t find interface-file declaration for type constructor or class …” when compiling with GHC 6.8 then don’t panic. This seems to be because of a bug in the (non-official) type family support of GHC 6.8. However, it seems to be harmless.
+
=== Released versions ===
   
=== Released version ===
+
Grapefruit is released on [[Hackage]]. If you do not have special requirements, you can install Grapefruit by saying <code>cabal install grapefruit-ui-gtk grapefruit-examples</code>.
   
You need at least GHC&nbsp;6.8.3 and Gtk2Hs&nbsp;0.9.13 to build and use Grapefruit. GHC&nbsp;6.8.2 can ''not'' be used because of [http://hackage.haskell.org/trac/ghc/ticket/1981 GHC&nbsp;bug #1981]. Grapefruit was tested with GHC&nbsp;6.8.3 and Gtk2Hs&nbsp;0.9.13 as well as with GHC&nbsp;6.10.1 and a Gtk2Hs&nbsp;0.10.0.
+
If you do not have installed the <code>gtk</code> package yet, this command will also try to install this package. However, this will fail unless <code>gtk2hs-buildtools</code> is already installed. See the [http://projects.haskell.org/gtk2hs/ Gtk2Hs website] for further information.
   
Grapefruit is released on [[Hackage]]. If you do not have special requirements, you can install Grapefruit and its prerequisites as follows:
+
=== Development versions ===
# Install GHC&nbsp;6.10.1 (see [http://www.haskell.org/ghc/download_ghc_6_10_1.html]).
 
# Install cabal-install (see [http://ghcmutterings.wordpress.com/2008/11/10/bootstrapping-cabal-install/]).
 
# Insert the line <code>documentation: True</code> into the cabal-install configuration file ($HOME/.cabal/config on UNIX-like systems).
 
# Install Gtk2Hs&nbsp;0.10.0 (see [http://sourceforge.net/project/showfiles.php?group_id=49207&package_id=42440&release_id=659598]).
 
# Install Grapefruit by entering <code>cabal update</code>, followed by <code>cabal install grapefruit-ui-gtk grapefruit-examples</code> on a command line.
 
   
=== Current development version ===
+
Currently, Grapefruit is undergoing a complete rewrite, which will base it on new concepts. For each part of the new Grapefruit, there is a corresponding [[Darcs|darcs]] repository at <nowiki>http://darcs.grapefruit-project.org/</nowiki>''package-name''/main. The code of the old 0.1&nbsp;branch of Grapefruit resides in a single darcs repository at http://darcs.grapefruit-project.org/monolithic/0.1.
 
The current development version can be fetched from the [[Darcs|darcs]] repository at http://code.haskell.org/grapefruit/main/. You can build it by building the individual [[Cabal]] packages in the grapefruit-* directories. Note that grapefruit-graphics is currently defunct.
 
 
=== Classic version ===
 
 
If you want to try out the classic version, please get it from the darcs repository at http://code.haskell.org/grapefruit/classic/. You can build it by building the individual [[Cabal]] packages in the grapefruit-* directories. Alternatively, you can use the Setup.lhs script in the root directory to easily build all packages. You can run the following:
 
;<code>runghc Setup.lhs clean</code>
 
:cleans all packages
 
;<code>runghc Setup.lhs up-to-install ''configure-options'' -- ''build-options'' -- ''install-options''</code>
 
:configures, builds and installs all packages
 
;<code>runghc Setup.lhs up-to-register ''configure-options'' -- ''build-options'' -- ''register-options''</code>
 
:configures and builds all packages and registers all library packages (which are all except grapefruit-examples)
 
 
The classic version does not work with GHC&nbsp;6.10.1 and the global Setup.lhs script does not work with newer Cabals.
 
   
 
== Running the examples ==
 
== Running the examples ==
 
=== Released version and current development version ===
 
   
 
You can run the examples by typing the following lines into GHCi:
 
You can run the examples by typing the following lines into GHCi:
   
<blockquote><p><code>import Graphics.UI.Grapefruit.Circuit</code><br /><code>import Graphics.UI.Grapefruit.''UIBackend''</code><br /><code>import Examples.Grapefruit.''Example''</code><br /><code>run ''UIBackend'' mainCircuit</code></p></blockquote>
+
<blockquote><p><code>import Graphics.UI.Grapefruit.Circuit</code><br /><code>import Graphics.UI.Grapefruit.'''''UIBackend'''''</code><br /><code>import Examples.Grapefruit.'''''Example'''''</code><br /><code>run '''''UIBackend''''' mainCircuit ()</code></p></blockquote>
   
Replace <code>''Example''</code> with the name of the example to run and <code>''UIBackend''</code> with the name of the UI backend you want to use.
+
Replace <code>'''''Example'''''</code> with the name of the example to run and <code>'''''UIBackend'''''</code> with the name of the UI backend you want to use. At the moment, the only meaningful replacement for <code>'''''UIBackend'''''</code> is <code>GTK</code>. Possible replacements for <code>'''''Example'''''</code> are <code>Converter</code>, <code>ListView</code>, <code>SetView</code>, <code>Simple</code>, and <code>Switching</code>.
At the moment, the only meaningful replacement for <code>''UIBackend''</code> is <code>GTK</code> and the only meaningful replacements for <code>''Example''</code> are <code>Simple</code> and <code>Switching</code>.
 
   
 
We do not provide ready-to-use executables since it is possible (at least in theory) to run the examples with different UI backends and an executable would be fixed to a specific backend.
 
We do not provide ready-to-use executables since it is possible (at least in theory) to run the examples with different UI backends and an executable would be fixed to a specific backend.
 
=== Classic version ===
 
 
The package grapefruit-examples provides an executable for each example.
 
 
== Documentation ==
 
 
=== Released version ===
 
 
For the following packages, complete documentation is available on [[Hackage]]:
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/grapefruit-frp grapefruit-frp]
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/grapefruit-records grapefruit-records]
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/grapefruit-ui grapefruit-ui]
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/grapefruit-examples grapefruit-examples]
 
 
For [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/grapefruit-ui-gtk grapefruit-ui-gtk], only the overiew page is available. The reason is that Hackage cannot build grapefruit-ui-gtk since Gtk2Hs is not installed on Hackage. However, if you have installed Grapefruit as described above, you have the documentation locally installed (under $HOME/.cabal/share/doc/ under UNIX-like systems).
 
 
=== Current development version ===
 
 
You can build the documentation by issuing <code>runghc Setup.lhs haddock</code> inside the Grapefruit package directories.
 
 
=== Classic version ===
 
 
There is only little documentation of the classic version and there are no plans to change this situation. So you will have to live with what is there. If you have questions, you may always ask the author of Grapefruit as listed in the *.cabal files.
 
 
To build the documentation, issue <code>runghc Setup.lhs haddock</code> inside the Grapefruit package directories.
 
   
 
== Publications and talks ==
 
== Publications and talks ==
   
The following publications and talks are related to Grapefruit:
+
See [https://grapefruit-project.org/publications-and-talks the respective list] on [https://grapefruit-project.org/ the new Grapefruit website].
* Wolfgang Jeltsch: Declarative Programming of Interactive Systems with Grapefruit. [http://www.cs.uu.nl/wiki/Stc Software Technology Colloquium of Utrecht Universiteit]. May 29, 2008.
 
** [http://www.cs.uu.nl/wiki/bin/view/Stc/DeclarativeProgrammingOfInteractiveSystemsWithGrapefruit time, place and abstract]
 
** [http://www.informatik.tu-cottbus.de/~jeltsch/research/uustc-20080529-slides.pdf slides] (including non-shown additional material)
 
   
* Wolfgang Jeltsch: Improving Push-based FRP. [http://www.st.cs.ru.nl/AFP_TFP_2008/ 9th Symposium on Trends in Functional Programming]. May 26–28, 2008.
+
== Community ==
** [http://www.informatik.tu-cottbus.de/~jeltsch/research/tfp-2008-paper.pdf draft paper] (published in the draft proceedings)
 
** [http://www.informatik.tu-cottbus.de/~jeltsch/research/tfp-2008-slides.pdf slides] (including non-shown additional material)
 
   
* Wolfgang Jeltsch: Funktionale GUI-Programmierung in Haskell mit Grapefruit. [http://www.iba-cg.de/haskell.html Haskell in Leipzig&nbsp;2]. July 10, 2007.
+
Grapefruit has a [http://projects.haskell.org/cgi-bin/mailman/listinfo/grapefruit mailing list] and a [http://trac.haskell.org/grapefruit/ project management website] where you can [http://trac.haskell.org/grapefruit/newticket report bugs], for example.
** [http://video.google.com/videoplay?docid=-8925440604853415181 video]
 
** [http://www.informatik.tu-cottbus.de/~jeltsch/research/hal-2-slides.pdf slides]
 
   
 
== Screenshots ==
 
== Screenshots ==
   
Below are some screenshots from the examples of the classic version. The Simple example is also available in the released version (along with the Switching example, not mentioned here).
+
Below are some screenshots from the examples of an earlier Grapefruit version. The Simple example is also available in the current version, along with several other examples not mentioned here.
 
;Simple
 
;Simple
 
:Clicking on the button adds a star to the caption of the button. This doesn’t look very meaningful. However, Simple is actually a very important example since it demonstrates that feedbacks work—the output of the button is transformed and then used as the button’s input.
 
:Clicking on the button adds a star to the caption of the button. This doesn’t look very meaningful. However, Simple is actually a very important example since it demonstrates that feedbacks work—the output of the button is transformed and then used as the button’s input.

Latest revision as of 14:47, 10 February 2012


Contents

[edit] 1 About

Grapefruit is a library for Functional Reactive Programming (FRP) with a focus on user interfaces. FRP makes it possible to implement reactive and interactive systems in a declarative style. With Grapefruit, user interfaces are described as networks of communicating widgets and windows. Communication is done via different kinds of signals which describe temporal behavior.

[edit] 2 Features

Grapefruit has the following important features:

  • a push-based FRP implementation where signals
    • can be memoized using ordinary variable bindings
    • can be merged without doubling of simultaneous events
    • cannot behave differently by starting them at different times
  • a record system which makes it possible that
    • input signals can be left out to get default behavior
    • output signals can be left out to ignore uninteresting data
    • output signals can be chosen and fetched by pattern matching
  • an abstract UI implementation which can work with different backends which in turn use different toolkits to provide different look and feel with one and the same application code (At the moment, the only supported UI toolkit is GTK+ (via Gtk2Hs). We plan to support Qt in the future, making use of the HQK project’s output.)

You might be interested in a comparison of Grapefruit to other FRP libaries

[edit] 3 Installation

[edit] 3.1 Released versions

Grapefruit is released on Hackage. If you do not have special requirements, you can install Grapefruit by saying cabal install grapefruit-ui-gtk grapefruit-examples.

If you do not have installed the gtk package yet, this command will also try to install this package. However, this will fail unless gtk2hs-buildtools is already installed. See the Gtk2Hs website for further information.

[edit] 3.2 Development versions

Currently, Grapefruit is undergoing a complete rewrite, which will base it on new concepts. For each part of the new Grapefruit, there is a corresponding darcs repository at http://darcs.grapefruit-project.org/package-name/main. The code of the old 0.1 branch of Grapefruit resides in a single darcs repository at http://darcs.grapefruit-project.org/monolithic/0.1.

[edit] 4 Running the examples

You can run the examples by typing the following lines into GHCi:

import Graphics.UI.Grapefruit.Circuit
import Graphics.UI.Grapefruit.UIBackend
import Examples.Grapefruit.Example
run UIBackend mainCircuit ()

Replace Example with the name of the example to run and UIBackend with the name of the UI backend you want to use. At the moment, the only meaningful replacement for UIBackend is GTK. Possible replacements for Example are Converter, ListView, SetView, Simple, and Switching.

We do not provide ready-to-use executables since it is possible (at least in theory) to run the examples with different UI backends and an executable would be fixed to a specific backend.

[edit] 5 Publications and talks

See the respective list on the new Grapefruit website.

[edit] 6 Community

Grapefruit has a mailing list and a project management website where you can report bugs, for example.

[edit] 7 Screenshots

Below are some screenshots from the examples of an earlier Grapefruit version. The Simple example is also available in the current version, along with several other examples not mentioned here.

Simple
Clicking on the button adds a star to the caption of the button. This doesn’t look very meaningful. However, Simple is actually a very important example since it demonstrates that feedbacks work—the output of the button is transformed and then used as the button’s input.
Grapefruit-screenshot-Simple.png
Codebreaker
This is a Mastermind™-like game. The Add button is enabled if and only if the input field contains a valid code and the display box is enabled if and only if the list of guesses does not contain the code chosen by the computer. These properties are described in a declarative way in the source code.
Grapefruit-screenshot-Codebreaker.png
CircuitingObjects
This example demonstrates Grapefruit’s support for animations.
Grapefruit-screenshot-CircuitingObjects.png