Em Ter, 2009-02-03 às 19:28 +0100, Axel Simon escreveu: > On Tue, 2009-02-03 at 15:03 -0200, Marco Túlio Gontijo e Silva wrote: > > > class Cast widget where > > > cast :: GObjectClass obj => obj -> widget > > > > > instance Cast Window where > > > cast = castToWindow > > > > Is it bad to have this Cast class in gtk2hs? > > Thus, using your class Cast, you'd still need to add a type > signature somewhere. This might be less of a hassle than using a > specific castToComboBoxEntry, but only in some cases. Unless you have a > very good example where the Cast class would be simpler than a castToFoo > function, I'd rather not add yet another layer of type classes.
I don't know if it's a very good example, but I usually use PatternSignatures, so my code would look like: let getWidget' :: (Cast widget, WidgetClass widget) => String -> IO widget getWidget' = getWidget glade (window :: Window) <- getWidget' "window" (cancel :: Button) <- getWidget' "cancel" (list :: TreeView) <- getWidget' "list" instead of: (window :: Window) <- getWidget' castToWindow "window" For me, it seems useful enough, but I don't think it would be a problem to have this class in a separate package, as it's not so useful for a lot of people. Thanks. -- marcot http://marcot.iaaeee.org/ ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel