Attached is a darcs patch for the function toResponse and
fromResponse, which convert ResponseId and integer values.
toResponse, which converts an integer i coming from C-land into a
Haskell value of type ResponseId, was missing cases for i = 0, or i <
-11. The GTK docs say the following about the C enum type
All predefined values are negative, GTK+ leaves positive values for
application-defined response ids.
This of course says nothing about the value zero. In C, a response id
of 0 passes through silently, while in gtk2hs it causes a pattern
match error. Not sure if the intention here is to make unspecified =
fail. Personally I think it should just be left as unspecified, so
that the pattern match error is pushed out of the library and into the
user's code. Note that in glade, it is possible to set the response id
to any integer, and the _default_ response id for buttons is 0. (At
least in my version of glade.) So it is possible to cause this pattern
match error using only gtk2hs and glade.
This patch makes all undefined response ids into ResponseUser values.
In general, what is the consensus among gtk2hs devs about unspecified
behavior? Does the library try to fail as early as possible, or just
ignore errors and try to match the C behavior? Was this pattern match