tags:

views:

169

answers:

4

I am studying Haskell and use Emacs+Haskell mode as my editor.

After playing some simple expressions in GHCi, I am wondering whether these IDE/editor functionality that exist in Visual Stuido for F#:

  1. Can I send the content in the clipboard into the interpreter? Currently I can only :load the file into the interpreter. This is inconvienent when I gradually write functions in a script file. Like 'Alt+Enter' in visual stuido.

  2. After compiling, I hope to see the signature of the function, e.g.

    let double x = x + x

so that I can better understand the type inference mechanism in Haskell.

+1  A: 

TAIM claims to send selected expressions in vim to ghci(haven't tried it)

I'm not sure about function signatures inside the editor but in ghci its ":t func"

Actually looking at their youtube video it looks like TAIM may be able to select ":t func" in vim and send it to interpreter.

Roman A. Taycher
+3  A: 
  1. On Windows, there's WinGHCi, a gui including (poor, but often sufficient) support for copy and paste. Dunno about the command line version.

  2. Use :type double (or the shortcut :t double) to get the type signature of double. There's also :info which applies to values (including functions) as well as types and typeclasses (e.g. :info Bool lists the definition of Bool and all typeclasses it is an instance of) and says where it was defined.

delnan
+2  A: 

As far as I know, there is no support for sending the clipoards to the interpreter "out of the box", but it should not take more than couple of lines of elisp. I'd look in the support modes for other languages and copied it from there if I were you.

Regarding the types, you could type C-c C-t or C-c C-i on any symbol in your code, which would trigger ":t <symbol>" and ":i <symbol>" commands in the ghci process

ADEpt
+3  A: 

Regarding question 2, to see the inferred type of an expression every time you type one in, you can give inside ghci :set +t . I think you could also put that in a .ghci file, inside your home directory, as described in http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/ghci-dot-files.html .

christosc