haskellcomboboxgtk2hs

ComboBox in Gtk2hs compiling error


How can I handle a ComboBox with Gtk2hs? On this page I found a solution:

store <- listStoreNew ["green", "yellow", "..."]
comboElem <- comboBoxNewWithModel store
ren <- cellRendererTextNew
cellLayoutPackEnd comboElem ren True
cellLayoutSetAttributes comboElem ren store
  (\txt -> [cellText := Just txt])

However while compiling I get this error (which occurs in the last line of my code example):

Main.hs:36:17:
No instance for (System.Glib.UTFString.GlibString (Maybe [Char]))
  arising from a use of ‘cellText’
In the first argument of ‘(:=)’, namely ‘cellText’
In the expression: cellText := Just txt
In the expression: [cellText := Just txt]

How can I fix the problem?

Thanks in advance


Solution

  • GlibString Doesn't appear to have an instance for Maybe String. It may have at one point, but you should be able to just use cellText := txt instead. If for whatever reason you need to use a Maybe String, you could implement the instance yourself.