Rewrite pretty printer#62
Merged
Merged
Conversation
this should probably only be done in untyped mode, though currently the `can_unify_with` check eliminates all ill-typed instantiations in typed mode so it won't change anything for now
Collaborator
|
Is this ready to be merged? If so, let's do it. Also, can you handle #60 as well? That can also be merged, but it seems like there would be some conflicts between these two PRs. |
VietAnh1010
reviewed
Sep 10, 2025
Collaborator
There was a problem hiding this comment.
I guess this is not necessary anymore?
Collaborator
Author
There was a problem hiding this comment.
Yes, all callers of Subst use the typed version now.
| visitors { variety = "mapreduce"; name = "mapreduce_spec" }, | ||
| ord] | ||
|
|
||
| let spec_calls_func spec f_name = |
Collaborator
There was a problem hiding this comment.
What does this function do?
Collaborator
Author
There was a problem hiding this comment.
This is currently used to check if a specification of some function refers to itself (which is the case for the inferred spec of a recursive function). The old check for this used to be in Pretty for some reason.
need to check tests if the changes are only format-wise
currently unsure if a Format-based approach can still be salvaged or if a handrolled one is needed to achieve the desired outputs all the tests are broken but Trust Me BroTM it's just formatting changes
all code has already been ported over to typed subst
done by adding a group to wrap the annotations, to make the split choice independent of the context
439ebc7 to
ec600d5
Compare
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.
Changes the pretty printing algorithm to use (what I believe are) more reasonable spacing and indentation defaults.
Some selected examples to demonstrate the change:
let match100 : (int) list = ens ((res = xs) /\ emp) in (((ens ((match100 = []()) /\ (true = true) /\ emp); ens ((res = []()) /\ emp)) \/ ex xs' : (int) list. ex x : int. (ens ((match100 = ::(x, xs')) /\ (true = true) /\ emp); let v98 : int = let v97 : int = ens ((res = (x + x)) /\ emp) in (ens ((res = (v97 + x)) /\ emp)) in (let v99 : (int) list = thrice_list(xs') in (ens ((res = ::(v98, v99)) /\ emp)))))(ens (res = xs)); match100. ens (match100 = [] /\ true = true /\ emp); ens (res = []) \/ ex xs'. ex x. (ens (match100 = x :: xs' /\ true = true /\ emp); ((ens (res = x + x)); v97. (ens (res = v97 + x))); v98. ((thrice_list(xs')); v99. ens (res = v98 :: v99)))let v14 : unit->int = ens ((res = (fun _v12 : unit (*@ (tick(()); (tick(()); let a : 'tv1670 = get(()) in ((tick(()); let v13 : int = get(()) in (ens ((res = (v13 - a)) /\ emp)))))) @*) )) /\ emp) in (run_state(v14))( ens (res = (fun _v12 -> (*@ tick(()); tick(()); (get(())); a. (tick(()); (get(())); v13. (ens (res = v13 - a))) @*) _)) ); v14. run_state(v14)Resolves #43, #55 (type display is now togglable via the
SHOW_TYPESenv var). Does partial work on #52 (the printer now uses the new syntax, but the parser for specifications in code comments is left unchanged.)