Recent Haskell mode developments
Christopher Done
chrisdone at googlemail.com
Sun Apr 1 21:23:47 BST 2012
Hello, Haskell mode users!
Last month I stopped work on my haskell-emacs package and started
porting all the features to haskell-mode.
Last week I described some of the things I added on Google+, but
probably there is a wider audience of haskell-mode users on this
mailing list, and I realise that Google+ might restrict viewing, so I
include the post verbatim in the post script of this email. Since then
I've added etags-based (hasktags) support for jump to definition via
the M-. keybinding. It is per session.
In summary I've added:
* Per Cabal project / session specific GHCi sessions
* Per project tags generation
* A new REPL with cleaned up and collapsed compile messages.
* Some goodies in haskell-mode for completion.
Whichever indentation mode you use, you should seriously look into
using the haskell-move-nested.el module. It will save you time.
I just updated the README.md on the repository to describe how to
setup these additions: https://github.com/haskell/haskell-mode See
section “Setup for new interactive mode”. These changes are all
non-breaking that are entirely optional. I'll maintain these features.
Philip's the haskell-mode maintainer but I'm also available to respond
to tickets (if it's not about the indentation modes…).
I have some small proposals to make that I'd like to run by everyone:
1. Any cool features and ideas documented on that HaskellWiki should
probably be solidly integrated solutions in the haskell-mode package
and enabled by configuration.
2. Suppose we move the source files to an "src" directory. The list is
getting quite large now. It's only a cosmetic suggestion, but more or
less standard, at least in the Haskell world. We can just update the
makefile and haskell-site-file.el regenerated will work as normal.
Once I get a working microphone I'll make a screencast of using Emacs.
Lots more to come as always,
Ciao!
P.S.
BEGIN GOOGLE+ POST
Been hacking on haskell-mode all weekend. Adding three things (from my
haskell-emacs package which I have been using in place of haskell-mode
for just under a year). Some screenshots vaguely demonstrating the REP
and things http://imgur.com/a/0RfVu (I will post a more detailed blog
and spoken screencast when I've finished porting the rest of the
features.) To try it out git pull the latest haskell-mode and set
these bindings: http://hpaste.org/65941
1. A new interactive mode (replaces inferior-haskell's comint mode)
which automatically collapses error messages to one line (GHC error
messages generally have the first line sum up the problem), but
hitting tab on them toggles expanding the rest of the messages. One
time out of ten want to see a complete GHC error message, the rest of
the time I don't care.
It also displays build messages in a simplified manner as the normal
output is again more than I care to see. Errors and warnings also
appear at the end rather than mixed inbetween module compilations. I
find this nicer looking and slightly easier to run through at times.
It doesn't even show “Compiling” or “Loading package X…” (actually
this is only ever in the minibuffer) in the REPL when loading in GHCi,
it shows these messages in the minibuffer. I found in my day to day
work this suits the workflow better. I just want to know if it
compiles or not and if not what's the error, I don't want to be
bringing up the REPL just for this.
The current Cabal project can be compiled (and there is some ido-mode
prompting of the command) and the output will be displayed in this
buffer and formatted in the same way (similar to current
inferior-haskell mode).
It also prompts, when loading/building, to add language extensions if
the compiler suggests them. You have no idea how nice this is when you
have it!
2. A new inferior-haskell process backend. Just talks to GHCi via a
pipe and has an asynchronous command queue (useful for many things but
basically means using GHCi programmatically is trivial and order is
taken care of). This module is what makes most of the above trivial
and fast. This can support either normal GHCi or cabal-dev GHCi.
Potentially it can support hugs or virtualhenv GHCi or whatever that
project was called. I started out with just comint filters but that
quickly got unwieldy for the types of things I was doing, so I ended
up going directly to the pipe. In the end that simplified things.
3. A new sessions module for attaching Cabal projects, GHCi process
and REPL buffer together. It prompts the user (with some intelligent
suggestions for each) for the session name, cabal path, and current
directory when working in GHCi. From this information cabal-dev can be
launched properly, for example.
Further, project-wide etags be generated with hasktags (this is better
than GHCi's etags generation IME). I have successfully done and been
using this for months with haskell-emacs. It's just a matter of adding
it to haskell-mode now. The process backend above helps with that. And
etags plays very nicely auto-complete, within haskell-mode or in the
REPL. And also provides jump-to-definition for free.
Another simple feature I have to add from haskell-emacs is that REPL
type errors don't get put in the buffer, instead an error buffer pops
up and you hit 'q' to close it and continue editing your line. Not
only is this less annoying than the normal workflow, it also makes
your REPL look like you never make type errors!
Also need to add Show collapse/expanding within the REPL: Demo of
Haskell Show instance collapsing in Emacs But need to implement a
haskell-src-exts-based Haskell Show output → sexp utility because the
PEG parser I made in Elisp is slow, incomplete and suffers from
Elisp's limited stack size.
Anyway, more to come. I've added enough features to haskell-mode to
make it just about useable for actual work, so I'll see how it fares
this week; for sure there'll be some bug patches and feature
additions. I'm curious whether it works on Windows but basically won't
bother trying to fix anything broken that is non-trivial right now.
More information about the Haskellmode-emacs
mailing list