Re: Are windows just ordinary widgets?

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

> Now perhaps we want a common datatype "Widget" with functions
>      toWidget :: Widget w => w -> Widget
> and fromWidget :: Widget w => Widget -> Maybe w
> 
> Perhaps we want a datatype "Pane" (or "Control" or whatever) with
> 	toPane :: Pane p => p -> Pane
> and so on.

I don't see the point in this. If you have classes, then surely you
don't need the types?

> If I had a "Pane" datatype, I wouldn't really need the "Widget" 
> anymore, but of course, one can never know.
> The "Pane" datatype would be the natural place to implement a lot of 
> functionality at least on Mac OS, so if it's there, I'm happy, and I 
> could then implement a Widget datatype as a simple discriminated union 
> datatype. If there was no Pane datatype, the implementation for the 
> widget datatype would become slightly ugly and inelegant on Mac OS...

The obvious solution seems to be to use classes. E.g. operations on
menu bars would operate on the MenuBar class, i.e.

	doSomethingToMenuBar :: MenuBar w => w -> ...

For MacOS, a menu bar would be an instance of MenuBar. For Motif, it
would be an instance of both MenuBar and Widget. Code which is meant
to be portable would only use the MenuBar methods; Motif-specific code
could also use the Widget methods.

It seems to me that, as far as possible, the CGA should define (and
use) classes rather than types.

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