To install the gi-gtk-declarative package in your project, follow these steps and guidelines:
The gi-gtk-declarative package builds on gi-gtk, and thus depend on the same libraries. First, follow the instructions on how to install GTK+ dependencies using your package manager of choice over at the gi-gtk README.
Make sure you're not using gi-gtk and this package with GHC 8.2.x (read more here)!
Once you have the GTK+ system libraries installed, it should be a regular Haskell package install with Cabal, Stack, Nix, or whatever floats your boat.
Executables using gi-gtk-declarative must be built with the
-threadedoption passed to GHC. If you are not seeing a window, check this first.
Let's look at an example of using Cabal to build a gi-gtk-declarative project. It's assumed you're running Cabal 2.x, and that you have an existing project to work with. If you don't have a project, and you're unsure how to set one up, have look at Introduction to Cabal.
Begin by including
build-depends list of your library or executable:
name: your-project ... executable your-executable build-depends: gi-gtk , gi-gtk-declarative , gi-gtk-declarative-app-simple , ... ghc-options: -threaded default-language: Haskell2010
gi-gtk-declarative-app-simple is not strictly required,
unless you want to write your application using the
Installing and Building
Install dependencies and build your executable:
cabal v2-build your-executable