Search code examples
haskellpackagecabal

Which package to install to run this code successfully


I am trying following simple code from here :

import Data.GI.Base
import qualified GI.Gtk as Gtk

main :: IO()
main = do
  Gtk.init Nothing
  Gtk.main

However, I am getting following error:

    Could not find module `Data.GI.Base'
    Use -v to see a list of the files searched for.
  |
1 | import Data.GI.Base
  | ^^^^^^^^^^^^^^^^^^^

simplewin.hs:2:1: error:
    Could not find module `GI.Gtk'
    Use -v to see a list of the files searched for.
  |
2 | import qualified GI.Gtk as Gtk
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Following attempts to install packages do not find any matches:

>cabal list Data.GI.Base
No matches found.

>cabal list GI.Gtk
No matches found.

Which packages do I install with cabal to correct above errors?


Solution

  • You can search Stackage (the FPComplete package repository, the de-facto standard for Haskell) for the module, type, or function name.

    For example, when I type in Data.GI.Base, I get its documentation page, which tells me (at the very top) that the module is available in the package haskell-gi-base.

    Not every package is available on Stackage though. If you can't find something, try Hackage next. It's less regulated and controlled, but has more stuff because of it.