1
votes

I have created an app that uses GTK via gi-gtk in Haskell, dependencies managed with stack (lts-9.2). I compiled it successfully on Fedora 26. Then I have successfully executed the binary on other Linux distributions as well.

After a while I wanted to compile the same application on other system (elementary OS). I cloned the repository, called stack setup in the project directory and then stack build. It complained about some missing dependencies so I installed them and finally, I got an error from GHC about my own code:

Not in scope: 'GTK.popoverPopdown'
Perhaps you meant one of these:
  'GTK.popoverModal' (imported from GI.Gtk)
  'GTK.popoverPosition' (imported from GI.Gtk)
Module 'GI.Gtk' does not export 'popoverPopdown'.

Why? As I look at the documentation (https://hackage.haskell.org/package/gi-gtk-3.0.17/docs/GI-Gtk-Objects-Popover.html) there is popoverPopdown but nothing like popoverModal or popoverPosition.

Then I switched to another machine with another Linux distribution (Ubuntu Studio) and got the same error. Finally I took a machine with Fedora 27, did the same and got another error (also inside my app code):

Couldn't match expected type 'Maybe b1'
            with actual type 'GTK.Image'
In the second argument of 'GTK.buttonSetImage', namely 'icon'
In a stmt of a 'do' block: btn `GTK.buttonSetImage` icon

Again the documentation (https://hackage.haskell.org/package/gi-gtk-3.0.17/docs/GI-Gtk-Objects-Button.html#g:26) claims something different than GHC. Could somebody explain to me what's going on?

Answering to one of the comments: Below are what GTK versions are installed in the mentioned systems. Nonetheless GHC complains about Haskell code and I thought all the Haskell code is downloaded from Stackage. Are any dependencies generated locally on my system during stack build?

  • Ubuntu Studio 16.04 LTS: libgtk2.0-0 v2.24.30, libgtk-3-0 v3.18.9
  • elementary OS: libgtk2.0-0 v2.24.30, libgtk-3-0 v3.18.9
  • Fedora 26: gtk2 v2.24.31, gtk3 v3.22.21
  • Fedora 27: gtk2 v2.24.32, gtk3 v3.22.26
1
gi-gtk isn't on Stackage. Perhaps your different machines are choosing a different version from Hackage, or whatever source you are using for gi-gtk. - Daniel Wagner
Now I've found that in gi-gtk v3.0.18 the signature of buttonSetImage was changed. But stack list-dependencies returns gi-gtk 3.0.17. - Adam Głowacki
Do the GTK versions differ between these systems? - Li-yao Xia
@AdamGłowacki Ah, seems you're right and I misinterpreted this search result. The big "Hoogle" title at the top should have tipped me off that the search had not done what I thought it had. - Daniel Wagner

1 Answers

2
votes

Ok, now I can see that (contrary to what I had thought before) Haskell-GTK bindings are generated on my computer, during building gi-gtk package. Indeed in GTK v3.18 there was nothing like gtk_popover_popdown, that's why Haskell function popoverPopdown was not generated at all. And I guess that it's similar with gtk_button_set_image.

Now I need to remember that this Stackage/Hackage package is of a different kind. I must track the precise version of GTK I am building my application with and not rely on stack in this matter.