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

Simplify representation of measure names #2464

Merged
merged 6 commits into from
Dec 12, 2024

Conversation

facundominguez
Copy link
Collaborator

This PR changes the name field of measures to use LHName instead of Symbol. This makes possible to store more information in the name field, instead of paring the Measure records with LHName in specs.

I considered generalizing the type of the field instead of hard-coding it to LHName, but the new type parameter would have propagated to specs and it was a lot of changes and an extra parameter for no clear benefit.

Another commit provides a show function for LHNames that prints the structure of the name. And yet another commit fixes a problem where name resolution would panic if early stages produced an error and we allowed the resolution to proceed anyway, now we interrupt name resolution early if there are errors.

getLHNameResolved n@LHNUnresolved{} = error $ "getLHNameResolved: unresolved name: " ++ show n
getLHNameResolved n@LHNUnresolved{} = error $ "getLHNameResolved: unresolved name: " ++ showLHNameDebug n

showLHNameDebug :: LHName -> String

Choose a reason for hiding this comment

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

This should be the Show instance really, and what is now the instance should be a regular function that explains what it is for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried that, and found that it influenced error messages intended for users. I'll address this in a follow up PR.

Copy link

@sjoerdvisscher sjoerdvisscher left a comment

Choose a reason for hiding this comment

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

That cleans up nicely!

sp1
return (sp2, logicNameEnv0)
else
return (error "invalid spec", error "invalid logic environment")

Choose a reason for hiding this comment

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

Add a module name or function name to the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm counting on the error trace to show me the location. But I added the function name anyway in 919776d.

@facundominguez facundominguez force-pushed the fd/lhname-measure-names3 branch from c8f9a2a to 919776d Compare December 12, 2024 15:39
@facundominguez
Copy link
Collaborator Author

Thanks for the review @sjoerdvisscher!

@facundominguez facundominguez merged commit 5eaba17 into develop Dec 12, 2024
4 checks passed
@facundominguez facundominguez deleted the fd/lhname-measure-names3 branch December 12, 2024 16:34
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.

2 participants