This repository has been archived by the owner on Jan 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Code action add default type annotation to remove -Wtype-defaults
warning
#680
Merged
cocreature
merged 3 commits into
haskell:master
from
serhiip:code-action-add-default-type-annotation
Jul 10, 2020
Merged
Code action add default type annotation to remove -Wtype-defaults
warning
#680
cocreature
merged 3 commits into
haskell:master
from
serhiip:code-action-add-default-type-annotation
Jul 10, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is useful when using `traceShow` with with OverloadedStrings and type-defaults warning enabled Handle the following cases: - there is one literal and one contraint to be satisfied - there are mulitple literals and/or multiple constraints Adding type annotations to expressions that trigger type-defaults warning is not part of this changes
serhiip
commented
Jul 1, 2020
actions <- getCodeActions doc range | ||
let matches = sequence | ||
[ listToMaybe | ||
[ action | ||
| CACodeAction action@CodeAction { _title = actionTitle } <- actions | ||
, actionTitle == expectedTitle ] | ||
, expectedTitle `op` actionTitle] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I swapped the order of application of arguments. That matters only for T.isPrefixOf
(the version which I added), not for ==
serhiip
changed the title
Code action add default type annotation
Code action add default type annotation to remove Jul 1, 2020
-Wtype-defaults
warning
cocreature
approved these changes
Jul 10, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thank you
pepeiborra
pushed a commit
to pepeiborra/ide
that referenced
this pull request
Dec 29, 2020
…arning (haskell/ghcide#680) * Code action to add default type annotation to satisfy the contraints this is useful when using `traceShow` with with OverloadedStrings and type-defaults warning enabled Handle the following cases: - there is one literal and one contraint to be satisfied - there are mulitple literals and/or multiple constraints Adding type annotations to expressions that trigger type-defaults warning is not part of this changes * Simplify older test * Fix hlint issue
pepeiborra
pushed a commit
to pepeiborra/ide
that referenced
this pull request
Dec 29, 2020
…arning (haskell/ghcide#680) * Code action to add default type annotation to satisfy the contraints this is useful when using `traceShow` with with OverloadedStrings and type-defaults warning enabled Handle the following cases: - there is one literal and one contraint to be satisfied - there are mulitple literals and/or multiple constraints Adding type annotations to expressions that trigger type-defaults warning is not part of this changes * Simplify older test * Fix hlint issue
pepeiborra
pushed a commit
to pepeiborra/ide
that referenced
this pull request
Dec 29, 2020
…arning (haskell/ghcide#680) * Code action to add default type annotation to satisfy the contraints this is useful when using `traceShow` with with OverloadedStrings and type-defaults warning enabled Handle the following cases: - there is one literal and one contraint to be satisfied - there are mulitple literals and/or multiple constraints Adding type annotations to expressions that trigger type-defaults warning is not part of this changes * Simplify older test * Fix hlint issue
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a code action to add default type annotation suggested by GHC when
-Wtype-defaults
is enabled.I noticed that during development, when I use
traceShow
fromDebug.Trace
I often get annoyed by sudden warning displayed, so I usually urged to add that default type annotation manually. These changes add a way to do that via a hotkey.I hope this is useful to someone else.
These changes handle only literals, not expressions. For example for binding
f = 2 + 2
(without type signature defined) the warning will be shown, but no code action produced.I've tried to handle all the cases of the appearance of this warning, and I am interested in finding more examples to handle (if there is some).
If this doesn't seem like a useful addition, I am fine with not merging it