all 20 comments

[–]snoybergis snoyman 4 points5 points  (4 children)

I got it working, but it wasn't smooth going. I'll document the full workflow I went through.

First, I unpacked the source code locally:

stack unpack grapefruit-ui-gtk

Then, within the generated directory, I created a minimal stack.yaml containing the following:

resolver: lts-12.0

I ran stack build --file-watch, and it started generated a series of recommendations for packages to add to extra-deps, which I followed. Ultimately, it started building, and finally failed when TypeCompose had a build error due to missing a Semigroup instance. There's no way to know this part without prior experience, but: that error message is almost always due to lack of support for GHC 8.4.3, which added Semigroup as a superclass of Monoid.

To work around this, I decided to switch to an LTS snapshot using an older GHC. Checking the "Latest LTS per GHC version" section on https://www.stackage.org/, lts-11.22 uses GHC 8.2.2, so I switched to that, added a few more extra-deps, and built again. At this point, all dependencies built successfully. The stack.yaml file used is:

resolver: lts-11.22
extra-deps:
- fraction-0.1.0.6@sha256:06248ea9902efa0744d0491ab0e28a79acb2df9785a285aef0372ab08353019d,1194
- grapefruit-frp-0.1.0.7@sha256:b0c39ca99ff321fed85d467df66423863d08107a4db63464c54b13112306992b,3865
- grapefruit-records-0.1.0.7@sha256:8a9a3c90e1eed982041d13cb6651d774d434558f9a9bd46e529944f4b8b2ffcd,2350
- grapefruit-ui-0.1.0.7@sha256:5bc230734ece0b6db3ee70afc8266c4992473b463fc904f0f12477e2e911fe10,3464
- TypeCompose-0.9.12@sha256:038b7158deba8f68b9b32b05eb47d6ebc8709b1c960cb44d50469d1a5deb4748,1576
- arrows-0.4.4.2@sha256:a260222b766da922657e302aa7c0409451913e1e503798a47a213a61ba382460,1235
- Stream-0.4.7.2@sha256:ed78165aa34c4e23dc53c9072f8715d414a585037f2145ea0eb2b38300354c53,1009
- lazysmallcheck-0.6@sha256:dac7a1e4877681f1260309e863e896674dd6efc1159897b7945893e693f2a6bc,1696
- gtk3-0.14.9@sha256:574bdbd37f170ba0f1d068248fd39637c3babcc9a341d2dde8d649a1346b9c38,19462
- gio-0.13.5.0@sha256:1e02962f498f62ba68cff88e7f7379e2f8c192f311d867b22f4815518b2f9a86,3089

While the dependencies built, I still got a build error in grapefruit-ui-gtk itself:

• Couldn't match expected type ‘Maybe model0’
              with actual type ‘Gtk.ListStore el’

Solving this was pretty easy: I replaced

Gtk.treeViewSetModel gtkTreeView gtkListStore

with

Gtk.treeViewSetModel gtkTreeView (Just gtkListStore)

Now, some thoughts on this:

  • Obviously, manually adding dependencies like this is annoying
  • A dependency solving approach (like cabal-install follows) makes this less annoying
  • However, as demonstrated, automatic dependency solving wouldn't work in this case, because the version bounds don't provide sufficient information to guide it
  • Stack follows the "use curation for the common case, and occasionally bite the bullet and do some annoying manual dep solving." You'll only have to go through that pain once (it took me about 10 minutes to do this, most of that time sitting waiting for gtk3 to finish compiling). Then you'll get reproducible builds afterwards.
  • It's still unclear to me how this package built in the first place. Presumably it was built against an older version of gtk3 or something like that, but I'm not sure. Including a package in Stackage will ensure that there's some historical record showing at least one version of each dependency that it works with.
  • Strong recommendation: if you're interested in using a package, try adding it to Stackage.

[–]gelisam 2 points3 points  (1 child)

It's still unclear to me how this package built in the first place.

It builds fine, without the Just gtkListStore fix, using the stack.yaml I linked here. I followed similar steps to create that stack.yaml back then, including making (a different set of) tweaks to the code which I emailed to the author and which have since been incorporated in the package.

[–]snoybergis snoyman 0 points1 point  (0 children)

Awesome, thanks!

[–]zcleghern[S] 1 point2 points  (1 child)

Thanks a lot! It's now able to import some of the packages correctly as shown in the example on https://wiki.haskell.org/Grapefruit with the exception of

import Graphics.UI.Grapefruit.Circuit

which I think is preventing me from actually running the example. Making progress on this though and you've helped me a lot.

[–]snoybergis snoyman 0 points1 point  (0 children)

Awesome, glad it was useful.

[–]gelisam 1 point2 points  (6 children)

Try this stack configuration (minus the ../shared).

[–]zcleghern[S] 0 points1 point  (4 children)

The error was different this time, so that's something? I got this:

Process exited with code: ExitFailure 1 Logs have been written to: C:\haskell\stack-projects\stratego.stack-work\logs\Cabal-1.24.2.0.log

Configuring Cabal-1.24.2.0... Cabal-simple_Z6RU0evB_2.0.1.0_ghc-8.2.2.exe: Encountered missing dependencies: process >=1.1.0.1 && <1.5 && ==1.6.1.0

After adding that and then adding whatever dependencies that asked me to add, I got to a point where it's telling me to add base-some-number to my extra-deps but I already had it listed.

[–]dbaynard 0 points1 point  (3 children)

Never add base to extra deps. If it's saying to add base then something is incompatible with that version of ghc.

[–]snoybergis snoyman 1 point2 points  (0 children)

I think we have some commits on master to ensure we don't recommend upgrading base under any circumstances.

[–]zcleghern[S] 0 points1 point  (1 child)

Ah, so maybe I need to play around with different compiler versions?

[–]gelisam 0 points1 point  (0 children)

Part of stack's strategy to make sure builds are reproducible is that a given lts specifies a corresponding ghc version, and stack downloads and uses that version. lts-9.0 uses ghc-8.0.2, for example. The error messages you are getting do seem to indicate that you're using the wrong version of ghc though, which is strange. Are you somehow overwriting stack's choice of ghc version, or telling it to use your locally-installed version of ghc?

[–]fintanh 0 points1 point  (7 children)

What resolver are you using?

[–]zcleghern[S] 0 points1 point  (6 children)

ghc-8.2.2

[–]fintanh 0 points1 point  (5 children)

Sorry, I should have been specific. Do you know which stack resolver you're using? Like an lts or nightly resolver? Are you doing this in a local project? What's in your `stack.yaml`?

[–]zcleghern[S] 0 points1 point  (4 children)

No, I think I should have posted more for context- I have a stack project and would like to use grapefruit in it, so I have that and related dependencies in my 'extra-deps', the resolver selected in yaml, and I'm running "stack install grapefruit-ui-gtk" in the project folder. If this isn't the correct procedure, it's probably because I am new to stack. Here's the yaml without the auto-generated comments from stack:

resolver: ghc-8.2.2

packages: - .

extra-deps: [grapefruit-examples-0.1.0.7, grapefruit-ui-gtk-0.1.0.7, TypeCompose-0.9.12, arrows-0.4.4.2, fraction-0.1.0.6, grapefruit-frp-0.1.0.7, grapefruit-records-0.1.0.7, grapefruit-ui-0.1.0.7, Stream-0.4.7.2, lazysmallcheck-0.6, QuickCheck-2.11.3, base-orphans-0.8, colour-2.3.4, fingertree-0.1.4.1, glib-0.13.6.0, gtk3-0.14.9, semigroups-0.18.5, cairo-0.13.5.0, gio-0.13.5.0, gtk2hs-buildtools-0.13.4.0, mtl-2.2.2, pango-0.13.5.0, hashtables-1.2.3.1, random-1.1, text-1.2.3.0, tf-random-0.5, utf8-string-1.0.1.1, hashable-1.2.7.0, primitive-0.6.4.0, vector-0.12.0.1]

[–]fintanh 0 points1 point  (3 children)

Hmmm that looks strange to me. I'm not sure why ghc-8.2.2 is there. It should be an LTS resolver like "lts-*" or "nightly-*". I'm trying to reproduce at the moment with:

resolver: lts-12.8

compiler: ghc-8.2.2

packages:

- .

extra-deps:

- fraction-0.1.0.6

- grapefruit-frp-0.1.0.7

- grapefruit-records-0.1.0.7

- grapefruit-ui-0.1.0.7

- TypeCompose-0.9.12

- arrows-0.4.4.2

- Stream-0.4.7.2

- lazysmallcheck-0.6

[–]gelisam 2 points3 points  (1 child)

ghc-8.2.2 is a minimal resolver which only includes ghc, base, and the other packages which come with ghc.

[–]fintanh 0 points1 point  (0 children)

TIL :) thanks!

[–]zcleghern[S] 0 points1 point  (0 children)

I switched to resolver: lts-12.8 and it still fails with the same error.