Emacs/Keybindings and simple usage
Emacs for Haskell
Inferior Haskell processes |
Key bindings and usage
Key bindings in haskell-mode
(with haskell-indent
and inf-haskell.el
).
Code editing keys:
C-c C-=
inserts an=
sign and lines up type signatures and other pattern matches nicely.C-c C-|
inserts a guardC-c C-o
inserts a guard| otherwise =
and lines up existing guardsC-c C-w
inserts a where keywordC-c C-.
aligns code over a region in a "sensible" fashion.
Haskell interpreter keys:
C-c C-l
load current buffers file into Haskell interpreterC-c C-r
reload current Haskell interpreter sessionC-c C-t
gets :type for symbol at point, and remembers itC-u C-c C-t
inserts a type annotation, for symbol at point, on the line aboveC-c C-i
gets :info for symbol at pointC-c M-.
find definition of (interpreted) symbol at pointC-c C-b
orC-c C-z
switch to Haskell interpreter (starts one if needed)C-c C-d
find haddock documentation about symbolC-c TAB
query the haskell interpreter for the info of the given expressionC-c C-v
check current buffers file with hlint
(See C-h m
for more information).
Example
Here's an example for C-c C-=
. Put your cursor after myInt
and hit C-c C-=
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 C-c C-.
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.
Next: Indentation