D. Tweed writes:
> I guess it's arguable; as mentioned I masacre loads of trees due to my
> habit of working on printed out source code and I could argue that:
> supposing I'm reading a program where == is defined for a particular
> instance of class with the comment that `note the care taken to ensure
> transitivity', then I may very well want to find out if == is actually
> used anywhere for this type _under the assumption that it is transitive_
> without having to wade through lots of == on different classes. (From
> memory, I believe there's no H98 requirement == be transitive, but this is
> just a contrived example anyway.) Just because type class methods _ought_
> to be semantically related doesn't mean they necessarily will be.
First, the `semantic relation' I was thinking of was the equivalence class of
types for each class method. In this sense they are always semantically
related.
Second, I guess you could try to do a conservative type analysis to pick up
method uses whose instance is statically determined (as is often the case with
arithmetic operators) but I don't think that is something that should be
treated in a literate programming tool. For one thing, it means that the
reader of the documentation needs to know the algorithm used for the type
analysis if he wants to use the indexing to make the sort of informed decision
you suggested (because he needs to know which method uses will and won't be
caught by the analysis).
Personally, I think literate programming is all about syntax, so I would avoid
trying to make the tool do any sort of semantic analysis.
OTOH, one useful thing might be for it to partition indices of identifers
according to provable-isomorphism classes of types. I think such a tool was
written for Ocaml, although it was interactive.
Here is a page on type isomorphisms:
http://www.dmi.ens.fr/users/dicosmo/ResearchThemes/ISOS/ISOShomepage.html
At the very bottom of the page it even mentions something about Haskell source
code.
> Now I think about it, there's a problem even if you trust the programmer
> to ensure type class instance methods are semantically related: suppose
> I've got
>
> class Clothing where
> wear x = ....
>
> class Abraidable where
> wear x = ....
>
> I wouldn't want those two to be in the same index group (or is that what
> you meant by scoping -- I initially thought you meant things like let
> bindings?)
I had in mind both, and all other kinds of scoping as well, e.g., module
imports.
--
Frank Atanassow, Dept. of Computer Science, Utrecht University
Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands
Tel +31 (030) 253-1012, Fax +31 (030) 251-3791