<div dir="ltr">I'm sympathetic to the notion that instances are an important part of the API.  On the other hand, it's hard to argue against how much more usable the documentation becomes when all the page-long instance lists are collapsed.  I wonder if there's a compromise possible: in the collapsed form, the instance list could still show a list of the applicable class names, but all on one line instead of a page-long table.  Then it's just a click away to get from there to the details (instance context, source link, etc.) that are shown now.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 3, 2019 at 7:31 PM George Wilson <george@wils.online> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Type class instances are an essential part of a data type's API in<br>
Haskell so I'm against hiding them by default. A toggle to collapse<br>
all instance blocks on a page would be fine.<br>
<br>
Cheers,<br>
George<br>
<br>
On Fri, 4 Jan 2019 at 04:36, Nathan Collins <<a href="mailto:nathan.collins@gmail.com" target="_blank">nathan.collins@gmail.com</a>> wrote:<br>
><br>
> * I think collapsing instances by default is a great idea! +1<br>
><br>
> * Examples are already collapsed by default, and I think instances<br>
> should be treated the same way.<br>
><br>
> Re the concern that this would make the Servant docs worse, for me it<br>
> would just be a matter of knowing to expand the instance docs when I'm<br>
> interested in the corresponding class, the same way I expand the<br>
> examples only where I'm interested.<br>
><br>
> Here's an example of instance docs in Servant:<br>
> <a href="http://hackage.haskell.org/package/servant-0.15/docs/Servant-API.html#t:FromHttpApiData" rel="noreferrer" target="_blank">http://hackage.haskell.org/package/servant-0.15/docs/Servant-API.html#t:FromHttpApiData</a>.<br>
> Until I'm interested in the FromHttpApiData class, I don't personally<br>
> want to see that long list of instances with some examples. Also, in<br>
> my experience, having lots of docs/examples on the instances like this<br>
> is not very common.<br>
><br>
> Here's an instance of examples being collapsed by default to good<br>
> effect in the Prelude docs for Either:<br>
> <a href="https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#t:Either" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#t:Either</a><br>
><br>
> * Having a "collapse all/expand all" toggle at the top of the page<br>
> would be nice, but if the default is not "collapsed" then I'd want a<br>
> way to make that my personal default.<br>
><br>
> I don't know much about web development, but my impression is that we<br>
> could use a cookie and some simple JavaScript [1] to make "collapse by<br>
> default" a per-user preference, say by remembering the last state of<br>
> the hypothetical "collapse all/expand all" toggle button at the top.<br>
> Haddock already uses JavaScript, so I expect this would be a small<br>
> addition.<br>
><br>
> Cheers,<br>
><br>
> -nathan<br>
><br>
> [1] <a href="https://developer.mozilla.org/en-US/docs/Web/API/document/cookie" rel="noreferrer" target="_blank">https://developer.mozilla.org/en-US/docs/Web/API/document/cookie</a><br>
><br>
> On Wed, Jan 2, 2019 at 11:23 PM Oleg Grenrus <<a href="mailto:oleg.grenrus@iki.fi" target="_blank">oleg.grenrus@iki.fi</a>> wrote:<br>
> ><br>
> > How about a compromise: show dozen or so instances with "show rest" link-toggle. That would work very nicely, if we could control which instances (e.g. instances with haddocks) should be shown.<br>
> ><br>
> > E.g. in `servant` *a lot* of docs & examples are in instance haddocks, so making them hidden will make documentation strictly worse.<br>
> ><br>
> > - Oleg<br>
> ><br>
> > On 3 Jan 2019, at 7.50, Ryan Reich <<a href="mailto:ryan.reich@gmail.com" target="_blank">ryan.reich@gmail.com</a>> wrote:<br>
> ><br>
> > I think this is a great idea.  I do wonder, however, if it might exacerbate a kind of meta-documentation problem that I, at least, had when I was more of a beginner: it was not clear to me that most of a type's API is implicit in its instances of many standard classes, and specialized functions for things like mapping or folding or appending may not even be present in the rest of the module.  Obviously this is something that every Haskeller needs to learn, but it was an issue for me even when the instance lists were present for me to gloss over.<br>
> ><br>
> > Perhaps Haddock could, rather than establishing this as a new default, provide a "collapse all" and "expand all" set of functions at the top of the page?<br>
> ><br>
> > On Wed, Jan 2, 2019 at 8:03 PM Li-yao Xia <<a href="mailto:lysxia@gmail.com" target="_blank">lysxia@gmail.com</a>> wrote:<br>
> >><br>
> >> Hello Café,<br>
> >><br>
> >> I would like to propose making haddock keep instance lists collapsed by<br>
> >> default. Some discussion is in order since it would significantly affect<br>
> >> the documentation of many packages on Hackage.<br>
> >><br>
> >> Feel free to reply here or on the related Github thread:<br>
> >> <a href="https://github.com/haskell/haddock/issues/698" rel="noreferrer" target="_blank">https://github.com/haskell/haddock/issues/698</a><br>
> >><br>
> >> 1. Instance lists take a lot of screen estate<br>
> >><br>
> >> For a motivating example, I can point to the Prelude we all love.<br>
> >><br>
> >> <a href="https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html</a><br>
> >><br>
> >> We are immediately welcomed by half a page of instances of Bool, which<br>
> >> is not quite bad, but classes have the most impressive instance lists,<br>
> >> as you may see when you reach Eq.<br>
> >><br>
> >> Many packages, even commonly used ones, have the same issue. For an<br>
> >> extreme example, see the scrollbar jump when you fold the instance list<br>
> >> of Apply in singletons.<br>
> >><br>
> >> <a href="https://hackage.haskell.org/package/singletons-2.5.1/docs/Data-Singletons.html#t:Apply" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/singletons-2.5.1/docs/Data-Singletons.html#t:Apply</a><br>
> >><br>
> >> 2. Current workarounds<br>
> >><br>
> >> They can be collapsed manually one by one, and we can jump to the middle<br>
> >> of a module with the table of contents, but scrolling up from the bottom<br>
> >> of an instance list is still a chore.<br>
> >><br>
> >> Of course, instance lists also contain quite important information.<br>
> >> Would it become too easy to miss if it were hidden by default? Would a<br>
> >> more fine-grained alternative be better?<br>
> >><br>
> >> Regards,<br>
> >> Li-yao<br>
> >> _______________________________________________<br>
> >> Haskell-Cafe mailing list<br>
> >> To (un)subscribe, modify options or view archives go to:<br>
> >> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> >> Only members subscribed via the mailman list are allowed to post.<br>
> ><br>
> > _______________________________________________<br>
> > Haskell-Cafe mailing list<br>
> > To (un)subscribe, modify options or view archives go to:<br>
> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> > Only members subscribed via the mailman list are allowed to post.<br>
> ><br>
> > _______________________________________________<br>
> > Haskell-Cafe mailing list<br>
> > To (un)subscribe, modify options or view archives go to:<br>
> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> > Only members subscribed via the mailman list are allowed to post.<br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>