TransWikia.com

How to find what library provides the import?

Stack Overflow Asked by Daneel Yaitskov on November 27, 2021

I joined a project. The code base is new for me.
I am interested in a module, which is used in code base
and it is imported from a dependency.
The module is not defined in the project.

Is there an automatic / easy way to figure out what library provides
the module I am interested in?

Lot’s of dependencies are proprietary and hoogle cannot help me with that.

One Answer

You can use the ghc-pkg find-module command:

$ ghc-pkg find-module Data.List
/opt/ghc/8.10.1/lib/ghc-8.10.1/package.conf.d
    base-4.14.0.0
/home/simon/.ghc/x86_64-linux-8.10.1/package.conf.d
    (no packages)

In a stack project that uses its own package DBs, you'd have to wrap the command in stack exec:

$ stack exec -- ghc-pkg find-module Data.Fix
/home/simon/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
    (no packages)
/home/simon/.stack/snapshots/x86_64-linux/0d371d66c37115ac97bac3fbbc5cc7b3718e197710ba11b06c7e9d7fcf441a3f/8.6.5/pkgdb
    data-fix-0.2.0
/home/simon/src/dhall-haskell/.stack-work/install/x86_64-linux/0d371d66c37115ac97bac3fbbc5cc7b3718e197710ba11b06c7e9d7fcf441a3f/8.6.5/pkgdb
    (no packages)

I'm not sure how to best use ghc-pkg in a cabal project.

Answered by sjakobi on November 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP