Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Haskell package contains given module

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.

like image 878
luntain Avatar asked Sep 26 '08 20:09

luntain


People also ask

What is module Main where in Haskell?

A Haskell module is a collection of related functions, types and typeclasses. A Haskell program is a collection of modules where the main module loads up the other modules and then uses the functions defined in them to do something. Having code split up into several modules has quite a lot of advantages.

What is a Haskell package?

A package is a library of Haskell modules known to the compiler. GHC comes with several packages: see the accompanying library documentation. More packages to install can be obtained from HackageDB.

Where are Haskell packages stored?

By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.


2 Answers

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.

like image 117
wnoise Avatar answered Sep 21 '22 15:09

wnoise


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.
like image 43
hammar Avatar answered Sep 20 '22 15:09

hammar