From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 1F09FBC0A for ; Wed, 20 Dec 2006 16:45:10 +0100 (CET) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.238]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBKFj9RM004605 for ; Wed, 20 Dec 2006 16:45:09 +0100 Received: by wx-out-0506.google.com with SMTP id i31so2017137wxd for ; Wed, 20 Dec 2006 07:45:08 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=XJuBml3qEGsIw6taSbc8wHoFqUTxvnepvrAj0OH2UPW4HdBSATp1YYX/GZwqOmg8tdYCaQWP0GlN2NBr3NzUW4zlpX1PQSN90sv5DQ42G0SxZHv+Zu/8Eo75a5yUx3FDzl3pWmQApXXbaiohgBv88QCuwq+yQ8EyVABfw4QvKSw= Received: by 10.90.80.8 with SMTP id d8mr7323773agb.1166629102833; Wed, 20 Dec 2006 07:38:22 -0800 (PST) Received: by 10.90.115.2 with HTTP; Wed, 20 Dec 2006 07:38:22 -0800 (PST) Message-ID: <875c7e070612200738t6aa99d08nc7a9ec741467ec4d@mail.gmail.com> Date: Wed, 20 Dec 2006 10:38:22 -0500 From: "Chris King" To: caml-list@inria.fr Subject: Functional Reactive GUI for O'Caml MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 45895A85.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45895A85.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; o'caml:01 lambda:01 yaron:01 minsky:01 o'caml:01 haskell's:01 scheme's:01 lablgtk:01 mutable:01 hbox:01 hbox:01 vbox:01 camlp:01 syntax:01 val:01 (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/