ghc-imported-from: Find the Haddock documentation for a symbol.

[ bsd3, development, library, program ] [ Propose Tags ]

Given a Haskell module and symbol, determine the URL to the Haddock documentation for that symbol.

[Skip to Readme]
Versions [faq],,,,,,,,,,,,,,,,,,,,,
Change log
Dependencies base (>=4.6 && <4.8), Cabal (>=1.10 && <1.17 || >=1.18), containers, directory, filepath, ghc, ghc-imported-from, ghc-mod (>=4.1.1), ghc-paths, ghc-syb-utils, hspec, mtl, parsec, process, safe, syb, transformers [details]
License BSD-3-Clause
Author Carlo Hamalainen
Category Development
Home page
Uploaded by CarloHamalainen at 2014-06-01T08:59:53Z
Distributions NixOS:
Executables ghc-imported-from, fake-ghc-for-ghc-imported-from
Downloads 12042 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Successful builds reported [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for ghc-imported-from-

[back to package description]


For a given Haskell source file, determine the path to the Haddock documentation for a symbol at a particular line/col location.

Example: on the file src/Main.hs,

ghc-imported-from haddock-url src/Main.hs Main getArgs 69 13


SUCCESS: file:///home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-

since the usage of getArgs at line 160, column 13, is from the System.Environment module.

Difficulties arise because some symbols are exported from a certain package but defined in another, for example String is defined in GHC.Base but is exported from the standard prelude, the module Prelude. There are other cases to deal with including qualified imports, selective imports, imports with hidden components, etc.

Preference is given to any locally available Haddock documentation, and then to the generic url at


You may have to run

cabal build


cabal repl

in a project directory to sort out some of the dist/build/autogen files. At the moment ghc-imported-from has no functionality to do this boot process automatically. To run cabal repl you might need the latest Cabal from

If you see

<command line>: cannot satisfy -package hspec
    (use -v for more information)

then you may need the hspec and/or doctest packages:

cabal install hspec doctest

Feedback and pull requests most welcome!



Install into ~/.cabal:

git clone
cd ghc-imported-from
cabal install

Or, install into a sandbox:

git clone
cd ghc-imported-from

Either way, ensure that ghc-imported-from and fake-ghc-for-ghc-imported-from are in the current PATH.


Run the tests using cabal:

cabal test

If the tests hang, check that your version of Cabal/cabal-install has this fix:


Follow the instructions at to install the Vim plugin.


See the tests subdirectory for some examples. Or load your favourite Haskell project and hit F4.

Or watch the screencast (be sure to set 720p HD and then fullscreen):


ghc-imported-from uses both GHC and ghc-pkg, which accept arguments in differing formats. For example GHC takes -package-db while ghc-pkg takes --package-db=. For more details:


To see the GHC options that have been automatically detected, change into your project's directory and run:

$ cd ~/ghc-imported-from
$ cabal repl --with-ghc=fake-ghc-for-ghc-imported-from
Preprocessing library ghc-imported-from-
--interactive -fbuilding-cabal-package -O0 -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name ghc-imported-from- -hide-all-packages -no-user-package-db -package-db /home/user/ghc-imported-from/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d -package-db dist/package.conf.inplace -package-id Cabal-1.16.0-c6e09e008cd04cf255c1ce0c59aba905 -package-id base- -package-id containers- -package-id directory- -package-id filepath- -package-id ghc-7.6.3-18957ddbb817289f604552aa2da2e879 -package-id ghc-mod-4.1.0-a87501f2667239b3f0bef3e0f3753496 -package-id ghc-paths- -package-id ghc-syb-utils- -package-id mtl- -package-id process- -package-id safe-0.3.4-ba52ca348aecad429ba90450e3aba4c4 -package-id syb-0.4.1-9469ffdd9c6a7ebbf035421c915a08ee -package-id transformers- -XHaskell2010 Language.Haskell.GhcImportedFrom Language.Haskell.GhcImportedFrom.UtilsFromGhcMod Language.Haskell.GhcImportedFrom.Types -Wall


As far as I know the only alternative is the fpco/hoogle-doc function in Or try Ctrl-i in the web version of FP Complete.