
Wolfgang Thaller wrote:
[...] The question is, to what extent do we use type classes to achieve this, etc... I would advocate specifc types for specific widget classes (e.g. Button, ScrollBar, etc.), just because it's the Haskell Way ;-) .
Glynn Clements
Unfortunately, it's not the "typical GUI toolkit" way; at least, both Xt and Qt have an OO-style class hierarchy. While they differ on the exact hierarchy, both have a generic "Widget" class, with operations which apply to all widgets.
Since Haskell has a different type system from OO languages, we simply cannot do things the 'typical GUI toolkit' way. Instead, we have to find a way to encode as much as possible of the foreign type system in Haskell's type system. One way to do this is the one Wolfgang advocates: we provide a bunch of separate datatypes for each leaf node in the OO class hierarchy, we provide a class for each non-leaf node (or 'abstract class' if you prefer) in the OO class hierarchy and we use inheritance between the Haskell classes and instance declarations to encode the inheritance relations in the OO class hierarchy. This approach suffers a bit from being tedious to specify all the instances you need for each datatype but otherwise works pretty well. There are other ways, of course, and we should explore them. Perhaps you could make a concrete proposal Glynn? -- Alastair Reid alastair@reid-consulting-uk.ltd.uk Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/