Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make monadsyntax more aware of print depth #1232

Merged
merged 3 commits into from
May 10, 2024
Merged

Make monadsyntax more aware of print depth #1232

merged 3 commits into from
May 10, 2024

Conversation

hrutvik
Copy link
Collaborator

@hrutvik hrutvik commented May 4, 2024

Limiting print depth has an unusual effect on long monadic definitions, because all monadic assignments on the top-level "spine" of binds are printed at the same depth. This commit attempts to reduce the print depth further down the spine, so that later assignments are elided.

@mn200
Copy link
Member

mn200 commented May 5, 2024

If I understand you right, you're complaining about the fact that you might get output like:

  do
    v1 <- ... ; 
    v2 <- ... ; 
    v3 <- ... ; 
od

where you'd prefer to see, e.g.:

do 
   v1 <- ...; 
   ...
od

I'm not so sure about this, and may well have deliberately written the print-depth decrementing code to achieve the first effect. I have certainly found it annoying when list-forms are printed so as to lose the information about how many elements there are in a list. But equally, if the list/do-form is a million elements long, having to see them all when you've gone to the trouble of specifying a depth of 10 is a bit user-hostile. I also dislike the way that when printing lists you get a “triangular” decay so that later elements, if they are printed, get printed with less detail. Perhaps the logic could be that you don't get any more than depth elements printed, and that each element is printed with depth-1.

@binghe
Copy link
Member

binghe commented May 5, 2024

In the world of Lisp, there's the difference between *print-length* and *print-level* (depth) [1] when printing lists (s-expressions).

[1] https://www.lispworks.com/documentation/HyperSpec/Body/v_pr_lev.htm#STprint-lengthST

@mn200
Copy link
Member

mn200 commented May 6, 2024

@binghe That's interesting! Perhaps we should adopt something similar.

@hrutvik
Copy link
Collaborator Author

hrutvik commented May 7, 2024

Apologies @mn200, yes that example is the kind of thing I'm referring to (specifically the situation with very many elements in the list/do-form). I can see that having both behaviours could be useful - following @binghe's suggestion perhaps I can add a notion of "print length" as a separate reference in monadsyntax, which can then be set by the user?

@mn200
Copy link
Member

mn200 commented May 8, 2024

Thanks for getting this underway! Can you move the reference to the Globals structure to sit alongside the existing print_depth variable? I can then use it in the system’s printing of other “list forms” (sets, lists, records, let-bindings).

@mn200
Copy link
Member

mn200 commented May 10, 2024

Thanks!

@mn200 mn200 merged commit d80a697 into develop May 10, 2024
4 checks passed
@hrutvik hrutvik deleted the monadsyntax-depth branch May 10, 2024 08:19
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.

3 participants