Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Haskell-cafe] Idea for a very simple GUI llibrary

1 view
Skip to first unread message

Maurí­cio CA

unread,
Nov 22, 2009, 7:19:57 PM11/22/09
to haskel...@haskell.org
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
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Luke Palmer

unread,
Nov 22, 2009, 7:59:35 PM11/22/09
to Maurí­cio CA, haskel...@haskell.org
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 <mauricio...@gmail.com>:

Keith Holman

unread,
Nov 22, 2009, 10:18:34 PM11/22/09
to Luke Palmer, haskel...@haskell.org, Maurí­cio CA
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 <lrpa...@gmail.com>:

Martin DeMello

unread,
Nov 23, 2009, 3:50:56 AM11/23/09
to Keith Holman, Maurí­cio CA, haskel...@haskell.org
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

Maurí­cio CA

unread,
Nov 23, 2009, 5:38:22 AM11/23/09
to haskel...@haskell.org
> 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,

Eric Kow

unread,
Nov 23, 2009, 10:26:46 AM11/23/09
to haskel...@haskell.org
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-6.10

--
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9

signature.asc

Juan Maiz

unread,
Nov 23, 2009, 11:02:06 AM11/23/09
to haskel...@haskell.org
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/haskel...@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?

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAksKqZgACgkQBUrOwgisBPmGBQCfRnW1dcLV3JaLi2p5PppsO+XK
> 7uwAoMVhCV00sdNctgAjw2TyQGs6TyNv
> =tnXa
> -----END PGP SIGNATURE-----


>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskel...@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

unread,
Nov 23, 2009, 11:08:05 AM11/23/09
to haskel...@haskell.org
Forgot the URL: http://github.com/softa/rl

Bulat Ziganshin

unread,
Nov 23, 2009, 11:14:55 AM11/23/09
to Juan Maiz, haskel...@haskell.org
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.Z...@gmail.com

Juan Maiz

unread,
Nov 23, 2009, 11:19:27 AM11/23/09
to Bulat Ziganshin, haskel...@haskell.org
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
<bulat.z...@gmail.com>wrote:

> 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.Z...@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

Sam Martin

unread,
Nov 23, 2009, 1:05:06 PM11/23/09
to haskel...@haskell.org

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

Maurí­cio CA

unread,
Nov 23, 2009, 5:11:54 PM11/23/09
to haskel...@haskell.org
> 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

has...@kudling.de

unread,
Nov 24, 2009, 7:18:49 AM11/24/09
to Sam Martin, haskel...@haskell.org
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_binding_generators_for_haskell/

Sam Martin <sam.m...@geomerics.com> hat am 23. November 2009 um 19:04
geschrieben:

0 new messages