Pretty printing for Block IR#425
Open
ChingLongTin wants to merge 352 commits intohkust-taco:hkmc2from
Open
Conversation
this makes it so modules that are not the first node of the Block will still be staged
clean up function staging logic
this makes having to import Option and makes transformArg easier to implement
as BlockTransformer doesn't pass around a context, the implementation should be more than just a extension of BlockTransformer
this makes Block.Case line up with formalization of Pattern
we keep ShapeSet and Shape separate for now
LPTK
reviewed
Mar 24, 2026
…ngLongTin/mlscript into instrument-with-pretty-print
ValDefn is used in constructors of data classes that have paramters, which will need to be staged.
LPTK
reviewed
Mar 30, 2026
…ngLongTin/mlscript into instrument-with-pretty-print
LPTK
reviewed
Mar 31, 2026
| //│ > x = 4.2 | ||
| //│ > x | ||
|
|
||
| printCode(Define(ValDefn(Some(aSym), Symbol("x"), ValueLit(1)), End())) |
Contributor
There was a problem hiding this comment.
Note that Define nodes correspond to new definitions. Define(ValDefn) correspond to a val definition, not to an assignment. When you properly print a constructor within the scope of its enclosing object/class/module, it will all make sense.
Contributor
Author
There was a problem hiding this comment.
I have changed it back to using val instead of set. Later I will skip printing the ValDefn in a constructor, if the parameter list of the enclosing class already defined the symbol, i.e.
staged class C(val x) with
val y = 1
fun ctor(x) = Define(ValDefn(Some(sym), Symbol("x"), ValueRef(Symbol("x"))), ...)
class C(val x) with
val y = 1 // skip printing implicit ValDefn to x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
implements turning Block IR back into a mlscript string