Re: Common GUI API : What would the code look like?

Glynn Clements <[email protected]>
Newsgroups gmane.comp.lang.haskell.gui
Message-ID <[email protected]>
David Sankel wrote:

> Questions ::
> 1) How does the interface look in Test_midlevel.hs? 
> Is there any critiques in
>   regard to using this style in CGA (Common GUI API)?

1. Widgets aren't being given names. This makes it impossible to refer
to them from outside of the code. It also eliminates the possibility
of implementing a useable Xt (e.g. Motif) backend. Toolkits which
don't name widgets can just ignore the name.

2. Widget properties (label, position, dimension) are being embedded
in the code, which is a bad idea. This point is closely tied in with
point 1.

3. Personally, I would prefer a generic widget creation function,
rather than a different function for each type of widget. E.g. Xt has
XtCreateWidget(), with the widget class being passed as an argument.
A more Haskell-ish approach would be to use typeclasses, e.g.:

	class Widget a where
		create :: String -> a -> [Property] -> IO a
	--	create name parent properties = ...

Of course, you can always provide type-specific constructors in
addition; doing the reverse is more involved.

-- 
Glynn Clements <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.