Re: [Haskell-cafe] Pure functional GUI (was

Well, if you want to make it as big as QT, yes. But even just a simple purely functionaly GUI framework that is part of the library would be nice, because right now it gives the impression it cannot be done in Haskell... E.g. Concurrent Clean seems to have a simple UI library.
----- Oorspronkelijk bericht ----- Van: Duncan Coutts [mailto:duncan.coutts@worc.ox.ac.uk] Verzonden: woensdag, augustus 8, 2007 09:36 PM Aan: 'Peter Verswyvelen' CC: 'Donn Cave', haskell-cafe@haskell.org Onderwerp: re: [Haskell-cafe] Pure functional GUI (was "a regressive view of support for imperativeprogramming in Haskell")
On Wed, 2007-08-08 at 19:14 +0000, Peter Verswyvelen wrote:
So could you please tell me more about the problem with pure functional GUIs and why this is not part of the Haskell library? I mean a GUI library completely written in Haskell, not wrapping a popular library.
Partly because just getting the drawing and interaction behaviour to be acceptable would be many person-years of work.
GUI toolkits are not especially simple things. Even if you could do it in just 1/10th of the number of lines of code of Gtk+ or Qt it'd be a massive undertaking.
Duncan

On Wed, Aug 08, 2007 at 08:22:41PM +0000, Peter Verswyvelen wrote:
Well, if you want to make it as big as QT, yes.
But even just a simple purely functionaly GUI framework that is part of the library would be nice, because right now it gives the impression it cannot be done in Haskell... Perhaps the yi keybaard mapping library can be seen as ui ? At least everything is written in haskell, parsing keyboard events and displaying reactions.. I will never compete with gtk etc though.
I think this might be an example that it can be done in haskell Marc Weber

To be fair, GTK is pretty standard. This is so even for "big name" gc'd imperative languages such as C#. Sure, you can use Windows.Forms in C#, but you often wouldnt, because of the patent burden. Also, gtk in partnership with glade rocks! How easy is gtk to use from haskell by the way? In gc'd imperative languages, typically only one thread is allowed to communicate with the GUI, and you need to set up a whole bunch of message-parsing stuff to communicate with other threads. To what extent is this easier in Haskell? Other question on using gtk from haskell: how easy is it to integrate with glade? ie, can we directly bind glade form elements to haskell variables? How easy is it to bind events to glade form elements from within Haskell?

Other question on using gtk from haskell: how easy is it to integrate with glade? ie, can we directly bind glade form elements to haskell variables? How easy is it to bind events to glade form elements from within Haskell? Download the source and have a look at the demo/glade folder.. ;-) (I've pasted the most important lines below)
Marc [...] -- load up the glade file dialogXmlM <- xmlNew "simple.glade" let dialogXml = case dialogXmlM of (Just dialogXml) -> dialogXml Nothing -> error "can't find the glade file \"simple.glade\" \ \in the current directory" -- get a handle on a couple widgets from the glade file window <- xmlGetWidget dialogXml castToWindow "window1" button <- xmlGetWidget dialogXml castToButton "button1" [...]

On 8/9/07, Marc Weber
-- load up the glade file dialogXmlM <- xmlNew "simple.glade" let dialogXml = case dialogXmlM of (Just dialogXml) -> dialogXml Nothing -> error "can't find the glade file \"simple.glade\" \ \in the current directory"
-- get a handle on a couple widgets from the glade file window <- xmlGetWidget dialogXml castToWindow "window1" button <- xmlGetWidget dialogXml castToButton "button1"
Oooo... nice :-)

Hello Hugh, Thursday, August 9, 2007, 4:59:04 AM, you wrote:
How easy is gtk to use from haskell by the way? In gc'd imperative languages, typically only one thread is allowed to communicate with the GUI, and you need to set up a whole bunch of message-parsing stuff to communicate with other threads. To what extent is this easier in Haskell?
you can just send actions to the GUI thread :) something like this: main = do c <- newChan getChanContents c >>= forkOS . guiThread for [1..10] $ \i -> do writeChan c (print i) ... guiThread (a:actions) = do a guiThread actions -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Thu, 2007-08-09 at 08:59 +0800, Hugh Perkins wrote:
To be fair, GTK is pretty standard. This is so even for "big name" gc'd imperative languages such as C#. Sure, you can use Windows.Forms in C#, but you often wouldnt, because of the patent burden. Also, gtk in partnership with glade rocks!
How easy is gtk to use from haskell by the way? In gc'd imperative languages, typically only one thread is allowed to communicate with the GUI, and you need to set up a whole bunch of message-parsing stuff to communicate with other threads. To what extent is this easier in Haskell?
The story on this isn't as nice as it could be. It depends on which GHC runtime system you choose to use. In the single threaded rts, you can use threads willy nilly as they all run in the context of one OS thread (though it requires a little bit of code to set up cooperative scheduling). In the fully threaded rts you have to be very careful to only use GUI stuff from a single OS thread. Gtk2Hs provides a couple functions to post actions to the main GUI thread. We've been thinking of ways to make this more transparent but it's not so easy.
Other question on using gtk from haskell: how easy is it to integrate with glade? ie, can we directly bind glade form elements to haskell variables? How easy is it to bind events to glade form elements from within Haskell?
It's pretty easy, see the Gtk2Hs/Glade tutorial: http://haskell.org/gtk2hs/docs/tutorial/glade/ Duncan

Duncan Coutts wrote:
On Thu, 2007-08-09 at 08:59 +0800, Hugh Perkins wrote:
uestion on using gtk from haskell: how easy is it to integrate with glade? ie, can we directly bind glade form elements to haskell variables? How easy is it to bind events to glade form elements from within Haskell?
It's pretty easy, see the Gtk2Hs/Glade tutorial:
Indeed - the *hard* part seems to be figuring out how to run Glade on Windoze...

Indeed - the *hard* part seems to be figuring out how to run Glade on Windoze...
I did not dare to ask this question because I could not believe this was hard... So anybody know how to do this? Run Glade on Window$? -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andrew Coppin Sent: Thursday, August 09, 2007 7:31 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Pure functional GUI Duncan Coutts wrote:
On Thu, 2007-08-09 at 08:59 +0800, Hugh Perkins wrote:
uestion on using gtk from haskell: how easy is it to integrate with glade? ie, can we directly bind glade form elements to haskell variables? How easy is it to bind events to glade form elements from within Haskell?
It's pretty easy, see the Gtk2Hs/Glade tutorial:
Indeed - the *hard* part seems to be figuring out how to run Glade on Windoze... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

2007/8/9, Peter Verswyvelen
Indeed - the *hard* part seems to be figuring out how to run Glade on Windoze...
I did not dare to ask this question because I could not believe this was hard... So anybody know how to do this? Run Glade on Window$?
The google knows?? http://gladewin32.sourceforge.net/modules/news/ Frankly, I'm using Linux now, and even under windows (I must use it at work) I use vmware with ubuntu.. But not so long ago I ran glade on windows using stuff from this page. HTH, Radek. -- Przedszkole Miejskie nr 86 w Lodzi: http://www.pm86.pl/

Yeah I tried that one, but only the runtime, because I assumed that glade would be part of it, but I could not find it. I guess I should install the development version. Windows users look differently at these things, they expect all tools to be precompiled ;) I'll try again and dig deeper.
-----Original Message-----
From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Radoslaw Grzanka
Sent: Thursday, August 09, 2007 10:22 PM
To: Haskell-Cafe@haskell.org
Subject: Re: [Haskell-cafe] Pure functional GUI
2007/8/9, Peter Verswyvelen
Indeed - the *hard* part seems to be figuring out how to run Glade on Windoze...
I did not dare to ask this question because I could not believe this was hard... So anybody know how to do this? Run Glade on Window$?
The google knows?? http://gladewin32.sourceforge.net/modules/news/ Frankly, I'm using Linux now, and even under windows (I must use it at work) I use vmware with ubuntu.. But not so long ago I ran glade on windows using stuff from this page. HTH, Radek. -- Przedszkole Miejskie nr 86 w Lodzi: http://www.pm86.pl/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

2007/8/9, Peter Verswyvelen
Yeah I tried that one, but only the runtime, because I assumed that glade would be part of it, but I could not find it. I guess I should install the development version. Windows users look differently at these things, they expect all tools to be precompiled ;) I'll try again and dig deeper.
Runtime is enough.. But Glade is packaged separetly. http://gladewin32.sourceforge.net/modules/wfdownloads/viewcat.php?cid=2 I just cheked it and it works flawlessly (as far as my 1 minute test goes ;) ) (Oh. I seem to remember that I needed GTK runtime from THIS page. It didn't go nicely with runtime installed with "GIMP for windows" package.) Have fun, Radek -- Codeside: http://codeside.org/ Przedszkole Miejskie nr 86 w Lodzi: http://www.pm86.pl/

Another way to get glade on Windows is to download mono, which contains both gtk and glade. One advantage of getting it this way is you then have mono at your disposal for benchmarking ghc ;-) (Not that you'd benchmark a gui app, but it seems there are many people who still think that comparing haskell with non-gc'd imperative languages having a corruptable stack/heap, such as C, is meaningfull ;-) )

Radosław Grzanka wrote:
The google knows?? http://gladewin32.sourceforge.net/modules/news/
Ah - most optimal... Now finally I can try Glade. :-D
participants (7)
-
Andrew Coppin
-
Bulat Ziganshin
-
Duncan Coutts
-
Hugh Perkins
-
Marc Weber
-
Peter Verswyvelen
-
Radosław Grzanka