ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.7k stars 415 forks source link

Documentation needs access to original type definition for type aliases #745

Open SeanTAllen opened 8 years ago

SeanTAllen commented 8 years ago

By time the doc generation run ends, we have a type checked AST. This is awesome because it's easy to know for any name, what package etc it is in and allows for easy cross linkage in documentation. However, for type aliases instead of putting the alias like:

Compare

we instead get

(Less | Equal | Greater)

which is the fully type checked version of

type Compare is (Less | Equal | Greater)

It would enhance the documentation if we had a full type checked AST but access still to the original type alias (so we could use it instead and easily link to it).

jemc commented 8 years ago

The idea I proposed in our discussion for solving this one - refactoring the compiler AST to represent the type as a list of types (instead of a single type). The first item in the list would be the nominal type given in the source code, if any; the last item in the list would be the fully resolved type (up to the latest pass run by the compiler so far); the items in between would be the various stages of resolution between these two points, if any. This way, we never "throw away" an earlier resolution of a type as we continue to resolve.

I think it seems appropriate, but we may find otherwise when we go to implement it.