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

Wingman: Destruct on empty case #1721

Merged
merged 32 commits into from
Apr 16, 2021
Merged

Wingman: Destruct on empty case #1721

merged 32 commits into from
Apr 16, 2021

Conversation

isovector
Copy link
Collaborator

@isovector isovector commented Apr 12, 2021

This PR adds a code lens to empty case x of expressions, offering to expand out their pattern matches. It works by looking for empty case matches, typechecking their scrutinee, and then grafting newly generated Match es back into the AST. Seems to work pretty well.

destruct on empty case

Fixes #1716

@wz1000
Copy link
Collaborator

wz1000 commented Apr 12, 2021

I wonder if this would be better to implement as a completion rather than a code action?

@isovector isovector changed the title [wip] Destruct on empty case Wingman: Destruct on empty case Apr 15, 2021
@isovector isovector marked this pull request as ready for review April 15, 2021 05:49
Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

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

This is awesome! I have wanted this feature so many times!

Comment on lines 117 to 122
instance Show (HsExpr GhcPs) where
show = unsafeRender

instance Show (HsExpr GhcTc) where
show = unsafeRender

instance Show (HsDecl GhcPs) where
show = unsafeRender

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please consider moving these to the Orphans module

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Happy to --- followup PR ok?

@isovector isovector added the merge me Label to trigger pull request merge label Apr 15, 2021
@mergify mergify bot merged commit 083cdbc into haskell:master Apr 16, 2021
@isovector isovector deleted the empty-case branch May 21, 2021 16:37
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.

case split on case of statement with no destructor cases declared
3 participants