[Haskell-cafe] Re: [Haskell] ANNOUNCE: Phooey -- a Functional UI
library for Haskell
Brian Hulley
brianh at metamilk.com
Tue Dec 12 09:16:07 EST 2006
Brian Hulley wrote:
> Conal Elliott wrote:
>
>> GUIs are usually programmed in an "unnatural" style, in that ...
>
> Also, suppose you have a gui consisting of an edit widget such that
> when the user types something it gets lexed, parsed, and fontified as
> a Haskell program, ie from the user's point of view the widget
> maintains a syntax highlighted view of the code which is
> "continuously" updated. Would your system do the lexing/parsing for
> every key that was pressed or only once, when the widget needs to be
> re-rendered (a typical gui for Windows would only propagate changes
> and re-draw the gui (ie lex/parse/fontify) when there are no event
> messages pending)?
Thinking about this more, a better example would be a gui with 2 widgets: an
edit widget to type in code and a list widget which displays a list of top
level functions defined in that code. (The code could be Haskell or some
simple toy language.)
Then the question becomes: how to set things up such that the code in the
edit widget is only parsed when the list widget (and/or edit widget) is
asked to render it's contents rather than every time the user presses a key.
I think perhaps the problem would be solved by the edit widget passing a
lazy parse tree (ie an expression evaluating to the parse tree) to the list
widget.
But an interesting thing is if you compare this to imperative guis, in the
functional gui each widget passes lazy expressions eagerly whereas in
imperative guis each widget passes eagerly evaluated expressions lazily ie
functional is "push messages" whereas imperative is "pull changes when I'm
asked to pick or render something etc and I'm dirty". (Have I got this
wrong?)
I imagine that the overhead of eager passing in the functional gui is a
small price to pay for the ease of using a functional gui, since the
important thing is that in both guis, the hard work of parsing the code in
the edit buffer would only be done on demand, unless I'm much mistaken.
If you're still thinking of examples for your paper it would also be really
great to see how you'd create a widget that displays the result of another
process (eg a window that displays the output as ghc compiles a program) or
some other example of how to use the IO monad inside a widget for those
unfamiliar with combining arrows with monads.
It would also be useful to know more about the relationship between the
functional gui and WxWidgets to see what characteristics an imperative gui
toolkit must have in order to be usable with it. (Like the extremely useful
discussion of low level details in the Fudgets thesis.)
Best regards, Brian.
--
http://www.metamilk.com
More information about the Haskell-Cafe
mailing list