-
-
Notifications
You must be signed in to change notification settings - Fork 389
Add change type signature quick fix #2436
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
Comments
Would love to see this as well: code lenses are distracting. |
Note that there's already a code action for adding a missing signature, if you don't like the lens. |
I couldn't find it. In Visual Studio Code, when clicking on the light bulb that appears next to a top-level definition, I only see retrie's fold/unfold actions. |
Works for me! Unless |
I would say code lenses for missing type signature is one of the more appropiate uses of lenses. It displays just the code which will be added if you click it, no replaces or subsitutions and helps you even if you dont add them. @michaelpj what do you think to move upstream the code lenses as code actions thing of emacs lsp mode. Unconditionally or only if user disable the code lenses explicitly. |
Hmm, maybe that's only used to apply the edit, ignore me. |
I can't find where |
HLS code actions are driven by warnings. If you don't see the "add missing signature" code action, enable Screen.Recording.2021-12-08.at.14.48.38.mov |
Ah, that might well be it. There's definitely a code action: I just checked and it's part of a code action response from the server. |
It's a bit odd that you can get one and not the other... |
That works, but I don't want to enable that warning for normal compilation, and I don't want the yellow squiggles. The fold/unfold actions don't rely on warnings, so surely there's a way! |
Tying code actions to warnings allows users to select which quick fixes they care about. So it's not a technical limitation, it's a design decision. |
Well, change the type signature, the topic of the issue, will be tied to a compiler error, so it will be always available ;-)
Agree both should be in sync |
If there isn't any movement on this, I'll take a look. |
There are a couple questions I ran into at the start of thinking about how this would work:
foo :: Int -> Int -> Int
foo x y = x + y
bar :: Integer -> Integer
bar x = foo x 20
foo :: Int -> Int
foo x = x + ord c The error message looks something like:
I'm not well-versed enough in the GHC API to know if it's possible to "solve" the expected signature? Naively, I could replace the first |
interesting questions, maybe we could try first the simple way and no handle changes in number of params which could be an improvement in a 2 iteration and change only the function target of the ghc error, if that breaks other function a bunch of errors will be spawned and the user will decide if going back or forward |
When you change the body of a function and the type signature does not match you get the obvious compiler error:
F.e. for
you get
It would be nice to have a quick fix (better than a code lens imo) which changes the type signature to match the body new type, something like
Change type signature to: (Traversable t, Monad m) =>t a -> (a -> m b) -> m (t b)
That type is already shown on hover.
Additional context
The text was updated successfully, but these errors were encountered: