[Haskell-cafe] How to determine the right path to haddock html documentation?
Roman Cheplyaka
roma at ro-che.info
Fri Dec 13 22:28:27 UTC 2013
String is defined in GHC.Base, but GHC.Base is an internal (not exposed)
module of the base package; that's why there's no documentation for it.
Instead of asking where the thing is defined, you should be asking where
it's exported from. In this case, String is re-exported from Prelude.
Roman
* Carlo Hamalainen <carlo at carlo-hamalainen.net> [2013-12-13 22:50:40+0100]
> 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
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131214/d65df930/attachment-0001.sig>
More information about the Haskell-Cafe
mailing list