Hi everyone !

Sorry for the double post between haskell-beginners and this
mailing-list but I am having trouble binding some part of Glib
and Xfconf to Haskell.

Below is my original post:
===================================================================
To exercise my Haskell skills, I'm currently trying to bind
libxfconf-0 with Haskell. A small preview can be found on
patch-tag[0].

[0]: https://patch-tag.com/r/obbele/xfconf/home

Since XFCE projects rely heavily on glib, I am borrowing (lots
of) code from the gtk2hs package(s). I am still having issues
with gobject casts and foreign pointer finalizers, but lets focus
on GHashTable for now.

For those who are not familiar with glib (neither I am),
GHashTable[1] are hashes with homogenous key types but values of
arbitrary types. In xfconf, keys are all cstring but values can
be any type of gpointers (gchar *, gint*, gdouble*, widget*,
struct* ?).

[1]: http://library.gnome.org/devel/glib/stable/glib-Hash-Tables.html

I've tried to wrap the glib hash table in a haskell data type
this way:

> data GHashTable k v = GHashTable GHashTablePtr

The GHashTablePtr is our Haskell foreign pointer, courtesy
of C→HS. It is bound later with a g_hash_table_destroy finalizer
in order to (automatically) manage memory .

My real problems are:
- I cannot simply map (GHashTable k v) to a (Data.Map.Map k v)

- I don't know how to constraint k and v to be of type (Ptr a) (Ptr
  CChar is ok but not Char or CChar). I remebered from RWH that
  type constraints on data type declarations are evil, so
  should I just let things be this way ?

Does anyone have a solution or some pointers on it ?
===================================================================

Thanks for your efforst on glib/gtk2hs and
thanks for your time,
/John

Attachment: pgpYPhWS7qIoO.pgp
Description: PGP signature

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to