How does ghc resolve paths for libraries ?

1.3k Views Asked by At

I'm starting to to use haskell with nixpkgs. From the official guide to nixpkgs I read:

GHC expects to find all installed libraries inside of its own lib directory.

As it is stated it seems that it is saying that ghc require all the library to be installed in the same path.

I thought that ghc was able to find out the path of libraries by looking at packages database configured through ghc-pkg. If this is the case, it should be possible to put libraries under different directories in the filesystem and configuring the package-db to resolve these different paths. But this would contradict what said in the above mentioned link, so what am I not getting?

Thanks in advance for any answer.

1

There are 1 best solutions below

2
On BEST ANSWER

GHC has several command line options which allow you to manipulate how it searches for packages:

https://downloads.haskell.org/~ghc/7.10.3/docs/html/users_guide/flag-reference.html#idp46686514389712

In short, GHC allows you to specify a stack of of package directories (like a package db search path) so you can have it access libraries in different directories.