The newAttrFromUIntProperty type functions were using Int instead of
Word.There were a couple other similar minor errors, such as using
GType.uint for the Char properties, and UChar properties were missing.
From: Axel Simon <Axel.S<imon@en...> - 2009-11-21 11:00:42
On Fri, 2009-11-20 at 19:27 -0500, Matt Arsenault wrote:
> The newAttrFromUIntProperty type functions were using Int instead of
> Word.There were a couple other similar minor errors, such as using
> GType.uint for the Char properties, and UChar properties were missing.
Thanks for your patch. However, I think in Haskell, it is very common to
use Int even if a value is guaranteed to be unsigned. For instance,
length :: [a] -> Int returns an Int even though the length of a list can
never be negative. We follow this convention in Gtk2Hs since otherwise
(and in contrast to C) you need to sprinkle fromIntegral everywhere in
your program which rather obfuscates the code.
While it could be that we get wrong values for very large numbers (which
will become negative when represented by Int), this is already the case
for Int since according to the Haskell standard, Int does not have to
have more than (I think) 29 bits or so. Thus, even converting a CInt to
a Haskell Int is prone to incorrect representation.
As to UChar, I don't think there are any properties that we bind that
are of this type. Since the modules in Glib are only really used to
create the bindings in Gtk.* and other modules, we only bind things we
Thus, what you've repaired is a deliberate design choice that is meant
to make the life of an application developer easier. Hence, I think its
better not to apply your patch.