15

I know a Haskell module name, but I can't figure out in what package it is defined. This is bad because I can't compile without a package exposing this module.

Specificaly it is Text.Regex that I can't locate, but I would like to know how to solve that problem in general.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
luntain
  • 4,560
  • 6
  • 37
  • 48

4 Answers4

15

http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html

ghc-pkg find-module Text.Regex

But that only works for (a) recent GHCs, and (b) packages installed on your system.

You can also grep through the package file (e.g. /usr/lib/ghc-6.8.2/package.conf) to see what's installed.

You can also use either the haskell API search engines hoogle or the hackage search engine hayoo.

Text.Regex is in the package regex-base, and a few others built on top of it.

wnoise
  • 9,764
  • 37
  • 47
  • I could find it only by clicking on a few of the results from hoogle. At the moment there seem to be no easy way to find those packages. Hopefully new release of ghc will fix this issue. – luntain Sep 26 '08 at 21:08
  • +1 Hoogle. It is by far the easiest way I have found. Command line stuff is a bit unnecessary when there's a perfectly good search engine option :) (imho) – OJ. Oct 01 '08 at 06:02
  • 1
    That's less helpful when you're offline. Hopefully such barbarism is rare, but... – wnoise Oct 01 '08 at 19:21
2

If you're using Cabal and you have the package installed, you can just try to compile it with cabal build, and Cabal will inform you of which package you forgot to add to your dependencies:

Main.hs:1:8:
    Could not find module `Text.Regex':
      It is a member of the hidden package `regex-compat-0.93.1'.
      Perhaps you need to add `regex-compat' to the build-depends in your .cabal file.
      Use -v to see a list of the files searched for.
hammar
  • 138,522
  • 17
  • 304
  • 385
1

The best tools are:

Both are search engines for Haskell modules and functions.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
0

If you are using Debian and the Debian-provided packages, there is a global documentation index at /usr/share/doc/ghc-doc/html/libraries/index.html which lists the package in the last column.

Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139