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

Create overloadable function for string representations of types #537

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MilesCranmer
Copy link

@MilesCranmer MilesCranmer commented Jan 17, 2024

Fixes #535

Example:

Screenshot 2024-01-17 at 21 46 24

Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

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

Add a few tests?

TypedSyntax/src/show.jl Show resolved Hide resolved
@MilesCranmer
Copy link
Author

Okay I think I'm hitting some recursive types now. It's not fully general but the user can always overload behavior when needed.

For the tests I think I'm doing something wrong in that I don't understand Cthulhu.cthulhu_typed's output and whether it actually triggers type_string or not. Mind taking a look?

return string(T)
else
wrapper = Base.typename(T).wrapper
return string(wrapper, '{', join(map(type_string, T.parameters), ','), '}')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit wary of this code mapping over T.parameters as there were quite a few issues doing a similar thing elsewhere.
In that code we had to check for whether each element in T.parameters was assigned, I don't know if that's a concern here or not.
See https://github.com/JuliaDebug/Cthulhu.jl/pull/508/files for that code and some issues with previous versions of that code are #491, #492, #494.

@simeonschaub simeonschaub added the enhancement New feature or request label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user to overload printing behavior
4 participants