Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find what library provides the import?

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.

like image 506
Daniil Iaitskov Avatar asked Jul 20 '20 14:07

Daniil Iaitskov


People also ask

How do I use the import library when linking programs?

After you create the import library (.lib) and the export file (.exp) for the program, you use the import library when linking the other program or programs. LINK creates an import library for each exporting program it builds. For example, if you run LIB on the objects and exports for ONE.dll, you create ONE.lib and ONE.exp.

How do I import specific items from a library or module?

Using the keywords from…import we can import specific items from a library or module. These may include functions or classes within that specific library. This is important especially when you do not intend to use only a specific function in a module and therefore it is needless to import the entire module.

How do I import and export a library in Linux?

In the LIB command, list all objects and libraries for the program and specify /DEF. If the program uses a .def file or /EXPORT specifications, specify these as well. After you create the import library (.lib) and the export file (.exp) for the program, you use the import library when linking the other program or programs.

How do I import a library into a Python program?

Using the import keyword at the top of your code file, you can import certain library functions or the entire library at once. For example, to import the entire requests library, you must first install requests using your terminal with pip install requests . Then you can write the following code in your text editor:


1 Answers

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.

like image 119
sjakobi Avatar answered Oct 30 '22 05:10

sjakobi