[Haskell-beginners] glib heterogenous hash table
john.obbele at gmail.com
Sun Sep 5 16:57:45 EDT 2010
Hi everyone !
To exercise my Haskell skills, I'm currently trying to bind
libxfconf-0 with Haskell. A small preview can be found on
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 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*,
I've tried to wrap the glib hash table in a haskell data type
> 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 C pointers (Ptr
CChar is ok but not Char or CChar).
Does anyone have a solution or some pointers on it ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/beginners/attachments/20100905/eab824c9/attachment.bin
More information about the Beginners