haskell / haddock

Haskell Documentation Tool

Home Page:www.haskell.org/haddock/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Finish the hi-haddock story

bgamari opened this issue · comments

Today, Haddock relies on the GHC API to re-typecheck modules for which it is generating documentation. This both increases the surface area of the GHC-Haddock interface and leads to unnecessarily long compilation times. Historically this was necessary because GHC had no means of persisting Haddock documentation in its build artifacts.

In 2018 we started down the road of preserving docstrings in GHC's interface files (see the GSoC proposal). The GHC side of this resulted in two commits (one in 2018 and another in 2021) which together introduce the necessary fields into GHC's interface file syntax along with necessary parsing logic, and implement a :doc command to GHCi. During the course of this work Haddock was minimally updated (e.g. see 0280391) to track the changes made in GHC. However, there is a larger refactoring that still needs to be done...

Specifically, Haddock should be refactored to drop its typechecking logic and instead load the already-compiled interface files of the modules being documented from disk.

Okay, thank you very much for this recap. From what I understand, this commit (https://gitlab.haskell.org/ghc/haddock/-/commit/dfab819b24eec31c00a4ffc6a64516acbb0a8216) by @harpocrates would be the missing piece?

@harpocrates Would you like to pair with me sometime so that we can bring this to the finish line? :)

@Kleidukos, that is correct.

@bgamari I think I'm on the verge of making things compile, however the patch was written prior to changes that happened in GHC 9.4.
Especially, I need to get a [ClsInst] to feed createInterface1. However this commit replaces the type of md_insts from [ClsInst] (what I seem to need) to InstEnv through mkInstEnv.

This is a territory in which I am everything but familiar, and some direction would be appreciated.

Here is the current state of the PR: #1571

@Kleidukos perhaps GHC.Core.InstEnv.instEnvElts helps?