Skip to content

[Feature Request] Hover Docs for function arguments/return types #2258

Closed

Description

@konn

Currently, hover documents for functions shows only haddock comment associated for a function, without haddock comments of their arguments or return types.
It would be great if we could show documentation also for arguments and return types.

If someone would give me some hints, I would love to implement this feature!

There are some design choices where to print such documentation: along with type document, dedicated table or some view.

Activity

  1. konn commented on Oct 10, 2021

    @konn
    CollaboratorAuthor

    I've just started experimenting around this here: https://github.com/konn/haskell-language-server/tree/argument-haddocks.
    As I haven't implemented desired feature itself yet, so I have not opened pull req for the time being).

    It turns out that it is relatively easy to retrieve argument documents from HIE files.
    The remaining (not so non-trivial, but rather tedious) parts seem:

    • Recovering the correspondence between the argument types and their documents
      • We need to correctly strip quantified variables and constraint arguments correctly; I haven't found the exact procedure to determine the corresponding type with the given index in mi_arg_docs.
      • What if forall-quantifier appears in returned type and haddock comments are placed for the types inside the quantifier? Is it banned, or just counted as the ordinary cases?
      • We need to decompose IfaceTypes, not only Types, which doesn't provide smart deconstructors like splitFunTys for Types, so we have to implement it first.
    • Pretty-prints it aside with the argument/return types.
      • We have to decide the appropriate style of documentation.
      • We must pay attention to number only vanilla arguments (i.e. non-dictionary arguments).
      • As arrows (->) can be annotated with multiplicity since GHC 9.0, we need to be careful to implementing prettyprinting procedure.
    • (Optional) Alternative parsing implementation in the case of HieFresh.
  2. konn commented on Nov 14, 2021

    @konn
    CollaboratorAuthor

    Superseded by #2348.

  3. Anton-Latukha commented on Nov 14, 2021

    @Anton-Latukha
    Collaborator

    Oh, sorry. I had no idea it was not in HLS. I thought it should be downstream somewhere in LSP chain so I send the request into the haskell/lsp & it go transfered into HLS. & the day before the transfer, I was looking at the code about it.

    Today I try to stay away from programming. I know this is important to have. I would strive to finish the main process on the week.

  4. konn commented on Nov 15, 2021

    @konn
    CollaboratorAuthor

    No problem! I certainly need this feature, but I have less time to spend on it. So really appreciate you for working on this feature! I hope the information noted above could help your process. Thanks!

  5. Anton-Latukha commented on Nov 16, 2021

    @Anton-Latukha
    Collaborator

    Wanted to clean-rebase/cherrypick your commit:

    Screenshot-2021-11-16-20:12:25

    Can not cherrypick it clean & because I would change it much - the signature authorship would change.

    So would redo & attribute work in the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions