Search code examples
haskellgtkhackagestackage

Can I install dependecies that are not part of the LTS package set?


I am trying to build gi-gtk-4.0.8 on Windows10 through stack. But the latest LTS version is only 3.0.41. which I am able to build. I see for example that for ArchLinux version 4.0.8 is available, looking at the hackage website. I have installed the 22.18 LTS version, along with the 3.0.41 gi-gtk package.

Could you point me in the right direction? I'm somewhat new to programming and I don't know what I'm doing wrong. Thank you

I uploaded a picture of the listed versions of gi-gtk found on Hackage.enter image description here

My GHC version is 9.6.4, using Stack 2.13.1

I am trying to code with the Haskell language.

At first I tried modifying the package.yaml file, in the dependencies I specified to use - gi-gtk >= 4.0 && <5 (https://i.sstatic.net/tj25w.png)

But it threw the error:

stack build

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gtk-intro-seven-0.1.0.0:
         * gi-gtk must match >=4.0 && <5, but gi-gtk-3.0.41 is in the Stack configuration (latest
           matching version is 4.0.8).
       needed since gtk-intro-seven is a build target.
       
       Some different approaches to resolving some or all of this:
       
         * To ignore all version constraints and build anyway, in
           C:\Users\bu\AppData\Roaming\stack\config.yaml (global configuration) or
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration), set
           allow-newer: true.
         
         * To ignore certain version constraints and build anyway, also add these package names
           under allow-newer-deps: gtk-intro-seven.
         
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gtk-4.0.8@sha256:6011c2d7880c6f9b1a319a593db6b76e5175b3f020fc4b3ca86707ee70c3a1d8,35759

Compilation exited abnormally with code 1 at Wed Apr 24 15:14:13

I then tried modifying the extra-deps in stack.yaml adding the suggested - gi-gtk-4.0.8@sha256:6011c2d7880c6f9b1a319a593db6b76e5175b3f020fc4b3ca86707ee70c3a1d8,35759

But it threw the error:

stack build

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gi-gtk-4.0.8:
         * gi-gdk must match >=4.0 && <4.1, but gi-gdk-3.0.28 is in the Stack configuration (latest
           matching version is 4.0.7).
         * gi-gsk must match >=4.0 && <4.1, but no version is in the Stack configuration (latest
           matching version is 4.0.7).
       needed due to gtk-intro-seven-0.1.0.0 -> gi-gtk-4.0.8
       
       Some different approaches to resolving some or all of this:
       
         * To ignore certain version constraints and build anyway, in
           C:\Users\bu\AppData\Roaming\stack\config.yaml (global configuration) or
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration), set
           allow-newer: true and add these package names under allow-newer-deps: gi-gtk.
         
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gdk-4.0.7@sha256:e1915be39e2eebaf445584986dea7b750aef57c00894d1a218a54811da27b381,9025
           - gi-gsk-4.0.7@sha256:1c96f0d0fdc39b1dfa3314cb00e57cb39931bd7f1a125fb0890435fcae624952,7393

Compilation exited abnormally with code 1 at Wed Apr 24 14:56:30

Again I modified, as suggested, the stack.yaml setting allow-newer: true and allow-newer-deps: gi-gtk

But it threw the error

stack build

Warning: Ignoring gi-gtk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gtk is an allow-newer-dep and allow-newer enabled.

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gi-gtk-4.0.8:
         * gi-gsk must match >=4.0 && <4.1, but no version is in the Stack configuration (latest
           matching version is 4.0.7).
       needed due to gtk-intro-seven-0.1.0.0 -> gi-gtk-4.0.8
       
       Some different approaches to resolving some or all of this:
       
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gsk-4.0.7@sha256:1c96f0d0fdc39b1dfa3314cb00e57cb39931bd7f1a125fb0890435fcae624952,7393

Compilation exited abnormally with code 1 at Wed Apr 24 15:02:06

At this point it feels as if it is going in circles as even after trying to add the suggested - gi-gsk-4.0.7@sha256:1c96f0d0fdc39b1dfa3314cb00e57cb39931bd7f1a125fb0890435fcae624952 to stack.yaml it throws the error

stack build

Warning: Ignoring gi-gtk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gtk is an allow-newer-dep and allow-newer enabled.

Warning: Not ignoring gi-gsk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gsk is not an allow-newer-dep although allow-newer enabled.

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gi-gsk-4.0.7:
         * gi-gdk must match >=4.0 && <4.1, but gi-gdk-3.0.28 is in the Stack configuration (latest
           matching version is 4.0.7).
       needed due to gtk-intro-seven-0.1.0.0 -> gi-gsk-4.0.7
       
       Some different approaches to resolving some or all of this:
       
         * To ignore all version constraints and build anyway, in
           C:\Users\bu\AppData\Roaming\stack\config.yaml (global configuration) or
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration), set
           allow-newer: true.
         
         * To ignore certain version constraints and build anyway, also add these package names
           under allow-newer-deps: gi-gsk.
         
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gdk-4.0.7@sha256:e1915be39e2eebaf445584986dea7b750aef57c00894d1a218a54811da27b381,9025

Compilation exited abnormally with code 1 at Wed Apr 24 15:04:43

I tried adding gi-gsk in the allow-newer-deps, it did start compiling but I got an error saying > [3 of 3] Linking C:\Users(myusername)\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7.stack-work\dist\ab060f89\setup\setup.exe gi-graphene > Did not find a GI repository for Graphene-1.0 in ["C:\Program Files\gir-1.0","/opt/homebrew/share/gir-1.0"].

Although it is compiling and it is saying it's ignoring the bounds on gi-gdk, it still falls back on the gi-gdk-3.0.28 version. :(

Here's the full message

stack build

Warning: Ignoring gi-gtk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gtk is an allow-newer-dep and allow-newer enabled.

Warning: Ignoring gi-gsk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gsk is an allow-newer-dep and allow-newer enabled.
blaze-builder         > using precompiled package
cabal-doctest         > using precompiled package
colour                > using precompiled package
data-default-class    > using precompiled package
haskell-gi-base       > using precompiled package
haskell-gi-overloading> using precompiled package
haskell-lexer         > using precompiled package
integer-logarithms    > using precompiled package
os-string             > using precompiled package
primitive             > using precompiled package
regex-base            > using precompiled package
happy                 > configure
happy                 > Configuring happy-1.20.1.1...
blaze-markup          > using precompiled package
safe                  > using precompiled package
ansi-terminal-types   > using precompiled package
split                 > using precompiled package
splitmix              > using precompiled package
unliftio-core         > using precompiled package
vector-stream         > using precompiled package
xdg-basedir           > using precompiled package
happy                 > build
hashable              > using precompiled package
happy                 > Preprocessing executable 'happy' for happy-1.20.1.1..
happy                 > Building executable 'happy' for happy-1.20.1.1..
xml-types             > using precompiled package
regex-tdfa            > using precompiled package
blaze-html            > using precompiled package
zlib                  > using precompiled package
ansi-terminal         > using precompiled package
random                > using precompiled package
resourcet             > using precompiled package
vector                > using precompiled package
async                 > using precompiled package
scientific            > using precompiled package
unordered-containers  > using precompiled package
happy                 > [ 1 of 19] Compiling AbsSyn
happy                 > [ 2 of 19] Compiling GenUtils
happy                 > [ 3 of 19] Compiling NameSet
happy                 > [ 4 of 19] Compiling ParamRules
temporary             > using precompiled package
happy                 > [ 5 of 19] Compiling ParseMonad
happy                 > [ 6 of 19] Compiling Lexer
bitvec                > using precompiled package
typed-process         > using precompiled package
attoparsec            > using precompiled package
network               > using precompiled package
happy                 > [ 7 of 19] Compiling AttrGrammar
vector-algorithms     > using precompiled package
happy                 > [ 8 of 19] Compiling AttrGrammarParser
happy                 > [ 9 of 19] Compiling Grammar
streaming-commons     > using precompiled package
mono-traversable      > using precompiled package
conduit               > using precompiled package
happy                 > [10 of 19] Compiling LALR
conduit-extra         > using precompiled package
xml-conduit           > using precompiled package
happy                 > [11 of 19] Compiling First
happy                 > [12 of 19] Compiling Parser
happy                 > [13 of 19] Compiling Paths_happy
happy                 > [14 of 19] Compiling Info
happy                 > [15 of 19] Compiling PrettyGrammar
happy                 > [16 of 19] Compiling ProduceGLRCode
happy                 > [17 of 19] Compiling Target
happy                 > [18 of 19] Compiling ProduceCode
happy                 > [19 of 19] Compiling Main
happy                 > 
happy                 > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\happy-1.20.1.1\src\Main.lhs:35:3: warning: [-Wunused-imports]
happy                 >     The import of `Foreign.Marshal.Array' is redundant
happy                 >       except perhaps to import instances from `Foreign.Marshal.Array'
happy                 >     To import instances alone, use: import Foreign.Marshal.Array()
happy                 >    |
happy                 > 35 | > import Foreign.Marshal.Array
happy                 >    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
happy                 > 
happy                 > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\happy-1.20.1.1\src\Main.lhs:36:3: warning: [-Wunused-imports]
happy                 >     The import of `Foreign' is redundant
happy                 >       except perhaps to import instances from `Foreign'
happy                 >     To import instances alone, use: import Foreign()
happy                 >    |
happy                 > 36 | > import Foreign
happy                 >    |   ^^^^^^^^^^^^^^
happy                 > 
happy                 > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\happy-1.20.1.1\src\Main.lhs:37:3: warning: [-Wunused-imports]
happy                 >     The import of `Foreign.C' is redundant
happy                 >       except perhaps to import instances from `Foreign.C'
happy                 >     To import instances alone, use: import Foreign.C()
happy                 >    |
happy                 > 37 | > import Foreign.C
happy                 >    |   ^^^^^^^^^^^^^^^^
happy                 > [20 of 20] Linking .stack-work\dist\ab060f89\build\happy\happy.exe
happy                 > copy/register
happy                 > Installing executable happy in C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\bin
pretty-show           > configure
pretty-show           > Configuring pretty-show-1.10...
pretty-show           > build
pretty-show           > Preprocessing library for pretty-show-1.10..
pretty-show           > Building library for pretty-show-1.10..
pretty-show           > [1 of 6] Compiling Paths_pretty_show
pretty-show           > [2 of 6] Compiling Text.Show.Value
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Value.hs:84:27: warning: [GHC-62161] [-Wincomplete-uni-patterns]
pretty-show           >     Pattern match(es) are non-exhaustive
pretty-show           >     In a pattern binding: Patterns of type `[Value]' not matched: []
pretty-show           >    |
pretty-show           > 84 |         | otherwise -> do ~(v1:vs1) <- delMany (v:vs)
pretty-show           >    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Value.hs:93:25: warning: [GHC-62161] [-Wincomplete-uni-patterns]
pretty-show           >     Pattern match(es) are non-exhaustive
pretty-show           >     In a pattern binding:
pretty-show           >         Patterns of type `[Value]' not matched:
pretty-show           >             []
pretty-show           >             [_]
pretty-show           >             (_:_:_:_)
pretty-show           >    |
pretty-show           > 93 |       Ratio v1 v2 -> do ~[a,b] <- delMany [v1,v2]
pretty-show           >    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^
pretty-show           > [3 of 6] Compiling Text.Show.PrettyVal
pretty-show           > [4 of 6] Compiling Text.Show.Parser
pretty-show           > [5 of 6] Compiling Text.Show.Html
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Html.hs:112:1: warning: [-Wunused-top-binds]
pretty-show           >     Defined but not used: `tallTuple'
pretty-show           >     |
pretty-show           > 112 | tallTuple els = table "tallTuple" $ map (tr . return . td) els
pretty-show           >     | ^^^^^^^^^
pretty-show           > [6 of 6] Compiling Text.Show.Pretty
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Pretty.hs:52:22: warning: [-Wunused-imports]
pretty-show           >     The import of `Foldable' from module `Data.Foldable' is redundant
pretty-show           >    |
pretty-show           > 52 | import Data.Foldable(Foldable,toList)
pretty-show           >    |                      ^^^^^^^^
pretty-show           > Preprocessing executable 'ppsh' for pretty-show-1.10..
pretty-show           > Building executable 'ppsh' for pretty-show-1.10..
pretty-show           > [1 of 2] Compiling Main
pretty-show           > [2 of 2] Compiling Paths_pretty_show
pretty-show           > [3 of 3] Linking .stack-work\dist\ab060f89\build\ppsh\ppsh.exe
pretty-show           > copy/register
pretty-show           > Installing library in C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\lib\x86_64-windows-ghc-9.6.4\pretty-show-1.10-7QJQR28ntpqAaVVCcnieFO
pretty-show           > Installing executable ppsh in C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\bin
pretty-show           > Registering library for pretty-show-1.10..
haskell-gi            > using precompiled package
gi-cairo              > using precompiled package
gi-freetype2          > using precompiled package
gi-glib               > using precompiled package
gi-gmodule            > using precompiled package
gi-gobject            > using precompiled package
gi-gio                > using precompiled package
gi-harfbuzz           > using precompiled package
gi-atk                > using precompiled package
gi-gdkpixbuf          > using precompiled package
gi-pango              > using precompiled package
gi-gdk                > using precompiled package
gi-graphene           > configure
gi-graphene           > [1 of 3] Compiling Main             ( C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\Setup.hs, C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\Main.o )
gi-graphene           > [2 of 3] Compiling StackSetupShim   ( C:\Users\bu\AppData\Roaming\stack\setup-exe-src\setup-shim-9p6GVs8J.hs, C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\StackSetupShim.o )
gi-graphene           > [3 of 3] Linking C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\setup.exe
gi-graphene           > Did not find a GI repository for Graphene-1.0 in ["C:\\Program Files\\gir-1.0","/opt/homebrew/share/gir-1.0"].
gi-graphene           > CallStack (from HasCallStack):
gi-graphene           >   error, called at lib\Data\GI\GIR\Repository.hs:94:20 in haskell-gi-0.26.8-BZLvOUaH1kP82JAb00n5xq:Data.GI.GIR.Repository

Error: [S-7282]
       Stack failed to execute the build plan.
       
       While executing the build plan, Stack encountered the error:
       
       [S-7011]
       While building package gi-graphene-1.0.7 (scroll up to its section to see the error) using:
       C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\setup --verbose=1 --builddir=.stack-work\dist\ab060f89 configure --with-ghc=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\ghc-9.6.4\bin\ghc-9.6.4.exe --with-ghc-pkg=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\ghc-9.6.4\bin\ghc-pkg-9.6.4.exe --user --package-db=clear --package-db=global --package-db=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\pkgdb --libdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\lib --bindir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\bin --datadir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\share --libexecdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\libexec --sysconfdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\etc --docdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\doc\gi-graphene-1.0.7 --htmldir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\doc\gi-graphene-1.0.7 --haddockdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\doc\gi-graphene-1.0.7 --dependency=Cabal=Cabal-3.10.1.0 --dependency=base=base-4.18.2.0 --dependency=bytestring=bytestring-0.11.5.3 --dependency=containers=containers-0.6.7 --dependency=gi-glib=gi-glib-2.0.29-LSlYN00ugpvDuZbItzaRkx --dependency=gi-gobject=gi-gobject-2.0.30-Jg9NCcBQUdtHGMnuLld8Lp --dependency=haskell-gi=haskell-gi-0.26.8-BZLvOUaH1kP82JAb00n5xq --dependency=haskell-gi-base=haskell-gi-base-0.26.4-KnYJdEEMlhpJUcSA5ahpRO --dependency=haskell-gi-overloading=haskell-gi-overloading-1.0-6w3IXGDooXgu3RA2LfTuf --dependency=text=text-2.0.2 --dependency=transformers=transformers-0.6.1.0 --extra-include-dirs=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\include --extra-lib-dirs=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\lib --extra-lib-dirs=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\bin --exact-configuration --ghc-option=-fhide-source-paths
       Process exited with code: ExitFailure 1 

Compilation exited abnormally with code 1 at Wed Apr 24 15:29:16

Solution

  • Update: See below for a better general setup, but the specific error you're getting is because you are missing the Gobject introspection data for Graphene. I got the same error when building with the configuration I suggest below:

    gi-graphene           > Did not find a GI repository for Graphene-1.0 in ["C:\\Program Files\\gir-1.0","/opt/homebrew/share/gir-1.0"].
    gi-graphene           > CallStack (from HasCallStack):
    gi-graphene           >   error, called at lib\Data\GI\GIR\Repository.hs:94:20 in haskell-gi-0.26.8-BZLvOUaH1kP82JAb00n5xq:Data.GI.GIR.Repository
    

    This indicates that you don't have the development files for the Graphene library installed. On my Debian system, installing the gnome-devel metapackage installed these files as well as a number of other required development files. I don't know what the equivalent would be on Windows.

    Anyway, back to my original answer, which still applies, even if it won't fix your current problem...

    For tightly coupled packages, like gi-gtk and gi-gdk, there's probably no way to get a newer version of one working with an older version of the other, so in this situation, the advice to set allow-newer and/or allow-newer-deps is bad advice. Instead, you need to follow the alternate advice and keep adding new versions of the related packages to extra-deps until Stack stops complaining.

    This can be a nightmare, but in this case it's not too bad. I was able to build and run the Gtk4 test program here using the following stack.yaml file, which uses the latest LTS 22.18 and just overrides the versions for gi-gtk, gi-gdk, and gi-gsk:

    resolver: lts-22.18
    
    packages:
    - .
    
    extra-deps:
    - gi-gtk-4.0.8
    - gi-gdk-4.0.7
    - gi-gsk-4.0.7
    

    My Cabal file was nothing special. It was entirely generic (from a template) except for the build-depends clause. I specified some version requirements for gi-gtk, though these are not actually necessary since Stack will use the gi-gtk version specified in the extra-deps clause of the stack.yaml file:

    build-depends:       base >= 4.7 && < 5
                       , gi-gtk >= 4.0 && < 5
                       , haskell-gi-base
    

    (This was on a Debian Linux system with the gnome-devel package installed, to satisfy all the build dependencies.)

    The full set of files I used follows:

    stack.yaml

    resolver: lts-22.18
    
    packages:
    - .
    
    extra-deps:
    - gi-gtk-4.0.8
    - gi-gdk-4.0.7
    - gi-gsk-4.0.7
    

    gtk4test.cabal

    name:                gtk4test
    version:             0.1.0.0
    -- synopsis:
    -- description:
    author:              
    maintainer:          
    copyright:           
    category:            
    build-type:          Simple
    cabal-version:       >=1.10
    executable main
      main-is:             Main.hs
      default-language:    Haskell2010
      build-depends:       base >= 4.7 && < 5
                         , gi-gtk >= 4.0 && < 5
                         , haskell-gi-base
      ghc-options:         -Wall
                           -Wcompat
                           -Widentities
                           -Wincomplete-record-updates
                           -Wincomplete-uni-patterns
                           -Wmissing-export-lists
                           -Wmissing-home-modules
                           -Wpartial-fields
                           -Wredundant-constraints
    

    Setup.hs

    import Distribution.Simple
    main = defaultMain
    

    Main.hs

    See https://github.com/haskell-gi/haskell-gi/blob/master/examples/Gtk4/gtk4-example.hs

    {-# LANGUAGE OverloadedStrings, OverloadedLabels, ImplicitParams #-}
    
    import Control.Monad (void)
    import System.Environment (getArgs, getProgName)
    
    import Data.Int (Int32)
    
    import qualified GI.Gtk as Gtk
    import Data.GI.Base
    
    -- | An example of a signal callback accessing the ?self parameter
    -- (that is, the object raising the callback). See
    -- https://github.com/haskell-gi/haskell-gi/issues/346
    -- for why this is necessary when dealing with even controllers in gtk4.
    pressedCB :: (?self :: Gtk.GestureClick) => Int32 -> Double -> Double -> IO ()
    pressedCB nPress x y = do
        button <- #getCurrentButton ?self
        putStrLn $ "Button pressed: " <> show nPress <> " "
          <> show x <> " " <> show y <> " button: " <> show button
    
    activate :: Gtk.Application -> IO ()
    activate app = do
      box <- new Gtk.Box [#orientation := Gtk.OrientationVertical]
    
      adjustment <- new Gtk.Adjustment [#value := 50, #lower := 0, #upper := 100,
                                        #stepIncrement := 1]
      slider <- new Gtk.Scale[#adjustment := adjustment, #drawValue := True]
      #append box slider
      spinButton <- new Gtk.SpinButton [#adjustment := adjustment]
      #append box spinButton
    
      controller <- new Gtk.GestureClick [After #pressed pressedCB]
      #addController slider controller
    
      window <- new Gtk.ApplicationWindow [#application := app,
                                           #title := "Hello",
                                           #child := box]
      #show window
    
    main :: IO ()
    main = do
      app <- new Gtk.Application [#applicationId := "haskell-gi.Gtk4.test",
                                  On #activate (activate ?self)]
    
      -- If the application does not need to parse command line arguments
      -- just pass Nothing.
      args <- getArgs
      progName <- getProgName
      void $ #run app (Just $ progName : args)