caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Chris King" <colanderman@gmail.com>
To: caml-list@inria.fr
Subject: Functional Reactive GUI for O'Caml
Date: Wed, 20 Dec 2006 10:38:22 -0500	[thread overview]
Message-ID: <875c7e070612200738t6aa99d08nc7a9ec741467ec4d@mail.gmail.com> (raw)

(Cross-posted from Lambda the Ultimate at the advice of Yaron Minsky...)

Hi all,

I've been working for the past few months on a functional reactive GUI
system for O'Caml called "O'Caml Reactive Toolkit", "functional
reactive" meaning that functional expressions can be built whose
values change over time in response to user input without relying on
imperative constructs (much like dataflow or visual programming
languages).  For those familiar with extant FR systems, the core FR
logic is based heavily on Haskell's Yampa, while the FR API is modeled
after PLT Scheme's FrTime, so there is not much new there. The novelty
is in the GUI API, which, although layered on lablgtk2, constructs a
GUI via functions rather than objects and exposes no mutable state:
response to user input is modeled using functional reactive
constructs.  As an example, here is a toy temperature conversion
program:

open Fr
open FrGui

let float_view f = text_view (lift (string_of_float @f))

let _ =
    let temp_box, temp = spin_box 20. in
    let fahrenheit = lift ((@temp -. 32.) *. 1.8)
    and celsuis = lift (@temp /. 1.8 +. 32.) in
    let main_window = window
        ~title: "Temperature converter"
        (hbox [
            hbox [label "Convert "; temp_box; label " to:"];
            vbox [
                hbox [label "degrees Fahrenheit: "; float_view fahrenheit];
                hbox [label "degrees Celsius: "; float_view celsius]]]) in
    run_dialog (main_window, main_window#close)

The temperature entered by the user is instantly converted to both
degrees Fahrenheit and degrees Celsius.  The "lift" construct is a
camlp4 syntax extension which provides a way to create functional
reactive expressions: inside it, "@val" refers to a value which
changes with time (a "behavior").

Though O'Caml RT is far from complete I made a prerelease because I
want to solicit feedback from others who are interested in functional
reactive programming and in creating a portable GUI API for O'Caml. I
made a web page[1] providing links to the source code, documentation
(on both functional reactive programming and FrGui), and (coming soon)
examples. It's known to compile both to bytecode and native code on
Mac OS X and Linux (feedback from Windows users would be greatly
appreciated!), and it should be possible already to write many simple
GUI applications using it.

My questions to you are:

    * Am I duplicating work? I know of functional reactive GUI systems
such as Fudgets, SuperGlue, and Flapjax for other languages but I know
of no such system for O'Caml.
    * What would you want to see in a functional-reactive GUI toolkit?
i.e. what things which are often awkward to express in procedural
langauges do you think should be made easy in O'Caml RT?
    * What are some examples of things which are easy in procedural
languages but you think would be awkward in a functional-reactive
setting?
    * Is the API clear and understandable? e.g. does the above example
make sense, even to those not familiar with functional reactive
programming?

Thanks in advance for your feedback!

[1] http://users.wpi.edu/~squirrel/ocamlrt/


             reply	other threads:[~2006-12-20 15:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20 15:38 Chris King [this message]
2006-12-20 16:20 ` [Caml-list] " Virgile Prevosto
2006-12-20 22:34   ` Jonathan Roewen
2006-12-21 10:04     ` Virgile Prevosto
2006-12-20 17:00 ` Gabriel Kerneis
2006-12-21  3:36   ` Chris King
2006-12-21  8:31 Louis Mandel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875c7e070612200738t6aa99d08nc7a9ec741467ec4d@mail.gmail.com \
    --to=colanderman@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).