<div dir="ltr">Ross Paterson wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Thu, Aug 14, 2008 at 08:00:25PM +0200, Sean Leather wrote:<br>
> Well, the warning is right that you don't need to re-export module B:<br>
> instances are implicitly exported. So you could just remove the export of<br>
> "module B", unless there's a reason to export it (such as, you might add<br>
> some exported functions or data types to it later)<br>
><br>
> Hmm, the disappointing result of removing module B from the export list<br>
> is that now it doesn't show up in the Haddock-generated documentation<br>
> for module A. Not that there was anything specific in B to document,<br>
> because it's only instances. But I do want the user to know that<br>
> importing A also imports B. Sigh... I suppose there's CPP if I really<br>
> want it.<br>
<br>
</div>That shouldn't be necessary. Because instances are implicitly exported<br>
and imported, you'll really want to avoid orphan instances, so that the<br>
user can be sure that if both the class and the data type are in scope,<br>
so is the instance. But then the instance will be listed under both<br>
the class and the type in the Haddock documentation. It won't matter<br>
where the instance was defined, just as it doesn't matter where other<br>
stuff is defined, just where it is in scope.<br>
</blockquote><div><br>In my case, it does matter where instances are in scope. My library requires orphan instances by design. If the programmer imports the top-level module, then s/he gets a default set of instances. But the programmer has the option to import select modules and get a different set of classes and instances.<br>
<br>My goal was to put the default set of instances into a separate module and re-export that from a higher-level module. That way, it is more clearly documented where things are located.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Unfortunately Haddock does not allow doc comments to be attached to<br>
instances, but that's independent of whether the defining module is shown.<br></blockquote><div><br>Agreed. I am getting the impression that it would be nice if there were a lot of things that were more explicit about instances, both in Haskell and in Haddock.<br>
<br>Sean<br></div></div></div>