caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>,
	 David MENTRE <dmentre@linux-france.org>
Cc: OCaml Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] OCaml vs Ada and/or GUI options
Date: Thu, 12 Sep 2013 10:16:22 +0200	[thread overview]
Message-ID: <52317856.5000906@frisch.fr> (raw)
In-Reply-To: <843DB424-8563-45A7-A22A-2FA65338298B@math.nagoya-u.ac.jp>

On 09/12/2013 12:03 AM, Jacques Garrigue wrote:
> BTW, lexifi has also some internal system to build GUIs automatically.
> I don't know if there is a blog post on that.

Indeed, we build GUIs automatically, mapping type definitions to entry 
screens (e.g. a sum type will produce a combobox, a list of record of 
simple types will produce a data grid, etc).  This is based on our 
runtime type extension, and we use attributes on type definitions to 
tweak the GUI layout/behavior (e.g. displaying some float field as a 
percentage, or adding a groupbox around several fields).  Some 
customizations (such as adding buttons) can be added through "patches" 
on the GUI. To specify these patches, we rely on a notion of "type path" 
(strongly typed values describing a path in a data type seen as a tree).

All in all, this is very useful to generate large numbers of entry 
screens without writing any GUI code while ensuring a great level of 
uniformity across the application.  This also makes it possible to 
switch from one underlying GUI technology to another one quite easily 
(our Windows desktop applications currently relies on .NET Windows 
Forms, but we have other GUI backends in place -- including a web based 
one).

Of course, the entire application is not only made of those "uniform" 
entry screens, there are menus, toolbars, interactive charts, pages 
using ad hoc widgets, etc, which are written in a more standard manual 
style.  For these parts, we found it quite convenient to use a 
programming style allowing recursive definitions of controls and 
associated callbacks.  This is described in the "lazy let binding" 
section of this blog post:

  https://www.lexifi.com/blog/ocaml-extensions-lexifi-semi-implicit-laziness

This allows for a more functional style of building GUIs, while keeping 
the standard underlying paradigm (as opposed to FRP GUI frameworks). 
Here is the example from the blog post:

=============================================================
lazy let rec button1 =
   button ~click:(fun () -> button2 # disable) "Button1"
and button2 =
   button ~click:(fun () -> button1 # disable) "Button2"
and my_form =
   form ~title:"Dialog example"
    (hbox
      [
        button1;
        button2;
        button ~click:(fun () -> my_form # close) "Close";
      ]
    )
in
my_form # run_modal
=============================================================

The typical equivalent of this code would require creating the form 
object, the hbox panel, adding widgets to the hbox, adding the hbox to 
the form, setting some text properties, and then registering a callback 
on the buttons.

I guess it would be feasible to write some thin layer on top of LabGTK 
supporting this style (assuming the "lazy let" binding goes upstream!), 
and it would already make the client code look nicer.


Alain

  reply	other threads:[~2013-09-12  8:16 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-10 21:09 Gour
2013-09-10 21:38 ` Paolo Donadeo
2013-09-11  5:24   ` Adrien Nader
2013-09-11  7:21     ` Kakadu
2013-09-11  8:21       ` [Caml-list] " Gour
2013-09-11  8:14     ` Gour
2013-09-11 18:17       ` Adrien Nader
2013-09-11 19:31         ` Gour
2013-09-11 19:53           ` Adrien Nader
2013-09-11 20:41             ` Gour
2013-09-11 21:01               ` Adrien Nader
2013-09-12  5:44                 ` Gour
2013-09-12  6:31                   ` Adrien Nader
2013-09-12  5:36             ` Gour
2013-09-12  6:48               ` Adrien Nader
2013-09-12  7:26                 ` Gour
2013-09-11 20:06         ` Jon Harrop
2013-09-11 20:48           ` Anthony Tavener
2013-09-11 21:04             ` Adrien Nader
2013-09-12 14:40             ` [Caml-list] " Jon Harrop
2013-09-12 14:51               ` Alain Frisch
2013-09-12 14:57                 ` Lukasz Stafiniak
2013-09-12 15:04                   ` Alain Frisch
2013-09-14  3:05                 ` Jon Harrop
2013-09-14  7:10                   ` Kakadu
2013-09-14 11:37                     ` Jon Harrop
2013-09-15  8:32                       ` Kakadu
2013-09-14 23:51                   ` Francois¡¡Charles Matthieu¡¡Berenger
2013-09-11 22:17           ` [Caml-list] " Richard W.M. Jones
2013-09-12 13:49             ` [Caml-list] " Jon Harrop
2013-09-12 13:58               ` Richard W.M. Jones
2013-09-11  9:49     ` David MENTRE
2013-09-11 10:14       ` Kakadu
2013-09-11 15:21         ` David MENTRE
2013-09-12  1:31           ` Francois Berenger
2013-09-11 18:43         ` Adrien Nader
2013-09-11 18:36       ` Adrien Nader
2013-09-11 19:34         ` [Caml-list] " Gour
2013-09-11 19:45           ` Adrien Nader
2013-09-11 22:06             ` [Caml-list] " Jacques Garrigue
2013-09-12  3:25         ` Ivan Gotovchits
2013-09-12  6:41         ` Adrien Nader
2013-09-12 11:49           ` Gerd Stolpmann
2013-09-11 19:17       ` [Caml-list] " Gour
2013-09-11 22:03       ` [Caml-list] " Jacques Garrigue
2013-09-12  8:16         ` Alain Frisch [this message]
2013-09-11 12:26     ` Jon Harrop
2013-09-11 18:48       ` Adrien Nader
2013-09-11 13:22     ` Paolo Donadeo
2013-09-11 13:33       ` Kakadu
2013-09-11 14:09         ` Paolo Donadeo
2013-09-11 19:36           ` Jon Harrop
2013-09-11 19:45             ` [Caml-list] " Gour
2013-09-12 12:55               ` [Caml-list] " Jon Harrop
2013-09-11 18:57       ` Adrien Nader
2013-09-11 19:01         ` Rudi Grinberg
2013-09-11 19:15           ` Adrien Nader
2013-09-11  8:10   ` [Caml-list] " Gour
2013-09-11  1:00 ` [Caml-list] " Francois Berenger
2013-09-11  5:07   ` rixed
2013-09-11  8:26     ` [Caml-list] " Gour
2013-09-11  9:23       ` rixed
2013-09-11 12:54         ` Leo White
2013-09-11 12:59           ` Gour
2013-09-11 19:06             ` Adrien Nader
2013-09-11  8:16   ` Gour
2013-09-11  9:00     ` Francois Berenger
2013-09-11 19:19       ` Gour
2013-11-17 20:12       ` [Caml-list] " Gour
2013-09-11  7:38 ` Gabriel Kerneis
2013-09-11  8:20   ` [Caml-list] " Gour
2013-09-11 11:42     ` Gerd Stolpmann
2013-09-18 11:42       ` [Caml-list] " Gour
2013-09-18 12:24         ` Gerd Stolpmann
2013-09-20  4:47           ` Gour
2013-09-19  8:11         ` Alain Frisch
2013-09-19  8:30           ` Daniel Bünzli
2013-09-19  8:47             ` Andreas Rossberg
2013-09-20  4:51           ` Gour
2013-09-20 12:04             ` Gerd Stolpmann

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=52317856.5000906@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=dmentre@linux-france.org \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).