Type/info tooltips on selection #133
Comments
Well, it is possible to assign a keybinding to show type of selected expression. Querying ghc-mod on every cursor movement would be a bad idea on larger projects. |
Yes, it might slow things down. But being able to assign a keybinding would be fine as well. |
Well, you could consult https://github.com/atom-haskell/haskell-ghc-mod#keybindings and https://github.com/atom-haskell/ide-haskell#keyboard-shortcuts. Also possibly https://atom.io/docs/v1.3.3/using-atom-basic-customization#customizing-key-bindings You might also want to fiddle with haskell-ghc-mod settings (which actually provides show type/show info etc functionality) for more fine-grained control over when to show and when to hide type tooltip. |
@lierdakil on sublime text with I'd also like to mention those features in
@lierdakil the clickable links + prefix removal is done this way:
final note about this issue: I think the completion hint panel is not a good place to show expression types, but I'm in favor of having a way to always show types, with refresh at each cursor move / selection change. I'm used to use selection as a way to understand my code. I really think it speeds up my code understanding. |
@rvion, I think I could manage type/info tooltips on (non-empty) selection. As for prefix removal, I'd ask you to file separate issue if possible (since it's not directly related and I'm still on the fence on that one, because it may get confusing -- consider e.g. |
@rvion, I've added experimental support for 'show type on selection'. It's disabled by default. To enable, see 'showTypeOnSelection' option in haskell-ghc-mod. Feel free to file new issues if something doesn't work right. |
@lierdakil big thanks !! |
For anyone interested, prefix hiding can be achieved with recent language-haskell using something like this in your stylesheet (provided syntax highlighting in tooltips is enabled): ide-haskell-tooltip .hint.haskell .module {
display: inline-block;
white-space: nowrap;
width: 1ex;
overflow-x: hidden;
vertical-align: bottom;
position: relative;
&::before {
content: "_";
}
} You can also make it show prefix on mouseover with something like ide-haskell-tooltip .hint.haskell .module {
display: inline-block;
white-space: nowrap;
width: 1ex;
overflow-x: hidden;
vertical-align: bottom;
position: relative;
&::before {
content: "_";
}
//show on hover
pointer-events: auto;
&:hover {
&::before {
content: none;
}
width: initial;
}
} |
Is there a way to reuse that in a static HTML system for litterate haskell stuff ? what would be the entry point to process haskell litterate source and get the HTML representation with tooltips classes ? |
@nrolland, I'm sorry, but I'm not sure what exactly you are trying to do. Could you maybe explain in more detail? |
Sure, I have some literate haskell files, which I compile down to HTML with pandoc via hakyll. It would be nice to be able to generate the type info along the way, very much the same way you can do with say fsharp here |
Ah, ok, I get it now. Regrettably, ide-haskell uses ghc-mod to dynamically query type information (via node's But if you're willing to invest some time and effort into this, you could use ghc-mod as a library from hakyll. One caveat is that ghc-mod gets type information for a single point in input source, so you'll likely have to reimplement some of the logic in You would also have to insert annotations into lhs source 'manually', i.e. there would be no direct mapping to Pandoc's AST (unless you do this via a pandoc filter, which is possible). Overall, this would be relatively complicated and time-consuming, and ide-haskell can't help you there much, if at all, but ghc-mod could at least simplify things. If you decide to do that and have any questions/difficulties, you can try asking for help on ghc-mod repo or on #ghc-mod @ freenode IRC channel. P.S. Note that ghc-mod is currently undergoing a huge code reorganization. We're aiming to split the code that deals with GHC API directly into a separate library (currently named ghc-mod-core), so |
They do typecheck, that's the point of this litterate file : the same source is both the program and the documentation. The question would be what's the best way to retrieve the typing information at each point, then store that type information (in the output file, not to the lhs itself) The entry point you provided for ghc-mod seems well suited for that. An alternative to this might be to load the litterate haskell file in a context akin to atom-haskell, and upon client hover, to issue a request with the hovered location info to that context, retrieving the same info as you do from within atom-haskell, and forward the HTML answer to the client. Upon glancing quickly .. maybe that's what stack-ide does :) I wish there was more modularity in those developper tools : everything is already there, there is already a mapping from source to types in HTML, but that seems amazingly hard to reuse ! |
The first order of business with refactoring ghc-mod is to separate
ghc-specific code from front-end, while keeping API mostly intact. Then we
will proceed to cleaning up the library interface. So while I'll try to
keep this use case in mind, I can't promise much. Creating an issue on
ghc-mod repo might help with not forgetting about that.
There isn't really "type information in html" atm. Most tools I know of run
point-specific queries on user request, so you'd have to run ghc on the
backend to emulate that (and ghcjs can't build ghc yet, so no running that
client-side). But dumping type information for a given source file should
be relatively easy, and that could be then parsed and plugged into html.
It'd be relatively slow when compared to point queries, so that might be
why it's not implemented anywhere directly yet.
Also, note: you want to transform lhs to html. Latter will have structure
that differs a lot from source file. So you'd have to plug type information
before pandoc does its thing. Which could be a challenge in its own right.
вт, 31 янв. 2017 г., 13:24 Nicolas Rolland <notifications@github.com>:
… They do typecheck, that's the point of this litterate file : the same
source is both the program and the documentation.
The question would be what's the best way to retrieve the typing
information at each point, then store that type information would be stored
(in the output file, not to the lhs itself)
The entry point you provided for ghc-mod seems well suited for that.
It would be a very good thing to have that use case in mind in your
GHC-mod reorg.
A good architecture should make that kind of application a no-brainer, and
there are many contexts into which the typing information is to be
consumed. I unfortunately have little time to invest in such endeavour, I
can just extend things.
An alternative to this might be to load the litterate haskell file in a
context akin to atom-haskell, and upon client hover, to issue a request
with the hovered location info to that context, retrieving the same info,
as you do from within atom-haskell, and forward the HTML answer to the
client.
Upon glancing quickly .. maybe that's what stack-ide does :)
It seems that https://github.com/haskell-tools/haskell-tools can also
generate signature.
but not sure what's the scope of that project VS ghc-mod VS others..
I wish there was more modularity in those developper tools : everything is
already there, there is already a mapping from source to types in HTML, but
that seems amazingly hard to reuse !
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#133 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG8EZq5v_zBNvQvoEen0lOLQX2dFXMjiks5rXwvXgaJpZM4GvQWL>
.
|
It would be nice if you could see the type info of the word under the cursor in the completion hint panel as well instead of having to hover it with the mouse.
The text was updated successfully, but these errors were encountered: