haddock icon indicating copy to clipboard operation
haddock copied to clipboard

Multiline record field types and instance declarations

Open akshaymankar opened this issue 4 years ago • 1 comments

Currently haddock always puts the type of a record field in one line. This is good for most cases, but when looking at a Servant API, this may look a little cumbersome. Here is an example from my current project:

image

As much text as that is, the horizontal scrolling makes it even harder to understand. The source for this type is formatted like this:


data Api routes = Api
  { getUserUnqualified ::
      routes
        :- Summary "Get a user by UserId (deprecated)"
        :> ZUser
        :> "users"
        :> CaptureUserId "uid"
        :> GetUserVerb,
    getUserQualified ::
      routes
        :- Summary "Get a user by Domain and UserId"
        :> ZUser
        :> "users"
        :> QualifiedCaptureUserId "uid"
        :> GetUserVerb,
    getSelf ::
      routes
        :- Summary "Get your own profile"
        :> ZUser
        :> "self"
        :> Get '[JSON] SelfProfile,
...

Would it be possible to respect this source formatting in haddocks too?

This could also be useful for some typeclass instances like Servant.Server.HasServer.

akshaymankar avatar Nov 05 '21 09:11 akshaymankar

Since Haddock is being fed this information by GHC (and not by parsing the files), I think we'd have to piggy-back somehow on the exact-print infrastructure? This is a thorny problem. :)

Kleidukos avatar Nov 05 '21 09:11 Kleidukos