[Haskell-cafe] Displaying infered type signature of 'offside'functions

Claus Reinke claus.reinke at talk21.com
Sun Apr 29 07:04:54 EDT 2007

>On 28/04/07, Georg Sauthoff <g_sauthoff at web.de> wrote:
>> Well, I mention this, because I would like to integrate some
>> lookup feature (for type signatures) into vim (if it doesn't
>> exist yet).
>It's worth pointing out that Emacs's haskell-mode already has this.

as do many Vim Haskell modes. for instance, in my own, there are

_t : show type for id under cursor
_T : add type declaration for id under cursor before current line
_si : show info for id under cursor
CTRL-] : jump to definition of id under cursor

'_t' and '_T' use (cached) output from GHCi :browse for the current
and imported modules, '_si' calls GHCi :info, CTRL-] uses the tags
file generated by 'ghc -e :ctags <current>' (which is mapped to '_ct').

see http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/Vim/ 
for more info, a tour, and the scripts.

>I did forget to mention that this won't help with your 'offside'
>functions, though.

that, indeed, is the point. if it is reasonably easy to get that information,
without internal identifiers or non-source constructs, and with correct 
associations to source code positions, it would be a useful addition to 
editor bindings.

it would perhaps be nice to have a wiki page collecting Haskell IDE
features that have been implemented in at least one of the many tools,
so that everybody can try to implement a similar feature set for their
own editor/ide? 

there are features that depend on individual preferences, such as 
indentation, and there are obvious features that everybody wants, 
such as those above, but often, someone somewhere hacks up a 
little trick that makes Haskell hacking life a lot easier.

here is a near trivial example from my vimrc file (not even Haskell-

    map ,{ c{}<esc>P%
    map ,( c()<esc>P%
    map ,[ c[]<esc>P%

this allows me to insert parens by highlighting the part to be enclosed (*).

similarly, the emacs modes have a command to align patterns in
the middle of adjacent lines, such as '=', '::', which is different from 
indent, and sounds potentially quite useful, to align multiple equations 
and their type declaration, so i've started to reproduce that for vim.


(*) ',(' is mapped to: replace (c) highlighted, insert '()', escape to
    command mode (<esc>), paste cut buffer before current pos
    (P), jump to matching paren (%). so i just highlight an expr and
    hit ',(' to put it in parens, or ',[' to wrap it into a list, etc.

More information about the Haskell-Cafe mailing list