Idea for a very simple GUI llibrary

Hi, Here is a sketch for a library with these properties: -> Easy to test. All Haskell code can be tested in a text terminal. Also, testing code that uses the library can also be done without using a GUI. -> Extremely easy to document and use. -> Not even close to Gtk2hs power, but enough for small applications. -> Could be the first GUI to build on hackage :) What we need is: -> MyState. A user suplied type for application state. -> WidId. A user suplied type for widget identifiers. -> Gui wi. A type capable of describing an interface with all of its state. It's an instance of Eq. -> Event wi. A type for events. -> Prop. A type for properties than can related to a WidId. Running an application would be like this: main = runGUI initState -- An initial MyState. event -- :: MyState -> DiffTime -> Event WidId -> MyState props -- :: WidId -> [Prop] action -- :: MyState -> DiffTime -> IO (Maybe (MyState,Gui WidId)) timeout -- :: DiffTime DiffTime parameters for callbacks are always the time elapsed since application started. From initState and event, the implementation of runGUI can save a state that optionally changes with time. From props, it can get details on what to present in widgets associated with a WidId (selected state, picture to draw etc.). action presents a chance for using IO, and optionally change state and GUI description. timeout is the maximum time runGUI implementation is allowed to wait between calls to action. Examples for those types: newtype MyState = { lastUpdate :: DiffTime, builtGui :: Bool, earthCoordinates :: (Double,Double), map :: SVG, ... } data WidId = XCoord | YCoord | MapWindow | ReloadButton ... data Gui widid = TitleWindow (Gui widid) | Tabs [(String,Gui widid)] | PressButton String widid | Selection [String] widid | ... deriving Eq {- Eq is needed by runGUI to detect if GUI has changed after the last call to action. -} data Event widid = ButtonPressed widid | FileSelected String widid | OptionSelected String widid | ... data Prop widid = Active Bool | Text String | Draw SVG | ... I believe this can represent most kinds of simple applications, and be efficient enough for practical use. It's interesting that all of this can be designed, implemented and tested independent of runGUI implementation. Actually, if you want a pet project and want to write and design the Haskell part, I may probably be able to write runGUI for you :) Best, Maurício

Nice idea. I will try it if you write runGUI :-)
This is an imperative style library. For more Haskellian GUI library
ideas, see Fruit (http://www.haskell.org/fruit/) and TVs
(http://www.haskell.org/haskellwiki/TV). They may not pass the
"builds" constraint :-P
Luke
2009/11/22 Maurício CA
Hi,
Here is a sketch for a library with these properties:
-> Easy to test. All Haskell code can be tested in a text terminal. Also, testing code that uses the library can also be done without using a GUI.
-> Extremely easy to document and use.
-> Not even close to Gtk2hs power, but enough for small applications.
-> Could be the first GUI to build on hackage :)
What we need is:
-> MyState. A user suplied type for application state.
-> WidId. A user suplied type for widget identifiers.
-> Gui wi. A type capable of describing an interface with all of its state. It's an instance of Eq.
-> Event wi. A type for events.
-> Prop. A type for properties than can related to a WidId.
Running an application would be like this:
main = runGUI initState -- An initial MyState. event -- :: MyState -> DiffTime -> Event WidId -> MyState props -- :: WidId -> [Prop] action -- :: MyState -> DiffTime -> IO (Maybe (MyState,Gui WidId)) timeout -- :: DiffTime
DiffTime parameters for callbacks are always the time elapsed since application started.
From initState and event, the implementation of runGUI can save a state that optionally changes with time.
From props, it can get details on what to present in widgets associated with a WidId (selected state, picture to draw etc.).
action presents a chance for using IO, and optionally change state and GUI description.
timeout is the maximum time runGUI implementation is allowed to wait between calls to action.
Examples for those types:
newtype MyState = { lastUpdate :: DiffTime, builtGui :: Bool, earthCoordinates :: (Double,Double), map :: SVG, ... }
data WidId = XCoord | YCoord | MapWindow | ReloadButton ...
data Gui widid = TitleWindow (Gui widid) | Tabs [(String,Gui widid)] | PressButton String widid | Selection [String] widid | ... deriving Eq {- Eq is needed by runGUI to detect if GUI has changed after the last call to action. -}
data Event widid = ButtonPressed widid | FileSelected String widid | OptionSelected String widid | ...
data Prop widid = Active Bool | Text String | Draw SVG | ...
I believe this can represent most kinds of simple applications, and be efficient enough for practical use.
It's interesting that all of this can be designed, implemented and tested independent of runGUI implementation. Actually, if you want a pet project and want to write and design the Haskell part, I may probably be able to write runGUI for you :)
Best, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

You should also check out Fudgets and "Tangible Functional
Programming." Fudgets is a really old Haskell UI library concept;
Tangible FP is a recent Google talk about a UI library inspired by
Haskell types.
2009/11/22 Luke Palmer
Nice idea. I will try it if you write runGUI :-)
This is an imperative style library. For more Haskellian GUI library ideas, see Fruit (http://www.haskell.org/fruit/) and TVs (http://www.haskell.org/haskellwiki/TV). They may not pass the "builds" constraint :-P
Luke
2009/11/22 Maurício CA
: Hi,
Here is a sketch for a library with these properties:
-> Easy to test. All Haskell code can be tested in a text terminal. Also, testing code that uses the library can also be done without using a GUI.
-> Extremely easy to document and use.
-> Not even close to Gtk2hs power, but enough for small applications.
-> Could be the first GUI to build on hackage :)
What we need is:
-> MyState. A user suplied type for application state.
-> WidId. A user suplied type for widget identifiers.
-> Gui wi. A type capable of describing an interface with all of its state. It's an instance of Eq.
-> Event wi. A type for events.
-> Prop. A type for properties than can related to a WidId.
Running an application would be like this:
main = runGUI initState -- An initial MyState. event -- :: MyState -> DiffTime -> Event WidId -> MyState props -- :: WidId -> [Prop] action -- :: MyState -> DiffTime -> IO (Maybe (MyState,Gui WidId)) timeout -- :: DiffTime
DiffTime parameters for callbacks are always the time elapsed since application started.
From initState and event, the implementation of runGUI can save a state that optionally changes with time.
From props, it can get details on what to present in widgets associated with a WidId (selected state, picture to draw etc.).
action presents a chance for using IO, and optionally change state and GUI description.
timeout is the maximum time runGUI implementation is allowed to wait between calls to action.
Examples for those types:
newtype MyState = { lastUpdate :: DiffTime, builtGui :: Bool, earthCoordinates :: (Double,Double), map :: SVG, ... }
data WidId = XCoord | YCoord | MapWindow | ReloadButton ...
data Gui widid = TitleWindow (Gui widid) | Tabs [(String,Gui widid)] | PressButton String widid | Selection [String] widid | ... deriving Eq {- Eq is needed by runGUI to detect if GUI has changed after the last call to action. -}
data Event widid = ButtonPressed widid | FileSelected String widid | OptionSelected String widid | ...
data Prop widid = Active Bool | Text String | Draw SVG | ...
I believe this can represent most kinds of simple applications, and be efficient enough for practical use.
It's interesting that all of this can be designed, implemented and tested independent of runGUI implementation. Actually, if you want a pet project and want to write and design the Haskell part, I may probably be able to write runGUI for you :)
Best, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Has there been "real world" adoption of any of these, in the shape of
a moderately complex end-user application that is not just a library
demo?
martin
On Mon, Nov 23, 2009 at 8:48 AM, Keith Holman
You should also check out Fudgets and "Tangible Functional Programming." Fudgets is a really old Haskell UI library concept; Tangible FP is a recent Google talk about a UI library inspired by Haskell types.
2009/11/22 Luke Palmer
: Nice idea. I will try it if you write runGUI :-)
This is an imperative style library. For more Haskellian GUI library ideas, see Fruit (http://www.haskell.org/fruit/) and TVs (http://www.haskell.org/haskellwiki/TV). They may not pass the "builds" constraint :-P
Luke
2009/11/22 Maurício CA
: Hi,
Here is a sketch for a library with these properties:
-> Easy to test. All Haskell code can be tested in a text terminal. Also, testing code that uses the library can also be done without using a GUI.
-> Extremely easy to document and use.
-> Not even close to Gtk2hs power, but enough for small applications.
-> Could be the first GUI to build on hackage :)
What we need is:
-> MyState. A user suplied type for application state.
-> WidId. A user suplied type for widget identifiers.
-> Gui wi. A type capable of describing an interface with all of its state. It's an instance of Eq.
-> Event wi. A type for events.
-> Prop. A type for properties than can related to a WidId.
Running an application would be like this:
main = runGUI initState -- An initial MyState. event -- :: MyState -> DiffTime -> Event WidId -> MyState props -- :: WidId -> [Prop] action -- :: MyState -> DiffTime -> IO (Maybe (MyState,Gui WidId)) timeout -- :: DiffTime
DiffTime parameters for callbacks are always the time elapsed since application started.
From initState and event, the implementation of runGUI can save a state that optionally changes with time.
From props, it can get details on what to present in widgets associated with a WidId (selected state, picture to draw etc.).
action presents a chance for using IO, and optionally change state and GUI description.
timeout is the maximum time runGUI implementation is allowed to wait between calls to action.
Examples for those types:
newtype MyState = { lastUpdate :: DiffTime, builtGui :: Bool, earthCoordinates :: (Double,Double), map :: SVG, ... }
data WidId = XCoord | YCoord | MapWindow | ReloadButton ...
data Gui widid = TitleWindow (Gui widid) | Tabs [(String,Gui widid)] | PressButton String widid | Selection [String] widid | ... deriving Eq {- Eq is needed by runGUI to detect if GUI has changed after the last call to action. -}
data Event widid = ButtonPressed widid | FileSelected String widid | OptionSelected String widid | ...
data Prop widid = Active Bool | Text String | Draw SVG | ...
I believe this can represent most kinds of simple applications, and be efficient enough for practical use.
It's interesting that all of this can be designed, implemented and tested independent of runGUI implementation. Actually, if you want a pet project and want to write and design the Haskell part, I may probably be able to write runGUI for you :)
Best, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Nice idea. I will try it if you write runGUI :-)
Sure, just let me know :) If this is to be done, I think it's better that the person writing the Haskell code do not write runGUI, so the implementation details wouln't discourage ideas that make life easier for users.
This is an imperative style library. For more Haskellian GUI library ideas, see Fruit (http://www.haskell.org/fruit/) and TVs (http://www.haskell.org/haskellwiki/TV). They may not pass the "builds" constraint :-P
I do remember looking at TVs and also Fudgets as sugested by Keith. But there's a unfilled hole for a library that's conceptually simple. I believe that with the library I described users (begginers in Haskell?) could even use QuickCheck and HUnit with their GUI code. Thanks for your comments, Maurício

Minor aside.
-> Could be the first GUI to build on hackage :)
If you have wxWidgets installed, the new fully Cabalised wxHaskell builds just fine. It's quite handy/refreshing for 'cabal install wx' to finally "just work" :-) Unless you mean "build on the Hackage server" which should also be possible in principle, although the wxHaskell folks may want to have a quick look at http://hackage.haskell.org/packages/archive/wxcore/0.12.1.2/logs/failure/ghc... -- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9

Hi folks, my name is Juan Maiz and i'm starting to study Haskell (again).
Is anyone from Brazil in the list?i
I'm currently reading The Haskell Road to Logic, Maths and Programming and
having a lot of (geek) fun. By the way, i found this:
http://www.mail-archive.com/haskell-cafe@haskell.org/msg45406.html . It was
sent by Mattias Bengtsson. I made something similar using Ruby's Treetop,
with the difference that my concern was to validate and generate truth
tables for formulas using Unicode.
So... my first noob question to the list: What is the difference of Unicode
support in HUGS and GHCI ? In GHCI I can do something like:
(∧) = (&&)
Prelude> True ∧ False
*False*
(The carachter is the unicode for conjunction U+2227)
But in HUGS i can't. It says:
ERROR "conjunction.hs":1 - Unrecognised character `\8743'
Somebody?
On Mon, Nov 23, 2009 at 1:26 PM, Eric Kow
Minor aside.
-> Could be the first GUI to build on hackage :)
If you have wxWidgets installed, the new fully Cabalised wxHaskell builds just fine. It's quite handy/refreshing for 'cabal install wx' to finally "just work" :-)
Unless you mean "build on the Hackage server" which should also be possible in principle, although the wxHaskell folks may want to have a quick look at
http://hackage.haskell.org/packages/archive/wxcore/0.12.1.2/logs/failure/ghc...
-- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAksKqZgACgkQBUrOwgisBPmGBQCfRnW1dcLV3JaLi2p5PppsO+XK 7uwAoMVhCV00sdNctgAjw2TyQGs6TyNv =tnXa -----END PGP SIGNATURE-----
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Juan Maiz Lulkin Flores da Cunha --------------------------------------------------------------------------- Softa Consultoria para Desenvolvimento http://www.softa.com.br http://www.mailee.me - Finalmente e-mail marketing 2.0 http://www.linkedin.com/in/juanmaiz http://workingwithrails.com/recommendation/new/person/9354-juan-maiz “The most exciting breakthroughs of the 21st century will not occur because of technology but because of an expanding concept of what it means to be human” John Naisbitt

Forgot the URL: http://github.com/softa/rl
On Mon, Nov 23, 2009 at 2:01 PM, Juan Maiz
Hi folks, my name is Juan Maiz and i'm starting to study Haskell (again). Is anyone from Brazil in the list?i
I'm currently reading The Haskell Road to Logic, Maths and Programming and having a lot of (geek) fun. By the way, i found this: http://www.mail-archive.com/haskell-cafe@haskell.org/msg45406.html . It was sent by Mattias Bengtsson. I made something similar using Ruby's Treetop, with the difference that my concern was to validate and generate truth tables for formulas using Unicode.
So... my first noob question to the list: What is the difference of Unicode support in HUGS and GHCI ? In GHCI I can do something like:
(∧) = (&&) Prelude> True ∧ False *False*
(The carachter is the unicode for conjunction U+2227)
But in HUGS i can't. It says:
ERROR "conjunction.hs":1 - Unrecognised character `\8743'
Somebody?
On Mon, Nov 23, 2009 at 1:26 PM, Eric Kow
wrote: Minor aside.
-> Could be the first GUI to build on hackage :)
If you have wxWidgets installed, the new fully Cabalised wxHaskell builds just fine. It's quite handy/refreshing for 'cabal install wx' to finally "just work" :-)
Unless you mean "build on the Hackage server" which should also be possible in principle, although the wxHaskell folks may want to have a quick look at
http://hackage.haskell.org/packages/archive/wxcore/0.12.1.2/logs/failure/ghc...
-- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAksKqZgACgkQBUrOwgisBPmGBQCfRnW1dcLV3JaLi2p5PppsO+XK 7uwAoMVhCV00sdNctgAjw2TyQGs6TyNv =tnXa -----END PGP SIGNATURE-----
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Juan Maiz Lulkin Flores da Cunha --------------------------------------------------------------------------- Softa Consultoria para Desenvolvimento http://www.softa.com.br http://www.mailee.me - Finalmente e-mail marketing 2.0 http://www.linkedin.com/in/juanmaiz http://workingwithrails.com/recommendation/new/person/9354-juan-maiz “The most exciting breakthroughs of the 21st century will not occur because of technology but because of an expanding concept of what it means to be human” John Naisbitt
-- Juan Maiz Lulkin Flores da Cunha --------------------------------------------------------------------------- Softa Consultoria para Desenvolvimento http://www.softa.com.br http://www.mailee.me - Finalmente e-mail marketing 2.0 http://www.linkedin.com/in/juanmaiz http://workingwithrails.com/recommendation/new/person/9354-juan-maiz “The most exciting breakthroughs of the 21st century will not occur because of technology but because of an expanding concept of what it means to be human” John Naisbitt

Hello Juan, Monday, November 23, 2009, 7:01:39 PM, you wrote:
But in HUGS i can't. It says: ERROR "conjunction.hs":1 - Unrecognised character `\8743'
hugs doesn't accept unicode source files there are lots of unicode support problems in both haskell implementations. probably we have some wiki page what describes current state -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Yeah, I found many pages about it (some making fun of a interpreter that
"follows all H98 spec"). But i'm still crawling to understand who is who and
what are the pages to get help in Haskell community :D
And well, tha's bad, i've really enjoyed Hugs, but i'll have to use GHC
instead :D
Thanks.
On Mon, Nov 23, 2009 at 2:14 PM, Bulat Ziganshin
Hello Juan,
Monday, November 23, 2009, 7:01:39 PM, you wrote:
But in HUGS i can't. It says: ERROR "conjunction.hs":1 - Unrecognised character `\8743'
hugs doesn't accept unicode source files
there are lots of unicode support problems in both haskell implementations. probably we have some wiki page what describes current state
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
-- Juan Maiz Lulkin Flores da Cunha --------------------------------------------------------------------------- Softa Consultoria para Desenvolvimento http://www.softa.com.br http://www.mailee.me - Finalmente e-mail marketing 2.0 http://www.linkedin.com/in/juanmaiz http://workingwithrails.com/recommendation/new/person/9354-juan-maiz “The most exciting breakthroughs of the 21st century will not occur because of technology but because of an expanding concept of what it means to be human” John Naisbitt

Thinking of a parallel with Java for a second, is there a GUI library out there that's structured like Java Swing? Meaning, there is a GUI library that has a small platform-specific GUI foundation (e.g. a per platform implementation of the core AWT functionality) and the rest of the functionality is pure haskell? Supporting cross platform guis is often a bit ... complicated. Java attempted to resolve their debug-everywhere nightmare with AWT by making the per-platform bit as small as possible, and building everything else in Java. I guess in theory gtk and wxWidgets take on this support burden, but you do get some fairly hefty imperative apis as a result. Perhaps it would make sense to focus efforts on stabilising a small 'core gui' library that can act as the foundation stone for all manner of pure haskell gui libraries?* Or perhaps this already exists? Just a thought. Cheers, Sam

Thinking of a parallel with Java for a second, is there a GUI library out there that's structured like Java Swing? Meaning, there is a GUI library that has a small platform-specific GUI foundation (e.g. a per platform implementation of the core AWT functionality) and the rest of the functionality is pure haskell?
I believe the plan I sugested in the begining of the thread could be easily made into what you want. It could not be, however, as powerfull as the mainstream libraries. Maurício

I dream of mostly generated bindings for Haskell to the native windowing
toolkit.
Eclipse's SWT proves, this is a viable path.
See my proposal here:
http://www.reddit.com/r/haskell_proposals/comments/9w7nk/adjust_the_swt_bind...
Sam Martin
Thinking of a parallel with Java for a second, is there a GUI library out there that's structured like Java Swing? Meaning, there is a GUI library that has a small platform-specific GUI foundation (e.g. a per platform implementation of the core AWT functionality) and the rest of the functionality is pure haskell?
Supporting cross platform guis is often a bit ... complicated. Java attempted to resolve their debug-everywhere nightmare with AWT by making the per-platform bit as small as possible, and building everything else in Java.
I guess in theory gtk and wxWidgets take on this support burden, but you do get some fairly hefty imperative apis as a result. Perhaps it would make sense to focus efforts on stabilising a small 'core gui' library that can act as the foundation stone for all manner of pure haskell gui libraries?*
Or perhaps this already exists?
Just a thought.
Cheers, Sam
participants (9)
-
Bulat Ziganshin
-
Eric Kow
-
haskell@kudling.de
-
Juan Maiz
-
Keith Holman
-
Luke Palmer
-
Martin DeMello
-
Maurício CA
-
Sam Martin