haddock icon indicating copy to clipboard operation
haddock copied to clipboard

Better formatting for type signatures with long class constraints

Open sjakobi opened this issue 10 years ago • 7 comments

Two examples with screenshots from my computer (12.5 inch laptop):

  • http://haddock.stackage.org/nightly-2016-01-08/stack-1.0.0/Stack-Config.html#v:loadConfig screenshot - 09 01 2016 - 21 08 50
  • http://haddock.stackage.org/nightly-2016-01-08/stack-1.0.0/Stack-Build-Source.html#v:loadSourceMap screenshot - 09 01 2016 - 21 10 39

Ideas for improvement:

  • Add line breaks to overly long class constraints.
  • When the class constraint is long, add a line break before the => ... part.

sjakobi avatar Jan 09 '16 20:01 sjakobi

It would also be nice if we could selectively hide "large" contexts.

bgamari avatar Feb 08 '16 16:02 bgamari

This is really needed.

tomjaguarpaw avatar Oct 28 '16 21:10 tomjaguarpaw

@tomjaguarpaw what in particular do you propose here? It seems like there is a bit of design-work that remains to be done here.

bgamari avatar Oct 29 '16 23:10 bgamari

Allowing individual components of tuples to be commented (and extending this to contexts) would be one approach. For example

foo :: (Int,
    -- ^ Foo
    Bool)
    -- ^ Bar
   -> String
   -- ^ Baz
foo = foo

could generate a Haddock like

foo
  :: (Int,     Foo
      Bool)    Bar
  -> String    Baz

tomjaguarpaw avatar Oct 30 '16 07:10 tomjaguarpaw

This issue seems to have gone quiet, but I'd love to see it revived.

I think a reasonable starting point is identifying a max line length. Formatting beyond that could conform to tibbe style since that has arisen as a canonical style.

eborden avatar May 30 '17 22:05 eborden

I'd love to see it revived.

Me too.

tomjaguarpaw avatar May 30 '17 22:05 tomjaguarpaw

As a workaround, might it be possible to do something CSS-ish? Perhaps with max-width on those types?

nrnrnr avatar Jan 27 '22 21:01 nrnrnr