Skip to content

Wingman: Destruct on empty case#1721

Merged
mergify[bot] merged 32 commits into
haskell:masterfrom
isovector:empty-case
Apr 16, 2021
Merged

Wingman: Destruct on empty case#1721
mergify[bot] merged 32 commits into
haskell:masterfrom
isovector:empty-case

Conversation

@isovector

@isovector isovector commented Apr 12, 2021

Copy link
Copy Markdown
Collaborator

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

wz1000 commented Apr 12, 2021

Copy link
Copy Markdown
Collaborator

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

@pepeiborra pepeiborra left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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