As you see, each entity is annotated with the module and package where it was
originally defined, and also with its fixity. Additionally, class methods, field
selectors, and data constructors are annotated with the class or type they
belong to.

Using interfaces

You can parse interface files directly, but a better idea is to use
Distribution.HaskellSuite.Packages API (from haskell-packages), combined with
the package database NamesDB defined in Language.Haskell.Modules.Interfaces.

Name resolution

There are two approaches to name resolution.

A simpler one is provided by the annotateModule function which annotates the
module with scoping information.

A more advanced interface is given by the Language.Haskell.Names.Open module.
Its essence is described in the article Open your name resolution.
It is, however, very experimental.

Example

Let's say you have a module and you want to find out whether it uses
Prelude.head.

Known issues

Because a non-trivial amount of packages are not designed to work with
anything except GHC, hs-gen-iface currently pretends to be GHC. This is of
course not acceptable — contributions here are welcome. (#32)

haskell-names doesn't perform validation yet. If a module is not valid
Haskell, then the behaviour is undefined. See the issues marked as
validation.