Ticket #2168 (new feature request)

Opened 5 years ago

Last modified 9 months ago

ghci should show haddock comments for identifier

Reported by: j.waldmann Owned by:
Priority: lowest Milestone: 7.6.2
Component: GHCi Version: 6.8.2
Keywords: Cc: claus, pho@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

This came up in comp.lang.haskell recently:  http://groups.google.com/group/comp.lang.haskell/msg/ae69f720377e7a3f

I like the idea.

Immediate thoughts:

  • if ghci reads the source file, it can read haddock annotations
  • if ghci reads the interface file only (for library modules), it needs to find the installed documentation

On the other hand the requested feature is a typical IDE functionality (cf. Eclipse/show source/show javadoc) and it's perhaps a bit much to require that from ghci.

Change History

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • description modified (diff)

Changed 5 years ago by igloo

The link says:

I really like the feature (in other languages like python) which shows
you the doc string for a function or object.

For example if I type from the python interpreter:

 >> help(function)
I get the docstring of function defined as

def function():
        """ docstring for function"""

Is it possible to have something similar in haskell??
The type of the object is very useful, but a little comment would be
even better... 

Changed 5 years ago by igloo

  • milestone set to 6.10 branch

If we want an IDE to be able to do it then we probably want the functionality to be in the GHC API, at which point GHCi may as well do it.

I don't think looking for the installed docs is a good idea; better would be to put the info in the .hi file (or another file installed alongside the .o and .hi files; perhaps it would even make sense to spit the parsed source out into a file, so that we can also do things like :list?).

Changed 5 years ago by claus

  • cc claus added

the  haskellmode for vim plugins have supported this for quite some time, but only for installed packages, by going the awkward route of parsing the urls out of the doc-index-*.html files. replacing that hack with something supported by ghc would be nice.

haddock comments are often meant to be used from within a browser, with interlinkage/highlighting/etc, so the plugins call a browser, and i'd recommend ghci doing the same, separating out the need for a text/console-renderer.

that reduces the problem to

1 finding the correct base urls, which is mostly ghc-pkg responsibility (currently outside ghc api, i think) - ghc --print-docdir would give one location; ghc-pkg field '*' haddock-html gives all locations (the latter is a recent addition to ghc-pkg and not yet used in the haskellmode plugins).

2 constructing the correct relative urls, which ghc api ought to provide help with

3 finding the correct tool instance (which ghc-pkg is the one to call for the current ghci session?). there's a ticket somewhere for this general problem, iirc.

4 do something about sources/modules not yet processed by haddock

given solutions to 2&3, accessible from within ghci, one could then use ghc-pkg to construct the complete url for an identifier, and call a browser for it. i'd be tempted to require running haddock to avoid treating 4 specially, but a purely cmdline-based interface might be nice, too.

Changed 5 years ago by simonmar

The documentation is stored in the Haddock interface file now, and Haddock has a library that provides access to the .haddock files. So it seems to me the right way to go is for GHCi to invoke the Haddock library to get the docs. Unfortunately this needs some restructuring: the Haddock library would become a boot package.

Changed 5 years ago by PHO

  • cc pho@… added

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 21 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 9 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.