Skip to content

Pretty printing for Block IR#425

Open
ChingLongTin wants to merge 352 commits intohkust-taco:hkmc2from
ChingLongTin:instrument-with-pretty-print
Open

Pretty printing for Block IR#425
ChingLongTin wants to merge 352 commits intohkust-taco:hkmc2from
ChingLongTin:instrument-with-pretty-print

Conversation

@ChingLongTin
Copy link
Copy Markdown
Contributor

implements turning Block IR back into a mlscript string

ChingLongTin and others added 30 commits November 10, 2025 00:37
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
add back symName parameter to {block, shape}Ctor
this makes Block.Case line up with formalization of Pattern
we keep ShapeSet and Shape separate for now
//│ > x = 4.2
//│ > x

printCode(Define(ValDefn(Some(aSym), Symbol("x"), ValueLit(1)), End()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ChingLongTin ChingLongTin marked this pull request as ready for review March 31, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants