Planned 0.13 release to add Text support

I have prepared a 0.13 release that will add support for using Text (for functions that currently only work with String). It does this with a new GlibString type class that has instances for both String and Text. All the functions that currently use String have been changed to use this type class instead. This allows you to switch your code easily from String to Text or use a mix of the two if you wish (but not in the same function call as it would make for more type inference issues).

This is a breaking change (hence the bump to 0.13). If you have issues with existing code then it will most likely be ambiguous type errors. The solution will probably be one of:

  • Stick with 0.12 for now - set an upper bound in the cabal file (existing code should really have a <0.13 upper bound for Gtk2Hs packages already).
  • Add type signatures - to help GHC infer the type of strings you are using. Leksah required the addition of around 20 type signatures.

I think the most common issue will probably be when Nothing is passed to a function, because GHC cannot infer the type of this Nothing. One solution is to change it to (Nothing :: Maybe String).

The 0.13 code is currently in the master branches of the various https://github.com/gtk2hs repositories. Please try it out and let us know if there is anything we need to address before releasing it to Hackage. We can still fix stuff after that, but it would be nice to know if there is anything major that we should address now.

Hamish

Leave a Reply