Take the 2-minute tour ×

I have been working through the book The Haskell School of Expression by Paul Hudak and using its associated gtk based graphics library Graphics.SOE.Gtk (link to documentation) for small 2D drawing experiments.

This library is very basic however, and only really has the ability to draw shapes. At the moment I am writing some programs which require particular GUI widgets such as buttons and text boxes. My question is: Is it possible to use the drawing capabilities of the SOE library alongside the GUI widgets found in gtk2hs? E.g be able to write a program where I can click a button which causes the program to draw a triangle shape in another container in the same window.

I have searched online for a way to do this, but most tutorials suggest using cairo to do any graphics drawing with Gtk ; SOE graphic's API has the appearance of being a relatively self contained thing.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

No, there's not a really meaningful way for soegtk and regular gtk to interact. The reason is that soegtk keeps all its data types abstract; this is good practice from a "makes it easy for the implementor to change the implementation without changing the interface" point of view but it can be a bit limiting from a "I'm just a user that wants to munge things in ways the interface don't promise to allow" point of view.

You could:

  • make a copy of the text of the single module in the soegtk package, and adjust the export line to export more things and happily break any abstraction boundaries you dislike
  • interact non-meaningfully; e.g. have your gtk button open an soegtk window with the graphics of interest
  • learn a different drawing library, say, cairo or diagrams
share|improve this answer
Could you possibly elaborate on what you mean by the first option? I am fairly new to this. What extra things could I export to make this workable? Or is the most sensible option just to suck it up and learn cairo? –  Craig Innes Jan 5 '13 at 21:45
@CraigInnes I don't mean anything sophisticated. Just open up the source code of the module, then copy and paste into your own source file. Then you can make any changes to it you like (though, if you want to be legal about it, you will need to check the license and make sure you understand it). –  Daniel Wagner Jan 6 '13 at 2:51
add comment

Your Answer


