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

Prevent accidental Cthulhu summons #1760

Merged
merged 10 commits into from
Apr 20, 2021
Merged

Conversation

isovector
Copy link
Collaborator

This PR makes Wingman pick more idiomatic identifiers when generating new variables.

Before, the situation was quite bad for complicated types:

2021-03-23-233539_1104x328_scrot

But now, Wingman uses a bunch of rules to find acceptable names. It categorizes variables by their purpose, correlating roughly with intended semantic meaning. Right now, that means we can find things like monadic actions, functions, and predicates. For each purpose, we give a preferred ordering of variable names, and Wingman uses the first one that is available.

For long type constructors, Wingman will attempt to split them by camel case, turning eg HelloWorld into hw. if that fails, it uses the first syllable of the constructor.

This is not yet a perfect solution to naming, which should constrain names based on the relationship. But it's a significant step forward.

@isovector isovector changed the title Improve Wingman's naming scheme Prevent accidental Cthulhu summons Apr 19, 2021
Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

cthulhu (First fp') = _
cthulhu (Second fp') = _
cthulhu (Alongside fp' fp_rca'b') = _
cthulhu (Fanout fp' fp_rcab') = _
Copy link
Member

Choose a reason for hiding this comment

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

This means if we have a constructor like R'lyeh :: FreePro r c x y -> FreePro r c (Either a x) (Either b y) -> FreePro r c a b (or more complex second argument) then we can still summon one, right?

Copy link
Collaborator Author

@isovector isovector Apr 20, 2021

Choose a reason for hiding this comment

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

The _<blah> bit only shows up if all of your type arguments are variables, which prevents arbitrarily long terms. I think we're still safe.

@isovector isovector added the merge me Label to trigger pull request merge label Apr 20, 2021
@mergify mergify bot merged commit aa9b3c6 into haskell:master Apr 20, 2021
@isovector isovector deleted the better-names branch July 19, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants