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

haskell: use ghc-mod for "mhi" and "mht" bindings when enabled #3197

Closed
wants to merge 1 commit into from

Conversation

tko
Copy link
Contributor

@tko tko commented Sep 29, 2015

ghc-mod can get type / info without having to manually push the code to
REPL first. #3173

I'd think maybe the "needs repl" bindings should be moved under m s prefix to make the context more clear. Also the "mhT" function could probably be reimplemented in terms of ghc-mod.

ghc-mod can get type / info without having to manually push the code to
REPL first. syl20bnr#3173
@syl20bnr
Copy link
Owner

syl20bnr commented Oct 7, 2015

Can we disambiguate SPC m h t before merging this PR ? I can see that SPC m h t can be 3 different things.
Also the documentation has to be updated with the new key bindings.

@d12frosted
Copy link
Contributor

Originally haskell-mode has 'magic' key binding C-c C-t which is used by different modes to set proper behaviour. I don't think we should really mimic it. Instead, we could map SPC m h t to C-c C-t.

There are several such key bindings. So similarly we could map SPC m h i to C-c C-i.

@PierreR
Copy link
Contributor

PierreR commented Oct 8, 2015

I think we should go and ask the authors from haskell-mode what to do here ...

Right now ghc-show-type is doing more work compared to haskell-process-do-type so the PR is alright but what if in a near future the situation is opposite ...

That and the fact that in a near future we might want to integrate stack-ide which is yet another (quite promising) ghc-mod competitor.

@d12frosted
Copy link
Contributor

Well, that's why I propose to map SPC m h t to C-c C-t, because haskell-mode itself maps this key binding to function that will ask you to setup interactive mode. But, if you are using interactive mode, C-c C-t will be bound to haskell-process-do-type. When you are not using interactive mode, but using ghc-mod, C-c C-t will be bound to ghc-show-type.

As for ghci-ng - it uses haskell-mode-show-type-at (defined here in haskell-mode), but official tutorial says to bind this function to C-c C-t. For ghc-ng we already set SPC m h t to haskell-mode-show-type-at here, but probably it's easier to set it to C-c C-t (so it works as expected in haskell-mode) and then bind SPC m h t to C-c C-t.

As for stack-ide - it's immature yet, but I think that they will also reuse C-c C-t, because it's common.

P. S. Probably I am using wrong terminology, when I say bind SPC m h t to C-c C-t, but I hope you understand me 😄

@PierreR
Copy link
Contributor

PierreR commented Oct 9, 2015

bind SPC m h t to C-c C-t

That makes sense. How do we do this ?

@d12frosted
Copy link
Contributor

The only way I know is defining function like

(defun spacemacs/haskell-show-type ()
      (interactive)
      (call-interactively (lookup-key haskell-mode-map (kbd "C-c C-t"))))

And just making regular bind from SPC m h t to spacemacs/haskell-show-type.

@d12frosted
Copy link
Contributor

@tko What do you think about it?

d12frosted pushed a commit to d12frosted/spacemacs that referenced this pull request Oct 10, 2015
syl20bnr pushed a commit that referenced this pull request Oct 12, 2015
@syl20bnr
Copy link
Owner

Thank you for the PR, I close it in favor of #3345.

@syl20bnr syl20bnr closed this Oct 12, 2015
@PierreR
Copy link
Contributor

PierreR commented Oct 17, 2015

I have just tested the PR but it does not seem to work out. I am currently on develop e72dd8a.

Pressing c-c c-t will show me the type. On the other hand mht still requires loading haskell-process. It looks like mht is still bound to haskell-mod-show-type-at (or haskell-mode-enable-process-minor-mode if I don't use ghc-ng),

If I am correct the aim of the PR was to map mht to whatever c-c c-t is doing

@d12frosted
Copy link
Contributor

If I am correct the aim of the PR was to map mht to whatever c-c c-t is doing.

Yes, it should be mapped to whatever C-c C-t is. But, if you have ghci-ng enabled - then C-c C-t should not work, while mht should work, because for ghci-ng we need to explicitly set key bindings. Since C-c C-t is not spacemacs keybinding - we don't setup it for ghci-ng users.

As for you problem - 3 days ago it was working for me like a charm. I'll try to reproduce it once I am back.

@d12frosted
Copy link
Contributor

I'll take a look into problems with ghci-ng on weekends. Sorry for such a big delay!

@d12frosted
Copy link
Contributor

Still working. Just make sure that you are really running ghci-ng - there are some caveats with it, which I described in #3544.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants