Gtk2Hs: Ticket #1158: Widgets should implement Eq and Ord. <blockquote> <p> When using GTK+ from a typical imperative language such as C++, it's </p> </blockquote> <p> occasionally useful to use the object identity of a widget: for instance, you might want to create a set of "main" windows and terminate the program only when all of them close. Since widgets are represented by pointers, this is straightforward, and they can be stored in any standard container class (such as std::set). </p> <blockquote> <p> Unfortunately, the Haskell binding doesn't expose this information. </p> </blockquote> <p> It would be nice if GTK+ objects had instances of Ord and Eq based on pointer identity. Then they could, e.g., be stored in Data.Set.Set objects. </p> <blockquote> <p> (I know this can be worked around; it's just something that would </p> <blockquote> <p> save a little trouble) </p> </blockquote> </blockquote> <blockquote> <p> Daniel </p> </blockquote> <p> Reported on Debian BTS: <a class="ext-link" href=""><span class="icon"></span></a> </p> en-us Gtk2Hs Trac 0.11.1 pgavin Fri, 24 Apr 2009 17:34:49 GMT comment added; milestone set; owner changed <ul> <li><strong>owner</strong> changed from <em>somebody</em> to <em>axel</em> </li> <li><strong>milestone</strong> set to <em>0.10.2</em> </li> </ul> <p> I have some (purely pedantic) reservations with putting Widgets in Ord, but Eq should be fine. </p> <p> Axel? </p> Ticket axel Sun, 26 Apr 2009 15:43:27 GMT comment added; resolution set; status changed <ul> <li><strong>status</strong> changed from <em>new</em> to <em>closed</em> </li> <li><strong>resolution</strong> set to <em>fixed</em> </li> </ul> <p> Hm, Ord makes me hesitate a bit since it could lead to code that is compiled but doesn't make any sense, but the same holds for Eq if people think of an object as if it is a pure value (like a graphics context GC, for example). However, there is a general need, I think, to compare objects for pointer equality, for instance, when extracting the current widget from a notebook which needs to be compared to existing widgets. </p> <p> So, I've amended the type hierarchy generator to add Ord and Eq instance for all types except those that have a noEq attribute in hierarchy.list (this is a new tag). I did this because <a class="missing wiki" href="" rel="nofollow">ForeignPtr?</a> and Ptr also have Eq and Ord instances. Thus, it must be good. </p> Ticket