[Haskell-cafe] gui libs? no thanks, i'm just browsing.. ;-)

Claus Reinke claus.reinke at talk21.com
Wed Jul 18 19:12:12 EDT 2007

gui libs are wonderful, but haskell sometimes has too few 
and sometimes has too many. and those we have do not 
work with every haskell implementation. and when they do
work (usually with ghc, these days), they need to be rebuilt
whenever ghc is updated, even if the gui lib hasn't changed
at all (one gui lib binding per ghc version). still, we put up 
with that when we need all those gui lib features, because 
we have to, and we're happy to live in one of those periods
when there are such bindings to full-featured gui libraries.

but what about quick and dirty/cheap and cheerful graphics?
over the years, HGL/SOEGraphics has served as a persistent 
reminder that things keep changing, and that when they do, 
something breaks. even if all people want to do is draw some
simple graphics, or animations.

i don't have a solution, but i'd like to throw another alternative
into the ring, based on the ongoing fight between web browsers
and other guis for world dominance..

the idea is well known: build your app as a server, and put
an ajax-based gui in front of it, even if server and browser
run on the same machine.

attached is a silly quick&dirty demo of some of the relevant concepts,
including a fake haskell http-server, an html/canvas/httprequest/
javascript-based gui, and some simple graphics/buttons/text. 

tested on windows, with opera 9.01 and ghc 6.6.1. it will probably 
not work with other browsers, but it should work with opera on 
other platforms, or with other haskell implementations supporting 
Network. (you might have to hardcode the file name at the top of 
the source if not using ghc; to make it work with other browsers, 
you need workarounds for standard browser incompatibilities)

to run, load Canvas.hs into ghci and call main. then start up opera, 
and visit 'http://localhost:8000/start' (to change that port number, 
change both 'main' in the haskell source, and 'get' in the html 
source). that should yield an html page with further instructions.

have a look, and please let me know if it works on your os/
haskell implementation, and what you think about the idea.

i won't do it myself, but perhaps someone could code up 
SOEGraphics based on this?-) and if not, this might still help
out some of you who need simple low-overhead guis (things
can get hairy very quickly if you need more than simple guis)?
some of you might have to fight through implementing browser-
based guis for their day jobs anyhow, but may want to put haskell 
behind those guis; or you might find haskell prototyping an easier
sell, if the gui can be reused for the "real" implementation..


further reading/download:

Opera browser (windows, macos, solaris, linux, ..)

html 5 -- working draft, june 2007 (3.14.11 canvas element)

canvas tutorial

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Canvas.hs
Type: application/octet-stream
Size: 8707 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070719/db6f281b/Canvas.obj

More information about the Haskell-Cafe mailing list