feat: expose pretty printing helper for mast nodes #1441
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR exposes
MastNode::to_pretty_print
, which is too useful to keep internal to the crate, and without it, there is effectively no way to emit the textual MAST for specific nodes, such as in debug output. Strangely,Program
itself implementsPrettyPrint
, butLibrary
does not (and we would want to take advantage of the additional metadata inLibrary
toPrettyPrint
it differently anyway). The compiler use cases I have could probably be solved for by implementing pretty printers forLibrary
andProcedureInfo
as MAST, with accompanying path/digest information, but I think there is value in exposing the pretty printer forMastNode
directly anyway, since there may still be use cases where that is handy.We should probably aim to make things like this public unless we have a good reason not to, because in many cases, if it was useful to us inside the crate, it will be useful for downstream users of the crate as well (especially the compiler).
I'm going to pin the compiler to the tip of this branch (and
next
, once merged) until we can make a release to crates.io that contains it, since it is used in debugging efforts at the moment.