<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    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:<br>
    <br>
        $ ghc-mod info foo.hs Foo Just<br>
        data Maybe a = ... | Just a     -- Defined in `Data.Maybe'<br>
    <br>
        $ ghc-pkg find-module Data.Maybe --simple-output<br>
        haskell2010-1.1.1.0 base-4.6.0.1<br>
    <br>
        $ ghc-pkg field base-4.6.0.1 haddock-html<br>
        haddock-html:
/home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1<br>
    <br>
    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:<br>
    <br>
        $ ghc-mod info foo.hs Foo String<br>
        type String = [Char]     -- Defined in `GHC.Base'<br>
    <br>
        $ ghc-pkg find-module GHC.Base<br>
        /home/carlo/opt/ghc-7.6.3_build/lib/ghc-7.6.3/package.conf.d<br>
           base-4.6.0.1<br>
        /home/carlo/.ghc/x86_64-linux-7.6.3/package.conf.d<br>
    <br>
        $ ghc-pkg field base-4.6.0.1 haddock-html<br>
        haddock-html:
/home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1<br>
    <br>
        $ ls
/home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/GHC-Base.html<br>
        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<br>
    <br>
    because the html is in the src subdirectory:<br>
    <br>
        $ ls
/home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/src/GHC-Base.html<br>
       
/home/carlo/opt/ghc-7.6.3_build/share/doc/ghc/html/libraries/base-4.6.0.1/src/GHC-Base.html<br>
    <br>
    But this isn't even the right place to go, one should look at the
    Prelude file<br>
    <br>
    <a
href="http://hackage.haskell.org/package/base-4.6.0.1/docs/Prelude.html#t:String">http://hackage.haskell.org/package/base-4.6.0.1/docs/Prelude.html#t:String</a><br>
    <br>
    which is what Hoogle suggests. How does Hoogle get it right?<br>
    <br>
    It looks like haskell-mode for emacs runs into a similar problem:<br>
    <br>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <a
href="https://github.com/haskell/haskell-mode/blob/master/inf-haskell.el#L734-L740">https://github.com/haskell/haskell-mode/blob/master/inf-haskell.el#L734-L740</a><br>
    <br>
    -------------------------------<br>
      (defvar inferior-haskell-ghc-internal-ident-alist<br>
        ;; FIXME: Fill this table, ideally semi-automatically.<br>
        '(("GHC.Base.return" . "Control.Monad.return")<br>
          ("GHC.List" . "Data.List")))<br>
    <br>
      (defun inferior-haskell-map-internal-ghc-ident (ident)<br>
        "Try to translate some internal GHC identifier to its alter ego
    in haskell docs."<br>
    -------------------------------<br>
    <br>
    Thanks,<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Carlo Hamalainen
<a class="moz-txt-link-freetext" href="http://carlo-hamalainen.net">http://carlo-hamalainen.net</a></pre>
  </body>
</html>