-
Notifications
You must be signed in to change notification settings - Fork 343
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
Type query from up to date file information #185
Comments
There's no particular reason. It could send an import, or optionally a reload, before doing that. I wouldn't personally have it on by default, but it could be an option. |
I am curious why you would not have this on by default? For efficiency reason? If so, would a "reload-if-newer" approach be more desirable? |
Possibly, yeah. GHCi is a bit finicky. |
Well, here's one reason for not wanting this always: sometimes you're in the middle of editing your code when you want to check the type, and the code wouldn't type-check/parse yet properly... |
What would then be the expected type returned by such a check? |
Probably the last state during editing for which the code still made sense to the compiler... but we'd need incremental compiler support for this to become practical imho, as you can't trigger a save-buffer + reload in GHCi for each character you type... (+ reverting to previous state if |
I believe that the query should be in sync with what is shown in the buffer. Anything else is confusing. If I have to keep in mind what state is in ghci it will lead to some confusion. I would rather see with flycheck that the code does not parse and have |
Btw, you're contradicting yourself a little bit here. In the original issue description, you wanted the query to be based on the current file-contents, and now you're arguing for using the current buffer-contents instead... |
All I am saying is that it should reflect what the programmer sees and not what ghci last saw. Either the content of the buffer or the file is fine. If it is the file, I will have emacs save right before I do the query. |
...if you're prepared to type a (*) which currently saves the buffer as a side-effect w/o asking -- which should be made customizable anyway PS: don't get me wrong, like @chrisdone, I'm not against this feature, I just don't want it on by default |
I got the point. It sounds do-able, but if you know Elisp I can point you where you can start with the inferior process if you want. You'll need some ingredients:
One risk you have is losing type information—if the current module doesn't type-check—that you would've had otherwise. But that's a trade-off with what GHCi provides. If you don't know Elisp (learn it!), you can leave this ticket open, perhaps someone will add it. Like @hvr says, it's not saving you many key presses. |
Afterthought: I read your update posts and see that you'd prefer no type than a possibly-wrong type. Fair enough. |
@hvr I will have emacs save means that I will add a hook. I am not going to type it ;-) @chrisdone thanks for the pointers. My main goal with opening this issue was to figure out if there was any reason for the behavior I observed. I will give it a shot. What I am trying to do is get a neat functionality from ghc-mod which is |
Check out Getting type info a la ghc-mod will be difficult because GHCi gives very limited inspection capabilities. |
So far I seemed to get the same result with haskell-mode and ghc-mod. Do you have any example in mind where ghc-mod would give an answer but not ghci? |
Sub-expressions? When the file's invalid? |
@chrisdone are you sure |
@hvr I just checked. You cannot. |
This issue report was last update in 2013. Is it still relevant to current code state? |
hvr commented on 17 Jul 2013
I meant the reverse. GHCi gives you (old) info when the file is invalid. I think ghc-mod does not because it requests type info on-demand. gracjan commented an hour ago
Yup. |
It seems that HIE will provide this functionality. I do not see this happening in haskell-mode due to lack of resources. |
When I use the function
haskell-process-do-type
(C-c C-t
) I often get the answer "Top level: Not in scope:foo'". This is because the query made by
haskell-modeuses the current content loaded in
ghci` and not the content of the file.Is there a reason why the call to
haskell-process-do-type
does not reload the content of the file in ghci before querying it?The same question applies to
haskell-process-do-info
(C-c C-i
).The text was updated successfully, but these errors were encountered: