
Hi everyone ! 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 C pointers (Ptr CChar is ok but not Char or CChar). Does anyone have a solution or some pointers on it ? regards, /John

Hello! I don't know how many Gtk2Hs hackers lurk around the beginners list. You should probably repost your question to Gtk2Hs' mailing list, see [1]. [1] http://www.haskell.org/gtk2hs/documentation/#help Cheers! -- Felipe.
participants (2)
-
Felipe Lessa
-
John Obbele