pyret-lang
pyret-lang copied to clipboard
Print more useful info when evaluating a function name (doc strings and annotations)
Can we have it so that doc strings and annotations are presented by the REPL? E.g.
> foo
foo :: String * Number -> Tree
consumes a string and number and produces a balanced binary tree of that size and content
<function>
In particular, it is impossible right now to figure out how to use a library function, especially if the documentation isn't accessible (for Horizon items), even though it may very well be sitting right there in the definition.
In other words, right now we're gathering information and gratuitously throwing it away right now. You can find out what the annotations are by misusing the function but, perversely, not without doing so. You can't find out the doc string at all, at least not in any intuitive way.
Something more useful should certainly print. Doc strings are a little annoying since they are just strings, with no markup, etc. We could keep annotations around; we'll quickly want very rich rendering of the annotations, especially if they refer to types that aren't in the current module (so that they can be clickable to get more information). But maybe those are reasonable limitations; clearly what you're suggesting is is probably better than what we do now.
We actually used to print the doc string; it was removed in part because of overzealous attempts to remove observations on functions.
It might be nice if things with documentation rendered in a way that we could get to the documentation from them, either inline or linked.
Related: https://github.com/brownplt/pyret-lang/issues/526
Not just overzealous attempts to make functions less observable: it had had measurable consequences for memory usage when every single function stored a copy of its docstring, especially nested closures etc that got created more than O(1) times. This seems like another candidate for stuff that belongs in the metadata for a module, and not in the compiled code of it.
Related: #258
Poking - is this still something we want to track?
Yes! And I would hope that the new module system may make it easier to do this? @jpolitz @blerner
@jpolitz @blerner following up now that modules has landed. Has this become more doable?
Hmm. Printing annotations might be possible, though still harder than I'd like in all cases (e.g. refinements or other fancy types). We still don't track docstrings through compilation yet. It's not technologically impossible, but it will be fiddly.