
Hi, I'm writing a patch for ghcmod-vim so that a user can look up the haddock html documentation for a symbol. My code makes three system calls, e.g. to look up "Just" it does: $ ghc-mod info foo.hs Foo Just data Maybe a = ... | Just a -- Defined in `Data.Maybe' $ ghc-pkg find-module Data.Maybe --simple-output haskell2010-1.1.1.0 base-4.6.0.1 $ ghc-pkg field base-4.6.0.1 haddock-html haddock-html: /home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1 Then "Data.Maybe" is changed to Data-Maybe.html" and appended to the haddock-html value. But this procedure doesn't work in general, for example when looking up String: $ ghc-mod info foo.hs Foo String type String = [Char] -- Defined in `GHC.Base' $ ghc-pkg find-module GHC.Base /home/carlo/opt/ghc-7.6.3_build/lib/ghc-7.6.3/package.conf.d base-4.6.0.1 /home/carlo/.ghc/x86_64-linux-7.6.3/package.conf.d $ ghc-pkg field base-4.6.0.1 haddock-html haddock-html: /home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1 $ ls /home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/GHC-Base.html ls: cannot access /home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/GHC-Base.html: No such file or directory because the html is in the src subdirectory: $ ls /home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/src/GHC-Base.html /home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/src/GHC-Base.html But this isn't even the right place to go, one should look at the Prelude file http://hackage.haskell.org/package/base-4.6.0.1/docs/Prelude.html#t:String which is what Hoogle suggests. How does Hoogle get it right? It looks like haskell-mode for emacs runs into a similar problem: https://github.com/haskell/haskell-mode/blob/master/inf-haskell.el#L734-L740 ------------------------------- (defvar inferior-haskell-ghc-internal-ident-alist ;; FIXME: Fill this table, ideally semi-automatically. '(("GHC.Base.return" . "Control.Monad.return") ("GHC.List" . "Data.List"))) (defun inferior-haskell-map-internal-ghc-ident (ident) "Try to translate some internal GHC identifier to its alter ego in haskell docs." ------------------------------- Thanks, -- Carlo Hamalainen http://carlo-hamalainen.net