Emacs/Keybindings and simple usage
|Emacs for Haskell|
1 Key bindings and usage
Key bindings in
Code editing keys:
C-c C-=inserts ansign and lines up type signatures and other pattern matches nicely.=
C-c C-|inserts a guard
C-c C-oinserts a guardand lines up existing guards| otherwise =
C-c C-winserts a where keyword
C-c C-.aligns code over a region in a "sensible" fashion.
Haskell interpreter keys:
C-c C-lload current buffers file into Haskell interpreter
C-c C-rreload current Haskell interpreter session
C-c C-tgets :type for symbol at point, and remembers it
C-u C-c C-tinserts a type annotation, for symbol at point, on the line above
C-c C-igets :info for symbol at point
C-c M-.find definition of (interpreted) symbol at point
C-c C-zswitch to Haskell interpreter (starts one if needed)
C-c C-dfind haddock documentation about symbol
C-c TABquery the haskell interpreter for the info of the given expression
C-c C-vcheck current buffers file with hlint
C-h m for more information).
2 ExampleHere's an example for
C-c C-=. Put your cursor after
blah :: Int -> Int blah myInt
note how the function signature is reindented to match the column of the = sign.
blah :: Int -> Int blah myInt =
You could also achieve the same effect by selecting the region and typing
You can also use haskell-mode to load Emacs buffers with Haskell code in either Hugs or GHC. To load something in Hugs or ghci, type
C-c C-l to load the file. Then, you can go on to type
C-c C-r (or simply
C-c C-l again) to reload the current module when you have made a change.